CODE | Simple Motor Control - Arduino Project 015

RonWang2 years ago (2023-09-18)电子编程 COD13

First, you’re going to simply control the speed of a DC motor in one direction, using a power transistor, diode, external power supply (to power the motor), and a potentiometer (to control the speed). Any suitable NPN power transistor designed for high current loads can replace the TIP120 transistor. 

The external power supply can be a set of batteries or a “wall wart” style external DC power supply. The power source must have enough voltage and current to drive the motor. The voltage must not exceed that required by the motor. For my testing purposes, I used a DC power supply that provided 5v at 500mA, which was enough for the 5v DC motor I was using. Note that if you use a power supply with voltage higher than the motor can handle, you may damage it permanently.

Arduino 电子编程--直流电机控制,包括两个项目,项目Project 15简单的电机控制和Project 16 L293D芯片控制电机。

项目 Project 15 Simple Motor Control 

/* Coding Ron Wang
   Aug.27th 2024
   Autaba support for coding hardware
 */
// Project 15 - Simple Motor Control

int potPin = 0; // Analog in 0 connected to the potentiometer
int transistorPin = 9; // PWM Pin 9 connected to the base of the transistor
int potValue = 0; // value returned from the potentiometer

void setup() {
 // set the transistor pin as output:
 pinMode(transistorPin, OUTPUT);
}
void loop() {
 // read the potentiometer, convert it to 0 - 255:
 potValue = analogRead(potPin) / 4;
 // use that to control the transistor:
 analogWrite(transistorPin, potValue);
}

Arduino Simple Motor Control Circuit

Arduino Simple Motor Control Schematic

Share with Friends:

Related Articles

CODE | Basic Stepper Control (Unipolar) - Arduino Project 028B

CODE | Basic Stepper Control (Unipolar) - Arduino Project 028B

In this very simple project, you will connect up a stepper motor and then get the Arduino to control…

STEM|60个好玩的 APP推荐

STEM|60个好玩的 APP推荐

STEAM教育理念最早是美国政府提出的教育倡议,为加强美国K12(中小学)关于科学、技术、工程、艺术以及数学的教育。STEAM的原身是STEM理念,即科学(Science)、技术(Technology…

Setting Up the Environment for Aliun Server

Setting Up the Environment for Aliun Server

阿里云服务器的环境搭建与调试从阿里云产品发布开始便一直在使用ECM云服务器,但是之前多使用的是Windows系统,后来摸索开始挑战自己使用CentOS系统,靠着几行程序和网上各位大咖的教程和分享,竟然…

Setting Up an LNMP Environment on CentOS 7.9 64-bit

Setting Up an LNMP Environment on CentOS 7.9 64-bit

CentOS 7.9 64位 搭建 LNMP环境What is a LAMPLAMP is a free and open source software suite combines four po…

CODE | SD Card Temperature Datalogger - Arduino Project 043

CODE | SD Card Temperature Datalogger - Arduino Project 043

Todady I made a simple Arduino datalogger using SD card and DHT11  relative humidity and t…

CODE | Serial Controlled Mood Lamp - Arduino Project 010

CODE | Serial Controlled Mood Lamp - Arduino Project 010

For Project 10, you will revisit the circuit from Project 8 — RGB Mood Lamp, but you’ll now delve in…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.