xxxx
Dependencies: mbed
LED chaser with a ticker
The easy programm will schow you a ISR routine (InterruptService Routine). The information for the chaser is comming from a array.
B. Schiemann Feb 2018
main.cpp@0:bc201c33d58f, 2018-02-07 (annotated)
- Committer:
- BSchiemann
- Date:
- Wed Feb 07 14:20:22 2018 +0000
- Revision:
- 0:bc201c33d58f
Lauflicht with timer ticker
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BSchiemann | 0:bc201c33d58f | 1 | #//12a_Laufli_Ticker |
BSchiemann | 0:bc201c33d58f | 2 | #include "mbed.h" |
BSchiemann | 0:bc201c33d58f | 3 | |
BSchiemann | 0:bc201c33d58f | 4 | PortOut laufliPort(PortC, 0x00FF); |
BSchiemann | 0:bc201c33d58f | 5 | Ticker ticker; |
BSchiemann | 0:bc201c33d58f | 6 | const unsigned int laufliValues[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; |
BSchiemann | 0:bc201c33d58f | 7 | int state=-1; |
BSchiemann | 0:bc201c33d58f | 8 | |
BSchiemann | 0:bc201c33d58f | 9 | void isr_nextState() |
BSchiemann | 0:bc201c33d58f | 10 | { |
BSchiemann | 0:bc201c33d58f | 11 | state++; |
BSchiemann | 0:bc201c33d58f | 12 | state=state%8; |
BSchiemann | 0:bc201c33d58f | 13 | laufliPort = laufliValues[state]; |
BSchiemann | 0:bc201c33d58f | 14 | } |
BSchiemann | 0:bc201c33d58f | 15 | |
BSchiemann | 0:bc201c33d58f | 16 | int main() |
BSchiemann | 0:bc201c33d58f | 17 | { |
BSchiemann | 0:bc201c33d58f | 18 | ticker.attach(&isr_nextState,0.5); |
BSchiemann | 0:bc201c33d58f | 19 | while(1) { } |
BSchiemann | 0:bc201c33d58f | 20 | } |