Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The ITR1502SR40A is an infrared reflective sensor. It can be used as a line sensor in many applications, including line-following robots.
- This script will continuously read the analog value from the sensor and print it to the Serial Monitor. A low value indicates a reflection (line detected), while a high value indicates no reflection (no line).
- Adjust the sensorPin variable to match the actual Arduino pin the sensor is connected to. Connect the sensor's VCC to Arduino 5V, GND to Arduino GND, and OUT to the specified Arduino analog pin.
- Remember that the sensor readings may need to be calibrated or thresholded to work best in your particular environment.
- Here's an example of using this sensor with an Arduino:
- */
- const int sensorPin = A0; // Sensor connected to analog pin A0
- void setup() {
- Serial.begin(9600); // Set up serial communication at 9600 bps
- }
- void loop() {
- int sensorValue = analogRead(sensorPin); // Read the sensor
- Serial.println(sensorValue); // Print the sensor value to the serial monitor
- delay(100); // Short delay before next read
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement