OpenEduBot
Posted 25/04/2026
This tutorial makes use of a 2 wheeled light following robot. This is based on the braitenberg vehicle idea, where light following behaviour can come from simple wiring. The speed of a motor is proposrtional to the intensity of the light. If the sensor on the left side is wired to the motor on the right, and sensor on the right is wired to the motor on the left, the robot will move towards light. If it is the other way round, the robot will move away from light. But can we evolve this behaviour?
The robot chassis
Build instructions can be found here. The chassis contains two light sensitive resitorys and two dc motors. For a controller it makes use of a Raspberry Pi Pico. The library supports a few different boards (in order) the robotics board, motor driver and cytron board. In the library we refer to the boiard type (in order) as blank or "default", "pico", "pico_1".
Hardware bugs to watch out for:
- Firstly check the wires are going to the right pins. A common mistake is trying to read from a sensor and it is not in the right pin.
- If a component is very hot, its likely that there is a wring problem, make sure negative and positive are in the right place, and they have not crossed. (Screw mounting points can do this)
- If no power is found in the motors or sensors, its likely the switch on the motor driver is not switched on, or the batteries are empty.
- If the robot is slower or performing worse than before, it means i is low on power. Keep it powered up for best results!
- Make sure to keep the screws tight. This requires readjusting every so often.
The Library
Flashing CircuitPython
We have support for both MicroPython and CircuitPython. This tutorial will be focused on the CircuitPython approach because it contains a variant of numpy. Numpy is useful if we want to recreate networks on the device. Make sure the raspberry pi pico has circuitpython. You can check by connecting the robot via USB to your computer, opening Thonny IDE and seeing what is running on the device. If it gives you the option to install, it means there is no firmware on yet. If it says micropython, you will need to reflash it. If it has circuitpython already, then you are good to go! Flashing the device is quite simple, you disconnect the USB and power, hold down the boot select button on the Pico, and then reconnect to the computer while keeping the button surpressed. Drag and drop the latest circuitpython uf2 file from here onto the device. There are plent of online tutorials on how to do this if you get stuck. Make sure the uf2 is for the right controller. The pico and pico wireless use different uf2. Also the cytron board requires its own as well.The final thing is to make sure you have the right libraries on device. Download the Adafruit library bundle for the device you need. Copy and paste the files/folders from the library bundle download into the /lib directory of the Pico. Only copy the libraries you need. - simpleio - adafruit_motor If you get no module found errors, just look for it in the downloaded folder and copy it over. You will also need to upload the openEduBot Library found here.
Coding
The library is called using the following commands. If you are using the other boards you will need to change the parameter boardtype.
from EduBot_CP import wheelBot
bot = wheelBot()
from EduBot_CP import wheelBot
bot = wheelBot(board_type="pico")
from EduBot_CP import wheelBot
bot = wheelBot(board_type="pico_1")
To get code to run on boot, we must save it as code.py in the main directory of the Pico. This will always run on start up, whether or not the device is connected to a computer or not. As long as it has power.
Moving the robot is quire simple, we select the motor, a direction and a speed. The code below turns one of the motors for full speed for 5 seconds, then reverses the direction of rotation for another 5. It then rotates the other motor in the same way and finally stops moving.
speed_1=100 #100% speed
bot.motorOn(4, "r", speed_1)
time.sleep(5)
bot.motorOn(4, "f", speed_1)
time.sleep(5)
#other motor
bot.motorOn(3, "r", speed_1)
time.sleep(5)
bot.motorOn(3, "f", speed_1)
time.sleep(5)
bot.stop() #stop moving
So moving is fairly simple, lets connect to the light sensors now. We can test that the sensors are working by covering them with our hands and seeing the values printed change. Also using your phone torch. If there is no change then its likely the wiring is wrong. Try GP27 to replace whichever sensor is failing.
from analogio import AnalogIn
sensor_gain=0.5
def get_intensity(pint):
return (pin.value*3.3) /65536
s1 = AnalogIn(board.GP28)
s2 = AnalogIn(board.GP26)
while True:
print(get_intensity(s1),get_intensity(s2))
