A simple example of a serial communication interface for setting variables in an Mbed program with help of mydsc library.

Dependencies:   mbed mydsc

main.cpp

Committer:
ghsalazar
Date:
2019-03-12
Revision:
0:46aa79a823ee
Child:
1:2cd22f07b879

File content as of revision 0:46aa79a823ee:

/** 
    @file   main.cpp
    @author Gastón SALAZAR  <gaston_salazar@yahoo.com>
*/

#include "mbed.h"

const unsigned long DELAY   = 5000000UL;

Serial  serial(USBTX, USBRX);

void 
setup()
{
    serial.printf("Hello, world!\n");
    serial.printf("Display: %x\n", 0);
}

void
loop()
{
    static unsigned short   display_count   = 0;
    static unsigned long    delay_count     = DELAY;    

    if (delay_count == 0)
      {
        display_count++;
        display_count &= 0x0F;
        serial.printf("Display: %x\n", display_count);
        delay_count = DELAY;
      }
    
    delay_count--;
}

int main()
{
    setup();
    while(1)
        loop();
}