Buttons and switch limits state memorisation issue!

I would like to create a simple project with an arduino uno board , which contains a 24v DC motor with an L293D IC(to inverse the motor sens) , with two buttons and 2 switch limits , My project is a sliding door with a motor that changes it sens to open and close the door manually , 2 command buttons and 2 switch limits (switch limit2=HIGH && button1=HIGH then motor sens1=on then the motor stops when the door reachs switch limit1) (switch limit1=HIGH && button2=HIGH then motor sens2=on then the motor stops when the door reachs switch limit2) my probem is how to memorise the buttons and switch limits state?
Can you please help me with my code?

Hi zirus109,

What is the status of your project? What have you been able to do / not do so far? To help us guide you, paste your code onto a reply using the </> button above the reply text window and paste your code in the block.

I’m not quite sure what you mean by “memorizing” the button limits and states. Can you explain this a little more?

Pat.

Hello patduino,
I attached a proteus capture for my circuit and the code below
The initialized state must be like the circuit capture
and should be like that,
1-when button1 is pushed and cap1 is selected , motor turns on sens 1 then stops when cap2 is HIGH and cap1 is LOW again
2-when button2 is pushed and cap2 is selected , motor turns on sens 2 then stops when cap1 is HIGH and cap2 is LOW again
Thank you very much for asking , sorry for the late
I hope there is a solution

test.ino (1 KB)

Any suggestion please!

Re-wire the switches so when pressed the pin connects to Gnd. Turn on the internal pullup resistors:

pinMode (pinX, INPUT_PULLUP);

then test for a Low:

if (digitalRead(pinX) == LOW){
// button is pressed, do something
}
// and optionally
else {
// button is not pressed, do something else
}

L293D, I think you need Vcc1, pin 16, at 5V, and Vcc2, pin 8, at the motor supply voltage.

Hello CrossRoads, Thank you very much for your reply , i am going to try that soon and tell you the result Thank you again Friendly Zirus109