Question: Custom callback code: Now, create a new global variable, initializing it to zero, for storing the time in milliseconds. Create a second global variable (
Custom callback code: Now, create a new global variable, initializing it to zero, for storing the
time in milliseconds. Create a second global variable also initialized to zero to store the time
in seconds.
Implement custom code in timercallback that increments the new ms counter variable
every time the function is called.
Implement logic that ensures that if the current time in milliseconds is equal to or greater
than one second, it:
Decrements its own value by the ms equivalent of one second.
Increments the seconds variable by the equivalent of one second.
Toggles the onboard LED digital output
Note: This code should work if the time in ms is any value over than second.
Note : This code should be written so as it doesn't reset, clear, truncate, or lose time
information.
In the while loop in main add code that
computes the current time as a float in seconds with milliseconds behind the decimal
point
fills and prints a string with the current time in seconds, starting with and ending with
s using
Example:
Note: It is bad practice to put printf or sprintf functions in a callback because it takes so much
time to process.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
