Install on (2) Nucleo-L053R8's with an XBee PRO 900HP on the PA_9 and PA_10 serial pins. When the user button is pressed on one of the Nucleos, the LED flashes on the other.
Dependencies: SoftSerial mbed
Revision 0:be753a471114, committed 2017-06-23
- Comitter:
- jmckneel
- Date:
- Fri Jun 23 16:45:06 2017 +0000
- Commit message:
- 0001 Enabled user button communication between two Nucleo boards
Changed in this revision
diff -r 000000000000 -r be753a471114 SoftSerial.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SoftSerial.lib Fri Jun 23 16:45:06 2017 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/Sissors/code/SoftSerial/#a0029614de72
diff -r 000000000000 -r be753a471114 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 23 16:45:06 2017 +0000 @@ -0,0 +1,67 @@ +/* ----------------------------------------------------------------------------- + Author: Jared McKneely + Title: End-node firmware v. 1.0.0 + Date: June 8th, 2017 + Description: + +----------------------------------------------------------------------------- */ + +// Libraries ------------------------------------------------------------------- +#include "mbed.h" +#include "SoftSerial.h" + +// Macros ---------------------------------------------------------------------- +#define LED_ON (1) +#define LED_OFF (0) +#define TX (PB_3) +#define RX (PA_10) + +// Hardware Objects ------------------------------------------------------------ +DigitalOut led(LED1); +InterruptIn button(USER_BUTTON); +InterruptIn receive(PA_10); + +// Globals --------------------------------------------------------------------- +SoftSerial xb(TX, RX); +char tx = 'e'; +char rx = '0'; + +// send_light ------------------------------------------------------------------ +void send_light(void){ + if (xb.writeable()){ + xb.putc(tx); + } +} + +// blink_light ----------------------------------------------------------------- +void blink_light(void){ + led = LED_OFF; + led = LED_ON; + wait(0.05); + led = LED_OFF; +} + +// rx_process ------------------------------------------------------------------ +void rx_process(void){ + +} + +// Main ------------------------------------------------------------------------ +int main() { + + // Enable interrupt + button.rise(&send_light); + receive.rise(&rx_process); + + // While loop + while (true){ + if (xb.readable()){ + rx = xb.getc(); + if (rx == 'e'){ + blink_light(); + rx = '0'; + } + } + wait(0.1); + } +} \ No newline at end of file
diff -r 000000000000 -r be753a471114 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 23 16:45:06 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/0f02307a0877 \ No newline at end of file