Kristijan Župančić
/
Pulsni_valni_izlaz
Zadatak 3-4
main.cpp@0:8748fc4ae628, 2015-12-10 (annotated)
- Committer:
- Kzupancic
- Date:
- Thu Dec 10 14:59:30 2015 +0000
- Revision:
- 0:8748fc4ae628
Pulsni valni izlaz
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kzupancic | 0:8748fc4ae628 | 1 | #include "mbed.h" |
Kzupancic | 0:8748fc4ae628 | 2 | |
Kzupancic | 0:8748fc4ae628 | 3 | int main() { |
Kzupancic | 0:8748fc4ae628 | 4 | DigitalOut led1(LED1); |
Kzupancic | 0:8748fc4ae628 | 5 | DigitalIn inputsw(p7); |
Kzupancic | 0:8748fc4ae628 | 6 | inputsw.mode(PullUp); |
Kzupancic | 0:8748fc4ae628 | 7 | float tx=0.5; |
Kzupancic | 0:8748fc4ae628 | 8 | float ty=0.5; |
Kzupancic | 0:8748fc4ae628 | 9 | |
Kzupancic | 0:8748fc4ae628 | 10 | while(1){ |
Kzupancic | 0:8748fc4ae628 | 11 | led1=0; |
Kzupancic | 0:8748fc4ae628 | 12 | wait(tx); |
Kzupancic | 0:8748fc4ae628 | 13 | led1=1; |
Kzupancic | 0:8748fc4ae628 | 14 | wait(tx); |
Kzupancic | 0:8748fc4ae628 | 15 | if(inputsw==1){ |
Kzupancic | 0:8748fc4ae628 | 16 | tx=ty/2.0; |
Kzupancic | 0:8748fc4ae628 | 17 | } |
Kzupancic | 0:8748fc4ae628 | 18 | else if (inputsw==0) |
Kzupancic | 0:8748fc4ae628 | 19 | { |
Kzupancic | 0:8748fc4ae628 | 20 | tx=ty*2; |
Kzupancic | 0:8748fc4ae628 | 21 | } |
Kzupancic | 0:8748fc4ae628 | 22 | } |
Kzupancic | 0:8748fc4ae628 | 23 | } |