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 / circuit#includesbit

circuit#includesbit

|

Microcontroller › 8051 › Interface 8051 to a 12V dc motor › circuit#includesbit

March 31, 2012 at 6:21 pm #7369
tarun
Participant

wysiwyg_imageupload:4364:

#include<reg51.h>

sbit enable1=P1^0;
sbit enable2=P1^2;
sbit mtr1_1=P1^1;
sbit mtr1_2=P1^7;
sbit mtr2_1=P1^3;
sbit mtr2_2=P1^6;
sbit sw1=P2^2;
sbit sw2=P2^3;
sbit sw3=P2^4;
sbit sw4=P2^5;
void delay(void);
void main()
{
P1=0x00;
P2=0xff;
while(1)
{
enable1=0x00;
enable2=0x00;
delay();
if(sw1==0x00)
{
enable1=0x01;
enable2=0x01;
delay();
mtr1_1=0x01;
mtr1_2=0x00;
mtr2_1=0x01;
mtr2_2=0x00;
}
else if(sw2==0x00)
{
enable1=0x01;
enable2=0x01;
delay();
mtr1_1=0x00;
mtr1_2=0x01;
mtr2_1=0x00;
mtr2_2=0x01;
}
else if(sw3==0x00)
{
enable1=0x01;
enable2=0x01;
delay();
mtr1_1=0x01;
mtr1_2=0x00;
mtr2_1=0x00;
mtr2_2=0x01;
}
else if(sw4==0x00)
{
enable1=0x01;
enable2=0x01;
delay();
mtr1_1=0x00;
mtr1_2=0x01;
mtr2_1=0x01;
mtr2_2=0x00;
}
else if(sw1==0x0f&&sw2==0x0f&&sw3==0x0f&&sw4==0x0f)
{
enable1=0x00;
enable2=0x00;
delay();
}
}
}
void delay()
{
int i,j;
for(i=1;i<=2;i++)
for(j=1;j<=500;j++);
}

RSS Recent Posts

  • Flip Flop for My Mirrors January 16, 2026
  • Sine wave distortion January 16, 2026
  • potenciometer attachment / screwdriver January 16, 2026
  • flexible copper cable January 16, 2026
  • Variable audio oscillator January 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