implementação da entrada analogica

Dependencies:   mbed

Fork of projeto_final by Guilherme Paulino

Committer:
guilhermepaulino
Date:
Mon May 16 23:09:27 2016 +0000
Revision:
0:14a3f9fb0c13
Child:
1:57ddb7333156
Projeto Final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
guilhermepaulino 0:14a3f9fb0c13 1 #include "mbed.h"
guilhermepaulino 0:14a3f9fb0c13 2 int main(void)
guilhermepaulino 0:14a3f9fb0c13 3 {
guilhermepaulino 0:14a3f9fb0c13 4 Serial pc(USBTX, USBRX);
guilhermepaulino 0:14a3f9fb0c13 5 PwmOut rled(LED1);
guilhermepaulino 0:14a3f9fb0c13 6 PwmOut gled(LED2);
guilhermepaulino 0:14a3f9fb0c13 7 PwmOut bled(LED3);
guilhermepaulino 0:14a3f9fb0c13 8 char msg;
guilhermepaulino 0:14a3f9fb0c13 9 char num;
guilhermepaulino 0:14a3f9fb0c13 10 rled=1.0f;
guilhermepaulino 0:14a3f9fb0c13 11 gled=1.0f;
guilhermepaulino 0:14a3f9fb0c13 12 bled=1.0f;
guilhermepaulino 0:14a3f9fb0c13 13 while(true){
guilhermepaulino 0:14a3f9fb0c13 14 if(pc.readable()) {
guilhermepaulino 0:14a3f9fb0c13 15 msg = pc.getc();
guilhermepaulino 0:14a3f9fb0c13 16 num = pc.getc();
guilhermepaulino 0:14a3f9fb0c13 17 switch(msg){
guilhermepaulino 0:14a3f9fb0c13 18 case 'R': //brilho
guilhermepaulino 0:14a3f9fb0c13 19 rled = 1.0f - float(num)/255.0;
guilhermepaulino 0:14a3f9fb0c13 20 break;
guilhermepaulino 0:14a3f9fb0c13 21 case 'G':
guilhermepaulino 0:14a3f9fb0c13 22 gled = 1.0f - float(num)/255.0;
guilhermepaulino 0:14a3f9fb0c13 23 break;
guilhermepaulino 0:14a3f9fb0c13 24 case 'B':
guilhermepaulino 0:14a3f9fb0c13 25 bled = 1.0f - float(num)/255.0;
guilhermepaulino 0:14a3f9fb0c13 26 break;
guilhermepaulino 0:14a3f9fb0c13 27 }
guilhermepaulino 0:14a3f9fb0c13 28 }
guilhermepaulino 0:14a3f9fb0c13 29 }
guilhermepaulino 0:14a3f9fb0c13 30 }