Eurobot2012_Beacons

Committer:
narshu
Date:
Wed Oct 17 22:26:33 2012 +0000
Revision:
3:bf8a2e4b8012
Parent:
1:b0aa1251016a
Commit before publishing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
narshu 1:b0aa1251016a 1 #define BEACON_2
narshu 0:b8be0a00c4f8 2 #include "defines.h"
narshu 0:b8be0a00c4f8 3 #include "mbed.h"
narshu 0:b8be0a00c4f8 4 #include "RF12B.h"
narshu 0:b8be0a00c4f8 5
narshu 0:b8be0a00c4f8 6
narshu 0:b8be0a00c4f8 7 PwmOut IRled(p21);
narshu 0:b8be0a00c4f8 8
narshu 0:b8be0a00c4f8 9 Serial pc(USBTX, USBRX); // tx, rx
narshu 0:b8be0a00c4f8 10
narshu 1:b0aa1251016a 11 RF12B RF_Beacon(p5, p6, p7, p8, p9, p30); //RF module
narshu 0:b8be0a00c4f8 12
narshu 0:b8be0a00c4f8 13 void turnON (void);
narshu 0:b8be0a00c4f8 14 void turnOFF (void);
narshu 0:b8be0a00c4f8 15
narshu 0:b8be0a00c4f8 16 // interrupt driven
narshu 0:b8be0a00c4f8 17 Timeout toggle;
narshu 0:b8be0a00c4f8 18
narshu 0:b8be0a00c4f8 19 char data_in;
narshu 0:b8be0a00c4f8 20
narshu 0:b8be0a00c4f8 21 int main() {
narshu 0:b8be0a00c4f8 22 RF_Beacon.setCode(CODE);
narshu 0:b8be0a00c4f8 23 IRled.period_us(T_CARRIER);
narshu 0:b8be0a00c4f8 24 toggle.attach_us(&turnON, 1000);
narshu 0:b8be0a00c4f8 25 pc.printf("Beacon Side \n");
narshu 0:b8be0a00c4f8 26 while (1) {
narshu 0:b8be0a00c4f8 27 }
narshu 0:b8be0a00c4f8 28 }
narshu 0:b8be0a00c4f8 29
narshu 0:b8be0a00c4f8 30 void turnON (void) {
narshu 0:b8be0a00c4f8 31 IRled.pulsewidth_us(0); // note: the IR led is ON when this is low
narshu 0:b8be0a00c4f8 32 toggle.attach_us(&turnOFF, T_CARRIER * ON_CYCLE);
narshu 0:b8be0a00c4f8 33 }
narshu 0:b8be0a00c4f8 34
narshu 0:b8be0a00c4f8 35 void turnOFF (void) {
narshu 0:b8be0a00c4f8 36 IRled.pulsewidth_us(13); // note: the IR led is ON when this is low
narshu 0:b8be0a00c4f8 37 toggle.attach_us(&turnON, T_CARRIER * OFF_CYCLE);
narshu 0:b8be0a00c4f8 38 }