Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Created May 14, 2019 10:12
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/5cb78e3c63c400ed1c9a4bbdb721d0a6 to your computer and use it in GitHub Desktop.
Save avr-programmierung/5cb78e3c63c400ed1c9a4bbdb721d0a6 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz Taster 01
/* 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