Shuto Naruse / Mbed 2 deprecated Eurobot2012_Beacons
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #define BEACON_2
00002 #include "defines.h"
00003 #include "mbed.h"
00004 #include "RF12B.h"
00005 
00006 
00007 PwmOut IRled(p21);
00008 
00009 Serial pc(USBTX, USBRX); // tx, rx
00010 
00011 RF12B RF_Beacon(p5, p6, p7, p8, p9, p30);    //RF module
00012 
00013 void turnON (void);
00014 void turnOFF (void);
00015 
00016 // interrupt driven
00017 Timeout toggle;
00018 
00019 char data_in;
00020 
00021 int main() {
00022     RF_Beacon.setCode(CODE);
00023     IRled.period_us(T_CARRIER);
00024     toggle.attach_us(&turnON, 1000);
00025     pc.printf("Beacon Side \n");
00026     while (1) {
00027     }
00028 }
00029 
00030 void turnON (void) {
00031     IRled.pulsewidth_us(0);     // note: the IR led is ON when this is low
00032     toggle.attach_us(&turnOFF, T_CARRIER * ON_CYCLE);
00033 }
00034 
00035 void turnOFF (void) {
00036     IRled.pulsewidth_us(13);    // note: the IR led is ON when this is low
00037     toggle.attach_us(&turnON, T_CARRIER * OFF_CYCLE);
00038 }