Blink LED example for the Multitech mDot. Additionally, has serial comms via USB and RS232.

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 
00004 Serial rs232(PA_2, PA_3);  //9600 baud rate
00005 Serial mypc(USBTX, USBRX); //9600 baud rate
00006 
00007 DigitalOut led1(PA_0); //  MTUDK2-ST-MDOT Developer Kit D3
00008 DigitalOut led2(PA_1); //  MTUDK2-ST-MDOT Developer Kit D6
00009 DigitalOut led3(PA_11); //  MTUDK2-ST-MDOT Developer Kit D7
00010 
00011 
00012 // main() runs in its own thread in the OS
00013 int main() {
00014     
00015     led2 = 0; // The MTUDK2-ST-MDOT has a 74LCX14MTC before the LEDs, which inverts therefore 0 = on
00016     led3 = 0;
00017     
00018             
00019     while (true) {
00020         led1 = !led1;
00021         wait(2); //2s
00022         
00023         rs232.printf("Serial:LED is now %d\r\n", led1.read());
00024         mypc.printf("USB:I'm  working\r\n");
00025         
00026         rs232.putc(rs232.getc()); //wait for char from rs232 and echo it back
00027    }
00028 }
00029