ATmega88 @ 8MHz Taster 01
This file contains 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
/* taster_01.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
#include <util/delay.h> | |
int main(void) | |
{ | |
DDRB = (1<<PB0); // PORTB Pin0 = Ausgang (LED1) | |
DDRD = ~((1<<PIND0)|(1<<PIND1)); // PORTD PIN0 und PIN1 = Eingang | |
while(1) | |
{ | |
if (!(PIND & (1<<PIND0))) // Wenn Taster = LOW | |
{ | |
PORTB |= (1<<PB0); // LED = ON | |
} | |
else if (PIND & (1<<PIND1)) // Wenn Taster = HIGH | |
{ | |
PORTB &= ~(1<<PB0); // LED = OFF | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment