DC Motor Interfacing With ARM MBED - MBED
DC Motor Interfacing With ARM MBED - MBED
DC Motor
DC motor converts electrical energy in the form of Direct Current into mechanical energy in the form of rotational motion of
the motor shaft.
The DC motor speed can be controlled by applying varying DC voltage; whereas the direction of rotation of motor can be
changed by reversing the direction of current through it.
For applying varying voltage, we can make use of PWM technique.
For reversing the current, we can make use of H-Bridge circuit or motor driver ICs that employ the H-Bridge technique.
For more information about DC motors and how to use them, H-Bridge circuit configurations, and PWM technique, DC
Motors refer the topic DC Motors in the sensors and modules section.
Interfacing Diagram
Example
Here, we are going to control the speed and rotational direction of DC motor using ARM MBED.
Here, the potentiometer is used as a means for speed control and an input from the tactile switch is used to change the direction of
motor.
Program
#include "mbed.h"
#include "Motor.h"
AnalogIn pot(p15);
DigitalOut LED_1(LED1);
InterruptIn button(p9);
float potpin;
int pin;
void flip()
{
pin = !pin;
LED_1 = !LED_1;
int main() {
button.rise(&flip);
while(1) {
if (pin == 1){
potpin = pot.read();
Motors.speed(-potpin);
else {
potpin = pot.read();
Motors.speed(potpin);