Joseanne Viana
/
projeto_final
implementação da entrada analogica
Fork of projeto_final by
Diff: main.cpp
- Revision:
- 0:14a3f9fb0c13
- Child:
- 1:57ddb7333156
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 16 23:09:27 2016 +0000 @@ -0,0 +1,30 @@ +#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; + } + } + } +} \ No newline at end of file