Skip to content

Commit

Permalink
add heartbeat LEDs
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrake committed May 28, 2012
1 parent dc51b18 commit 69e9083
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
26 changes: 22 additions & 4 deletions examples/RemoteAlarm/Monitor/Monitor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,34 @@

#define LED_PIN 9 // activity LED, comment out to disable
#define BEEP_PIN 5 // P2
#define GREEN_LED_PIN 7 // P4

MilliTimer beepTimer;
MilliTimer sensorAliveTimer;
MilliTimer heartbeatLed;
int sensor_alive_minutes = 0;

static void activityLed (byte on) {
#ifdef LED_PIN
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, !on);
#endif
digitalWrite(LED_PIN, on);
}

void setup () {
Serial.begin(57600);
Serial.print("\n[JeenodeRangeRx]");
Serial.print("\n[BEC Alarm Monitor]");
rf12_initialize('R', RF12_915MHZ);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, 0);

// blink green LED on startup
pinMode(GREEN_LED_PIN, OUTPUT);
digitalWrite(GREEN_LED_PIN, 1);
delay(200);
digitalWrite(GREEN_LED_PIN, 0);
delay(200);
digitalWrite(GREEN_LED_PIN, 1);
delay(200);
digitalWrite(GREEN_LED_PIN, 0);
}

enum state {
Expand Down Expand Up @@ -119,5 +131,11 @@ void loop () {
}
}
}

if (heartbeatLed.poll(1000)) {
digitalWrite(GREEN_LED_PIN, 1);
delay(10);
digitalWrite(GREEN_LED_PIN, 0);
}
}

25 changes: 22 additions & 3 deletions examples/RemoteAlarm/Repeater/Repeater.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,31 @@
#include <JeeLib.h>

#define LED_PIN 9 // activity LED, comment out to disable
#define GREEN_LED_PIN 7 // P4

MilliTimer heartbeatLed;

static void activityLed (byte on) {
#ifdef LED_PIN
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, !on);
#endif
digitalWrite(LED_PIN, on);
}

void setup () {
Serial.begin(57600);
Serial.print("\n[BEC Alarm Repeater]");
rf12_initialize('S', RF12_915MHZ);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, 0);

// blink green LED on startup
pinMode(GREEN_LED_PIN, OUTPUT);
digitalWrite(GREEN_LED_PIN, 1);
delay(200);
digitalWrite(GREEN_LED_PIN, 0);
delay(200);
digitalWrite(GREEN_LED_PIN, 1);
delay(200);
digitalWrite(GREEN_LED_PIN, 0);
}

void send_payload(byte data)
Expand All @@ -41,5 +54,11 @@ void loop () {
Serial.print("\n");
send_payload(lastSeq);
}

if (heartbeatLed.poll(1000)) {
digitalWrite(GREEN_LED_PIN, 1);
delay(10);
digitalWrite(GREEN_LED_PIN, 0);
}
}

0 comments on commit 69e9083

Please sign in to comment.