-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update range TX program to blink LED and send at slower rate
- Loading branch information
Showing
1 changed file
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
// Transmit sketch used to report quality of reception. | ||
// 2012-03-22 <cbrake@bec-systems.com> http://opensource.org/licenses/mit-license.php | ||
|
||
// based on: https://github.com/jcw/jeelib/tree/master/examples/RF12/rfRangeTX | ||
// 2011-05-14 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php | ||
|
||
// Based on a sample implementation by Steve Evans (@tankslappa). | ||
|
||
#include <JeeLib.h> | ||
|
||
#define LED_PIN 9 // activity LED, comment out to disable | ||
|
||
byte outData, pending; | ||
MilliTimer sendTimer; | ||
|
||
static void activityLed (byte on) { | ||
#ifdef LED_PIN | ||
pinMode(LED_PIN, OUTPUT); | ||
digitalWrite(LED_PIN, !on); | ||
#endif | ||
} | ||
|
||
void setup() { | ||
rf12_initialize('T', RF12_868MHZ, 88); | ||
rf12_initialize('T', RF12_915MHZ); | ||
} | ||
|
||
void loop() { | ||
rf12_recvDone(); | ||
|
||
if (sendTimer.poll(100)) { | ||
if (sendTimer.poll(200)) { | ||
++outData; | ||
pending = 1; | ||
} | ||
|
||
if (pending && rf12_canSend()) { | ||
activityLed(1); | ||
rf12_sendStart(0, &outData, sizeof outData); | ||
pending = 0; | ||
delay(5); | ||
activityLed(0); | ||
} | ||
} |