EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / /*motor.c*//*try this out ,

/*motor.c*//*try this out ,

|

Microcontroller › 8051 › L293D interfacing with 8051 › /*motor.c*//*try this out ,

March 25, 2013 at 6:25 am #9369
Arjun Vaghani
Participant

/*motor.c*/

/*try this out , it’s very simple*/

/*LCD is not necessary for L293D’s interfacing with AT89S52, So i have not given, but u can add that code separately*/

 

/*program-start*/

 

#include<reg51.h>
main()
{
while(1)
{
unsigned char t;
t=P1&0x0f;                             //read the data from port P1
switch(t)
{                                              /*block for taking action according to input*/
case 0x02:P2=0x85;            /*forward*/
 break;
case 0x04:P2=0x86;          /*left*/
 break;
case 0x06:P2=0x89;           /*right*/
 break;
case 0x08:P2=0x8A;        /*backward*/
 break;
case 0x05:P2=0x00;          /*stop*/
 break;
case 0x00:P2=0x00;       /*no input*/
 break;
}
}
}
 

/*In Diagram Shown Below, by Configuring Port P1 for Different Input Combinations , U can get the Action Performed by the DC Motor, i.e Desired Motion.*/

 

wysiwyg_imageupload:7864:

 

RSS Recent Posts

  • RC Electronic Speed Control Capacitors February 17, 2026
  • Annex32 / Annex RDS For ESP Micros - A Quick and Dirty Example February 16, 2026
  • Convenient audio FFT module? February 16, 2026
  • CR2/CR123A Batteries In Projects February 16, 2026
  • Harman Kardon radio module BMW noise February 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise