I am making a binary clock and have tried to exercise different loops. Here is my logic...
I have 4 stored integers
a ( for units seconds) = 0
b ( for tens of seconds) = 0
c ( for units minuets) = 0
d ( for tens of minuets) = 0
The flow chart I have devised goes as so.
INT A-----> [ START COUNTING 1-9]
1
2
3
4
5
6
7
8
9
[ HAS A REACHED 9?]
l
l
Y E S NO-----------------------Return to top of loop and retest.
l
ADD ONE TO INT B AND RETEST (A) CONDITION----------------------------
l
INT B-----> [ START COUNTING 1-6]
1
2
3
4
5
6
[ HAS B REACHED 6]
l
l
Y E S NO-----------------------Return to top of loop and retest.
l
l
ADD ONE TO C AND RE TEST LOOP
and so on etc etc
I have A counting 1-9 and B going to 1 once A is reached 9 . Im now confused on how to get from A to B while recounting A and having it remember B in a loop that will let me display up to 59 with both columns. I have to do it with WHILE LOOPS. Here is my code.
// Binary clock
int a = 0;
int b = 0;
int c = 0;
int d = 0;
void setup ()
{
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
}
void loop ()
{
start:
while (a < 10)
{
// 1 bit
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
delay(1000);
a++;
// 2 bit
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
delay(1000);
a++;
//3 bit
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
delay(1000);
a++;
// 4 bit
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(1000);
a++;
// 5 bit
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(1000);
a++;
// 6 bit
digitalWrite(0, HIGH);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(1000);
// 7 bit
digitalWrite(0,LOW);
digitalWrite(1,LOW);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
delay(1000);
a++;
// 8 bit
digitalWrite(0, HIGH);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
delay(1000);
a++;
// 9 bit
digitalWrite(0, LOW);
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
delay(1000);
a=0;
if
(a == 9)
{
b++;
}
break;
}
while (b < 6)
{
digitalWrite(7, LOW);
delay(1000);
digitalWrite(8, L
{
goto start;
}
}
}