Prepare the breadboard

768639590545666120.jpg

Tone Output Using An Arduino

IMG_1674.heic

WechatIMG617.jpeg

This video that shows how the speaker work with the sensor. One question i have when I working on this lab is the speck keeps make sound and when i press the sensor, it stop. so i check the program and i make a little change.

const int threshold = 100; // minimum reading of the sensors that generates a note const int speakerPin = 8; // pin number for the speaker const int noteDuration = 20; // play notes for 20 ms

// notes to play, corresponding to the 3 sensors: int notes[] = { NOTE_A4, NOTE_B4,NOTE_C3 };

void setup() { Serial.begin(9600); }

void loop() { for (int thisSensor = 0; thisSensor < 3; thisSensor++) { // get a sensor reading: int sensorReading = analogRead(thisSensor);

// if the sensor is pressed hard enough:
if (sensorReading > threshold) {
  // play the note corresponding to this sensor:
  tone(speakerPin, notes[thisSensor], noteDuration);
  Serial.println(thisSensor);
}

} }

®YvonnE 2021-09-09 14.44.40.mp4

Project 1

for project one, my team decide making Wind chimes installation, using infrared sensor