You will write a program to make the buzzer buzz and LED blink.
Software Discovery: Constants, Digital output, Tone
Other Discovery: LED, Piezo Buzzer
Qty Part
1 LED
1 Piezo Buzzer
1 Resistor [220Ω]
Software Discovery: Constants, Digital output, Tone
Other Discovery: LED, Piezo Buzzer
Qty Part
1 LED
1 Piezo Buzzer
1 Resistor [220Ω]
Resources: |
|
Lets get Coding!
int led = 13; // LED connected to pin 13
int sound = 8; // piezo buzzer connected to pin 8
void setup()
{
pinMode(led, OUTPUT); // sets the LED as output
pinMode(sound, OUTPUT); // sets the buzzer alarm as output
}
void loop() // run the program continuously
{
digitalWrite(led, HIGH); // turn the LED on
tone(sound, 1000, 250); // play a tone with 1000 Hz for 250 ms
delay(2000); // wait for 2 seconds
digitalWrite(led, LOW); // turn the LED off
tone(sound, 6000, 250); // play a tone with 6000 Hz for 250 ms
delay(2000); // wait for 2 seconds
}
int led = 13; // LED connected to pin 13
int sound = 8; // piezo buzzer connected to pin 8
void setup()
{
pinMode(led, OUTPUT); // sets the LED as output
pinMode(sound, OUTPUT); // sets the buzzer alarm as output
}
void loop() // run the program continuously
{
digitalWrite(led, HIGH); // turn the LED on
tone(sound, 1000, 250); // play a tone with 1000 Hz for 250 ms
delay(2000); // wait for 2 seconds
digitalWrite(led, LOW); // turn the LED off
tone(sound, 6000, 250); // play a tone with 6000 Hz for 250 ms
delay(2000); // wait for 2 seconds
}
Challenge Yourself!
Watch any video on Crickets and listen to their sound.
By now, majority would have known (assumption needed) how fond I am with the rhyming cricket and cicada duo.
Using the same circuit, can you emulate the sound of a cricket? Your sketch may use at least 2 different tones.
(Hint: Refer to the #1 Blink. Modify the sketch to your desired outcome)
To give you a head start, watch how Zach Wendell cleverly create a cricket tone out from Arduino.
Another example: Chirping criket
Watch any video on Crickets and listen to their sound.
By now, majority would have known (assumption needed) how fond I am with the rhyming cricket and cicada duo.
Using the same circuit, can you emulate the sound of a cricket? Your sketch may use at least 2 different tones.
(Hint: Refer to the #1 Blink. Modify the sketch to your desired outcome)
To give you a head start, watch how Zach Wendell cleverly create a cricket tone out from Arduino.
Another example: Chirping criket