Vernier Software and Technology
Vernier Software & Technology
Arduino and Vernier Sensors

Produce a Tone Out that Depends on Sensor Reading

A simple, but useful, sketch with analog sensors is to use the raw voltage from any analog sensor to control the frequency of the sound produced. This sketch is based on the Tone2 Tutorial.

Read the voltage from the analog sensor in the normal way. Then use the Map and Tone commands to produce the tone. There are several ways that we have found this kind of system useful. First, for blind or low-vision students, it is great to have a tone produced that indicates the sensor reading. Also, sometimes when you are looking for a change in a sensor reading, it is easier to listen for a change than it is to stare at a meter or a graph.

Note that you do not need to deal with calibration in this sketch, since it is the raw voltage from the sensor that controls the frequency.

You can modify this sketch in many ways:

  • If you want to change the range of frequencies produced, change the last two numbers in the Map command, which are the lowest and highest frequencies to be produced.
  • If you have a sensor that puts out a voltage in a limited range, change the first two numbers in the Map command to the range of input voltages to be expected from the sensor.
  • As written, the program sends the analog voltage measure to the Serial Monitor. Because this is unnecessary; remove the Serial.println statement, if you like.

Contents

Introduction

Vernier Engineering Contest

Vernier recognizes instructors for creative uses of Vernier sensors to introduce engineering concepts and/or practices. Vernier Engineering Award »

Go to top