Im having trouble converting a String containing 7 numbers into a a byte[]
Whats happening is the numbers from the String are not translating through to the "real" number value
For instance, String value of 1 becomes 49, 2 becomes 50, 3 becomes 51, etc.
Obviously I want a String with a value of "1" to equal a byte value 1 not 49...
Here is my code
String days = "111111"
byte buff[days.length()];
char c;
for(int i=0;i<7;i++){
c = days.charAt(i);
buff[i] = byte(c);
Serial.print(buff[i]);
}
The output for is 49494949494949 instead of 1111111
How do I fix this!?
I know I must be missing a step here somewhere....
An answer plus a simple explanation would be fantastic!
Wow such a simple solution!
..just minus 48 from it...perfect.
"What is it you intend to do with the byte array?"
It represents the 7 days of the week as either 0 or 1...on or off...think scheduling...
"You have only six '1's in your String, but no semicolon after it."
yes, correct. 2 mistakes in my trying. This is just an extract of a much larger sketch (around 135Kb) hand typed
Lucky this html form isnt a C++ compiler..