Month: June 2014

Interfacing between Atmega 16/32 with LCd 16×2- Tutorial Lecture-2

Interfacing between Atmega 16/32 with LCd 16×2- Tutorial Lecture-2

In our second lecture, we describe the connectivity between
LCD 16×2 with ATmel Atmega16 Microcontroller.
Firstly, we have to know about the LCD, A 16×2 LCD means it’s having 16 rows & 2 columns,
that can display 16 characters per line & there are 2 such lines.
In this LCD, each
character is displayed in 5×7 pixel matrix. This LCD has two registers,
LCD 16×2 pin described in table image below,
The table of LCD 16×2 is show in the image geiven below. The image contain the description of all LCD pin.
The connectivity is shown in the figure below.

After we finish the hardware connectivity, we move for
programming. We write the program in the AVR studio 4 professional programming
window. We start the program as we write for glowing the led from header file. We
include the header files first.
We provide the demo code for LCD 16×2 for ATmel Atmega
series, written below-
#include<avr/io.h>
#include<util/delay.h>
#include”lcd.h”
// program to lcd display using for loop
void main()
{
InitLCD(0); // for initializing the LCD internal resister
unsigned char i;
LCDClear(); // clear the LCD
LCDWriteStringXY(0,0, “System is”);  // write the string in LCD first row
LCDWriteStringXY(1,0, “booting up “);  // write the string in LCD second row
for(i=0; i<=100; i++)                        //for
loop
{
LCDWriteIntXY(12,1,i,3);   
// for 0 to 100 counting display in lcd
LCDWriteStringXY(15,1,”%”); //for % sign
_delay_ms(50);
}
LCDClear();
LCDWriteString(“Please wait…”);
_delay_ms(1000);
LCDClear();
LCDWriteString(“Schematics”);
LCDWriteStringXY(0,1,”Micro Electronics”);
}
The output of this is program is as shown in the image below
Please note that we use external header & source file (lcd.c
& lcd.h) to operate the LCD commands & execute them.
for any queries & support, feel free to contact
us at www.smedehradun.com or write message to our facebook page or our
blog http://schematicslab.blogspot.in/

Basic Embedded System- Lecture 1- Glowing/ blinking of LED using Atmega16

Basic Embedded System- Lecture 1- Glowing/ blinking of LED using Atmega16

In the first lecture of basic embedded system, we start with
the glowing of led using binary operator. We are using Atmega 16 Microcontroller
to operate the led.
For the software development, we are using AVR Studio4 professional
& Proteus ISIS Professional for the Simulation.
AVR Studio4 Professional 

Proteus professionl ISIS
Connect the hardware as shown in to the figure. LED is
connected with pin 0 of PORT B. 
Please remember, when you connect the hardware,
it is essential to know about the voltage of LED. If you are using 3.3V LED,
Then please use 330 Ohm resister with LED.
We write the program in AVR studio 4 programming window as written
below-
#include<avr/io.h>
// #include<util/delay.h>
//PROGRAM TO RUN SINGE LED
void main()
{
DDRB=0b00000001;
PORTB=0b00000001;
}
This program glow the led continuously using Atmega 16.
if we want to blink the LED with 2 second of delay, the use below written program to blink the LED. We provide delay of 2 second (2000 millisecond) between on & off the LED.
#include<avr/io.h>
#include<util/delay.h>
//PROGRAM TO RUN SINGE LED of & off
void main()
{
//DDRB=0xFF;
DDRB=0b00000001;
while(1)
{
PORTB=0b00000001;
_delay_ms(2000);
PORTB=0b00000000;
_delay_ms(2000);
}
}
you can use same fundamentals to blink multiple LEDs or different pattern like shown below. 
For any assistance, please feel free to contact us here.
you can also join our tutorial lecture at our Facebook page