Created
May 14, 2019 09:46
-
-
Save avr-programmierung/b497de93dad9a65473cac535d3f72911 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz 07
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
/* code007.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
const uint8_t UPPER_LEVEL=200; // Deklaration einer Konstanten mit dem Namen upper_level | |
const uint8_t LOWER_LEVEL=100; // Deklaration einer Konstanten mit dem Namen lower_level | |
int main(void) | |
{ | |
uint8_t data = 110; | |
while(1) | |
{ | |
if (data > UPPER_LEVEL) // wenn data größer als UPPER_LEVEL | |
{ | |
PORTD = (1<<PD0); // PD0 = High | |
} | |
else if (data < LOWER_LEVEL) // wenn data kleiner als LOWER_LEVEL | |
{ | |
PORTD = (1<<PD1); // PD1 = High | |
} | |
else if ((data >= LOWER_LEVEL) && (data <= UPPER_LEVEL)) // wenn data größer gleich LOWER_LEVEL UND kleiner gleich UPPER_LEVEL | |
{ | |
PORTD = 0x00; // PORTD = LOW | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment