
Untitled
By: a guest on
May 5th, 2012 | syntax:
C++ | size: 0.55 KB | hits: 16 | expires: Never
uint8_t index=0;
char command=0;
char value[4];
uint8_t avalue=0;
while(index < 3){
if(Serial.available())
{
if(index==0){ // index is 0 so we are hopefully recieving a,b,c....
command = Serial.read();
}
else{ // index is more then 0, we should be recieving the value
value[index] = Serial.read();
}
index++
}
}
avalue = atoi(value); // convert from ascii to int
switch (command){
case a:
analogWrite(A, avalue);
break;
case b:
analogWrite(B, avalue);
//and so on
}
index=0;