Can someone explain way the code that you see below give these results?
void loop() {
byte test=00000101;
Serial.print("the byte test is:");
Serial.println(test);
int x=(int)test;
int y=(int)test<<8;
Serial.print("the int x is:");
Serial.println(x);
Serial.print("the int shifted y is:");
Serial.println(y);
byte tost=10000001;
int z=test+tost;
Serial.print("the int z is:");
Serial.println(z);
delay(1000);
}
Results:
the byte test is:65
the int x is:65
the int shifted y is:16640
the int z is:194
While if i change the test to 00000001 it performs great:
changed code:
void loop() {
byte test=00000001;
Serial.print("the byte test is:");
Serial.println(test);
int x=(int)test;
int y=(int)test<<8;
Serial.print("the int x is:");
Serial.println(x);
Serial.print("the int shifted y is:");
Serial.println(y);
byte tost=10000001;
int z=test+tost;
Serial.print("the int z is:");
Serial.println(z);
delay(1000);
}
the byte test is:1
the int x is:1
the int shifted y is:256
the int z is:130