Question: Need help show a 2-digit loop counter using two 7-segment displays and two 74LS47 chips using Arduino. The loop counter counts from 00 to 59
Need help show a 2-digit loop counter using two 7-segment displays and two 74LS47 chips using Arduino. The loop counter counts from 00 to 59 and back to 00. Set the counting delay to be 1000 ms.
This is what I have so far but it only count by 11
example
00, 11, 22, 33, 44, 55, 66, 77, 88, 99, then back to 00.
// Output pins. static int output[] = {0,1,2,3}; static int output2[] = {4,5,6,7}; // 8421 code lookup table. static int segs_encoding[][4] = {{0,0,0,0}, {0,0,0,1}, {0,0,1,0}, {0,0,1,1}, {0,1,0,0}, {0,1,0,1}, {0,1,1,0}, {0,1,1,1}, {1,0,0,0}, {1,0,0,1}, {1,0,1,0}, {1,0,1,1}, {1,1,0,0}, {1,1,0,1}, {1,1,1,0}, {1,1,1,1}}; // Outputs an 8421 decimal digit on the output pins from // base to base + 3 in big endian order. void show(int base, int num) { for (int i = 0; i < 4; ++i) { if(segs_encoding[num][i] == 1) { digitalWrite(base + 3 - i , HIGH); } else { digitalWrite(base + 3 - i , LOW); } } } // Output a decimal value. void show_decimal(int num) { show(4, num); show(0, num); } // the setup routine runs once when you press reset: void setup() { for (int i = 0; i < 4; ++i) pinMode(i, OUTPUT); for (int j = 4; j < 8; ++j) pinMode(j, OUTPUT); } // the loop routine runs over and over again forever: void loop() { static int i = 0; show_decimal(i); delay(1000); // Increases the counter. ++i; if (i == 10) i = 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
