Recepcion por Interrupcion Serial

Dependencies:   mbed

main.cpp

Committer:
franni
Date:
2017-05-08
Revision:
0:6c1c7f430469

File content as of revision 0:6c1c7f430469:

#include "mbed.h"

DigitalOut led_r(LED2);
DigitalOut led_b(LED3);
DigitalOut led_g(LED1);


Serial rs232(USBTX,USBRX);

void int_rx()
{
    int datoin = rs232.getc();

    switch (datoin) {


        case 'r':
            led_r=1;
            led_g=0;
            led_b=0;
        
        break;

        case 'g': 
            led_r=0;
            led_g=1;
            led_b=0;
        
        break;

        case 'b': 
            led_r=0;
            led_g=0;
            led_b=1;
        
        break;

        default:

            break;

    }
}

int main()
{
    rs232.baud(9600);
    rs232.attach(&int_rx);
    while(1) {}
}