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 / following program is correct

following program is correct

|

Microcontroller › 8051 › In what form signal is given to AT89c51 mc’s input › following program is correct

April 7, 2015 at 4:04 am #12774
nitish kumar singh
Participant

following program is correct for rotating the stepper motor half revolution in clock wise and anti-clock wise.?

My aim is to use this stepper motor to close and open the Railway crossing gate..

#include<reg51.h>
void MSDelay (unsigned int value);
sbit sense1=P1^0;
sbit sense2=P1^1;
void main ()
{
int i;
P1=0x03;
{
if ((sense1=='1')&& (sense2!='1'))
{
for (i=0;i<=2;i++)
{
P2=0x01;
MSDelay (10);
P2=0x02;
MSDelay (10);
P2=0x04;
MSDelay (10);
P2=0x08;
MSDelay (10);
}
}
sense1=0;
if ((sense2=='1') && (sense1!='1'))
{
for (i=0; i<=2;i++)
{
P2=0x01;
MSDelay (10);
P2=0x08;
MSDelay (10);
P2=0x04;
MSDelay (10);
P2=0x02;
MSDelay (10);
}
}
sense2=0;
}
}
void MSDelay (unsigned int value)
{
unsigned int x,y;
for(x=0; x<1275;x++)
for(y=0;y<value;y++);
}

RSS Recent Posts

  • To couple or decouple February 10, 2026
  • ANOTHER OLD PROJECT REDO February 10, 2026
  • analog logic of shmidt trigger bjt circuit February 10, 2026
  • Buffer design? February 10, 2026
  • XLR splitter to mono. February 10, 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