One level lift with one push button

Hello Guys,
It's my first day here and I am glad to be part of this community.

I have a project need to be done very soon, it should be a lift using dc motor with one push button. Basically when I press one push, the motor should spin for 5 second and going up and stops at level 1, then with the same push button I should press again and it goes down for 5 seconds and stops at G level.
Currently I have Arduino uno and L293 and DC motor 4.8V

I really appreciate your help in that.

You need a variable to keep track of the state of your system - perhaps called liftPosition and with 4 possible values 'U' (going up); 'T' (at the top); 'D' (going down) and 'B' (at the bottom).

Rather than time your motor it would be more reliable (as in real lift practice) to use a micro-switch at the top and bottom to identify when the move is complete.

Your single push button would cause the value of liftPosition to change from (say) 'T' to 'D' and your motorOperate() function would use the value of the variable to decide if the motor should operate. Then the bottom switch would cause the value to change from 'D' to 'B'

...R
Planning and Implementing a Program

Thanks a lot Robin2, you are completely right, but I should strictly do the way it should be for this project.
I will be thankful if you know how to code it.

saadi_1990:
I will be thankful if you know how to code it.

If that means "please write the program for me" then the answer is NO.

But I will be happy to help you if your best attempt at the program does not work as you want.

If you want someone to write a program for you then ask in the Gigs and Collaborations section and be prepared to pay.

...R

Hi,
Welcome to the forum.

I have a project need to be done very soon,

Is this a school/college/university project?

Have you programmed your UNO yet?

Can you tell us your electronics, programming, Arduino, hardware experience?

Thanks.. Tom... :slight_smile:

Thanks guy for your reply, sorry I am new here so I thought someone will jump on and help.
I will put more effort in that.

Thanks again Robin2 and TomGeorge
cheers.

saadi_1990:
I am new here so I thought someone will jump on and help.

If people give you the answer without any effort on your part you don't learn anything.

...R