First to directly answer your question: yes.
But honestly, I really don't understand what you want to accomplish. Maybe you could explain with a bit more context. We're pretty good at helping on this forum, but like all humans, we need to actually understand to do anything more than not-so-useful answers.
Hi Paul thanks for qucik response!
I have 6 LDR's on my Analog inputs, triggering 6 different samples I have already uploaded to my sd card.
Here is my entire code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav3; //xy=83,262
AudioPlaySdWav playSdWav4; //xy=104,335
AudioPlaySdWav playSdWav2; //xy=132,192
AudioPlaySdWav playSdWav5; //xy=159,414
AudioPlaySdWav playSdWav1; //xy=176,107
AudioPlaySdWav playSdWav6; //xy=227,497
AudioMixer4 mixer1; //xy=519,105
AudioMixer4 mixer3; //xy=522,177
AudioMixer4 mixer2; //xy=524,342
AudioMixer4 mixer4; //xy=527,416
AudioMixer4 mixer5; //xy=753,194
AudioMixer4 mixer6; //xy=756,349
AudioOutputI2S i2s1; //xy=941,263
AudioConnection patchCord1(playSdWav3, 0, mixer1, 2);
AudioConnection patchCord2(playSdWav3, 1, mixer2, 2);
AudioConnection patchCord3(playSdWav4, 0, mixer3, 0);
AudioConnection patchCord4(playSdWav4, 1, mixer4, 0);
AudioConnection patchCord5(playSdWav2, 0, mixer1, 1);
AudioConnection patchCord6(playSdWav2, 1, mixer2, 1);
AudioConnection patchCord7(playSdWav5, 0, mixer3, 1);
AudioConnection patchCord8(playSdWav5, 1, mixer4, 1);
AudioConnection patchCord9(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord10(playSdWav1, 1, mixer2, 0);
AudioConnection patchCord11(playSdWav6, 0, mixer3, 2);
AudioConnection patchCord12(playSdWav6, 1, mixer4, 2);
AudioConnection patchCord13(mixer1, 0, mixer5, 0);
AudioConnection patchCord14(mixer3, 0, mixer5, 1);
AudioConnection patchCord15(mixer2, 0, mixer6, 0);
AudioConnection patchCord16(mixer4, 0, mixer6, 1);
AudioConnection patchCord17(mixer5, 0, i2s1, 0);
AudioConnection patchCord18(mixer6, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=604,760
// GUItool: end automatically generated code
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14
const int ldrpins[] = {17, 18, 19, 20, 21, 22};
int ldr_pre[] = {0, 0, 0, 0, 0, 0};
int ldr_now[] = {0, 0, 0, 0, 0, 0};
bool ldr_state[] = {0, 0, 0, 0, 0, 0};
int treshold = 80;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
AudioMemory(100);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
//Left Channels
mixer1.gain(0, 0.15);
mixer1.gain(1, 0.15);
mixer3.gain(0, 0.15);
mixer3.gain(1, 0.15);
mixer5.gain(0, 0.15);
mixer5.gain(1, 0.15);
//Right Channels
mixer2.gain(0, 0.15);
mixer2.gain(1, 0.15);
mixer4.gain(0, 0.15);
mixer4.gain(1, 0.15);
mixer6.gain(0, 0.15);
mixer6.gain(1, 0.15);
delay(1000);
}
void loop() {
// Read and check if LDRs is covered or not
for (int i = 0; i < 6; i++) {
ldr_now
= analogRead(ldrpins);
if (ldr_now[0]-ldr_pre[0] > treshold) {
ldr_pre[0] = ldr_now[0];
Serial.print("LDR1 STATE: ");
Serial.print(ldr_now[0]);
Serial.println("Start playing");
playSdWav.play(".wav");
delay(10); // wait for library to parse WAV info
};
if (ldr_pre[0]-ldr_now[0] > treshold) {
ldr_pre[0] = ldr_now[0];
Serial.print("LDR1 STATE: ");
Serial.print(ldr_now[0]);
Serial.println("Stop playing");
playSdWav[i+1].stop();
};
}
}