Arduino Library
Last updated
Last updated
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.
To use Acrome Smart Motion Devices with Arduino library, follow the installation steps below.
Before you begin, make sure you have the following prerequisities:
Latest Arduino IDE (click to download)
Any programmable Arduino board
Once you have met the prerequisites, you can follow the steps.
Open Arduino IDE
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.
Click "Install".
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.
First of all, the Arduino and SMD connections should be made. Connect your Arduino to the PC and place the Arduino gateway module 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.
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:
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.
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 Starter Kit.
We start with the communication setup, and then add the necessary motor control functions, which will be explained below.
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.
Then, we specified the RPM and CPR value of motor, in order to be tuned properly. Brushed DC motor in Starter Kit has 100 RPM and 6533 CPR 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 all detailed function and feature explanations of Arduino library, visit the Arduino library GitHub page.
For more use cases, visit the projects and see the Arduino codes: