Created
May 14, 2019 10:15
-
-
Save avr-programmierung/c441c17c1a1ed96f301cc0f0bf5815a4 to your computer and use it in GitHub Desktop.
ATmega88 @ 1MHz Binärzähler
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
/* binaerzaehler_01.c ATmega88 @ 1MHz */ | |
#include <avr/io.h> | |
#include <avr/delay.h> | |
int main(void) | |
{ | |
DDRB = ~(1<<PB6); // PinB6 = Eingang | |
DDRC |= 0xFF; // PORTC = Ausgang | |
while(1) | |
{ | |
if (!(PINB & (1<<PINB6))) // Wenn Taster an PB6 = gedrückt (LOW) | |
{ | |
_delay_ms(20); // 20ms Prellzeit nach Tastendruck abwarten | |
if (PINB & (1<<PINB6)) // Wenn Taster an PB6 = losgelassen (HIGH) | |
{ | |
_delay_ms(20); // 20ms Prellzeit nach dem Loslassen des Tasters abwarten | |
PORTC ++; // PORTC um 1 erhöhen | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment