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

Arduino Project 016 - L293D Motor Driver IC

RonWang3个月前 (09-03)电子编程73

In the previous project, you used a transistor to control the motor. In this project, you are going to use a very popular motor driver IC called an L293D. The advantage of using this chip is that you can control two motors at the same time, plus you can control their direction. The chip can also be used to control a stepper motor, as you will find out in Project 28. (You can also use a pin-for-pin compatible chip known as the SN754410, which has a higher current rating.) Notice anything missing from the parts list  Diodes, perhaps? Not to worry; the IC has its own internal diodes, so you do not need one for this project.

项目Project 16  Using an L293D Motor Driver IC 

/* Coding Ron Wang
   Sep.3rd 2024
   Autaba support for coding hardware
 */
// Project 16 - Using an L293D Motor Driver IC
#define switchPin 2 // switch input
#define motorPin1 3 // L293D Input 1
#define motorPin2 4 // L293D Input 2
#define speedPin 9 // L293D enable Pin 1
#define potPin 0 // Potentiometer on Analog Pin 0
int Mspeed = 0; // a variable to hold the current speed value

void setup() {
//set switch pin as INPUT
pinMode(switchPin, INPUT);
// set remaining pins as outputs
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(speedPin, OUTPUT);
}

void loop() {
 Mspeed = analogRead(potPin)/4; // read the speed value from the potentiometer
 analogWrite(speedPin, Mspeed); // write speed to Enable 1 pin
 if (digitalRead(switchPin)) { // If the switch is HIGH, rotate motor clockwise
 digitalWrite(motorPin1, LOW); // set Input 1 of the L293D low
 digitalWrite(motorPin2, HIGH); // set Input 2 of the L293D high
 }
 else { // if the switch is LOW, rotate motor anti-clockwise
 digitalWrite(motorPin1, HIGH); // set Input 1 of the L293D low
 digitalWrite(motorPin2, LOW); // set Input 2 of the L293D high
 }
}

Arduino L293D Motor Driver IC Circuit

Arduino L293D Motor Driver IC Schematic

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

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

标签: Arduino

相关文章

Arduino Programming Basic - Variables

Arduino Programming Basic - Variables

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静...

Arduino Project 035 - Keypad 4X4 or 4X3

Arduino Project 035 - Keypad 4X4 or 4X3

Most of the time we are used key, button, or switch to get input value in our projects. When we inte...

Arduino Project 012 - Piezo Sounder Melody Player

Arduino Project 012 - Piezo Sounder Melody Player

Rather than using the piezo to make annoying alarm sounds, why not use it to play a melody? You are...

Arduino Project 032 - BMP280 Pressure Sensor LCD Display

Arduino Project 032 - BMP280 Pressure Sensor LCD Display

For this project we will use Arduino Uno and BMP280 along with LCD 16x2 display module to display te...

Arduino Programming Basic - Input and Outpput

Arduino Programming Basic - Input and Outpput

The pins on the Arduino can be configured as either inputs or outputs. This document explains the fu...

Arduino Project 023C - Liquid Crystal Displays - Serial to Display

Arduino Project 023C - Liquid Crystal Displays - Serial to Display

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

发表评论

访客

看不清,换一张

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