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

main.cpp

Committer:
montanari9
Date:
2014-10-24
Revision:
3:ffd85399bece
Parent:
2:7ddee354bdfa

File content as of revision 3:ffd85399bece:

//    NUCLEO-072 n.1       NUCLEO-072 n.2
//    TX-A0 ----------------- RX-A1
//    RX-A1 ----------------- TX-A0
//    GND   ----------------- GND



#include "mbed.h"
 
Serial pc(A0, A1);    // tx, rx
DigitalOut myled(LED1);             // This LED is on NUCLEO-L152RE
DigitalIn BlueButton(USER_BUTTON);  // This is Blue-Button and is on NUCLEO-L153RE

#define Pressed 0
#define NotPressed 1

int Car='\0';

int main() {
    while(1) 
    {

    if (BlueButton == Pressed)
        pc.putc('E');
    
    if(pc.readable()) 
        {
        Car = pc.getc();
        if (Car == 'E')
            {
            myled = 1;
            wait(0.1);
            }
        myled = 0;
        Car = '\0';
        }

    }
}