Author: Vio Zhu (yz9617) | Sep 19, 2023 | Fall 2023 section: Rios, Tuesday

1. Lab: Tone Output

1.1 Check the sensor input range

Serial.println(analogValue); ranges from 0 to 960.

1.2 Check that the Speaker Works

1.3 Play Tones

Read the analog input and map the result to a range from 100 to 1000. The example below assumes your analog input circuit ranges from 200 to 900, so adjuct for your actual values.

// map the results from the sensor reading's range
// to the desired pitch range:
float frequency = map(sensorReading, 200, 900, 100, 1000);
// change the pitch, play for 10 ms:
tone(8, frequency, 10);
delay(10);

IMG_1393.MOV

1.4 Play It Loud

Use a transistor to amplify the sound from the speaker.

The shop is running out of TIP 120 so I picked a TIP 102 as replacement.

IMG_1394.mov

1.5 Use Headphones

The shop is running out of audio jack so I’m not able to try this out.