m (Sandeep moved page 8.AVR Interfacing:Switches & LEDs to 8.AVR Switches and LED: Nice title)
(No difference)

Revision as of 10:20, 21 November 2014


Code

  1. #include <avr/io.h>
  2. #define SW 0
  3. #define LED 1
  4. int main(void)
  5. {
  6. DDRB &= ~(1<<SW); //switch as input
  7. DDRB |= (1<<LED); //led as output
  8. while(1)
  9. {
  10. if ((PINB&(1<<SW)) == 1)
  11. PORTB |= (1<<LED);
  12. PORTB &= ~ (1<<LED);
  13. }
  14. }

Schematic

Schematic AVR Interfacing Switches & LEDS.JPG Code and Explanation will be updated soon..