Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Created May 14, 2019 09:46
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/b497de93dad9a65473cac535d3f72911 to your computer and use it in GitHub Desktop.
Save avr-programmierung/b497de93dad9a65473cac535d3f72911 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz 07
/* 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