Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

will this run? const int segmentPins [ ] = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9

will this run? const int segmentPins[]={2,3,4,5,6,7,8,9}; // Pins for segments (A to G, DP)
const int digitPins[]={9,10,11,12}; // Pins for digit control
const int countdownDuration =10; // Set the countdown duration in seconds
void setup(){
// Set all segment and digit pins as OUTPUT
for (int i =0; i <8; i++){
pinMode(segmentPins[i], OUTPUT);
}
for (int i =0; i <4; i++){
pinMode(digitPins[i], OUTPUT);
}
}
void loop(){
// Countdown loop
for (int count = countdownDuration; count >=0; count--){
displayNumber(count);
delay(1000); //1-second delay
}
}
void displayNumber(int num){
// Display a number on the 7-segment display
const byte numMap[]={
B11111100,//0
B01100000,//1
B11011010,//2
B11110010,//3
B01100110,//4
B10110110,//5
B10111110,//6
B11100000,//7
B11111110,//8
B11110110//9
};
for (int i =0; i <4; i++){
// Enable the corresponding digit
digitalWrite(digitPins[i], LOW);
// Set the segments based on the number to be displayed
for (int j =0; j <8; j++){
digitalWrite(segmentPins[j], bitRead(numMap[num], j));
}
delay(1); // A short delay to make the display stable
// Turn off the segments for the next iteration
for (int j =0; j <8; j++){
digitalWrite(segmentPins[j], HIGH);
}
// Disable the digit for the next iteration
digitalWrite(digitPins[i], HIGH);
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions