Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The code below is running on an Arduino board. Pin 3 is connected to a signal generator that is producing a 33Hz square wave at
The code below is running on an Arduino board. Pin 3 is connected to a signal generator that is producing a 33Hz square wave at 5V amplitude. Determine how many times the LED connected to pin 13 will flash on during each 10 second interval. For full credit, you must explain how this is 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 Timeri.initialize (33333); // set a timer of length 33333 useconds (or 0.033333 sec) Timeri.attachInterrupt( timerIsr); attachInterrupt (digitalPinToInterrupt (3), pulseIsr, FALLING); } void loop() { inval - digitalRead(3); if ((inval != lastval) && (inval == true)) { digitalWrite(13, digitalRead( 13 ) ^ 1); 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 ) ^ i); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started