Answered step by step
Verified Expert Solution
Link Copied!

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 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

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

love of humour, often as a device to lighten the occasion;

Answered: 1 week ago

Question

orderliness, patience and seeing a task through;

Answered: 1 week ago

Question

well defined status and roles (class distinctions);

Answered: 1 week ago