//#include <SD.h>
//#include <SPI.h>
//#include <TMRpcm.h>
//#define SD_ChipSelectPin 10
//TMRpcm audio;
//Boutons Choix du verbe conjugé
const int r[]={A5,A4,A3,A2,A1,A0};
const int s[]={A12,A13,A14,A15};
//const int sensor[]={8,9};
//Bouton de choix du Pronom personel
const int start = A6;
// Connexion arduino avec 74HC595:
///Pin connected to DS of 74HC595
int dataPin = 5;
///Pin connected to ST_CP of 74HC595
int latchPin = 6;
///Pin connected to SH_CP of 74HC595
int clockPin = 7;
// Connexion arduino avec 74HC595 (2):
///Pin connected to DS of 74HC595 (2)
int dataPin_2 = 2;
///Pin connected to ST_CP of 74HC595 (2)
int latchPin_2 = 3;
///Pin connected to SH_CP of 74HC595 (2)
int clockPin_2 = 4;
byte leds = 0;
byte Yleds = 0;
boolean shifting = true;
//audio.speakerPin= 9;
void setup()
{
pinMode(start, INPUT_PULLUP);
//
for(int i=0;i<6;i++) {pinMode(r[i], INPUT_PULLUP);}
for(int i=0;i<4;i++) {pinMode(s[i], INPUT);}
//set pins to output so you can control the shift register 74HC595
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
//set pins to output so you can control the shift register 74HC595 (2)
pinMode(latchPin_2, OUTPUT);
pinMode(clockPin_2, OUTPUT);
pinMode(dataPin_2, OUTPUT);
//audio.play("intro.wav")
}
void updateShiftRegister2()
{
digitalWrite(latchPin_2, LOW);
shiftOut(dataPin_2, clockPin_2, LSBFIRST, leds);
digitalWrite(latchPin_2, HIGH);
}
void Yled_on(int x)
{
Yleds=0;
bitSet(Yleds,8-x);
digitalWrite(latchPin, LOW);
if (bitRead(leds,8-x)==1)
{shiftOut(dataPin, clockPin, LSBFIRST, bitSet(Yleds,1));}
else
{shiftOut(dataPin, clockPin, LSBFIRST, bitSet(Yleds,0));
//if (s[0] ==1 && s[1]==1 && s[2]==1 && s[3]==1){audio.play("p1.wav");}
//if (s[0] ==1 && s[1]==0 && s[2]==0 && s[3]==0){audio.play("p2.wav");}
//if (s[0] ==0 && s[1]==1 && s[2]==0 && s[3]==0){audio.play("p3.wav");}
//if (s[0] ==0 && s[1]==0 && s[2]==1 && s[3]==0){audio.play("pp1.wav");}
//if (s[0] ==0 && s[1]==0 && s[2]==0 && s[3]==1){audio.play("pp2.wav");}
//if (s[0] ==1 && s[1]==0 && s[2]==1 && s[3]==0){audio.play("pp3.wav");}
//if (s[0] ==0 && s[1]==1 && s[2]==1 && s[3]==0){audio.play("f1.wav");}
//if (s[0] ==0 && s[1]==1 && s[2]==0 && s[3]==1){audio.play("f2.wav");}
//if (s[0] ==0 && s[1]==0 && s[2]==1 && s[3]==1){audio.play("f3.wav");}
}
digitalWrite(latchPin, HIGH);
}
void loop()
{
if (digitalRead(start)==LOW)
{
delay(250);
shifting=!shifting;
}
if (shifting==true)
{
leds =0;
bitSet(leds, random(2,8));
updateShiftRegister2();
delay(80);
}
if(digitalRead (r[0]) == LOW){Yled_on(1);}
if(digitalRead (r[1]) == LOW){Yled_on(2);}
if(digitalRead (r[2]) == LOW){Yled_on(3);}
if(digitalRead (r[3]) == LOW){Yled_on(4);}
if(digitalRead (r[4]) == LOW){Yled_on(5);}
if(digitalRead (r[5]) == LOW){Yled_on(6);}
}