implementação da entrada analogica

Dependencies:   mbed

Fork of projeto_final by Guilherme Paulino

main.cpp

Committer:
guilhermepaulino
Date:
2016-05-16
Revision:
0:14a3f9fb0c13
Child:
1:57ddb7333156

File content as of revision 0:14a3f9fb0c13:

#include "mbed.h"
int main(void)
{   
    Serial pc(USBTX, USBRX);
    PwmOut rled(LED1);
    PwmOut gled(LED2);
    PwmOut bled(LED3);
    char msg;
    char num;
    rled=1.0f;
    gled=1.0f;
    bled=1.0f;
    while(true){
        if(pc.readable()) {
            msg = pc.getc();
            num = pc.getc();
            switch(msg){
                case 'R': //brilho
                    rled = 1.0f - float(num)/255.0;
                    break;
                case 'G':
                    gled = 1.0f - float(num)/255.0;
                    break;
                case 'B':
                    bled = 1.0f - float(num)/255.0;
                    break;
            }
        }
    }
}