当前位置:首页 > 科学研究 > 电子编程 > 正文内容

Arduino Project 015 - Simple Motor Control

RonWang3个月前 (08-27)电子编程77

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

版权声明:本文为原创文章,版权归donstudio所有,欢迎分享本文,转载请保留出处!

本文链接:http://www.donstudio.cn/?id=265

标签: Arduino

相关文章

Arduino Project 027 - Joystick Servo Control

Arduino Project 027 - Joystick Servo Control

In this tutorial, we are going to learn how to use Arduino and a joystick to control two servo motor...

Arduino Project 023A - Liquid Crystal Displays - Autoscroll

Arduino Project 023A - Liquid Crystal Displays - Autoscroll

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14...

Arduino Project 014 - Light Sensor

Arduino Project 014 - Light Sensor

This project introduces a new component known as a Light Dependent Resistor, or LDR. As the name imp...

Arduino Project 021 -  LED Dot Matrix Display - Scrolling Message

Arduino Project 021 - LED Dot Matrix Display - Scrolling Message

There are many different ways to drive LEDs. Using shift registers is one way and they have their a...

Arduino Project 030B - MX1508 H-Driver Motor

Arduino Project 030B - MX1508 H-Driver Motor

MX1508 H-BridgeDual Motor DriverThe driver can drive up to two motors. The H-Bridge dual motor drive...

Arduino Project 001 - LED Blink

Arduino Project 001 - LED Blink

Arduino 电子编程--灯项目及控制,主要使用Arduino编程控制LED灯,实现基本控制Project 1 LED闪烁,基本的应用Project 3和4红绿灯项目项目1 Project...

评论列表

Tommy
Tommy
3天前

哇,简单的电机控制这个程序很棒,我折腾了很久都没有搞定,照这个做一下搞定了。

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。