Acrome-SMD Docs
All Acrome ProductsReferencesBlogCase StudiesContact Us
  • ACROME SMD
  • Electronics
    • 🔴SMD Red
      • Coding Guide
      • Robot with Raspberry Pi Setup Guide
      • Robot with Arduino Setup Guide
      • Troubleshooting Guide
    • 🔵SMD Blue
    • 🟢SMD Green
    • Gateway Modules
      • Arduino Gateway Module
      • USB Gateway Module
    • Electrical Motors
      • Brushed DC Motors (BDC)
      • Stepper DC Motors (SDC)
      • Brushless DC Motor (BLDC)
      • Linear Actuator with Feedback
    • Add-on Modules
      • Ambient Light Sensor Module
      • Button Module
      • Buzzer Module
      • IMU Module
      • Joystick Module
      • Potentiometer Module
      • Reflectance Sensor Module
      • RGB LED Module
      • Servo Module
      • Ultrasonic Distance Sensor Module
  • SMD Kits
    • Starter Kit
      • What You Can Build
    • Education Kit
      • What You Can Build
    • Motion Kit
      • What You Can Build
  • Software
    • Libraries
      • Python Library
      • Arduino Library
      • Java Library
      • Matlab Library
    • SMD UI
    • SMD Blockly
      • Introducing Customized Blockly Blocks
  • SMD Applications
    • Basics
      • Blink
      • Action - Reaction
      • Autonomous Lighting
      • Smart Doorbell
      • Security System
      • Distance Buzzer Warning
      • Distance Auto Stop
      • Smart Light Control
    • Interactive
      • Automatic Trash Bin
      • Radar
      • Chrome Dino Game Player
      • Play Chrome Dino Game With Joystick
      • Snake Game With Joystick
      • Pan-Tilt with Joystick Module
      • Joystick Mouse Control
      • Rev Up the Engine
      • Motor Rotation Based on Turn Input Value
      • Basic Motor Speed Control Application
      • Basic Motor Control Application Using PWM Input
      • Basic Motor Position Control Application
      • Basic Motor Torque Control Application
      • Motor Rotation Based on Joystick Counting
    • Robotics
      • Differential Robot Projects
      • Mouse Cursor Tracker Motion Robot
      • Waypoint tracker robot
      • Braitenberg Robot
      • Line-Follower Robot
      • Teleoperation Robot
      • Obstacle Avoidance Robot
      • ESP32 Wireless Controlled Mobile Robot
  • AI
    • Object Tracking Robot
    • Groq Chatbot-Controlled Robot
  • ROS
    • Teleoperation Robot with ROS
  • Mechanics
    • Building Set
      • Plates
        • 2x2 Plate Package
        • 2x3 120° Plate Package
        • 3x3 Plate Package
        • 3x5 Plate Package
        • 3x9 Plate Package
        • 11x19 Plate
        • 9x19 Plate
        • 5x19 Plate
        • 3x19 Plate
        • 9x11 Plate
        • 5x13 Plate
      • Joints
        • 60° Joint Package
        • 90° Joint Package
        • 120° Joint Package
        • Slot Joint M2 Package
        • Slot Joint M3 Package
        • U Joint Package
      • Mounts
        • Add-on Mount Package
        • Motor L Mount Package
        • Pan-Tilt Package
      • Wheels
        • Ball Wheel Package
        • Caster Wheel Package
        • Wheel Package
      • Cables
        • Power Cable 10 cm Package
        • Power Cable 20 cm Package
        • Power Cable 35 cm Package
        • RJ-11 Cable 7.5 cm Package
        • RJ-11 Cable 20 cm Package
        • RJ-11 Cable 35 cm Package
        • RJ-45 Cable 7.5 cm Package
        • RJ-45 Cable 20 cm Package
        • RJ-45 Cable 35 cm Package
      • Fasteners
        • M2x5 Allen Hex Screw Package
        • M3x6 Allen Hex Screw Package
        • M3x8 Allen Hex Screw Package
        • M3 Hex Nut Package
  • Help
    • Manual
    • Shops
    • Reach Us
Powered by GitBook
On this page
  • What is SMD Red?
  • Important: Understanding IDs
  • Part 1: Coding with Python (Using VS Code)
  • Part 2: Coding with Arduino IDE
  • Tips for Beginners
  • Troubleshooting Tips (SMD Red Troubleshooting Guide)
  1. Electronics
  2. SMD Red

Coding Guide

PreviousSMD RedNextRobot with Raspberry Pi Setup Guide

Last updated 21 hours ago

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 . 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

Step 2: Install Python Packages

Open VS Code, then open a new terminal ("Terminal" → "New Terminal"). Run this command:

pıp3 install acrome-smd
pip3 install pyserial flask flask-cors acrome-smd

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:

# Import necessary libraries from SMD Red
from smd_red import Master

# Establish connection to SMD Red controller via USB
master = Master("/dev/ttyUSB0")

# Motor Control Example:
# Set motor speed (50 means half speed forward, -50 means half speed backward)
master.set_motor(0, 50)  # Controls motor connected to SMD Red ID 0

# Wait for 2 seconds, motors keep moving
import time
time.sleep(2)

# Stop motor
master.set_motor(0, 0)

# Servo Control Example:
# Move servo motor to specific angle (90 degrees)
master.set_servo(0, 4, 90)  # Servo module ID 4 on SMD Red ID 0

# Sensor Reading Example:
# Read data from sensor connected with module ID 5
sensor_data = master.get_sensor_data(0, 5)
print("Sensor data:", sensor_data)

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

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:

// Include Acrome SMD Red library
#include <Acrome-SMD.h>
#define BAUDRATE 115200

// Initialize communication with SMD Red board ID 0
Red smd(0, Serial, BAUDRATE);

void setup() {
  // Start serial communication at the defined baud rate
  Serial.begin(BAUDRATE);

  // Start communication with SMD Red
  smd.begin();

  // Set operation mode for controlling motor speed (PWM mode)
  smd.setOperationMode(PWMControl);

  // Enable motor torque (power)
  smd.torqueEnable(1);
}

void loop() {
  // Move motor forward at half speed
  smd.setpoint(0, 50);
  delay(2000);  // Wait for 2 seconds

  // Stop the motor
  smd.setpoint(0, 0);
  delay(2000);

  // Servo example: Move servo (module ID 4) to 90 degrees
  smd.setServo(0, 4, 90);
  delay(1000);

  // Read data from a sensor (module ID 5)
  int sensor_value = smd.getSensorData(0, 5);
  Serial.print("Sensor data: ");
  Serial.println(sensor_value);
  delay(1000);
}

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

  • Test each module separately before combining them.

  • Regularly test your code and debug using Serial Monitor or Python print statements.


  • Double-check connections (USB, RJ11, RJ45).

  • If errors occur, revisit installation and wiring steps.

Python: Download from . Choose the latest version and install it.

Visual Studio Code (VS Code): Download from . This will be your coding editor.

Download Arduino IDE from , install and open it.

Clearly verify and set unique SMD Red IDs using the app.

Troubleshooting Tips ()

Verify module and SMD Red IDs using the app.

🔴
SMD UI
python.org
code.visualstudio.com
arduino.cc
SMD UI
SMD Red Troubleshooting Guide
SMD UI