Question: The code below is running on an Arduino board. Pin 3 is connected to a signal generator that is producing a 23Hz square wave at

The code below is running on an Arduino board. Pin 3 is connected to a signal generator that is producing a 23Hz square wave at 5V amplitude. Determine how many times the LED connected to pin 13 will flash on during each 10 second interval. How is this determined and show some math. Note that there is a timer interrupt in this code, a pin interrupt in this code, and some polling code in loop().

#include bool inval; bool lastval = false; void setup() { // Initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards pinMode(13, OUTPUT); pinMode(3, INPUT); 5 Timer1.initialize(33333); // set a timer of length 33333 seconds (or 0.033333 sec) Timer1.attachInterrupt( timerIsr ); attachInterrupt(digitalPinToInterrupt(3), pulseIsr, FALLING); } void loop() { inval = digitalRead(3); if ((inval != lastval) && (inval == true)) { digitalWrite( 13, digitalRead( 13 ) ^ 1 ); } lastval = inval; } /// -------------------------- /// ISR Timer Routine /// -------------------------- void timerIsr() { // Toggle LED digitalWrite( 13, digitalRead( 13 ) ^ 1 ); } /// -------------------------- /// ISR Pin 3 Routine /// -------------------------- void pulseIsr() { // Toggle LED digitalWrite( 13, digitalRead( 13 ) ^ 1 ); }

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!