José María Ruiz de Velasco / Mbed 2 deprecated liveControl

Dependencies:   mbed

Fork of frdm_gpio by Freescale

main.cpp

Committer:
cheperuiz
Date:
2015-07-20
Revision:
10:163208bd16a8
Parent:
9:32e85f1fcd15

File content as of revision 10:163208bd16a8:

#include "mbed.h"
#define ON 0
#define OFF 1
#define ID '0'

DigitalIn  magic(PTB0);
DigitalOut redLED(LED_RED);
DigitalOut greenLED(LED_GREEN);
DigitalOut blueLED(LED_BLUE);
Serial pc(USBTX,USBRX);

int main()
{
    unsigned char last = magic,t=0;
    while(true)
    {
        if(last != magic)
        {
            last = magic;
            printf("%d",(int)magic);    
         //   wait(0.02);
        }
        if(pc.readable())
        {
            t=pc.getc();
            switch(t)
            {
                case '0': //IDLE
                redLED = ON;
                greenLED = OFF;
                blueLED = OFF;
                break;   
                
                case '1': //PLAY
                redLED = OFF;
                greenLED = ON;
                blueLED = OFF;
                break;
                
                case '2': //STOP
                redLED = OFF;
                greenLED = OFF;
                blueLED = ON;
                break;
                
                case '3': //REC
                redLED = ON;
                greenLED = ON;
                blueLED = OFF;
                break;
                
                case '?':
                pc.putc(ID);
                break;
                
                default:
                redLED = OFF;
                greenLED = OFF;
                blueLED = OFF;
                break;                
            }
        }    
        wait(0.02);    
    }
}