Question: Q . write a code for self down counter from count 9 9 9 9 and decremnt till 0 0 0 0 and as it

Q.write a code for self down counter from count 9999 and decremnt till 0000 and as it rreches 0000 the value must be constantly display in ssd and the speed at which decremnt is done is wrt the potentiometer input void main(void){void main(void){
init_config();
unsigned char ssd[MAX_SSD_CNT];
unsigned int count =9999; // Initialize count
unsigned int adc_reg_val;
const unsigned int max_adc_value =1023;
while (count >0){
adc_reg_val = read_adc(); // Read the potentiometer value
// Calculate delay based on potentiometer reading
// Adjust the scaling factor (e.g.,10) based on your requirements
unsigned int delay =(max_adc_value - adc_reg_val)*10;
// Update SSD display if the delay threshold is reached
if (delay <=0){
ssd[0]= digit[(count /1000)];
ssd[1]= digit[(count /100)%10];
ssd[2]= digit[(count /10)%10];
ssd[3]= digit[count %10];
display(ssd);
count--; // Decrement count
}
// Optionally, add a small delay here to stabilize readings
}
// Once the count reaches 0, display 0000
for (int i =0; i < MAX_SSD_CNT; i++){
ssd[i]= digit[0]; // digit[0] represents '0'
}
display(ssd);
while (1){
// Optionally, halt further operations or enter low power state
}
return;
}void main(void){
init_config();
unsigned char ssd[MAX_SSD_CNT];
unsigned int count =9999; // Initialize count
unsigned int adc_reg_val;
const unsigned int max_adc_value =1023;
while (count >0){
adc_reg_val = read_adc(); // Read the potentiometer value
// Calculate delay based on potentiometer reading
// Adjust the scaling factor (e.g.,10) based on your requirements
unsigned int delay =(max_adc_value - adc_reg_val)*10;
// Update SSD display if the delay threshold is reached
if (delay <=0){
ssd[0]= digit[(count /1000)];
ssd[1]= digit[(count /100)%10];
ssd[2]= digit[(count /10)%10];
ssd[3]= digit[count %10];
display(ssd);
count--; // Decrement count
}
// Optionally, add a small delay here to stabilize readings
}
// Once the count reaches 0, display 0000
for (int i =0; i < MAX_SSD_CNT; i++){
ssd[i]= digit[0]; // digit[0] represents '0'
}
display(ssd);
while (1){
// Optionally, halt further operations or enter low power state
}
return;
}
init_config();
unsigned char ssd[MAX_SSD_CNT];
unsigned int count =9999; // Initialize count
unsigned int adc_reg_val;
const unsigned int max_adc_value =1023;
while (count >0){
adc_reg_val = read_adc(); // Read the potentiometer value
// Calculate delay based on potentiometer reading
// Adjust the scaling factor (e.g.,10) based on your requirements
unsigned int delay =(max_adc_value - adc_reg_val)*10;
// Update SSD display if the delay threshold is reached
if (delay <=0){
ssd[0]= digit[(count /1000)];
ssd[1]= digit[(count /100)%10];
ssd[2]= digit[(count /10)%10];
ssd[3]= digit[count %10];
display(ssd);
count--; // Decrement count
}
// Optionally, add a small delay here to stabilize readings
}
// Once the count reaches 0, display 0000
for (int i =0; i < MAX_SSD_CNT; i++){
ssd[i]= digit[0]; // digit[0] represents '0'
}
display(ssd);
while (1){
// Optionally, halt further operations or enter low power state
}
this code si not working what to do

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!