Hello all my name is Casey Hafeman. I have been struggling with this all night, and not sure how to attempt this anymore. I have the code working right when input P1^0 or P1^1 is true (1). But, I would like to add somewhere inside the code where when both inputs (P1^0, and P1^1 go false (0) there is a time delay of 5-10 seconds that it keeps cycling through the loop. Then finally turns completely off.
//Railroad Warning Light (With Lights and Bell) Source Code #include <reg51.h> void MSDelay (unsigned int); void MSDelay2 (unsigned int); sbit input = P1^0; sbit input2 = P1^1; sbit LLight = P0^1; sbit RLight = P0^2; sbit Bell = P0^4; void main(void) { unsigned int i; input = 0x00; //'input' As Input Port input2 = 0x00; //'input2' As Input Port LLight = 0xFF; //'LLight' As Output Port RLight = 0xFF; //'RLight' As Output Port Bell = 0xFF; //'Bell' As Output Port { LLight = 0; RLight = 0; Bell = 0; i=0; } for (;;) { if (input==1|input2==1) { MSDelay2 (1250); } LLight = 0; RLight = 0; Bell = 0; } } void MSDelay (unsigned int itime) { unsigned int i, j; for (i = 0; i < itime; i++) for(j = 0; j < 1275; j++); } void MSDelay2 (unsigned int itime) { unsigned int i; for (i = 0; i < itime; i++); { { Bell = 1; LLight = 1; RLight = 0; MSDelay (1250); } { Bell = 1; LLight = 0; RLight = 1; MSDelay (1250); } } }