Arduino sensors
A sensor turns something in the world around it into an electrical signal. Connect a potentiometer, a light-dependent resistor and an ultrasonic sensor to Arduino and watch the values in the Serial Monitor.
The ultrasonic sensor finds distance in centimetres from the echo time. Show the result with an LED bar or sound and build an automatic night light, a digital tape measure and a parking sensor.
In this lab
- analog input 0…1023
- LDR and potentiometer
- ultrasonic sensor
- parking sensor and theremin
What you learn
A sensor turns a quantity from the world (light, distance, a turning angle) into an electrical signal. The Arduino analog input turns a voltage into a number 0…1023, and the ultrasonic sensor finds distance from the echo time. The aim is to measure, convert the number into meaningful units and make decisions from the result.
Tasks
- Read a potentiometer and print it to the serial monitor
- Measure light with a photoresistor and make an automatic lamp
- Rescale a number with map
- Measure distance in centimetres with the ultrasonic sensor
- Show the result on a display, an LED bar or with sound
What you can build
- Light meter — Light level shown as 0…9 on the display.
- Automatic night light — The LED switches on by itself when it gets dark.
- Digital tape measure — Prints the distance to an obstacle in centimetres.
- Parking sensor — The closer the obstacle, the faster the buzzer beeps.
- Theremin — Play a tune by moving your hand: distance → frequency.
- Intruder alarm — Light and sound if someone comes closer than 30 cm.