Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Program is in Arduino and C. I need help with explaining the code and explain the data collected. Encovou WN /* TIMERS MADE EASY

image text in transcribedThe Program is in Arduino and C.

I need help with explaining the code and explain the data collected.

Encovou WN /* TIMERS MADE EASY BY HERNAN LOZANO unsigned long ms runtime; int one_ms_timer; //DEFINE ALL TIMERS AS UNSIGNED VARIABLES unsigned long timer1 = 0; // timeri increments every 10 Oms = 0.1s const int USER LED = 13; const int BUTTON_PIN = 2; void setup() { // initialize the digital pin as an output. pinMode (USER LED, OUTPUT); pinMode (BUTTON_PIN, INPUT); Serial.begin(9600); } void loop() { //run loop forever static int state,old_state, counter; timers(); //logic for state change if (state == 0) { if (digitalRead (BUTTON_PIN) == 1) { if(timeri > 5) state = 1; 13 14 15 else timer1 = 0; JOU WOOCO von W NOC else if(state == 1) { if(digitalRead (BUTTON PIN) == 0) { if(timeri > 5) state = 0; else timer1 = 0; 42 //execute commands based on state if (state == 1) digitalWrite (USER_LED, HIGH); else if (state == 0) digitalWrite (USER_LED, LOW); //monitor and print changes of state if(old_state != state) counter++; Serial.print("counter = "); Serial.println(counter); 48 void timers (void) old_state = state; 49 Elf 50 int i; if(millis() > (ms_runtime + 1)) { ms runtime = ms_runtime + 1; one_ms_timer++; 47 L else if(ms runtime > millis()) ms runtime = millis(); if(one ms timer > 99) { timerl++; one_ms_timer = 0

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

More Books

Students also viewed these Databases questions