Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
task arduino
Published

How to Drive DC Motor with Arduino

This diagram will show you how to drive a DC motor using an Arduino. Normally, an Arduino digital pin can only provide 5V 20mA current.

BeginnerFull instructions provided1 hour18,103
How to Drive DC Motor with Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Flux, Soldering
Solder Flux, Soldering
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

wiring diagram

Code

ARDUINO CODE

C Header File
//Arduino DC motor controlling

#define motor_pin 3

void setup() { //setup function
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Arduino Motor controller");

  pinMode(motor_pin, OUTPUT);
}

void loop() { //loop function
  // put your main code here, to run repeatedly:
  Serial.println("Motor ON");
  digitalWrite(motor_pin, HIGH); //turn ON motor

  delay(1000); //wait 1second

  Serial.println("Motor 0FF");
  digitalWrite(motor_pin, LOW); //turn OFF motor

  delay(1000); //wait 1second
}

Credits

task arduino

task arduino

3 projects • 1 follower

Comments