DC Motor Interfacing with 8051 Microcontroller - CodesExplorer

 DC Motor Interfacing with 8051 Microcontroller

Fig 1 DC Motor
This Code is specially developed for ALS 8051 Evaluation Board.

DC motor is basically converts direct current electrical energy into mechanical energy. They have a wide range of applications in bots and in other electronic devices.By interfacing DC motor to the microcontroller, we can do many things like controlling the direction of the motor, controlling the speed of the motor. This article describes you how to control the DC motor using AT89C51 controller.
In this article we will be just rotating DC Motor
DC Motor will be connected to any one of the Ports. In our case we will be connecting it to PORT0 .To be more specific P0^6 or P0^7.
In ALS 8051 Evaluation Board we can connect two DC Motors.

Lets See the code Now.....

CODE: 

// DC MOTOR INTERFACING USING 8051
//----------------------------------------------------------------
// CONTROLLER   : 8051 AT89C51ED2
// Developed By  : CodesExplorer
//----------------------------------------------------------------
#include <at89c51xd2.h >
sbit dc1=P0^6;
sbit dc2=P0^7;
void delay();
void main()
{
 while(1)
 {
  dc1=1;
  delay();
  dc1=0;
  delay();
 }
}
void delay()
{
 unsigned int i,j;
 for(i=0;i<500;i++)
 {
  for(j=0;j<10;j++);
 }
}

No comments:

Powered by Blogger.