Yes, My code is the same. So where did the -1 come from? i have never seen it before. The complete code is here...
#define outputpin 13
int ser_in1=0, ser_in2=0;
void setup()
{
pinMode(outputpin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(Serial.available() > 0)
{
ser_in1 = Serial.read();
Serial.print(ser_in1);
if(ser_in1 == 66)
{
ser_in2 = Serial.read();
Serial.print(ser_in2);
if(ser_in2 == 48)
control_device(0);
if(ser_in2 == 49)
control_device(1);
}
}
}
void control_device(int state)
{
digitalWrite(outputpin,state);
}
And the output i get when i pass 'B1' now is 66-149
How do i correct this? :-/