Acrome-SMD Docs
All Acrome ProductsReferencesBlogCase StudiesContact Us
  • ACROME SMD
  • Electronics
    • 🔴SMD Red
      • 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 – 75 lbs
    • 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
      • Basic Brushed DC motor Applications
    • Education Kit
    • Motion Kit
      • Differential Robot Projects
  • 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
      • Mouse Cursor Tracker Motion Robot
      • Waypoint tracker robot
      • Braitenberg Robot
      • Line-Follower Robot
      • Object Tracking Robot
      • Teleoperation Robot
      • Obstacle Avoidance Robot
      • ESP32 Wireless Controlled Mobile Robot
  • AI
    • Groq Chatbot-Controlled Robot
  • 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
  • Installation
  • Verification of Installation
  • Basic Use of Arduino Library
  1. Software
  2. Libraries

Arduino Library

PreviousPython LibraryNextJava Library

Last updated 8 months ago

SMD Arduino library is designed to improve the mobility of your system by enabling the operation of SMD with Arduino. The library simplifies the process of programming various projects and gives lots of ways to control motors in your system. It also works seamlessly with all SMD modules, which gives more imagination for countless projects.

The Arduino library can be used directly with Arduino IDE. It is user friendly as well as Arduino, familiarity and ease of programming an Arduino project with your Arduino and precise motor control availability is indispensable for makers.

Installation

To use with Arduino library, follow the installation steps below.

Prerequisities

Before you begin, make sure you have the following prerequisities:

  • Latest (click to download)

  • Any programmable Arduino board

Once you have met the prerequisites, you can follow the steps.

  1. Open Arduino IDE

  2. In the Arduino IDE, go to Sketch -> Include Library -> Manage Libraries... or simply click the book stack icon on the left, and search for Acrome-SMD in the search bar.

  3. Click "Install".

Verification of Installation

To verify that Arduino library successfully installed, open Arduino IDE and open a new sketch. Type this code line into your first line of sketch as shown in the image below, then click "Verify" button on the top left.

#include <Acrome-SMD.h>

Basic Use of Arduino Library

Since SMD cards can be connected to each other, each of them can have a different ID by user's choice. However, an SMD Red has an ID of 0 by default. This value can be intentionally changed between 0 - 255 .

SMD can communicate with different baud rates, user may want to change baud rate depending on the needs of the project. SMD Red has a default baud rate of 115200.

With all this information, the crucial part of coding can begin.

Here is the first part of the code:

#include <Acrome-SMD.h>

#define ID        0        // ID of the SMD board
#define BAUDRATE  115200   // Baud rate of the communication


Red master(ID, Serial, BAUDRATE);    // Defines the Arduino gateway module

void setup() {

}

void loop() {

}

This code snippet acts as a communication setup for SMD.

We defined baud rate as 115200 and ID as 0 (default SMD ID, if it wasn't changed), and used Red class to create an object named master, object name depends on user. Then, we used necessary parameters of Red class, which are ID, Serial (communication with Arduino), and baud rate.

We start with the communication setup, and then add the necessary motor control functions, which will be explained below.

#include <Acrome-SMD.h>

#define ID        0        // ID of the SMD board
#define BAUDRATE  115200   // Baud rate of the communication

Red master(ID, Serial, BAUDRATE);    // Defines the Arduino gateway module

void setup() {
    master.begin();    // Starts the communication
    
    master.setMotorRPM(100);      // Defines the motor RPM value as 100
    master.setMotorCPR(6533);     // Defines the motor CPR value as 6533
    master.setOperationMode(VelocityControl);    // Sets the motor's operation mode as "Velocity"
    master.torqueEnable(1);       // Enables motor to operate
    
    master.tune();    // Starts the PID auto-tune process
    delay(30000);     // Waits 30 seconds for the process to complete
}

void loop() {
    
}

There are various operation modes for motor control, for example, we have selected "Velocity" control mode, which allows the motor to be controlled in terms of RPM value.

To run the PID auto-tune process, we use the tune() function with the object name of the target SMD. After running the function, the motor will start spinning and the process will take about 30 seconds. That's why we put the delay(30000) in order to wait for any other processes before the end of the process.

For more use cases, visit the projects and see the Arduino codes:

First of all, the Arduino and SMD connections should be made. Connect your Arduino to the PC and place the on your Arduino board as the front two pins of the module should meet with the RX-TX pins and analog pins of module should sit on the analog pin slots. Then, connect SMD to the Arduino gateway module with an RJ-11 cable. Finally, connect a 12V adapter to supply power to the SMD.

Then we can do our first application , PID auto-tune and velocity control, to practice with our library. In addition to the Arduino board, you will need an SMD, Arduino gateway module, and a brushed DC motor, which are included in the .

Then, we specified the RPM and CPR value of motor, in order to be tuned properly. Brushed DC motor in has 100 RPM and 6533 CPR value.

For all detailed function and feature explanations of Arduino library, visit the .

Arduino gateway module
Starter Kit
Starter Kit
Arduino library GitHub page
Acrome Smart Motion Devices
Arduino IDE
Arduino SMD Library
Arduino Library Verification