Sensors & Modules with Python
Read and process sensor data in Python — distance, line, light, and analog inputs.
Distance Sensor in Python
Read the HC-SR04 ultrasonic sensor with `pybot.distance()`, display the live reading on the OLED, and apply a threshold to trigger a LED and buzzer alert.
Line Sensor in Python
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.
Light Sensor in Python
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.
Analog Reads with ADC
Go beyond the named sensor functions and read raw ADC values from any GPIO pin. Use MicroPython's `machine.ADC` to read the trimpot on GP27 and scale the result to a 0–100 range — the same way `pybot.light()` works under the hood.
Sensor Thresholds and Alerts
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.
Temperature & Humidity in Python
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.