Posts

Showing posts from April, 2017

AUTOMATIC STREET LIGHT WITH ATMEGA16 MICROCONTROLLER

Image
#include <avr/io.h> #include<util/delay.h> int main(void) { DDRC=0x11; DDRA=0x00; while(1) { if(PINA==0x00) { PORTC=0x01; } else PORTC=0x00; }}

DIGITAL WATCH USING ATMEGA16

Image
#include <avr/io.h> #include <util/delay.h> #include"lcd.h" int main(void) { int hrs,sec,min; char h[4],s[4],m[4]; lcd_init(); lcdcmd(0x80); display("HOUR:MIN:SEC"); for(hrs=0;hrs<25;hrs++) { lcdcmd(0xc5); display(" "); itoa(hrs,h,10); lcdcmd(0xc1); display(h); { for(min=0;min<61;min++) { lcdcmd(0xc8); display(" "); itoa(min,m,10); lcdcmd(0xc4); display(m); { for(sec=0;sec<61;sec++) { itoa(sec,s,10); lcdcmd(0xc7); display(s); _delay_ms(1000); } }}} } // THE HEADER FILE IS:---- void lcdcmd(char x) {DDRD=0b11111111;          DDRC=0b11111111; PORTD=x; PORTC=0b00000100; _delay_ms(10); PORTC=0b00000000; _delay_ms(10); } void lcddata(char x) { DDRD=0b11111111;          DDRC=0b11111111; PORTD=x;         PORTC=0b00000101; _dela...

DIGITAL COUNTER/VISITOR COUNTER WITH ATMEGA16 MICROCONTROLER

Image
#include <avr/io.h> #include <util/delay.h> #include"lcd.h" int main(void) { int a=0,b=0; char x[5]; DDRA=0b00000000; DDRC=0b11111111; DDRD=0b11111111; lcd_init(); while(1) { if(PINA==0b00000001) {  lcdcmd(0x01); a++; itoa(a,x,10); display(x); _delay_ms(500); } else if(PINA==0b00000010) { lcdcmd(0x01); a--; itoa(a,x,10); display(x); _delay_ms(500); if(a<=0) {lcdcmd(0x01); a=0; itoa(a,x,10); display(x); _delay_ms(100); } } }} // THE HEADER FILE FOR LCD IS:--- void lcdcmd(char x) { PORTD=x; PORTC=0b00000100; _delay_ms(10); PORTC=0b00000000; _delay_ms(10); } void lcddata(char x) { PORTD=x;         PORTC=0b00000101; _delay_ms(10); PORTC=0b00000001; _delay_ms(10); } void display(char a[]) {        int i; for(i=0;a[i]!='\0';i++) {lcddata(a[i]); } } void lcd_init() { lcd...

STEPPER MOTOR INTERFACING WITH ATMEGA16

Image
#include <avr/io.h> #include<util/delay.h> int main(void) { DDRC=0b11111111;     while(1)     {        PORTC=0x01;   _delay_ms(1000);   PORTC=0x02; _delay_ms(1000);   PORTC=0x04; _delay_ms(1000);   PORTC=0x08;   _delay_ms(1000);     } }

THE ELECTRONIC VOTING MACHINE using ATMEGA 16

Image
#include<avr/io.h> #include<util/delay.h> #include"lcd.h"; int main(void) { char a=0,b=0,c=0,d=0; int i,j; char x[5],y[5],z[5],m[5]; DDRC=0b11111111; DDRD=0b11111111; DDRA=0b00000000; DDRB=0b11111111; lcd_init(); for(j=0;j<3;j++) { lcdcmd(0x01); display("***WELCOME TO 2017 ELECTION***"); for(i=0;i<33;i++) { lcdcmd(0x18); _delay_ms(10); }} lcdcmd(0x01); lcdcmd(0x83); display("**PRESS**"); _delay_ms(2000); lcdcmd(0x01); display("1->BJP"); _delay_ms(200); lcdcmd(0x88); display("2->CONG"); _delay_ms(200); lcdcmd(0xc0); display("3->AAP"); _delay_ms(200); lcdcmd(0xc8); display("4-->SP"); _delay_ms(300); lcdcmd(0x01); display("ENTER YOUR VOTE"); _delay_ms(200); lcdcmd(0x01); display("BJP-"); lcdcmd(0x88); display("CONG-"); lcdcmd(0xc0); ...

7 segment display interfacing with atmega16

#include <avr/io.h> #include<util/delay.h> int main(void) { DDRC=0b11111111;     while(1)     { PORTC=0b00111111; _delay_ms(1000); PORTC=0b00000110; _delay_ms(1000); PORTC=0b01011011; _delay_ms(1000); PORTC=0b01001111; _delay_ms(1000); PORTC=0b01100110; _delay_ms(1000); PORTC=0b01101101; _delay_ms(1000); PORTC=0b11111100; _delay_ms(1000); PORTC=0b00000111; _delay_ms(1000); PORTC=0b01111111; _delay_ms(1000); PORTC=0b01100111; _delay_ms(1000);             } }

display string on 16*2 lcd without using headrer file

Image
#include <avr/io.h> #include<util/delay.h> int main(void) { DDRC=0b11111111; DDRD=0b11111111; PORTD=0x38; PORTC=0b00000100; _delay_ms(10); PORTC=0b00000000; _delay_ms(10); PORTD=0x0E; PORTC=0b00000100; _delay_ms(10); PORTC=0b00000000; _delay_ms(10); PORTD='S'; PORTC=0b00000101; _delay_ms(10);     PORTC=0b00000001; _delay_ms(10); PORTD='O'; PORTC=0b00000101; _delay_ms(10);     PORTC=0b00000001; _delay_ms(10); PORTD='N'; PORTC=0b00000101; _delay_ms(10);     PORTC=0b00000001; _delay_ms(10); PORTD='U'; PORTC=0b00000101; _delay_ms(10);     PORTC=0b00000001; _delay_ms(10); }

lcd interfacing with atmega16(with header file)

Image
#include <avr/io.h> #include<util/delay.h> #include"lcd.h" int main(void) {   lcd_init();   display("SONU_KUMAR_FABULOUS"); } //THE HEADER FILE IS:- oid lcdcmd(char x) {DDRD=0b11111111;          DDRC=0b11111111; PORTD=x; PORTC=0b00000100; _delay_ms(10); PORTC=0b00000000; _delay_ms(10); } void lcddata(char x) { DDRD=0b11111111;          DDRC=0b11111111; PORTD=x;         PORTC=0b00000101; _delay_ms(10); PORTC=0b00000001; _delay_ms(10); } void display(char a[]) { DDRD=0b11111111;          DDRC=0b11111111;        int i; for(i=0;a[i]!='\0';i++) {lcddata(a[i]); } } void lcd_init() { lcdcmd(0x38); lcdcmd(0x0E); lcdcmd(0x01); }

LED BLINK USING ATMEGA16(AVR CODE WITH PROTEUS SIMULATION)

#include <avr/io.h> #include<util/delay.h> int main(void) { DDRC=0b11111111;     while(1)     { PORTC=0b11111111; _delay_ms(2000); PORTC=0b00000001; _delay_ms(1000); PORTC=0b00000010;         _delay_ms(1000); PORTC=0b00000100; _delay_ms(1000); PORTC=0b00001000; _delay_ms(1000); PORTC=0b00010000; _delay_ms(1000); PORTC=0b00100000; _delay_ms(1000); PORTC=0b01000000; _delay_ms(1000); PORTC=0b10000000; _delay_ms(1000); PORTC=0b11111111; _delay_ms(2000);     } }