I am trying to make a binary clock and I need to store a variable as something that was printed earlier. If you could help me I would be most appreciative. Thanks! Here is the code.
setTime(hours, mins, secs); //changes time every second
secs++; //seconds increase
if(secs > 59)
secs = 0;
if(mins > 59)
mins = 0;
void setTime(int hour, int mins, int sec)
String strSec = String(sec, BIN);
int sec = 5;
printBinary(sec); //prints the binary version of sec (101)
int binSec = Serial.read();
Serial.println(binSec); //always prints -1 no matter what sec is
You need to post a complete program.
And you need to describe more clearly what you want to do.
Serial.read() returns a single character.
You may find the examples in Serial Input Basics useful. There is also a parse example.
I edited it. I know I am a long way off from a working binary clock, but I've been stuck on this part for so long and I think I can do the rest. Thanks for your help!
Thanks so much for your help! I found a way around it. Your post made me realize I was doing to much work.
Glad you got it working
I edited it.
For the future, major changes to an existing post are not welcome as they upset the chronological flow of the discussion. Just put addidional stuff in a new post.
Editing posts is fine to correct typos and such.