I have attached a very simple IR circuit that I have used with an UNO. When I hook this up to the Astar LV prime it does not work. The code I’ve used and the attachment is from parallax for Arduino.
[code]void setup() // Built-in initialization block
{
tone(4, 3000, 1000); // Play tone for 1 second
delay(1000); // Delay to finish tone
pinMode(10, INPUT); pinMode(9, OUTPUT); // Left IR LED & Receiver
Serial.begin(9600); // Set data rate to 9600 bps
}
void loop() // Main loop auto-repeats
{
int irLeft = irDetect(9, 10, 38000); // Check for object
Serial.println(irLeft); // Display 1/0 no detect/detect
delay(100); // 0.1 second delay
}
// IR Object Detection Function
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
}
][/code]
I set the circuit up on a breadboard and it works fine on the UNO but will not detect using the Astar.
I use these for detection a lot because it is easy to point them in the direction you want and I really like the Astar prime boards so I’m asking if you might know what I’m doing wrong here.