Hey Arduinos:
I wanted to ask you again for help in my long time project: The High Striker.
To summarize what's happening: I connected my Arduino to a remote control (by soldering), which enables me to choose between the chapter numbers: 0-9. There is always one video which reponds to the precedent one, this is why I created a 2D array with pairs (2,3;4,5;6,7...)
Now the thing; my code as it is doesn't allow my to adress chapter that demand the use of two inputs (e.g. 10,11,12,...up to 19). Since the DVD I'm using got more chapters than expected, I would like to enlarge the code a little.
Now the question:
Do you see a way (comprehensible for a beginner like me) to bring a pattern which makes it possible to embed these 2-input chapters ?
The code I am working with right now ...:
int lightbarrier = 12;
int myState = 0;
long TimerG;
long TimerN;
long periodNormal = 20000;
long periodDisturbed = 5000;
int pairs = 4; //man könnte hier einfach die Anzahl der Paare ändern, dies würde er dann mit in die For-Schleife nehmen
int Aktuell; // initialisieren
int remotePins[][2] = {{2,3},
{4,5},
{6,7},
{8,9}};
void setup()
{
Serial.begin(9600);
for (int i=0; i < pairs; i++) //Es sind stets Paare von zwei Videos
{
pinMode(remotePins[i][0], OUTPUT); //Deklaration aller oben genannten Pins als Output-Pins
pinMode(remotePins[i][1], OUTPUT);
}
pinMode(lightbarrier, INPUT);
}
void loop()
{
switch(myState)
{
case 0:
Aktuell = random(0, 4); //number of pairs
startVideo(Aktuell, 0);
myState = 1; // played video state
TimerN = millis();
break;
case 1:
if(millis()-TimerN>periodNormal)
{
myState = 0;
}
if (digitalRead(lightbarrier)==HIGH)
{
myState = 2; // Intervention
}
break;
case 2:
startVideo(Aktuell, 1);
myState = 3; // played video state
TimerG = millis();
break;
case 3:
if(millis()-TimerG>periodDisturbed)
{
myState = 0; // back to state 0
}
break;
}
}
void startVideo(int videoPaar, int gestoertOderNicht) // welches Videopaar wird gesteuert, und welches von diesen beiden wird gestartet (gestört oder normal)
{
Serial.print(" Choosed pair:");
Serial.print(remotePins[videoPaar][0]);
Serial.print(" ,");
Serial.print(remotePins[videoPaar][1]);
Serial.println(" ");
Serial.print("Played is video with pin-number:");
Serial.print(remotePins[videoPaar][gestoertOderNicht]);
Serial.print(" ");
digitalWrite(remotePins[videoPaar][gestoertOderNicht],HIGH);
delay(500);
digitalWrite(remotePins[videoPaar][gestoertOderNicht],LOW);
}
[\code]