Welcome to the PiCAN project! This repository showcases the capabilities of the RP2040 microchip in combination with CAN bus technology.
PiCAN demonstrates how to use the Raspberry Pi Pico with CAN bus communication to transfer data between devices. The project is divided into two main branches:
main
: A simple CAN bus message transfer example.add-joystick-servo-controls
: An advanced example where a joystick controls a servo via CAN bus.
The main
branch contains a straightforward example of CAN bus message transfer. In this example:
- One Raspberry Pi Pico receives input through the Serial Monitor.
- This input is then transmitted over the CAN bus.
- Another Raspberry Pi Pico receives the CAN bus message and outputs it through its Serial Monitor.
The add-joystick-servo-controls
branch extends the functionality by allowing a servo to be controlled with a joystick. The setup is as follows:
- A Raspberry Pi Pico with a joystick attached sends the joystick values over the CAN bus.
- Another Raspberry Pi Pico with a servo attached receives the joystick values.
- The receiving Pico sets the angle of the servo based on the joystick input.
- Raspberry Pi Pico
- CAN Bus Transceiver Module
- KY-023 Joystick Module
- SG90 Micro Servo Motor
- Wiring materials and a breadboard
Special thanks to the authors of these libraries.
- can2040 (Software CAN bus implementation)
- Pico-Servo (Pico C/C++ Servo Library)
-
Clone the repository:
git clone https://github.com/moeux/PiCAN.git cd PiCAN
-
Switch to the desired branch:
For the basic CAN bus message transfer:
git checkout main
For the joystick to servo control example:
git checkout add-joystick-servo-controls
-
Upload the code to your Raspberry Pi Pico boards:
Use your preferred method to upload the code to the Raspberry Pi Pico boards.
I recommend flashing the code onto the Raspberry Pi Pico using the Raspberry Pi Pico VSCode Extension.
For further setup instructions refer to the Getting Started Guide by Raspberry Pi.
Enjoy exploring the possibilities of RP2040 and CAN bus technology with PiCAN!