139741 Arduino Infrared Obstacle Avoidance Detection Photoelectric Sensor
Jump to navigation
Jump to search
Arduino Infrared Obstacle Avoidance Detection Photoelectric Sensor
Transmitter and receiver photoelectric sensor set; Voltage: DC 5V, current: 100mA, detection range: 3~80cm (adjustable); with potentiometer and output indicator light on the back
- Output current: 100mA
- Working voltage: DC 5V
- Current consumption: DC < 25mA
- Response time: < 2ms
- Sensing angle: Less than 15 degree
- Detecting range: 3~80 cm
- Working temperature: -25~55'C
- Wiring:
- red (DC 4.5~5V power high level)
- yellow (microcontroller) yellow is signal (with 10KOhm to the +)
- green (GND 0V power low level)
see also Obstacle Avoidance IR Robotic Sensor for Arduino - Yellow + Black (DC 5V)
Arduino sketch
/*
Code sample for 139741 Arduino Infrared Obstacle Avoidance Detection Photoelectric Sensor
Output current: 100mA
Working voltage: DC 5V
Current consumption: DC < 25mA
Response time: < 2ms
Sensing angle: Less than 15 degree
Detecting range: 3~80 cm
Working temperature: -25~55'C
Wiring:
red (DC 4.5~5V power high level)
yellow (Pin A0 microcontroller)
green (GND 0V power low level)
This code is in the public domain.
*/
const int analogInPin = A0; // Analog input pin that the sensor is attached to
int sensorValue = 0; // value read from the pot
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t distance = ");
Serial.println(map(sensorValue, 0, 1023, 3, 80));
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}