Created
October 3, 2014 07:39
-
-
Save manishiitg/3f451adcf0616ac997ba to your computer and use it in GitHub Desktop.
Atmega16/32 Basic LED Push Button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include <util/delay.h> | |
int main(void){ | |
DDRB |= 1 << PINB0;; //set pin0 as output | |
DDRB &= ~(1 << PINB1); // set pin1 input | |
PORTB |= 1 << PINB0; | |
while(1){ | |
// check if PB1 is clear or GND then turn on the led else turn it off | |
if(bit_is_clear(PINB,1)){ | |
PORTB = 0b00000001; | |
}else{ | |
PORTB = 0b00000000; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment