10-04-2017, 09:00 PM
we tried this source code for automatic railway gate.. it doesnot show any error while compiling in keil.
but we are not getting the output in proteus.. it is correct until the gate opens.. bt nothing else happens after that. pls help
#include<reg51.h>
sbit ir1=P1^6;
sbit ir2=P1^7;
sbit lm0=P2^0;
sbit lm1=P2^1;
sbit rm0=P2^2;
sbit rm1=P2^3;
sbit BUZ_PIN = P1^0;
sbit Yellow_LED_1 = P1^3 ;//indicator
sbit GATE_CLOSE_LED = P1^1;//red
sbit GATE_OPEN_LED = P1^2;//green
#define BUZZ_ON 0
#define BUZZ_OFF 1
#define LED_ON 0
#define LED_OFF 1
void delay(int t);
void closegateact(void);
void opengateact(void);
void switchOnBuzzer(void);
void switchOffBuzzer(void);
void gateClose(void);
void gateOpen(void);
void switchOnCloseGate_LED(void);
void switchOnOpenGate_LED(void);
void switchOffOpenGate_LED(void);
void switchOnYellowLeds(void);
void switchOffBlinkingLeds(void);
void closegateact(void)
{
switchOnYellowLeds();
switchOnBuzzer();
delay(500);
switchOffBuzzer();
gateClose();
switchOnCloseGate_LED();
switchOffOpenGate_LED();
}
void opengateact(void)
{
switchOffBlinkingLeds();
gateOpen();
switchOnOpenGate_LED();
}
void switchOffBlinkingLeds()
{
Yellow_LED_1= LED_OFF ;
GATE_CLOSE_LED= LED_OFF ;
}
void gateClose(void)
{
lm0=0;
lm1=1;
rm0=0;
rm1=1;
}
void gateOpen(void)
{
lm0=1;
lm1=0;
rm0=1;
rm1=0;
}
void switchOnBuzzer(void)
{
BUZ_PIN = BUZZ_ON;
}
void switchOffBuzzer(void)
{
BUZ_PIN = BUZZ_OFF;
}
void switchOnCloseGate_LED(void)
{
GATE_CLOSE_LED = LED_ON;
}
void switchOnOpenGate_LED(void)
{
GATE_OPEN_LED = LED_ON;
}
void switchOffOpenGate_LED(void)
{
GATE_OPEN_LED = LED_OFF;
}
void delay(int t)
{
int i,j;
for(i=0;i<t;i++)
{
for(j=0;j<1275;j++);
}
}
void switchOnYellowLeds(void)
{
Yellow_LED_1 = LED_ON;
}
void main()
{
while(1)
{
if((ir1==1)&&(ir2==1))
{
switchOnOpenGate_LED();
}
if((ir1==0)&&(ir2==1))
{
delay(500);
closegateact();
delay(500);
}
if((ir1==1)&&(ir2==0))
{
opengateact();
}
}
}