![](/media/cache/profiles/90a82bf94b4c5981e7e68ff425e519f3.50x50_q85.jpg)
LEDの点滅や、ブザーのOn,Offの周期測定をおこなう。 搬送波の周期は測定できない(10ms周期以上のON,OFF)
Dependencies: AQM0802A DigitalSw mbed
main.cpp@3:2a8fdcc54c95, 2017-06-05 (annotated)
- Committer:
- suupen
- Date:
- Mon Jun 05 12:31:15 2017 +0000
- Revision:
- 3:2a8fdcc54c95
- Parent:
- 1:d4291fd3a94c
- Child:
- 4:001603e48dc8
LCD????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
suupen | 3:2a8fdcc54c95 | 1 | #define LCD |
suupen | 3:2a8fdcc54c95 | 2 | |
suupen | 3:2a8fdcc54c95 | 3 | |
suupen | 0:c5384fa0fc28 | 4 | #include "mbed.h" |
suupen | 0:c5384fa0fc28 | 5 | #include "testLed.h" |
suupen | 3:2a8fdcc54c95 | 6 | #include "testSound.h" |
suupen | 1:d4291fd3a94c | 7 | #include "priodMsurement.h" |
suupen | 3:2a8fdcc54c95 | 8 | #include "DigitalSw.h" |
suupen | 0:c5384fa0fc28 | 9 | |
suupen | 0:c5384fa0fc28 | 10 | |
suupen | 3:2a8fdcc54c95 | 11 | #ifdef LCD |
suupen | 3:2a8fdcc54c95 | 12 | #include <AQM0802A.h> |
suupen | 3:2a8fdcc54c95 | 13 | I2C i2c(p28, p27); |
suupen | 3:2a8fdcc54c95 | 14 | AQM0802A lcd(i2c); // if 5.0v supply, (i2c, false); |
suupen | 3:2a8fdcc54c95 | 15 | #endif // LCD |
suupen | 3:2a8fdcc54c95 | 16 | |
suupen | 0:c5384fa0fc28 | 17 | //DigitalOut myled1(LED1); |
suupen | 0:c5384fa0fc28 | 18 | DigitalOut myled2(LED2); |
suupen | 1:d4291fd3a94c | 19 | //DigitalOut myled3(LED3); |
suupen | 1:d4291fd3a94c | 20 | //DigitalOut myled4(LED4); |
suupen | 0:c5384fa0fc28 | 21 | |
suupen | 3:2a8fdcc54c95 | 22 | |
suupen | 1:d4291fd3a94c | 23 | DigitalIn demoLedSw(p20, PullUp); |
suupen | 3:2a8fdcc54c95 | 24 | //DigitalSw startSw(p20); |
suupen | 3:2a8fdcc54c95 | 25 | DigitalSw upSw(p8); |
suupen | 3:2a8fdcc54c95 | 26 | DigitalSw downSw(p14); |
suupen | 0:c5384fa0fc28 | 27 | |
suupen | 1:d4291fd3a94c | 28 | int main() |
suupen | 1:d4291fd3a94c | 29 | { |
suupen | 3:2a8fdcc54c95 | 30 | int8_t p = 0; |
suupen | 3:2a8fdcc54c95 | 31 | int32_t loPriod; |
suupen | 3:2a8fdcc54c95 | 32 | int32_t hiPriod; |
suupen | 0:c5384fa0fc28 | 33 | |
suupen | 3:2a8fdcc54c95 | 34 | priodMsurementInitalize(); |
suupen | 3:2a8fdcc54c95 | 35 | testLedInitalize(); |
suupen | 3:2a8fdcc54c95 | 36 | testSoundInitalize(); |
suupen | 0:c5384fa0fc28 | 37 | |
suupen | 3:2a8fdcc54c95 | 38 | int count =0; |
suupen | 0:c5384fa0fc28 | 39 | |
suupen | 1:d4291fd3a94c | 40 | while(1) { |
suupen | 3:2a8fdcc54c95 | 41 | myled2 = !myled2; |
suupen | 3:2a8fdcc54c95 | 42 | |
suupen | 3:2a8fdcc54c95 | 43 | #if 0 |
suupen | 3:2a8fdcc54c95 | 44 | testSoundMain(!demoLedSw); |
suupen | 1:d4291fd3a94c | 45 | testLedMain(!demoLedSw); |
suupen | 3:2a8fdcc54c95 | 46 | #endif |
suupen | 3:2a8fdcc54c95 | 47 | |
suupen | 3:2a8fdcc54c95 | 48 | priodMsurementMain(); |
suupen | 3:2a8fdcc54c95 | 49 | |
suupen | 3:2a8fdcc54c95 | 50 | if(upSw.getOnEdge() == 1) { |
suupen | 3:2a8fdcc54c95 | 51 | if(++p >= 50) { |
suupen | 3:2a8fdcc54c95 | 52 | p = 49; |
suupen | 3:2a8fdcc54c95 | 53 | } |
suupen | 3:2a8fdcc54c95 | 54 | } |
suupen | 3:2a8fdcc54c95 | 55 | |
suupen | 3:2a8fdcc54c95 | 56 | if(downSw.getOnEdge() == 1) { |
suupen | 3:2a8fdcc54c95 | 57 | if(--p <= 0) { |
suupen | 3:2a8fdcc54c95 | 58 | p = 0; |
suupen | 3:2a8fdcc54c95 | 59 | } |
suupen | 3:2a8fdcc54c95 | 60 | } |
suupen | 3:2a8fdcc54c95 | 61 | |
suupen | 3:2a8fdcc54c95 | 62 | #ifdef LCD |
suupen | 3:2a8fdcc54c95 | 63 | if(true == surementData((uint8_t)p, &hiPriod, &loPriod)) { |
suupen | 3:2a8fdcc54c95 | 64 | lcd.cls(); |
suupen | 3:2a8fdcc54c95 | 65 | lcd.printf("p = %2d hi = %d\n",p, hiPriod); |
suupen | 3:2a8fdcc54c95 | 66 | lcd.printf(" lo = %d",loPriod); |
suupen | 3:2a8fdcc54c95 | 67 | wait(0.2); |
suupen | 3:2a8fdcc54c95 | 68 | } |
suupen | 3:2a8fdcc54c95 | 69 | #endif // LCD |
suupen | 0:c5384fa0fc28 | 70 | |
suupen | 0:c5384fa0fc28 | 71 | } |
suupen | 3:2a8fdcc54c95 | 72 | |
suupen | 0:c5384fa0fc28 | 73 | } |