Python5 tutorials

Sensors & Modules with Python

Read and process sensor data in Python — distance, line, light, and analog inputs.

Distance Sensor in Python

IntermediatePython

Read the onboard time-of-flight distance sensor with `pybot.distance()`, display the live reading on the OLED, and apply a threshold to trigger a LED and buzzer alert.

DistanceToFSensorOLEDIntermediate

Line Sensor in Python

IntermediatePython

Read the left and right TCRT5000 line sensors using `pybot.line_left()` and `pybot.line_right()`. Combine boolean readings to detect where a dark line is relative to the robot.

Line SensorTCRT5000BooleanSensorIntermediate

Light Sensor in Python

IntermediatePython

Read the PT19 phototransistor with `pybot.light()` and map the 0–100 value to LED brightness. Watch the LEDs respond in real time as the room lighting changes.

Light SensorPT19ADCMappingLEDIntermediate

Sensor Thresholds and Alerts

AdvancedPython

Combine multiple sensors in one program. Read distance and light level, apply compound conditions, and trigger different buzzer alerts depending on which threshold is crossed. The full data → decision → action pattern.

DistanceLight SensorMulti-sensorThresholdsBuzzerAdvanced

Temperature & Humidity in Python

IntermediatePython

Read the SHT40 sensor with `pybot.temperature()` and `pybot.humidity()` and display both values live on the OLED. Then add a heat alert that lights the RED LED whenever the temperature crosses a threshold.

SHT40TemperatureHumiditySensorOLEDIntermediate