![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
TaDA
Fork of luce_rossa_piezo by
main.cpp@0:5daff114eb4a, 2016-04-18 (annotated)
- Committer:
- Karrots3
- Date:
- Mon Apr 18 19:28:48 2016 +0000
- Revision:
- 0:5daff114eb4a
- Child:
- 1:0e967fe8862e
.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Karrots3 | 0:5daff114eb4a | 1 | #include "mbed.h" |
Karrots3 | 0:5daff114eb4a | 2 | DigitalIn bottone(p23); |
Karrots3 | 0:5daff114eb4a | 3 | DigitalOut ledR(p25); |
Karrots3 | 0:5daff114eb4a | 4 | DigitalOut ledG(p24); |
Karrots3 | 0:5daff114eb4a | 5 | DigitalOut ledB(p26); |
Karrots3 | 0:5daff114eb4a | 6 | PwmOut piezo(p22); |
Karrots3 | 0:5daff114eb4a | 7 | bool flag=0; |
Karrots3 | 0:5daff114eb4a | 8 | int c=0; |
Karrots3 | 0:5daff114eb4a | 9 | int main() |
Karrots3 | 0:5daff114eb4a | 10 | { |
Karrots3 | 0:5daff114eb4a | 11 | while(1) { |
Karrots3 | 0:5daff114eb4a | 12 | |
Karrots3 | 0:5daff114eb4a | 13 | if(bottone==1&& c>0 && c<=10000) { |
Karrots3 | 0:5daff114eb4a | 14 | ledR=0; |
Karrots3 | 0:5daff114eb4a | 15 | flag=0; |
Karrots3 | 0:5daff114eb4a | 16 | c=0; |
Karrots3 | 0:5daff114eb4a | 17 | piezo.period(1.0 / 200.0); |
Karrots3 | 0:5daff114eb4a | 18 | piezo.write(0.5); |
Karrots3 | 0:5daff114eb4a | 19 | wait(2); |
Karrots3 | 0:5daff114eb4a | 20 | piezo.write(0); |
Karrots3 | 0:5daff114eb4a | 21 | wait(0.05); |
Karrots3 | 0:5daff114eb4a | 22 | } else if(bottone==1) { |
Karrots3 | 0:5daff114eb4a | 23 | ledR=1; |
Karrots3 | 0:5daff114eb4a | 24 | flag=1; |
Karrots3 | 0:5daff114eb4a | 25 | } else if (c>10000) { |
Karrots3 | 0:5daff114eb4a | 26 | piezo.period(1.0 / 600.0); |
Karrots3 | 0:5daff114eb4a | 27 | piezo.write(0.5); |
Karrots3 | 0:5daff114eb4a | 28 | wait(1.0 / 2); |
Karrots3 | 0:5daff114eb4a | 29 | piezo.write(0); |
Karrots3 | 0:5daff114eb4a | 30 | wait(0.05); |
Karrots3 | 0:5daff114eb4a | 31 | } |
Karrots3 | 0:5daff114eb4a | 32 | |
Karrots3 | 0:5daff114eb4a | 33 | if(flag==1) { |
Karrots3 | 0:5daff114eb4a | 34 | c++; |
Karrots3 | 0:5daff114eb4a | 35 | } |
Karrots3 | 0:5daff114eb4a | 36 | |
Karrots3 | 0:5daff114eb4a | 37 | wait_ms(1); |
Karrots3 | 0:5daff114eb4a | 38 | |
Karrots3 | 0:5daff114eb4a | 39 | } |
Karrots3 | 0:5daff114eb4a | 40 | } |