LEDの点滅や、ブザーのOn,Offの周期測定をおこなう。 搬送波の周期は測定できない(10ms周期以上のON,OFF)
Dependencies: AQM0802A DigitalSw mbed
Diff: main.cpp
- Revision:
- 0:c5384fa0fc28
- Child:
- 1:d4291fd3a94c
diff -r 000000000000 -r c5384fa0fc28 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat May 20 01:33:48 2017 +0000 @@ -0,0 +1,78 @@ +#include "mbed.h" +#include <AQM0802A.h> +#include "testLed.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; + +Ticker tickerLed1; +Ticker tickerLed2; + +InterruptIn lightIn(p16); + +void ledOn(void) +{ +// myled4 = 1; + + offTime = timer.read_ms(); + timer.reset(); + lcd.cls(); + lcd.printf("on %d off %d",onTime, offTime); + + } + +void ledOff(void) +{ + // myled4 = 0; + + onTime = timer.read_ms(); + timer.reset(); + lcd.cls(); + lcd.printf("on %d off %d",onTime, offTime); + + + } + +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; + + } +}