LoRa node acquiring random float value and sending to LoRa Server - Working ok
Fork of SX1276GenericLib by
Arduino-mbed-APIs/examples/TimerTest/TimerTest.ino
- Committer:
- Helmut Tschemernjak
- Date:
- 2017-11-18
- Revision:
- 99:0e85871f676a
- Parent:
- 75:7330dd86cdea
- Child:
- 100:c80d1416bdf6
File content as of revision 99:0e85871f676a:
#include "arduino-mbed.h" void TestTimeoutFunc(void); void TestTimeoutFunc55(void); void TestTimeoutFunc10(void); void TestTimeoutFunc1m(void); void SwitchInput(void); #ifdef ARDUINO_ARCH_ESP32 #define SW0 0 #define LED 2 #define MYSERIAL Serial #else #define SW0 3 // switch needs pullup #define LED LED_BUILTIN #define MYSERIAL Serial #endif DigitalOut led(LED); InterruptIn intr(SW0); Timeout tp; Timeout tp2; Timeout tp3; Timeout tp4; void setup() { MYSERIAL.begin(230400); InitSerial(&MYSERIAL, 5000, &led, true); ser->println("TimerTest"); tp.attach(callback(&TestTimeoutFunc), 1000); tp2.attach(callback(&TestTimeoutFunc55), 5500); tp3.attach(callback(&TestTimeoutFunc10), 10000); // tp4.attach(callback(&TestTimeoutFunc1m), 1); intr.mode(PullUp); intr.fall(callback(&SwitchInput)); } void loop() { // led = !led; sleep(); // or deepsleep() } void TestTimeoutFunc(void) { tp.attach(callback(&TestTimeoutFunc), 1000); led = !led; ser->print(ms_getTicker(), DEC); ser->println(" TestTimeoutFunc 1 sec"); } void TestTimeoutFunc55(void) { tp2.attach(callback(&TestTimeoutFunc55), 5500); ser->print(ms_getTicker(), DEC); ser->println(" TestTimeoutFunc 5.5 sec"); } void TestTimeoutFunc10(void) { tp3.attach(callback(&TestTimeoutFunc10), 10000); ser->print(ms_getTicker(), DEC); ser->println(" TestTimeoutFunc 10 sec"); } void TestTimeoutFunc1m(void) { tp4.attach(callback(&TestTimeoutFunc1m), 1); } void SwitchInput(void) { ser->print(ms_getTicker(), DEC); ser->println(" SwitchInput"); led = !led; }