Motor Control Module
This module allows you to control actuators such as DC motors and servo motors.
To control a DC motor, select either Motor 1 or Motor 2. You can vary its speed using the slider and change the direction of rotation by selecting the respective button.
To control a servo, select either Servo 1 or Servo 2. You can vary the servo angle by sliding the yellow bar in the clockwise direction.
The Motor Control module allows you to control actuators such as DC motors and servo motors.
You can control 2 DC Motors and 2 Servo Motors using this module.
DC Motor Control
Using the DC Motor control you can control the direction in which the motor should rotate (clockwise or anti-clockwise) and the speed of rotation (adjustable from 0 to 100).
For evive, you can control the motors connected to motor channel 1 and motor channel 2.
For controlling motors using Arduino Uno or Mega, you have to use a motor driver having controls through these pins:
- Direction Pin 1 – Digital Pin
- Direction Pin 2 – Digital Pin
- PWM Pin – PWM Pin
You have to assign those pins in the Arduino Program to control the motor through this module. The example is given in the Arduino tab below.
Servo Motor Control
Using the Servo Motor control you can control the direction of the servo from 0 degrees to 180 degrees by changing the yellow bar in the clockwise direction.
For evive, you can control the servo motors attached to the servo motor channel 1 and 2.
For controlling servo motors using Arduino Uno or Mega, you have to use a PWM pin connected to the signal pin of the servo motor.
- PWM pins in Arduino Uno are digital pin 3,5,6,9,10 and 11.
- PWM pins in Arduino Mega are digital pin 2 to 13, 44 and 45.
You have to assign those pins in the Arduino Program to control the servo motor through this module. The example is given in the Arduino tab below.
Enable Motor Control Block
To enable the Motor Control feature, you have to upload the following script.
As you can see, there is a stack block named as “ enable motor control” and its function is to enable the Motor Control feature of Dabble.
To include the LED Control module in the Arduino program, you have to include the following header:
After defining the above mention headers, you have to include the dabble library:
You can download the library from here:
Enabling Bluetooth Communication
To enable Bluetooth communication, you have to initialize serial communication using the following code:
Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.
Refreshing the data
To refresh the data that the device has got from the mobile app, you have to use the following line of code:
The following functions can be used to get the DC motor and servo motor control:
- Control.getpwm_Motor1(): This function gets the PWM value of Motor 1 from the app. It returns value from -255 to 255, which is divided into 3 parts:
- -255 to -1 means that the motor should rotate counterclockwise with the PWM speed of the absolute value got from the app.
- 0 means that the motor should be OFF.
- 1 to 255 means that the motor should rotate clockwise with the PWM speed got from the app.
- Control.getpwm_Motor2(): This function gets the PWM value of Motor 2 from the app.
- Control.getangle_Servo1(): This function returns the servo angle value of servo motor 1. The value can be between 0 to 180.
- Control.getangle_Servo2(): This function returns the servo angle value of servo motor 2. The value can be between 0 to 180.
The first example shown below is all motors control. In this program, we are controlling both DC motor and servo motor.