Untitled
Anonymous
c_cpp
04/28/2022 3:08 AM
696 B
21
Indexable
int irDetect(int irLedPin, int irReceiverPin) {
// set LED to 64 which is 25% brightness on a scale of 0-255
analogWrite(irLedPin, 64);
// However much time it needs for the LED to light
// up and the IR receiver to receive
delay(8);
// Read the state of the IR sensor
int ir = digitalRead(irReceiverPin);
// turn LED back off
analogWrite(IR_LED_PIN, 0);
// Down time before recheck
delay(1);
return ir; // Return 1 no detect, 0 detect
}Editor is loading...