Code based on the emcu example, for more info under the first example see here: http://www.emcu.it/NUCLEOevaBoards/U2andL152/U2andL152.html

Dependencies:   mbed-src mbed

Fork of NucleoL152RE_two_boards_connected_via_USART2 by Enrico Marinoni

Committer:
montanari9
Date:
Fri Oct 24 19:40:27 2014 +0000
Revision:
3:ffd85399bece
Parent:
2:7ddee354bdfa
STM32F072 Nucleo - two boards connected thru USART4, turn on LED when BUTTON is pressed, no hardware change is needed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
montanari9 3:ffd85399bece 1 // NUCLEO-072 n.1 NUCLEO-072 n.2
montanari9 3:ffd85399bece 2 // TX-A0 ----------------- RX-A1
montanari9 3:ffd85399bece 3 // RX-A1 ----------------- TX-A0
montanari9 3:ffd85399bece 4 // GND ----------------- GND
emcu 0:5bb2b3fd5215 5
emcu 0:5bb2b3fd5215 6
emcu 0:5bb2b3fd5215 7
emcu 0:5bb2b3fd5215 8 #include "mbed.h"
emcu 0:5bb2b3fd5215 9
montanari9 3:ffd85399bece 10 Serial pc(A0, A1); // tx, rx
emcu 0:5bb2b3fd5215 11 DigitalOut myled(LED1); // This LED is on NUCLEO-L152RE
emcu 0:5bb2b3fd5215 12 DigitalIn BlueButton(USER_BUTTON); // This is Blue-Button and is on NUCLEO-L153RE
emcu 0:5bb2b3fd5215 13
emcu 0:5bb2b3fd5215 14 #define Pressed 0
emcu 0:5bb2b3fd5215 15 #define NotPressed 1
emcu 0:5bb2b3fd5215 16
emcu 0:5bb2b3fd5215 17 int Car='\0';
emcu 0:5bb2b3fd5215 18
emcu 0:5bb2b3fd5215 19 int main() {
emcu 0:5bb2b3fd5215 20 while(1)
emcu 0:5bb2b3fd5215 21 {
emcu 0:5bb2b3fd5215 22
emcu 0:5bb2b3fd5215 23 if (BlueButton == Pressed)
emcu 0:5bb2b3fd5215 24 pc.putc('E');
emcu 0:5bb2b3fd5215 25
emcu 0:5bb2b3fd5215 26 if(pc.readable())
emcu 0:5bb2b3fd5215 27 {
emcu 0:5bb2b3fd5215 28 Car = pc.getc();
emcu 0:5bb2b3fd5215 29 if (Car == 'E')
emcu 0:5bb2b3fd5215 30 {
emcu 0:5bb2b3fd5215 31 myled = 1;
emcu 0:5bb2b3fd5215 32 wait(0.1);
emcu 0:5bb2b3fd5215 33 }
emcu 0:5bb2b3fd5215 34 myled = 0;
emcu 0:5bb2b3fd5215 35 Car = '\0';
emcu 0:5bb2b3fd5215 36 }
emcu 0:5bb2b3fd5215 37
emcu 0:5bb2b3fd5215 38 }
emcu 0:5bb2b3fd5215 39 }