Microcontroller › 8051 › Interface 8051 to a 12V dc motor › /*Connections: 1. Connect
March 31, 2012 at 6:24 pm
#7370
Dinesh Kumawat
Participant
/*Connections:
1. Connect P2.0 to E1 pin of L293D Section on the kit
2. Connect P2.1 to I1 pin of L293D Section on the kit
3. Connect P2.2 to I2 pin of L293D Section on the kit
4. Connect VS pin of L293D section to Vcc Pin. The Vcc pin is the 1st pin on the 6 pin header (marked as ISP) just above the 89V51RD2 IC. This provides 5V to the DC Motor. In case your DC motor requires higher voltage (max 12V) then connect external DC power source to VS & GND pins of L293D section.*/
#include <REG52.H> /* special function register declarations */
/* for the intended 8051 derivative */
#include <stdio.h> /* prototype declarations for I/O functions */
//L293D Pin Defines
sbit E1 = P2^0;
sbit I1 = P2^1;
sbit I2 = P2^2;
void MSdelay(unsigned int rtime)
{
unsigned int r,s;
for(r=0;r<rtime;r++)
for(s=0;s<1275;s++);
}
void main (void) {
E1 = 1; //Set E1 pin High to Enable Channel of L293D
while(1) //End less while so that program never ends
{
//Rotate in One Direction
I1 = 0;
I2 = 1;
MSdelay(500);
//Rotate in Other Direction
I1 = 1;
I2 = 0;
MSdelay(500);
}
}