![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Remote control code for https://developer.mbed.org/users/ivo_david_michelle/code/QuadTrio/
Dependencies: Analog_Joystick Sender mbed
Fork of ESE350-Whack-a-Mole by
rc.cpp@9:2a3b3e067847, 2016-04-07 (annotated)
- Committer:
- ivo_david_michelle
- Date:
- Thu Apr 07 22:04:42 2016 +0000
- Revision:
- 9:2a3b3e067847
- Parent:
- 8:ff7cd3525c32
- Child:
- 10:8981152753a6
successful communication;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ivo_david_michelle | 7:8714628b62e5 | 1 | #include "mbed.h" |
ivo_david_michelle | 5:3ad830e95ffd | 2 | #include "MRF24J40.h" |
ivo_david_michelle | 5:3ad830e95ffd | 3 | #include "sender.h" |
ivo_david_michelle | 5:3ad830e95ffd | 4 | #include "analog_joystick.h" |
ivo_david_michelle | 5:3ad830e95ffd | 5 | |
ivo_david_michelle | 7:8714628b62e5 | 6 | #include <string.h> |
ivo_david_michelle | 5:3ad830e95ffd | 7 | |
ivo_david_michelle | 5:3ad830e95ffd | 8 | // RF tranceiver to link with handheld. |
ivo_david_michelle | 5:3ad830e95ffd | 9 | MRF24J40 mrf(p11, p12, p13, p14, p21); |
ivo_david_michelle | 5:3ad830e95ffd | 10 | |
ivo_david_michelle | 5:3ad830e95ffd | 11 | // LEDs you can treat these as variables (led2 = 1 will turn led2 on!) |
ivo_david_michelle | 5:3ad830e95ffd | 12 | DigitalOut led1(LED1); |
ivo_david_michelle | 5:3ad830e95ffd | 13 | DigitalOut led2(LED2); |
ivo_david_michelle | 5:3ad830e95ffd | 14 | DigitalOut led3(LED3); |
ivo_david_michelle | 5:3ad830e95ffd | 15 | DigitalOut led4(LED4); |
ivo_david_michelle | 5:3ad830e95ffd | 16 | |
ivo_david_michelle | 5:3ad830e95ffd | 17 | // Timer |
ivo_david_michelle | 5:3ad830e95ffd | 18 | Timer timer; |
ivo_david_michelle | 5:3ad830e95ffd | 19 | |
ivo_david_michelle | 5:3ad830e95ffd | 20 | // Serial port for showing RX data. |
ivo_david_michelle | 5:3ad830e95ffd | 21 | Serial pc(USBTX, USBRX); |
ivo_david_michelle | 5:3ad830e95ffd | 22 | |
ivo_david_michelle | 9:2a3b3e067847 | 23 | int main (void) |
ivo_david_michelle | 9:2a3b3e067847 | 24 | { |
ivo_david_michelle | 9:2a3b3e067847 | 25 | long long id = 0; |
ivo_david_michelle | 5:3ad830e95ffd | 26 | uint8_t channel = 3; |
ivo_david_michelle | 5:3ad830e95ffd | 27 | |
ivo_david_michelle | 5:3ad830e95ffd | 28 | //Set the Channel. 0 is default, 15 is max |
ivo_david_michelle | 5:3ad830e95ffd | 29 | mrf.SetChannel(channel); |
ivo_david_michelle | 5:3ad830e95ffd | 30 | |
ivo_david_michelle | 5:3ad830e95ffd | 31 | //Start the timer |
ivo_david_michelle | 5:3ad830e95ffd | 32 | timer.start(); |
ivo_david_michelle | 7:8714628b62e5 | 33 | |
ivo_david_michelle | 5:3ad830e95ffd | 34 | pc.printf("START\r\n"); |
ivo_david_michelle | 7:8714628b62e5 | 35 | |
ivo_david_michelle | 9:2a3b3e067847 | 36 | char txBuffer[250]; |
ivo_david_michelle | 6:db985df4354b | 37 | |
ivo_david_michelle | 9:2a3b3e067847 | 38 | while(1) { |
ivo_david_michelle | 9:2a3b3e067847 | 39 | sprintf(txBuffer, "%lld,%f,%f,%f,%f", id, read_thrust(), read_yaw(), read_pitch(), read_roll()); |
ivo_david_michelle | 5:3ad830e95ffd | 40 | rf_send(mrf, txBuffer, strlen(txBuffer) + 1); |
ivo_david_michelle | 5:3ad830e95ffd | 41 | pc.printf("RC Sent: %s \r\n", txBuffer); |
ivo_david_michelle | 7:8714628b62e5 | 42 | |
ivo_david_michelle | 9:2a3b3e067847 | 43 | id++; |
ivo_david_michelle | 5:3ad830e95ffd | 44 | } |
ivo_david_michelle | 5:3ad830e95ffd | 45 | } |