Sensors
Using the IR sensors on NanoNav.
Introduction
To best interact with its environment, your NanoNav kit comes with infrared sensors that can be used for detecting how reflective the surface under it is.
Quick Example
from nanonav import NanoBot
import time
# Create a NanoBot object
robot = NanoBot()
while True:
# Repeatedly print the IR sensor values
print(f'left: {robot.ir_left()} right: {robot.ir_right()}')
time.sleep(0.5)
Note that this code snippet uses print which means it will only work while connected to a computer.
Calibration
Initially, and if you ever notice the IR sensors not detecting the white line correctly, you may need to calibrate the sensors. The below video (for a very similar IR sensor model) shows how to do this.
Usage
Return true if the left IR sensor detects white.
- Return type:
boolean
Return true if the right IR sensor detects white.
- Return type:
boolean