I'm sorry I have been confusing, I have just been tired and stressed trying to figure this out and only have about a day to do this. Here is the code I have been working on, no matter what I do it just tells me that there an obstacle in the way. These are my actual pins. I'll pot more info if I can later.
void setup() // Built-in initialization block
{
pinMode(3, INPUT);
pinMode(5, INPUT);
pinMode(11, INPUT);
pinMode(13, OUTPUT);
}
void loop() // Main loop auto-repeats
{
int irLeft = irDetect(13, 3, 38000); // Check for object on left
int irRight = irDetect(13, 5, 38000); // Check for object on right
if((irLeft == 0) && (irRight == 0)) // If both sides detect
{
Serial.println("Stop something is ahead!!");
}
else // Otherwise, no IR detected
{
Serial.println("Clear!!");
}
delay(100);
}
int irDetect(int irLedPin, int irReceiverPin, long frequency)
{
tone(irLedPin, frequency, 8); // IRLED 38 kHz for at least 1 ms
delay(1); // Wait 1 ms
int ir = digitalRead(irReceiverPin); // IR receiver -> ir variable
delay(1); // Down time before recheck
return ir; // Return 1 no detect, 0 detect
}