I am working on a project using Arduino and the Grove kit. I ordered 4 motion sensors and 4 sound recorders. My goal is for the motion sensors to set off the sound recorders (Each motion recorder/ sound recorder controlled independently from the others). The sounds are already recorded. I have some code already finished. It allows the sound recorders to play, but all at random. They cannot all be controlled separately within the code. And I don’t have any code that makes the motion sensor trigger the sound recorder. So, if not all 4 sound recorders I need to get 2 of the modules working separately with separate inputs. I am very new to Arduino and am working on this for a class. Any help would be greatly appreciated!!!
This code makes all the sound recorders work at random ( No motion sensors in this code.)
// Bare Bones Playback of Sounds from Grove Sound Recorder
// Record Sounds Manually
// Use this sketch to playback
// include our sound recorder library
#include <GroveSoundRecorder.h>
// initialize a recorder
#define SEL1 1 // SEL1 connects to pin# 2 on the Stem Base Shield, only use the DIGITAL pins
GroveSoundRecorder recorder(SEL1);
// initialize a recorder
#define SEL3 3 // SEL3 connects to pin# 3 on the Stem Base Shield, only use the DIGITAL pins
GroveSoundRecorder recorder(SEL3);
{
recorder.initialize(); // initialize the sound recorder
}
// initialize a recorder
#define SEL4 4 // SEL4 connects to pin# 4 on the Stem Base Shield, only use the DIGITAL pins
GroveSoundRecorder recorder(SEL4);
{
recorder.initialize(); // initialize the sound recorder
}
// initialize a recorder
#define SEL5 5 // SEL5 connects to pin# 5 on the Stem Base Shield, only use the DIGITAL pins
GroveSoundRecorder recorder(SEL5);
void setup()
{
recorder.initialize(); // initialize the sound recorder
}
void loop()
{
delay(1000);
{
recorder.beginPlayback(TRACK2); //Track2 = K2 Bennie and the jets
delay(10000);
recorder.beginPlayback(TRACK3); //Track3 = K3 …countdown
delay(10000);
recorder.beginPlayback(TRACK4); //Track4 = K4 …A,B,C,D,E
delay(10000);
recorder.beginPlayback(TRACK3); //Track3 = K3 …countdown
delay(10000);
}
}
Here is a code I found about making the motion sensor work, but again I’m having problems. And this code does not make the motion sensor trigger the sound.
const int ledPin=13;//The led to indicate the motion
void setup(){
Serial.begin(9600);
pinMode(12, INPUT);//Use pin 12 to receive the signal outputted by the module
pinMode(ledPin, OUTPUT);
}
void loop() {
int sensorValue = digitalRead(2);
if(sensorValue==1)
digitalWrite(ledPin,HIGH);
else
digitalWrite(ledPin,LOW);
Serial.println(sensorValue, DEC);//Print the state of the signal through the serial monitor.
}