Arduino and Reflective Sensor KTIR0711S

A short guide showing how to connect Arduino and the bounce sensor.

The following elements are used in the example:

Connecting the sensor from Arduino:

To operate the sensor with Arduino, connect the circuit as follows:

Sensor Pin Arduino
GND GND
OUT A1
VCC 5 V

Wiring diagram of the sensor from Arduino Uno.

Program for Arduino

The following code was used in the example:

  1. int sensor = A1; //pin analogue A1 connected to sensor signal
  2.  
  3. void setup(){
  4. Serial.begin(9600); //initialisation of a serial monitor
  5. Serial.println("Reflective sensor test");
  6. }
  7.  
  8. void loop(){
  9. int odl = analogueRead (sensor); //reading value from sensor
  10. Serial.println(odl); // display it on the monitor
  11.  
  12. delay(200); // delay between readings
  13. }

The values read on the serial monitor decrease as you approach an obstacle. The effects of the program can be observed on the screen below:

A screenshot of the serial monitor.

Botland.store - shop for makers!