Testing with Daniel
Dependencies: mbed Blinker TextLCD
main.cpp@0:fdb33524a029, 2017-01-07 (annotated)
- Committer:
- jurgis
- Date:
- Sat Jan 07 12:47:40 2017 +0000
- Revision:
- 0:fdb33524a029
- Child:
- 1:b95c3509df0f
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jurgis | 0:fdb33524a029 | 1 | #include "mbed.h" |
jurgis | 0:fdb33524a029 | 2 | |
jurgis | 0:fdb33524a029 | 3 | DigitalOut led1(LED1); |
jurgis | 0:fdb33524a029 | 4 | DigitalOut greenLed(D8); |
jurgis | 0:fdb33524a029 | 5 | DigitalIn button(D9); |
jurgis | 0:fdb33524a029 | 6 | Serial pc(USBTX, USBRX); |
jurgis | 0:fdb33524a029 | 7 | |
jurgis | 0:fdb33524a029 | 8 | double ledWait = 0.2; // sec |
jurgis | 0:fdb33524a029 | 9 | |
jurgis | 0:fdb33524a029 | 10 | double getWaitTime() |
jurgis | 0:fdb33524a029 | 11 | { |
jurgis | 0:fdb33524a029 | 12 | double waitTime = (button == 0) ? 0.2 : 1.0; |
jurgis | 0:fdb33524a029 | 13 | pc.printf("waitTime: %0.1f\r\n", waitTime); |
jurgis | 0:fdb33524a029 | 14 | return waitTime; |
jurgis | 0:fdb33524a029 | 15 | } |
jurgis | 0:fdb33524a029 | 16 | |
jurgis | 0:fdb33524a029 | 17 | int main() |
jurgis | 0:fdb33524a029 | 18 | { |
jurgis | 0:fdb33524a029 | 19 | greenLed = 0; |
jurgis | 0:fdb33524a029 | 20 | pc.baud(115200); |
jurgis | 0:fdb33524a029 | 21 | pc.printf("Hello world\r\n"); |
jurgis | 0:fdb33524a029 | 22 | |
jurgis | 0:fdb33524a029 | 23 | while(1) |
jurgis | 0:fdb33524a029 | 24 | { |
jurgis | 0:fdb33524a029 | 25 | pc.printf("ON\r\n"); |
jurgis | 0:fdb33524a029 | 26 | led1 = 1; // LED is ON |
jurgis | 0:fdb33524a029 | 27 | greenLed = 0; |
jurgis | 0:fdb33524a029 | 28 | |
jurgis | 0:fdb33524a029 | 29 | wait(getWaitTime()); |
jurgis | 0:fdb33524a029 | 30 | |
jurgis | 0:fdb33524a029 | 31 | pc.printf("OFF\r\n"); |
jurgis | 0:fdb33524a029 | 32 | led1 = 0; // LED is OFF |
jurgis | 0:fdb33524a029 | 33 | greenLed = 1; |
jurgis | 0:fdb33524a029 | 34 | |
jurgis | 0:fdb33524a029 | 35 | wait(getWaitTime()); |
jurgis | 0:fdb33524a029 | 36 | } |
jurgis | 0:fdb33524a029 | 37 | } |