root / RF12 / examples / radioBlip / radioBlip.pde
History | View | Annotate | Download (773 Bytes)
| 1 | 7763 | jcw | //>>> The latest version of this code can be found at https://github.com/jcw/ !! |
|---|---|---|---|
| 2 | 7763 | jcw | |
| 3 | 6049 | jcw | // Send out a radio packet every minute, consuming as little power as possible |
| 4 | 5971 | jcw | // 2010-08-29 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php |
| 5 | 5971 | jcw | // $Id$ |
| 6 | 5971 | jcw | |
| 7 | 5994 | jcw | // all the low-power functions have been moved into the Ports library |
| 8 | 5971 | jcw | |
| 9 | 5971 | jcw | #include <Ports.h> |
| 10 | 5971 | jcw | #include <RF12.h> |
| 11 | 5971 | jcw | |
| 12 | 5980 | jcw | static word payload; |
| 13 | 5980 | jcw | |
| 14 | 5971 | jcw | void setup() {
|
| 15 | 6540 | jcw | #ifndef SDCR |
| 16 | 6540 | jcw | DDRB |= bit(0); |
| 17 | 6540 | jcw | for (byte i = 0; i < 6; ++i) {
|
| 18 | 6540 | jcw | PINB = bit(0); |
| 19 | 6540 | jcw | delay(128); |
| 20 | 6540 | jcw | } |
| 21 | 6540 | jcw | #endif |
| 22 | 5971 | jcw | rf12_initialize(4, RF12_868MHZ, 5); |
| 23 | 5971 | jcw | } |
| 24 | 5971 | jcw | |
| 25 | 5971 | jcw | void loop() {
|
| 26 | 5971 | jcw | ++payload; |
| 27 | 5971 | jcw | |
| 28 | 5971 | jcw | while (!rf12_canSend()) |
| 29 | 5971 | jcw | rf12_recvDone(); |
| 30 | 5971 | jcw | |
| 31 | 6540 | jcw | rf12_sendStart(0, &payload, sizeof payload); |
| 32 | 5971 | jcw | |
| 33 | 6540 | jcw | MilliTimer t; |
| 34 | 6540 | jcw | while (!t.poll(1000)) |
| 35 | 6540 | jcw | rf12_recvDone(); |
| 36 | 5971 | jcw | } |