Statistics
| Revision:

root / RF12 / examples / radioBlip / radioBlip.pde

History | View | Annotate | Download (773 Bytes)

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