m
Line 22: Line 22:
  
 
[[File:Schematic AVR Interfacing Switches & LEDS.JPG|680px]]
 
[[File:Schematic AVR Interfacing Switches & LEDS.JPG|680px]]
 +
 
'''Code and Explanation will be updated soon..'''
 
'''Code and Explanation will be updated soon..'''

Revision as of 17:27, 19 March 2015


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..