Your shopping cart is empty!
Mobile Robot using TinyUSB
- Khor Jia Yong
- 29 Dec 2023
- Project
- Intermediate
- 694
Introduction
In contrast to traditional remote control cars that rely on a controller for radio-frequency signal transmission, this project allows mobile robots, or "mobile robots," to function through a USB connection using TinyUSB. More specifically, the control of your mobile robot is achieved by employing a wireless joystick in this particular project.
Note: This project serves as a continuation of the "HID Recogniser using TinyUSB" project.
Hardware Components
- Maker Pi RP2040
- USB Connector A Type Female
- Wireless USB joystick
- Dual Axis TT Gear Motor with wheel kit
Software Requirement
Project Development
Hardware setup
1. Set up the circuit as shown in the figure by connecting two DC motors with a wheel kit to the existing Maker Pi RP2040.
2. The instructions for connecting DC motors to the Maker Pi RP2040 are outlined below.
DC motor | Maker Pi RP2040 |
Red wire (+) | M1B |
Black wire (-) | M1A |
|
Software setup
1. On your Arduino IDE, follow the steps: Examples > Adafruit TinyUSB Library > DualRole > HID > hid_device_report.
2. Edit the given source code.
i. The figure shows datasets from the joystick. Count the number of datasets based on the illustration.
ii. Adjust the array size of the variable "uint8_t button_pressed[]" to match the number of datasets. For instance, if there are 27 datasets, change the array size to 26.
iii. Press the joystick button to collect data
iv. Observe the serial monitor for changes, specifically noting the 5th row as it corresponds to the triggered button.
v. Record the changing data and incorporate it into the condition statement along with the desired motor actions in the "void loop()" function for the core 0.
3. Upload the sketch to the board and observe the output by controlling the joystick.
Source Code
This is the sample code of the "Mobile Robot using TinyUSB" project.