Sei sulla pagina 1di 5

28/2/2016 DownloadControlyourmotorswithL293DandArduinoAllaspdf

ControlyourmotorswithL293DandArduinoAll

T o o l s

ShowAllItems
Afterlongresearchandtrialanderror,Ihavecameuptoanewwalkthroughregardingthisnicechip,theL293D.

Eachprojectisoneprojectandeachonehasitsownuniquepowerconfigurations,soyoumustbeawareofthebestbattery
choiceandhowtodistributevoltagethroughyourrobot.

Istronglyadviceyoutoreadthefollowingarticles:

PickingBatteriesforyourRobot
Onceyou'vedecidedonbatteries,howdoyouregulatethevoltage

************************************************

L293Dgivesyouthepossibilitytocontroltwomotorsinbothdirectionsdatasheet
Step 1: Basic implementation

Thiswebsiteusescookies
Thiswebsiteusescookiestoimproveuserexperience.Byusingourwebsiteyouconsent
toallcookiesinaccordancewithourCookiePolicy.

Iagree Readmore

Freecookieconsentbycookiescript.com

http://instructablespdf.abuouday.com/download.php 1/5
28/2/2016 DownloadControlyourmotorswithL293DandArduinoAllaspdf

ShowAllItems
Thisisthemostbasicimplementationofthechip.

Asyoucansee,a5VVoltageRegulatorisbetweenthebatteryandpins1,9,16.

Pin8getspowerbeforetheVReg,ifyourmotorneedsforexample6Vyoushouldput6Vdirectlyinthispin,alltheotherpins
shouldnotgetmorethan5V.

Thiswillworkwithnoproblematall,butifyouwanttodotherightimplementationtakealookatthenextexample:
Step 2: Advanced implementation

http://instructablespdf.abuouday.com/download.php 2/5
28/2/2016 DownloadControlyourmotorswithL293DandArduinoAllaspdf

ShowAllItems
ThisisthecorrectImplementation(withthecapacitors),andnotethatpin8isfeededbyunregulatedvoltage.Thismeansthat
ifyourmotorsneedmorethan5V,youshouldpowerthispinwiththatamountofvoltage,andtherestofthecircuitwith5V.

Step 3: Arduino code


//UsethiscodetotestyourmotorwiththeArduinoboard:

//ifyouneedPWM,justusethePWMoutputsontheArduino
//andinsteadofdigitalWrite,youshouldusetheanalogWritecommand

//Motors

http://instructablespdf.abuouday.com/download.php 3/5
28/2/2016 DownloadControlyourmotorswithL293DandArduinoAllaspdf

intmotor_left[]={2,3}
intmotor_right[]={7,8}

//Setup
voidsetup(){
Serial.begin(9600)

//Setupmotors
inti
for(i=0i<2i++){
pinMode(motor_left[i],OUTPUT)
pinMode(motor_right[i],OUTPUT)
}

//Loop
voidloop(){

drive_forward()
delay(1000)
motor_stop()
Serial.println("1")

drive_backward()
delay(1000)
motor_stop()
Serial.println("2")

turn_left()
delay(1000)
motor_stop()
Serial.println("3")

turn_right()
delay(1000)
motor_stop()
Serial.println("4")

motor_stop()
delay(1000)
motor_stop()
Serial.println("5")
}

//Drive

voidmotor_stop(){
digitalWrite(motor_left[0],LOW)
digitalWrite(motor_left[1],LOW)

digitalWrite(motor_right[0],LOW)
digitalWrite(motor_right[1],LOW)
delay(25)
}

voiddrive_forward(){
digitalWrite(motor_left[0],HIGH)
digitalWrite(motor_left[1],LOW)

digitalWrite(motor_right[0],HIGH)
digitalWrite(motor_right[1],LOW)
http://instructablespdf.abuouday.com/download.php 4/5
28/2/2016 DownloadControlyourmotorswithL293DandArduinoAllaspdf

voiddrive_backward(){
digitalWrite(motor_left[0],LOW)
digitalWrite(motor_left[1],HIGH)

digitalWrite(motor_right[0],LOW)
digitalWrite(motor_right[1],HIGH)
}

voidturn_left(){
digitalWrite(motor_left[0],LOW)
digitalWrite(motor_left[1],HIGH)

digitalWrite(motor_right[0],HIGH)
digitalWrite(motor_right[1],LOW)
}

voidturn_right(){
digitalWrite(motor_left[0],HIGH)
digitalWrite(motor_left[1],LOW)

digitalWrite(motor_right[0],LOW)
digitalWrite(motor_right[1],HIGH)
}

Downloaded using:
instructables-pdf.abuouday.com Privacy Policy

http://instructablespdf.abuouday.com/download.php 5/5

Potrebbero piacerti anche