Turn on the LED to the switch using codevision AVR.
This post, I will provide a tutorial for ATMega 16 microcontroller based LED lights with a push button input using CodeVision AVR compiler software.
First we create a simulation in proteus, as shown below :
LED lights, I connect with port C0-C7 on ATmega16 microcontroller. Push button connected to the port A0.
Setting codevision same as the previous post about LED light using Code Vision AVR.
type the following syntax :
while (1)
{
// if the push button is pressed on PINA.0 (short to VCC) LED on PORTC will shift right.
if(PINA.0 == 1)
{
PORTC=1;
delay_ms(100);
PORTC=3;
delay_ms(100);
PORTC=7;
delay_ms(100);
PORTC=15;
delay_ms(100);
PORTC=31;
delay_ms(100);
PORTC=63;
delay_ms(100);
PORTC=127;
delay_ms(100);
PORTC=255;
delay_ms(100);
}
}
}
Tidak ada komentar:
Posting Komentar