Valery Roman
/
Nucleo_pwm
gg wp
main.cpp@0:1b0885c2fe42, 2018-04-03 (annotated)
- Committer:
- oZGi
- Date:
- Tue Apr 03 11:24:57 2018 +0000
- Revision:
- 0:1b0885c2fe42
body loh;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oZGi | 0:1b0885c2fe42 | 1 | #include "mbed.h" |
oZGi | 0:1b0885c2fe42 | 2 | |
oZGi | 0:1b0885c2fe42 | 3 | DigitalOut led(LED2); |
oZGi | 0:1b0885c2fe42 | 4 | |
oZGi | 0:1b0885c2fe42 | 5 | DigitalIn ButtoIn(D4); |
oZGi | 0:1b0885c2fe42 | 6 | |
oZGi | 0:1b0885c2fe42 | 7 | AnalogOut tri(A2); |
oZGi | 0:1b0885c2fe42 | 8 | |
oZGi | 0:1b0885c2fe42 | 9 | |
oZGi | 0:1b0885c2fe42 | 10 | int main() { |
oZGi | 0:1b0885c2fe42 | 11 | led = 0; |
oZGi | 0:1b0885c2fe42 | 12 | while(1) { |
oZGi | 0:1b0885c2fe42 | 13 | |
oZGi | 0:1b0885c2fe42 | 14 | // if(ButtoIn == 0){ |
oZGi | 0:1b0885c2fe42 | 15 | // //led = 1; |
oZGi | 0:1b0885c2fe42 | 16 | //// wait(1); |
oZGi | 0:1b0885c2fe42 | 17 | // |
oZGi | 0:1b0885c2fe42 | 18 | // tri = tri + 0.1; |
oZGi | 0:1b0885c2fe42 | 19 | // wait_us(1); |
oZGi | 0:1b0885c2fe42 | 20 | // if(tri == 1){ |
oZGi | 0:1b0885c2fe42 | 21 | // tri = 0; |
oZGi | 0:1b0885c2fe42 | 22 | // } |
oZGi | 0:1b0885c2fe42 | 23 | // wait(0.5); |
oZGi | 0:1b0885c2fe42 | 24 | // |
oZGi | 0:1b0885c2fe42 | 25 | // } |
oZGi | 0:1b0885c2fe42 | 26 | // led = 0; |
oZGi | 0:1b0885c2fe42 | 27 | |
oZGi | 0:1b0885c2fe42 | 28 | if(ButtoIn == 1){ |
oZGi | 0:1b0885c2fe42 | 29 | tri = tri +0.1; |
oZGi | 0:1b0885c2fe42 | 30 | wait_us(1); |
oZGi | 0:1b0885c2fe42 | 31 | if(tri == 1){ |
oZGi | 0:1b0885c2fe42 | 32 | tri = 0; |
oZGi | 0:1b0885c2fe42 | 33 | } |
oZGi | 0:1b0885c2fe42 | 34 | } |
oZGi | 0:1b0885c2fe42 | 35 | |
oZGi | 0:1b0885c2fe42 | 36 | } |
oZGi | 0:1b0885c2fe42 | 37 | } |