This was a small project for some students in Industrial Design class for Installation Art.
The sensor is a variable resistor called a photo-resistor or LDR.
The resistor value will change with the amount of light.
A high amount of light and the LDR resistance will decrease so that the voltage over the fixed resistor will increase and thus the voltage over the fixed resisitor will increase.
The voltage changes from 0 to 5V. Arduino has 6 analog to digital convertors (ADC). The voltage value can be read on pin A0 and the value range from from 0 to 1023
We read the value of the ADC, and then play a diferent sound file.
The sound files are played using an DFPlayer. Using the serial port from the arduino, commands can be send to the DFplayer For example "play" and "stop". After starting the play, we must wait a few seconds for the audio to complete.
The files must be named 0001.mp3 to 0005.mp3 and placed in a subfolder on the SD card. The SD card must be FAT formatted.
The code sets a target value with a range in which the target lies. When the value is within the target range 0003.mp3 file will be played back.
The usage of the files are as follows:
- 0001.mp3 far away
- 0002.mp3 stil far away
- 0003.mp3 just right
- 0004.mp3 to close
- 0005.mp3 very close
Updating MP3 files can be done using the USB connector.
- Set the switch is set in "ON" position
- Connect a computer is to the DFPlayer USB connector
- Connect powerto the Arduino
- The dfplayer will act an an USB drive and files can be moved from the PC to the dfplayer.
- Disconnect the usb connectors
- Set the switch to "OFF"
- Power on the Arduino. ** List of materials **