Markus Müller
/
ampel_01
fabian lutscht :o
main.cpp@2:cd8fa44e7f22, 2014-05-28 (annotated)
- Committer:
- p0ckin3d
- Date:
- Wed May 28 12:34:40 2014 +0000
- Revision:
- 2:cd8fa44e7f22
- Parent:
- 1:69b163b1e72d
lucijan lutscht :o
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 | 2:cd8fa44e7f22 | 6 | AnalogIn poti(p19); |
p0ckin3d | 2:cd8fa44e7f22 | 7 | AnalogIn poti2(p20); |
p0ckin3d | 0:16e4a044f776 | 8 | |
p0ckin3d | 0:16e4a044f776 | 9 | void start() |
p0ckin3d | 0:16e4a044f776 | 10 | { |
p0ckin3d | 0:16e4a044f776 | 11 | for(unsigned char i=0; i < 4; i++) |
p0ckin3d | 0:16e4a044f776 | 12 | { |
p0ckin3d | 0:16e4a044f776 | 13 | rgb = ~0x02; |
p0ckin3d | 0:16e4a044f776 | 14 | wait(1); |
p0ckin3d | 0:16e4a044f776 | 15 | rgb = 0xFF; |
p0ckin3d | 0:16e4a044f776 | 16 | wait(1); |
p0ckin3d | 0:16e4a044f776 | 17 | } |
p0ckin3d | 0:16e4a044f776 | 18 | rgb = ~0x03; |
p0ckin3d | 0:16e4a044f776 | 19 | wait(3); |
p0ckin3d | 0:16e4a044f776 | 20 | rgb = ~0x01; |
p0ckin3d | 0:16e4a044f776 | 21 | for(unsigned char i = 0; i < 50; i++) |
p0ckin3d | 0:16e4a044f776 | 22 | { |
p0ckin3d | 2:cd8fa44e7f22 | 23 | speaker.period_us(poti.read() * 1000); |
p0ckin3d | 0:16e4a044f776 | 24 | speaker.write(0.9); |
p0ckin3d | 0:16e4a044f776 | 25 | wait(0.1); |
p0ckin3d | 0:16e4a044f776 | 26 | speaker.write(0.0); |
p0ckin3d | 2:cd8fa44e7f22 | 27 | wait(poti2.read()); |
p0ckin3d | 0:16e4a044f776 | 28 | } |
p0ckin3d | 0:16e4a044f776 | 29 | speaker.write(0.0); |
p0ckin3d | 0:16e4a044f776 | 30 | rgb = ~0x03; |
p0ckin3d | 0:16e4a044f776 | 31 | speaker.write(0.0); |
p0ckin3d | 0:16e4a044f776 | 32 | wait(3); |
p0ckin3d | 0:16e4a044f776 | 33 | rgb = ~0x02; |
p0ckin3d | 0:16e4a044f776 | 34 | } |
p0ckin3d | 0:16e4a044f776 | 35 | |
p0ckin3d | 0:16e4a044f776 | 36 | |
p0ckin3d | 0:16e4a044f776 | 37 | int main() { |
p0ckin3d | 0:16e4a044f776 | 38 | button.rise(&start); |
p0ckin3d | 0:16e4a044f776 | 39 | speaker.period_us(1000); |
p0ckin3d | 0:16e4a044f776 | 40 | rgb = ~0x02; |
p0ckin3d | 0:16e4a044f776 | 41 | while(1) { |
p0ckin3d | 0:16e4a044f776 | 42 | |
p0ckin3d | 0:16e4a044f776 | 43 | } |
p0ckin3d | 0:16e4a044f776 | 44 | } |