From c2f9c584b9468cd4727d9cb01530534f83f293b8 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Fri, 15 Jan 2016 15:56:55 +0100 Subject: [PATCH] at init set buzzer to low,at adc vonversion stop shedular dutycycle --- examples/osd/arduino-wateralert/sketch.pde | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/osd/arduino-wateralert/sketch.pde b/examples/osd/arduino-wateralert/sketch.pde index 7f7360eb1..b8a6d559a 100644 --- a/examples/osd/arduino-wateralert/sketch.pde +++ b/examples/osd/arduino-wateralert/sketch.pde @@ -13,6 +13,7 @@ extern "C" { #include "rest-engine.h" +extern volatile uint8_t mcusleepcycle; // default 16 extern resource_t res_moisture, res_battery; uint8_t moisture_pin = A5; uint16_t moisture_voltage = 0; @@ -27,7 +28,7 @@ void setup (void) digitalWrite(LED_PIN, HIGH); // setup Buzzer pinMode(BUZZER_PIN, OUTPUT); - digitalWrite(BUZZER_PIN, HIGH); + digitalWrite(BUZZER_PIN, LOW); // init coap resourcen rest_init_engine (); rest_activate_resource (&res_moisture, "s/moisture"); @@ -36,10 +37,12 @@ void setup (void) void loop (void) { + mcusleepcycle=0; // dont sleep moisture_voltage = analogRead(moisture_pin); if(moisture_voltage < 800){ digitalWrite(BUZZER_PIN, LOW); }else{ digitalWrite(BUZZER_PIN, HIGH); } + mcusleepcycle=32; // sleep, wakeup every 32 cycles }