Markus Müller
/
ampel_01
fabian lutscht :o
main.cpp@1:69b163b1e72d, 2014-05-28 (annotated)
- Committer:
- p0ckin3d
- Date:
- Wed May 28 12:19:06 2014 +0000
- Revision:
- 1:69b163b1e72d
- Parent:
- 0:16e4a044f776
- Child:
- 2:cd8fa44e7f22
bugfix
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
p0ckin3d | 0:16e4a044f776 | 1 | #include "mbed.h" |
p0ckin3d | 0:16e4a044f776 | 2 | |
p0ckin3d | 0:16e4a044f776 | 3 | BusOut rgb(p23, p24, p25); |
p0ckin3d | 0:16e4a044f776 | 4 | InterruptIn button(p14); |
p0ckin3d | 0:16e4a044f776 | 5 | PwmOut speaker(p26); |
p0ckin3d | 0:16e4a044f776 | 6 | |
p0ckin3d | 0:16e4a044f776 | 7 | void start() |
p0ckin3d | 0:16e4a044f776 | 8 | { |
p0ckin3d | 0:16e4a044f776 | 9 | for(unsigned char i=0; i < 4; i++) |
p0ckin3d | 0:16e4a044f776 | 10 | { |
p0ckin3d | 0:16e4a044f776 | 11 | rgb = ~0x02; |
p0ckin3d | 0:16e4a044f776 | 12 | wait(1); |
p0ckin3d | 0:16e4a044f776 | 13 | rgb = 0xFF; |
p0ckin3d | 0:16e4a044f776 | 14 | wait(1); |
p0ckin3d | 0:16e4a044f776 | 15 | } |
p0ckin3d | 0:16e4a044f776 | 16 | rgb = ~0x03; |
p0ckin3d | 0:16e4a044f776 | 17 | wait(3); |
p0ckin3d | 0:16e4a044f776 | 18 | rgb = ~0x01; |
p0ckin3d | 0:16e4a044f776 | 19 | for(unsigned char i = 0; i < 50; i++) |
p0ckin3d | 0:16e4a044f776 | 20 | { |
p0ckin3d | 0:16e4a044f776 | 21 | speaker.write(0.9); |
p0ckin3d | 0:16e4a044f776 | 22 | wait(0.1); |
p0ckin3d | 0:16e4a044f776 | 23 | speaker.write(0.0); |
p0ckin3d | 0:16e4a044f776 | 24 | wait(0.1); |
p0ckin3d | 0:16e4a044f776 | 25 | } |
p0ckin3d | 0:16e4a044f776 | 26 | speaker.write(0.0); |
p0ckin3d | 0:16e4a044f776 | 27 | rgb = ~0x03; |
p0ckin3d | 0:16e4a044f776 | 28 | speaker.write(0.0); |
p0ckin3d | 0:16e4a044f776 | 29 | wait(3); |
p0ckin3d | 0:16e4a044f776 | 30 | rgb = ~0x02; |
p0ckin3d | 0:16e4a044f776 | 31 | } |
p0ckin3d | 0:16e4a044f776 | 32 | |
p0ckin3d | 0:16e4a044f776 | 33 | |
p0ckin3d | 0:16e4a044f776 | 34 | int main() { |
p0ckin3d | 0:16e4a044f776 | 35 | button.rise(&start); |
p0ckin3d | 0:16e4a044f776 | 36 | speaker.period_us(1000); |
p0ckin3d | 0:16e4a044f776 | 37 | rgb = ~0x02; |
p0ckin3d | 0:16e4a044f776 | 38 | while(1) { |
p0ckin3d | 0:16e4a044f776 | 39 | |
p0ckin3d | 0:16e4a044f776 | 40 | } |
p0ckin3d | 0:16e4a044f776 | 41 | } |