Example Code for Arduino-Motor Control
Last revision 2026/01/24
This guide offers comprehensive instructions on controlling motors with Arduino, covering hardware setup, software requirements, and providing example code for managing motor direction and speed.
Hardware Preparation
- Romeo for Intel® Edison Controller(SKU: DFR0350) ×1
- Intel® Edison Module(SKU: DFR0335) ×1
- Micro Metal Gear Motor(SKU: FIT0302) x1
- micro USB ×1
Software Preparation
- Download Arduino IDE: Click to download Arduino IDE.
- Download DFRobot_Edison library V1.1.
- We made a lot of update for "Romeo for Edison main board", to manage them easily we have moved it on github.
NG.ino is ATmega8 firmware; DFRobotEdison is Romeo motor and analog driver library.- The product manufactured after Sep. 2015 have burned the newest firmware. Please use the corresponding library to avoid bugs.For the older product, you could update ATmega8 firmware to use the newest library.
- New Romeo for Edison library
- Old Romeo for Edison library- Leave the downloaded library file under Arduino library folder: e.g. arduino-1.6.3\libraries Directory.
Wiring Diagram

Other Preparation Work
- Download and install the DFRobot_Edison library V1.1.
- Open Arduino IDE, select Tools --> Board --> Intel Edison and Tools --> Serial Port --> COM xx.
Sample Code
Init M1 motor, cycle control its start/stop, direction and speed.
#include <DFRobot.h>
#include <IIC1.h>
DFrobotEdison Motor;
void setup() {
Motor.begin(M1); /*Initializes the motor drive*/
}
void loop() {
Motor.move(); /*Start Motor*/
delay(3000);
Motor.setDirection(CLOCKWISE); /*Motor clockwise rotation*/
Motor.setSpeed(100); /*Motor speed*/
delay(3000);
Motor.setDirection(ANTICLOCKWISE); /*Motor anticlockwise rotation*/
Motor.setSpeed(200); /*Motor speed*/
delay(3000);
Motor.stop(); /*Stop*/
delay(3000);
}
Result
The motor starts running, then rotates clockwise at speed 100, then anticlockwise at speed 200, and finally stops. The cycle repeats every 12 seconds.
Was this article helpful?
