![](/media/cache/profiles/90a82bf94b4c5981e7e68ff425e519f3.50x50_q85.jpg)
LEDの点滅や、ブザーのOn,Offの周期測定をおこなう。 搬送波の周期は測定できない(10ms周期以上のON,OFF)
Dependencies: AQM0802A DigitalSw mbed
Diff: main.cpp
- Revision:
- 1:d4291fd3a94c
- Parent:
- 0:c5384fa0fc28
- Child:
- 3:2a8fdcc54c95
--- a/main.cpp Sat May 20 01:33:48 2017 +0000 +++ b/main.cpp Sat May 20 12:23:42 2017 +0000 @@ -1,78 +1,28 @@ #include "mbed.h" -#include <AQM0802A.h> #include "testLed.h" +#include "priodMsurement.h" -I2C i2c(p28, p27); -AQM0802A lcd(i2c); // if 5.0v supply, (i2c, false); //DigitalOut myled1(LED1); DigitalOut myled2(LED2); -DigitalOut myled3(LED3); -DigitalOut myled4(LED4); - -Timer timer; -uint16_t onTime; -uint16_t offTime; +//DigitalOut myled3(LED3); +//DigitalOut myled4(LED4); -Ticker tickerLed1; -Ticker tickerLed2; +DigitalIn demoLedSw(p20, PullUp); -InterruptIn lightIn(p16); - -void ledOn(void) -{ -// myled4 = 1; - offTime = timer.read_ms(); - timer.reset(); - lcd.cls(); - lcd.printf("on %d off %d",onTime, offTime); +int main() +{ + testLedInitalize(); + priodMsurementInitalize(); - } -void ledOff(void) -{ - // myled4 = 0; + testLedMain(true); - onTime = timer.read_ms(); - timer.reset(); - lcd.cls(); - lcd.printf("on %d off %d",onTime, offTime); - + while(1) { + testLedMain(!demoLedSw); + priodMsurementMain(); } - -void outputLed1(void) -{ -// myled1 = !myled1; - } - -void outputLed2(void) -{ - myled4 = !myled4; - } - -int main() { - testLedInitalize(); - - lcd.cls(); -// lcd.printf("iter: \r\n"); - lcd.printf("test"); - timer.start(); - - lightIn.rise(&ledOn); - lightIn.fall(&ledOff); - - tickerLed1.attach(&outputLed1, 0.1); - tickerLed2.attach(&outputLed2, 0.5); - - - testLedMain(true); - - while(1) { - testLedMain(false); - // myled3 =lightIn; - - } }