CODE | Simple Motor Control - Arduino Project 015

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

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 | How to Connect Remote Control - Arduino Project 047

CODE | How to Connect Remote Control - Arduino Project 047

In the first time I purchase this remote, I don't know why the operating mode is only non-latche…

C03 |  Program Structure

C03 | Program Structure

C语言教程03:C语言程序结构一个 C 语言程序由一个固定名称为 main 的主函数和若干个其他函数(可没有)组成。下面通 过几个例题,总结出 C 语言程序的结构特点。在 Dev C++环境下编写的第…

CODE | Line Following Robot - Arduino Project 030

CODE | Line Following Robot - Arduino Project 030

Project 30 Line Following RobotA line following robot is an autonomous vehicle that detects and foll…

Centos Install MemCached, Apcu and OpCache

Centos Install MemCached, Apcu and OpCache

This section provides instructions to install memcached on CentOS and Ubuntu. For additional informa…

The incredible growth of Python

The incredible growth of Python

Python is a powerful programming language and Big Scope of Python   Programming Language. Pytho…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.