Project of Audio Player based on Light

Greetings everyone!

So, I'm a Information Systems student from Brazil and my aunt is a teacher of an elementary school which every year has an event where the students come with a problem and a solution for this problem.

This year my aunt's students raised the problem of adults using a smartphone while driving their cars. Then, my aunt came to me looking for a solution where she could present her students to technology.

We thought about a little box that the parents could carry inside their cars and place their smartphones. If the parents took the smartphones out of the box, then a speaker would play their child voice saying something like: "Hey, dad, do not use your cellphone while driving, it's dangerous!".

As I didn't know anything about Arduino, I'd started to make some researches and, so far, I've done this:

The idea is:

  • A photo resistor is placed on the bottom of the box;
  • The pre-recorded file is stored in a micro SD card;
  • If the photo resistor gets a lot of light, then there's no cellphone in the box and the pre-recorded file is played.
  • If the photo resistor gets a low amount of light, then the cellphone is in the box and the pre-recorded file is stopped if it was being played.

I want to supply this circuit with a 9V battery.

What I want to know is this circuit and code are going to work as I want? And, also, if we will understand the audio file being played from the speaker.

Schematic:

Code:

#include <SPI.h>
#include <SD.h>
#include <TMRpcm.h>

#define SD_ChipSelectPin 10 //defines the digital pin used by CS terminal of BT module

TMRpcm audio; //creates an object to the speaker library

const int checkEvery = 300; //loop interval in miliseconds
const int shadowThreshold = 500; //threshold to the foto resistor that will define if the cellphone is in or out the box
const int audioFile = "audio.wav"; //the audiofile to be played

void setup() {
 audio.speakerPin = 9; //defining the speaker pin (it must be 9 in arduino uno)
 audio.setVolume(6); //defining the volume (1 a 7)
 pinMode(SS, OUTPUT);

 Serial.begin(9600);
 if(!SD.begin(chipSelect)) { //if the microSD can't be read
 return; //do nothing
 }
}

void loop() {
 checkCel(shadowThreshold); 
 delay(checkEvery);
}

void checkCel(int shadowLevelLimit) {
 int sensorValue = analogRead(A0);
 Serial.println(sensorValue);

 if (sensorValue > shadowLevelLimit) { //if there's a low amount of light
 if (audio.isPlaying()) { //if the audio file is being played
 audio.disable(); //stops the sound
 }
 } else { //if there's a hight amount of incoming light
 audio.play(audioFile); //play audio file
  }
  
}

Thank you so much for your attention :stuck_out_tongue:

up

Why not just put the key to the box ( could be the glove box) with the phone in it , on the same key ring as the ignition key ? ( or put the phone in the trunk)

The problem is , someone likely to use the phone won’t put it in the box in the first place, unless the car won’t run unless they did.

Hammy, where is the fun in that?

OP. What you presented can be done. However, to play an mp3 you will find you will need something like anDFPlayer. You will not be able to get any decent sound from the Arduino itself.

I like the idea, the sound might old-phone sounding (low bandwidth), and a speaker driver is needed, Arduino pins can't drive a speaker very loud.

I think it needs to be more interactive tho. Have it wired to the radio power perhaps, and the phone must be plugged in via its charger cord. If the box senses radio power being drawn, and the phone is not connected (sense power being drawn, or perhaps via some data being sent via USB), then it plays the voice reminder message.

First of all, thank all of you for your answers.

So, there is something I forgot to mention which is that the main idea here is not to come along with a practical solution, but to introduce technology to the 8-9 years old children and enchant them with it. Also, the project won't be presented inside a car but during a little science fair.

What I want, for now, is to help my aunt with the simplest idea as possible, because I don't want to totally dive into Arduino and circuits concepts. I really liked your idea CrossRoads, but it seems very complex for someone with little knowledge in Arduino to execute, isn't it?

Romonaga and CrossRoads, as both of you said, I won't get a decent sound from Arduino, so I've just thought in another solution. Instead of playing the audio file through the arduino speaker, is it possible to send the audio file to a portable bluetooth speaker and make it play the audio? I saw there's a bluetooth module, it might be easy to connect another device to the arduino bluetooth module, but is it easy to stablish this connection from the arduino itself to the portable speaker?

Again, thank you for your attention

Romonaga:
OP. What you presented can be done. However, to play an mp3 you will find you will need something like anDFPlayer. You will not be able to get any decent sound from the Arduino itself.

Maybe not HiFi, but Arduino's WAV playing quality is pretty decent. OP intends to use this library to play their sounds.