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.
void loop()
{
setTime(hours, mins, secs); //changes time every second
secs++; //seconds increase
if(secs > 59)
{
mins++;
secs = 0;
}
if(mins > 59)
{
hours++;
mins = 0;
}
delay(1000);
}
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
}
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!
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.