Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Analog_Joystick Sender mbed
Fork of ESE350-Whack-a-Mole by
rc.cpp
- Committer:
- ivo_david_michelle
- Date:
- 2016-04-07
- Revision:
- 8:ff7cd3525c32
- Parent:
- 7:8714628b62e5
- Child:
- 9:2a3b3e067847
File content as of revision 8:ff7cd3525c32:
#include "mbed.h"
#include "MRF24J40.h"
#include "sender.h"
#include "analog_joystick.h"
#include <string.h>
// RF tranceiver to link with handheld.
MRF24J40 mrf(p11, p12, p13, p14, p21);
// LEDs you can treat these as variables (led2 = 1 will turn led2 on!)
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
// Timer
Timer timer;
// Serial port for showing RX data.
Serial pc(USBTX, USBRX);
int iterations = 100;
//***************** send and receive methods *****************//
/*
void wait_for_ping(uint8_t length) {
int receive = 0;
uint8_t *rssi = 0;
while (receive == 0) {
receive = rf_receive_rssi(rxBuffer, rssi, length);
}
}
*/
//***************** main loop *****************//
int main (void) {
uint8_t channel = 3;
//Set the Channel. 0 is default, 15 is max
mrf.SetChannel(channel);
//Start the timer
timer.start();
pc.printf("START\r\n");
// send_three_way_handshake();
int i;
char txBuffer[250];
for (i = 0; i < iterations; i++) {
sprintf(txBuffer, "%f,%f,%f,%f", read_thrust(), read_yaw(), read_pitch(), read_roll());
rf_send(mrf, txBuffer, strlen(txBuffer) + 1);
pc.printf("RC Sent: %s \r\n", txBuffer);
wait(0.2); // TODO: change this value?
}
pc.printf("END\r\n");
}
