Created
May 14, 2019 09:30
-
-
Save avr-programmierung/32f4d1119e0bdf5c54c9ec09047fd6b3 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz 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
/* code002.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> // Einbinden der Headerdatei avr/io.h | |
#include <util/delay.h> // Einbinden der Headerdatei util/delay.h | |
uint8_t x=1, y=0; // Initialisierung der globalen Variablen x und y | |
int main(void) // Startpunkt eines C-Programms | |
{ | |
DDRD |= (1<<PD0); // Richtungsregister PORTD PinD0 auf Ausgang | |
while(1) // Beginn der Endlosschleife | |
{ | |
if (x <= 10) // Solange x kleiner oder gleich 10 | |
{ | |
PORTD |= (1<<PD0); // Portpin PD0 setzen = HIGH | |
_delay_ms(500); // 500ms warten | |
PORTD &= ~(1<<PD0); // Portpin PD0 löschen = LOW | |
_delay_ms(500); // 500ms warten | |
x ++; // x um 1 inkrementieren | |
y += x; // y summiert x (man könnte auch y=y+x; schreiben) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment