Introduction:
Our group’s project, Crossing Guard, is aimed at providing safe environment improving for the vulnerable people when crossing the intersection in busy urban areas. An audio noise like “crossing” or “wait” is needed to indicate if it is safe to cross especially for blind people. In this tutorial, we will mainly use Interface SD Card Module and a speaker to figure out how to play audio files with the Arduino.
Required Hardware:
Setup and Wiring:
Connections of the Interface SD Card Module
The module (MicroSD Card Adapter) is a Micro SD card reader module for reading and writing through the file system and the SPI interface driver. SCM system can be completed within a file MicroSD card, Support Micro SD Card or Micro SDHC card (high speed card). In this tutorial, we will use a file MicroSD card. Power supply is 4.5V ~ 5.5V, 3.3V voltage regulator circuit board.
Connect SD Card Module VCC to 5V.
Connect SD Card Module GND to GND.
Connect SD Card Module CS to pin4.
Connect SD Card Module MOSI to pin11.
Connect SD Card Module MISO to pin12.
Connect SD Card Module SCK to pin13.
Connections of the Speaker :
We need to connect two wires to the speaker jack with solder.
One wire from the speaker jack will connect to GND of the Arduino.
The other wire will connect to digital input 9 of the Arduino (The library use digital pin 9).
Create and Convert of audio file:
In this part, you need to record the audio like “Crossing” and “Wait” as signals for vulnerable people.
- I use phone application to record them. You can also use songs or music to show whether it is safe to cross the intersection if you want.
- After recording, you need to convert the audio file from mp3 to WAV. I use the online website https://audio.online-convert.com/convert-to-wav.Upload your audio you want to convert to WAV
Then change the settings as below:
bit resolution: 8 bit
sampling rate: 16000 Hz
audio channels: mono
After pressing “Start conversion”, our WAV audio files are ready.
- Then connect your SD card to your computer with a card reader. And save these files in the format of WAV to SD card.
- Finally, you will insert the SD card into the SD card module.
Code:
The code set up relatively simple in this tutorial. It is based on the wiring. You must pay attention to the code about pins of Arduino as they are connected to different pins of Interface SD Card Module. Do not mix them up.
What’s more, do not forget to add libraries and you can get the library from https://github.com/TMRh20/TMRpcm. Also, do not change the pin connections as the library is using these pins accordingly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
/* Tutorial for playing audio files * Yuyang Yin 11/14/2018 * Required Hardware: 1.Interface SD Card Module 2.Mini Speaker 3.2GB MicroSD 4.SD Card Reader 5.Jump Wires 6.Arduino Uno * Hardware connections: Interface SD Card Module: Connect SD Card Module VCC to 5V. Connect SD Card Module GND to GND. Connect SD Card Module CS to pin4. Connect SD Card Module MOSI to pin11. Connect SD Card Module MISO to pin12. Connect SD Card Module SCK to pin13. Speaker: Use solder to connect two jump wires to the speaker jack. One wire from the speaker jack will connect to GND. Another wire frome the speaker jack will connect to pin9. * The code is modified based on https://github.com/abhijitbrain/creative-research/blob/master/_1mp3.ino and https://github.com/TMRh20/TMRpcm/blob/master/examples/basic/basic.ino */ //Include libraries below #include <SD.h> //include SD module library #include <TMRpcm.h> //include speaker control library #define SD_ChipSelectPin 4 //define pin4 as CS pin TMRpcm tmrpcm; //crete an object for speaker library void setup(){ //Define speaker pin. The speaker library is using pin9. tmrpcm.speakerPin = 9; // Set up the serial port: Serial.begin(9600); //See if the card is present and can be initialized. if (!SD.begin(SD_ChipSelectPin)) { Serial.println("SD fail"); return; //Don't do anything more if not } //The sound file "2" will play each time the arduino powers up, or is reset tmrpcm.play("2.wav"); } void loop(){ if(Serial.available()){ //send the letter a over the serial monitor to start playback if(Serial.read() == 'a'){ // Set volume level. The range of numeber can be from 0-7. // Set the volume as 5 at this time. tmrpcm.setVolume(5); // Set the volume as 5. // Play the file 3. The file 3 is audio for Red Light. tmrpcm.play("3.wav"); } } } |
One reply on “CROSSING GUARD – ARDUINO TALKING AT THE INTERSECTION”
i had been trying to make make arduino project to speak but still this your codes and circuit i have not been able to make it possible please can you help