Created
May 14, 2019 10:13
-
-
Save avr-programmierung/a063225ff8ecdf27e9071a8e3359e282 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz Taster 02
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_02.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
#include <util/delay.h> | |
int main(void) | |
{ | |
DDRB = (1<<PB0); // PORTB Pin0 = Ausgang | |
DDRD = ~((1<<PIND0)|(1<<PIND1)); // PORTD PIN0 und PIN1 = Eingang | |
PORTD |= (1<<PD0); // internen Pull-Up Widerstand aktivieren | |
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