Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students explore these related Databases questions