What does each line in the code?? Please unsigned Long timer1; unsigned Long button_dbnc_tmr = 0; const int...

80.2K

Verified Solution

Question

Programming

What does each line in the code?? Please

unsigned Long timer1;
unsigned Long button_dbnc_tmr = 0;
const int User_Button = 2;
const int USER_LED_Pin = 13;
bool allow_change = 0;
int counter = 0;
int state;
void read_state_from_memory(void);
void write_state_to_memory(void);
void turnoff(void);
void flash_1s(void);
void flash_2s(void);
void flash_3s(void);

void setup()
{
read_state_from_memory();
pinMode(USER_LED_Pin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
timers();
if(digitalRead(User_Button) == 1)
{
if(allow_change == 1)
{
state++;
Serial.println(counter);
Serial.println(state);
allow_change = 0;
if(state > 3)
state = 0;
write_state_to_memory();
}
}
}
else
{    counter = 0;
    allow_change = 1;
button_dbnc_tmr = 0;
}
switch(state_
{
case 0:
turn off();
break;
case 1:
flash_1s();
break;
case 2:
flash_2s();
break;
case 3:
flash_3s();
break;
}
}
void turnoff()
{

//complete by me

}
void flash_1s()
{
//complete by me

}
void flash_2s()
{
//complete by me

}
void flash_3s()
{
//complete by me

}
void timers(void)
{
static unsigned Long ms_runtime;
static int one_ms_timer;

if(millis() > (ms_runtime + 1))
{   ms_runtime = ms_runtime + 1;
one_ms_timer++;
}
else if(ms_runtime > millis())x
ms_runtime = millis();

if(one_ms_timer > 99)
{   one_ms_timer = 0;
button_dbnc_tmr++;
timer1++;
}
}
void read_state_from_memory ()
{
//to be completed by me
}
void write_state_to_memory()
{
//to be completed by me
}

Answer & Explanation Solved by verified expert
3.7 Ratings (466 Votes)
The purpose of each line is added as command line Declare global variable timer1 as unsigned Long 32 bit size unsigned Long timer1 Declare global variable buttondbnctmr as unsigned Long and initialize it to 0 unsigned Long buttondbnctmr 0 Declare constant UserButton as integer type and initialize it to 2 const int UserButton 2 Declare constant USERLEDPin as integer type and initialize it to 13 const int USERLEDPin 13 Declare boolean variable allowchange and initialize it to 0 bool allowchange 0 Declare integer variable counter and initialize it to 0 int counter 0 Declare integer variable state int state Declare user defined function readstatefrommemory with void parameter and no return values void readstatefrommemoryvoid Declare user defined function writestatetomemory with void parameter and no return values void writestatetomemoryvoid Declare user defined function turnoff    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students