Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Created May 14, 2019 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avr-programmierung/a063225ff8ecdf27e9071a8e3359e282 to your computer and use it in GitHub Desktop.
Save avr-programmierung/a063225ff8ecdf27e9071a8e3359e282 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz Taster 02
/* 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