Created
May 14, 2019 09:34
-
-
Save avr-programmierung/38afbd65f7444f46e54708eaa947ad5a to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz 03
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
/* code003.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
#include <util/delay.h> | |
int main(void) | |
{ | |
DDRD = 0xFF; // Richtungsregister PORTD = 1111 1111 | |
uint8_t data = 0x00; // data = 0 | |
while(1) | |
{ | |
if (data & 0x08) // Maskierung mit 0000 1000 (Bit Nr. 3) | |
PORTD = (1<<PD0); // PD0 = High wenn data = 0x08 | |
if (data & 0x40) // Maskierung mit 0100 0000 (Bit Nr. 6) | |
{ | |
PORTD ^= (1<<PD1); // toggled PD1 wenn data = 0x40 | |
PORTD &= ~(1<<PD0); // PD0 = low wenn data = 0x40 | |
data = 0; // Setze data auf 0 zurück | |
} | |
data ++; // Erhöhe den Wert von data bei jedem Schleifendurchlauf um 1 | |
_delay_ms(100); // 100ms warten | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment