I'm working on a project where i'm making an elevator for 4 levels
Normally there are buttons inside the elevator for choosing the wanted level
and Buttons outside of it to request it wherever the elevator is
I need C implementation for the buttons outside of it , in other words if it's going up from 1st floor to 4th one and i'm outside at 2nd floor i will press the button and it shall stop
and if i pressed down from outside it will ignore the press and continue going up and come back to me after it finishes going up
it probably needs interrupt or if there is an easier way
my code for in buttons
Set Duty Cycle is for servo motor to pull elevator
i'm using c8051F02x toolkit and silicon lab IDE
void main (void) { EA = 1; /* Enable global interrupt */ ET0 = 1; /* Enable timer0 interrupt */ Timer_init(); Port_Init(); while(1) { if(Level0 == 0 ) { Set_DutyCycle_To(0.6); } else if(Level1 == 0 ) { Set_DutyCycle_To(1.2); } else if(Level2 == 0 ) { Set_DutyCycle_To(1.9); } else if(Level3 == 0 ) { Set_DutyCycle_To(2.6); } else { /* do Nothing*/ } } }