Elevator coding interrupt

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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*/
	}
	}
}

 

Last Edited: Mon. Apr 15, 2019 - 09:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

James,

 

https://www.avrfreaks.net/forum/...

 

did you ask there as suggested in your other locked thread ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

James McGarphy wrote:
i'm using c8051F02x toolkit and silicon lab IDE
Then you came to the wrong website. Silicon Labs are a competitor to Atmel/Microchip. Microchip pay the running costs for this forum for their users.

 

Locked.

Topic locked