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

#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);
   }
}

Schematic

Schematic AVR Interfacing Switches & LEDS.JPG

Code and Explanation will be updated soon..