Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Demonstrate External Interrupt, Audio: Use the NewTone Library. READ the syntax to learn how to use the NewTone() command. Hookup an LED to a digital

Demonstrate External Interrupt, Audio: Use the NewTone Library. READ the syntax to learn how to use the NewTone() command. Hookup an LED to a digital pin (dont forget the resistor). Hookup a passive piezo speaker (the one with NO white label) to a digital pin. Hook up a pushbutton to an interrupt pin. In the loop() function, blink the LED twice per second using the delay() function.

Using an interrupt, in the ISR make a 1kHz tone for two seconds (using the NewTone library) whenever the pushbutton is pushed. The LED should keep blinking (which is the whole idea of using an interrupt)!

What you are learning from this: Everything from #1 and how to hookup a pin to make an external interrupt (your pushbutton).

*I have the code where the led lights up and the speaker is making a tone I'll post it below*

#include

byte led = 8; volatile boolean state = HIGH; byte buzzer = 9; //Associate the buzzer to pin 4 void setup() { pinMode(led, OUTPUT);

// timerISR runs every 2 sec // initialize value in uS Timer1.initialize(500000); Timer1.attachInterrupt(timerISR); pinMode(buzzer, OUTPUT); //Set it up for output pinMode(led, OUTPUT); }

void loop() {

digitalWrite(buzzer, HIGH); // makes a 1kHz tone delayMicroseconds(500); digitalWrite(buzzer, LOW); delayMicroseconds(500);

}

void timerISR() { state = ! state; digitalWrite(led, state); }

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_2

Step: 3

blur-text-image_3

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

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

i need correct answrrs 6 4 2

Answered: 1 week ago