Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
hIOTron
Created February 16, 2021

Arduino DC Motor Speed & Direction Control using Relays

We outlined how we can control the direction and speed of a 24v high current motor utilizing Arduino and two relays.

Arduino DC Motor Speed & Direction Control using Relays

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
5v relay
×1
BC547
×2
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×2
IRF540N
×1
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×3
Resistor 10k ohm
Resistor 10k ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Run a program

Arduino
int x;
int y;
void setup() 
{
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(A0,INPUT);
}

void loop()
 {
  x=analogRead(A0);
  y=map(x,0,1023,0,255);
  analogWrite(6,y);
  digitalWrite(2,HIGH);
  digitalWrite(3,HIGH);
}

Credits

hIOTron
78 projects • 2 followers
hIOTron is an internet of things based company that offers an IoT Platform, products, IoT Solutions, and IoT Training.

Comments