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

  • Fun with AI and swordfish basic June 23, 2025
  • Simple LED Analog Clock Idea June 23, 2025
  • Microinverters and storeage batteries? June 23, 2025
  • PIC KIT 3 not able to program dsPIC June 23, 2025
  • Is AI making embedded software developers more productive? June 23, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 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