Skip to content

Instantly share code, notes, and snippets.

@manishiitg
Created October 3, 2014 07:39
Show Gist options
  • Save manishiitg/3f451adcf0616ac997ba to your computer and use it in GitHub Desktop.
Save manishiitg/3f451adcf0616ac997ba to your computer and use it in GitHub Desktop.
Atmega16/32 Basic LED Push Button
#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