Elevator Interfacing
Elevator Interfacing
DECODER
P1
Lower nibble
=ABCD
Upper nibble
to control
hardware &
blanking RED
LED
Floor travel count, red LED clear
code –tables:
CurFlr To ReqFlr
Sample Case: CurFlr < ReqFlr 1st To 4th
1 8
0x00 0x09
#include <at89c51xd2.h>
void main(void)
{ AUXR = 0x10; // Accessing Full XRAM
P1 = 0x00;
P1 = 0x0f0;
while(1)
{
P0 = 0x0f; // Configure Port as i/p
ReqFlr = P0 | 0xf0; // Append '1' at the Higher nibble
// position
while(ReqFlr == 0xff)
ReqFlr = P0 | 0xf0; /* Read Request Floor from P0 */
{
P1 = 0x0f0 | j;
j--;
delay(20000); // Delay to visualize the effect
}
}
else /* If Current floor is < request floor */
{
i = Flr[ReqFlr] - Flr[CurFlr]; // Get the no of
//floors to travel
j = Flr[CurFlr];