Coding Guide
This detailed guide teaches you exactly how to write your first code for SMD Red from scratch, suitable for beginners with no coding experience. You'll learn step-by-step, clearly and thoroughly, how to program motors and modules.
What is SMD Red?
SMD Red is a smart controller designed to simplify controlling Brushed DC motors, servos, and various sensors. It receives commands from your computer (Raspberry Pi using Python) or microcontroller (Arduino using Arduino IDE) and translates these commands into actions performed by your robot.
Important: Understanding IDs
SMD Red ID: Every SMD Red controller has a unique ID number. Initially, these IDs might be the same, but you must assign unique IDs when using multiple controllers in one project.
Module ID: Every connected sensor, servo, or other module has a predefined ID, which is generally fixed but can be physically rearranged.
Motor ID: Motors do not have individual IDs. Instead, they use the ID of the SMD Red controller they're attached to.
To manage and test your SMD Red boards and modules, It is recommended to use the SMD UI. This software allows you to:
Verify the IDs of connected modules and controllers
Change SMD Red IDs to unique values for project usage
Test functionality of motors and modules
Part 1: Coding with Python (Using VS Code)
Step 1: Install Required Tools
Python: Download from python.org. Choose the latest version and install it.
Visual Studio Code (VS Code): Download from code.visualstudio.com. This will be your coding editor.
Step 2: Install Python Packages
Open VS Code, then open a new terminal ("Terminal" → "New Terminal"). Run this command:
Step 3: Writing Your First Python Program (Detailed Explanation)
Open VS Code, create a file called robot_control.py
. Below is a simple and detailed starter program:
Explanation of Code:
Master connection: Links your computer to the SMD Red controller.
Motor commands: Uses the ID of SMD Red to send commands directly to connected motors.
Servo commands: Require specifying the SMD Red ID and servo module ID.
Sensor commands: Require specifying the SMD Red ID and sensor module ID to get sensor data.
Part 2: Coding with Arduino IDE
Step 1: Install Arduino IDE
Download Arduino IDE from arduino.cc, install and open it.
Step 2: Install SMD Red Arduino Library
In Arduino IDE, navigate to
Sketch → Include Library → Manage Libraries
Search for "Acrome-SMD", then install it.
Step 3: Wiring Arduino and SMD Red
Connect Arduino to SMD Red using an Arduino Gateway module (RX/TX pins).
Connect SMD Red boards via RJ11 cables and modules via RJ45 cables.
Step 4: Detailed Arduino Programming Example
Open Arduino IDE and create a new sketch:
Explanation of Arduino Code:
Library Import: Adds the necessary commands to control SMD Red.
Setup: Initializes communication, sets operation modes, and enables power to motors.
Loop: Repeatedly executes motor movement, servo positioning, and sensor data reading.
Tips for Beginners
Clearly verify and set unique SMD Red IDs using the SMD UI app.
Test each module separately before combining them.
Regularly test your code and debug using Serial Monitor or Python print statements.
Troubleshooting Tips (SMD Red Troubleshooting Guide)
Double-check connections (USB, RJ11, RJ45).
Verify module and SMD Red IDs using the SMD UI app.
If errors occur, revisit installation and wiring steps.
Last updated