To save others the hassle of downloading.
int anIn[] = {A0, A1, A2, A3, A4}; // an array of 5 inputs for the 5 sensors
int In[5];
int Out[] = {8, 9, 10}; // an array of 3 outputs: 1st(8) > turn right , 2nd(9) > turn left , 3rd(10) > forward
int timer = 800;
void setup()
{
// set the anIn array as INPUT
for (int i=0; i < 5; i++) {
pinMode(anIn[i], INPUT);
}
// set the Out array as OUTPUT
for (int i=0; i < 3; i++) {
pinMode(Out[i], OUTPUT);
}
}
void loop()
{
for (int i=0; i < 5; i++) {
analogRead(anIn[i]);
}
for (int i=0; i < 5; i++) {
if (anIn[i] < 512)
{
In[i] = LOW;
}
else
{
In[i] = HIGH;
}
}
if (In[5] == (LOW, LOW, LOW, LOW, LOW))
{
digitalWrite (Out[3], (LOW, LOW, LOW));
}
else if (In[5] == (LOW, LOW, LOW, HIGH, LOW) ||
In[5] == (LOW, LOW, LOW, LOW, HIGH) ||
In[5] == (LOW, LOW, LOW, HIGH, HIGH) ||
In[5] == (LOW, LOW, HIGH, HIGH, LOW) ||
In[5] == (LOW, LOW, HIGH, LOW, HIGH) ||
In[5] == (LOW, HIGH, LOW, LOW, HIGH) ||
In[5] == (LOW, LOW, HIGH, HIGH, HIGH) ||
In[5] == (LOW, HIGH, LOW, HIGH, HIGH) ||
In[5] == (HIGH, LOW, LOW, HIGH, HIGH) ||
In[5] == (HIGH, LOW, HIGH, HIGH, LOW) ||
In[5] == (LOW, HIGH, HIGH, HIGH, HIGH) ||
In[5] == (HIGH, LOW, HIGH, HIGH, HIGH))
{
digitalWrite (Out[3], (HIGH, LOW, HIGH));
}
else if (In[5] == (HIGH, LOW, LOW, LOW, LOW) ||
In[5] == (LOW, HIGH, LOW, LOW, LOW)||
In[5] == (HIGH, HIGH, LOW, LOW, LOW) ||
In[5] == (LOW, HIGH, HIGH, LOW, LOW) ||
In[5] == (HIGH, LOW, HIGH, LOW, LOW) ||
In[5] == (HIGH, LOW, LOW, HIGH, LOW) ||
In[5] == (HIGH, HIGH, HIGH, LOW, LOW) ||
In[5] == (HIGH, HIGH, LOW, HIGH, LOW) ||
In[5] == (HIGH, HIGH, LOW, LOW, HIGH) ||
In[5] == (LOW, HIGH, HIGH, LOW, HIGH) ||
In[5] == (HIGH, HIGH, HIGH, HIGH, LOW) ||
In[5] == (HIGH, HIGH, HIGH, LOW, HIGH))
{
digitalWrite (Out[3], (LOW, HIGH, HIGH));
}
else
{
digitalWrite (Out[3], (LOW, LOW, HIGH));
}
delay(timer);
}
if (In[5] == (LOW, LOW, LOW, LOW, LOW))
A five element array has no index 5.
Anyway, you can't compare entire arrays like that, or assign to them like this digitalWrite (Out[3], (LOW, LOW, HIGH));
.