Dear Arduinos. :o)
I'm working with friends since a few month on the following project: I want to connect my Arduino "on one side" (INPUT PIN 10) with a light barrier; the "other side" is connected to a remote control (OUT PIN 2-9) from a DVD player. You can find on the DVD we produced 8 chapters from which every second refers to the foregoing chapter (that is you have pairs of chapters: chapter 3 shows a modified version of the "clean" chapter 2; chapter 5 shows a modified version of the "clean" chapter 4 etc.). Last but not least, the remote control is used to control 4 DVD-Players of the same brand. Kind of a high striker...as soon as something crosses the light barrier.
Concerning the programming I work with a function which should control the output and an array to make clear that there's always pairs of videos and, altogether, 6 pairs).
I can't find the error in my programming. Moreover, Arduino starts to upload, but then, nothing happens.
Do you see where the problem could hide?
Big Thanks, Stephan
CODE;
int lightbarrierIN = 10;
int myState = 0;
long Timer;
long DauerNormal = 30000;
long DauerGestoert = 30000;
int numberpairs = 4;
int NowVideo;
int remotePins[][2] = {{2,3},
{4,5},
{6,7},
{8,9}};
void setup()
{
Serial.begin(9600);
for (int Info=0; i < numberpairs*2; i++) //
{
pinMode(remotePins [Info][0], OUTPUT);
pinMode(remotePins [Info][1], OUTPUT);
}
}
void loop()
{
switch(myState)
{
case 0:
NowVideo = random(0, 3);
startVideo(NowVideo, 0); //normal video starts
myState = 1;
break;
case 1:
if(millis()-DauerNormal>Timer)
{
myState = 0;
}
if(digitalRead(lightbarrierIN)==HIGH)
{
myState = 2;
}
break;
case 2:
NowVideo = random(0, 3);
startVideo(NowVideo, 1);
myState = 3; // distorted video starts
break;
case 3:
if(millis()-DauerGestoert>Timer)
{
myState = 0; // back to normal
}
break;
}
}
void startVideo(int pairs, int normalORdistorted)
{
digitalWrite(remotePins[pairs][normalORdistorted],HIGH);
delay(500);
digitalWrite(remotePins[pairs][normalORdistorted],LOW);
Timer = millis();
}
code tags added by moderator