Binary Clock creating a 6-bit counter that increments every second. The counter
ID: 3620465 • Letter: B
Question
Binary Clock
creating a 6-bit counter that increments every second. The counter should roll over to zero when the maximum displayable integer is reached. Each bit will correspond to an LED connected to your Arduino. For example, at second 2, the output should be 000010, where 0 means the corresponding LED is o and 1 means the corresponding LED is on. Similarly, at second 15, the output should be 001111. Finally, at second 21, the output should be 010101. Things to remember: All six LEDs should be connected to di_erent pins on the Arduino. Consider using a contiguous set of pins, as they are easier to keep straight. Remember to use current-limiting resistors with the LEDs. Most breadboards have a long continuous line for ground down the side. It is recommended that you use this to keep your circuit layout straightforward. Consider the pseudocode discussed in class when developing your software. Note that there is no power" function in the Arduino environment, requiring you to develop a way to deal with this. Also
note that there are other possible algorithms that you can use to set and unset the correct LEDs as well.
This what I came up with I didn’t compiled the code yet. I just want to know how write a loop that can go from one second to the other.
int myArray[6];
int ledPin [6] = {0, 3, 5, 7, 9,13};
int second [6]={0,0,0,0,0,0};
int count;
void setup() {
unsigned long time;
pinMode(0, OUTPUT);
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(7, OUTPUT);
pinMode(9, OUTPUT);
pinMode(13, OUTPUT);
}
void loop(){
static unsigned long lastTick = 0;
if (millis() - lastTick >= 1000) {
lastTick = millis();
second++;
}
int i;
int flip;
flip second [6];
if second[0]=0
for(i=1;i<5,i++){
else
if second[i-1];
flip second[0];
else
break
}
}
_
Explanation / Answer
123
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.