This project is a Raspberry Pi-controlled buggy robot powered by the gpiozero library. The robot can move in all directionsโforward, backward, left, and rightโwith adjustable speed. It is controlled via a keyboard interface using the curses module for smooth operation.
- Movement Control: Forward, backward, left, and right
- Adjustable Speed: Low, Medium, High ๐
- Status Logging: Logs robot status in
status.txt๐ - Graceful Shutdown: Shutdown Raspberry Pi safely ๐ด
- Raspberry Pi (Tested on Pi 5) ๐ฅ๏ธ
- L298N Motor Driver ๐
- 2 DC Motors โ๏ธ
- Power Source: 12V battery recommended ๐
- Male-to-female jumper wires ๐
| Motor Driver Pin | Raspberry Pi GPIO |
|---|---|
| IN1 | GPIO 22 (Pin 15) |
| IN2 | GPIO 17 (Pin 11) |
| IN3 | GPIO 23 (Pin 16) |
| IN4 | GPIO 24 (Pin 18) |
| ENA | Connected to 3.3V or PWM control |
| ENB | Connected to 3.3V or PWM control |
-
Install Dependencies:
sudo apt update sudo apt install python3-gpiozero
-
Clone the Repository:
git clone https://github.com/Samuel-Gbadamosi/BuggyRobot-RaspBerryProject.git cd BuggyRobot -
Run the Robot Script:
python3 robot.py
| Key | Action |
|---|---|
| โ (UP Arrow) | Move Forward |
| โ (DOWN Arrow) | Move Backward |
| โ (LEFT Arrow) | Turn Left |
| โ (RIGHT Arrow) | Turn Right |
| 'l' | Set speed to Low |
| 'm' | Set speed to Medium |
| 'h' | Set speed to High |
| 'p' | Shutdown Raspberry Pi |
| 'q' | Quit the program |
The robot's current status (movement direction and speed) is logged in status.txt for future reference and debugging.
- Check wiring connections.
- Ensure the motor driver is powered properly.
- Run
gpiosetcommands to test individual GPIO states.
- Swap motor connections to confirm if the issue is wiring-related.
- Ensure both ENA and ENB are powered or controlled via PWM.
- Run
robot.pywithsudo. - Add
print(f"Key pressed: {char}")in the loop to debug key inputs.
Feel free to fork the repository and submit pull requests for improvements! Contributions are always welcome ๐.
Enjoy building and controlling your BuggyRobot! ๐..๐จ
Created by Samuel Gbadamosi


