Bird
0
0
Arduinoprogramming~10 mins

Passive vs active buzzer difference in Arduino - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to turn on an active buzzer connected to pin 8.

Arduino
const int buzzerPin = 8;

void setup() {
  pinMode(buzzerPin, OUTPUT);
  digitalWrite(buzzerPin, [1]);
}

void loop() {
  // Buzzer is on
}
Drag options to blanks, or click blank then click option'
AHIGH
BLOW
CINPUT
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the pin to LOW turns the buzzer off.
Confusing pinMode with digitalWrite.
2fill in blank
medium

Complete the code to generate a tone on a passive buzzer connected to pin 9.

Arduino
const int buzzerPin = 9;

void setup() {
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  tone(buzzerPin, [1]);
  delay(1000);
  noTone(buzzerPin);
  delay(1000);
}
Drag options to blanks, or click blank then click option'
ALOW
B1000
CHIGH
D5000
Attempts:
3 left
💡 Hint
Common Mistakes
Using HIGH or LOW instead of a frequency.
Using too high frequency that the buzzer can't play.
3fill in blank
hard

Fix the error in the code to stop the passive buzzer sound.

Arduino
const int buzzerPin = 7;

void setup() {
  pinMode(buzzerPin, OUTPUT);
  tone(buzzerPin, 2000);
  delay(500);
  [1](buzzerPin);
}

void loop() {}
Drag options to blanks, or click blank then click option'
AnoTone
BdigitalWrite
Ctone
DpinMode
Attempts:
3 left
💡 Hint
Common Mistakes
Using digitalWrite to stop the tone doesn't work.
Calling tone again without parameters won't stop the sound.
4fill in blank
hard

Fill both blanks to create an array of structs that maps buzzer types to their control methods.

Arduino
struct BuzzerControl {
  const char* type;
  const char* method;
};

BuzzerControl controls[2] = {
  { "active", [1] },
  { "passive", [2] }
};
Drag options to blanks, or click blank then click option'
A"digitalWrite(HIGH)"
B"tone(frequency)"
C"digitalWrite(LOW)"
D"noTone()"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up control methods for active and passive buzzers.
Using noTone for active buzzers.
5fill in blank
hard

Fill all three blanks to complete the code that plays a 1kHz tone for 1 second on a passive buzzer, then stops it.

Arduino
const int buzzerPin = 6;

void setup() {
  pinMode(buzzerPin, OUTPUT);
  tone([1], [2]);
  delay(1000);
  [3](buzzerPin);
}

void loop() {}
Drag options to blanks, or click blank then click option'
AbuzzerPin
B1000
CnoTone
Dtone
Attempts:
3 left
💡 Hint
Common Mistakes
Using tone instead of noTone to stop the sound.
Swapping pin and frequency arguments.