Created
October 25, 2012 13:44
-
-
Save carlosmn/3952620 to your computer and use it in GitHub Desktop.
Fußgängerampel-Simulation
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
#define SLEEP_QUANTUM 10000 | |
#define SLEEP(n) do { \ | |
long time = n * 100000; /* wait() sleeps 10*n microseconds */ \ | |
while(time > SLEEP_QUANTUM) { \ | |
wait(SLEEP_QUANTUM); \ | |
time -= SLEEP_QUANTUM; \ | |
} \ | |
wait(time); \ | |
} while(0) | |
LED_OFF(LED_ROT | LED_GELB | LED_GRUEN); | |
//===Hier die Endlosschleife quasi das Betriebssystem===================== | |
while(1){ | |
while (!(P1IN & TASTE_LINKS)) { | |
; // Cycles verschwenden FTW | |
} | |
// Wenn die Taste gedrueckt wird | |
LED_ON(LED_GELB); | |
SLEEP(1); | |
LED_OFF(LED_GELB); | |
LED_ON(LED_ROT); | |
SLEEP(2); | |
LED_ON(LED_GELB); | |
SLEEP(3); | |
LED_OFF(LED_ROT | LED_GELB); | |
LED_ON(LED_GRUEN); | |
SLEEP(4); | |
LED_OFF(LED_GRUEN); | |
SLEEP(5); | |
} // Ende der Endlosschleife | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment