Difference between revisions of "Switch and a LED with AVR"
m (Sandeep moved page 8.AVR Interfacing:Switches & LEDs to 8.AVR Switches and LED: Nice title) |
m (Sandeep moved page 8.AVR Switches and LED to 8.AVR Switch and LED) |
(No difference)
|
Revision as of 10:20, 21 November 2014
Code
#include <avr/io.h> #define SW 0 #define LED 1 int main(void) { DDRB &= ~(1<<SW); //switch as input DDRB |= (1<<LED); //led as output while(1) { if ((PINB&(1<<SW)) == 1) PORTB |= (1<<LED); PORTB &= ~ (1<<LED); } }