HELP on Arduino Project!!!

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.
}

Hi there,

Thanks for you sharing the code.
Hope you can finally success with your project.

Best regards,

Yuri

Your code does not make sense. You’re defining an object “recorder” 4 times and initialize it shortly after. Only one of the initializations is done in the setup() routine (all should go there). You should define 4 DIFFERENT variables, one for every recorder connected and initialize alle within setup(). And take care that you don’t use adjacent pins for the recorders as every recorder needs 2 pins:

GroveSoundRecorder recorder(2);

This would use pins 2 and 3 for communication with the module. You cannot use pin 0, 1 and 7 as the selection value (2 in the above example).

Possible code is:

[code]GroveSoundRecorder recorder1(2);
GroveSoundRecorder recorder2(4);
GroveSoundRecorder recorder3(6);
GroveSoundRecorder recorder4(8);

void setup() {
recorder1.initialize();
recorder2.initialize();
recorder3.initialize();
recorder4.initialize();
}

void loop() {
// do what you wanna do here, like playing a sound or recording
}[/code]

Hope this helps!