Thanks to your help I am a little bit further with my work. Now my code looks as fallows:
#define inPin0 0
#include <Wtv020sd16p.h>
int resetPin = 2; // The pin number of the reset pin.
int clockPin = 3; // The pin number of the clock pin.
int dataPin = 4; // The pin number of the data pin.
int busyPin = 5; // The pin number of the busy pin.
const int numReadings = 10;
unsigned int analogVals[numReadings]; //Deklaracja tablicy
unsigned int i = 0;
Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);
void setup(void) {
Serial.begin(9600);
wtv020sd16p.reset();
Serial.println();
}
void loop(void) {
int pinRead0 = analogRead(inPin0);
float pVolt0 = pinRead0 / 1024.0 * 5.0;
if (pVolt0 >=3) {
pVolt0 = 1;
}
else {
pVolt0 = 0;
}
Serial.println(); //Aktualnie odczytana wartosc
Serial.println(pVolt0);
analogVals[i] = pVolt0; //Przypisz wartosc do i-tego miejsca w tablicy
Serial.println(i); // Aktualne polozenie w tablicy
i++;
if (i>=numReadings) { //Jesli zdefiniowan tablica pelna to
Serial.println("Odebrane dane:");
for(int i=0;i<=9;i++) {
Serial.print(analogVals[i]); //Wypisz tablice
}
int pattern[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; //Deklaracja wzorca
int pattern2[] = {0, 0, 1, 1, 1, 1, 1, 1, 1, 1}; //Deklaracja wzorca
int pattern3[] = {0, 0, 0, 0, 1, 1, 1, 1, 1, 1}; //Deklaracja wzorca
//int compare = memcmp(analogVals, pattern, sizeof(analogVals));
int compare;
if (compare = memcmp(analogVals, pattern, sizeof(analogVals))){
Serial.println("\nMatch with patter no. 1");
wtv020sd16p.asyncPlayVoice(0);
wtv020sd16p.pauseVoice();
delay(2000);
}
else if (compare = memcmp(analogVals, pattern2, sizeof(analogVals))){
Serial.println("\nMatch with patter no. 2");
wtv020sd16p.asyncPlayVoice(1);
wtv020sd16p.pauseVoice();
delay(2000);
}
else if (compare = memcmp(analogVals, pattern3, sizeof(analogVals))){
Serial.println("\nMatch with patter no. 3");
wtv020sd16p.asyncPlayVoice(2);
wtv020sd16p.pauseVoice();
delay(2000);
}
i=0;
delay(5000);
}
delay(1000);
}
The idea is to play different audio files depending on the signal received by photo diode. So I created three patterns and used "memcmp" to define which audio file will be played. But now i can only match with patterns 1 and 2. Any tips?