Hello arduino community im a average student making a arduino based project but i don't have any expirience at all . im building a arduino controled lock maquette , made in glass and it has 4 doors controled by servos and 2 water pumps with diferent jobs . the problem is that i want to control 2 diferent actions , the upper movement and the down one , to raise or lower the boat , i want to initialize this two actions with 2 diferent buttons but i only have 2p switches can you guys plz help me i am behind schedules and i am alone at this .
Wire your switches between pin and ground. Use the internal pullups (see pinMode reference). If the switch is pressed / active, digitalRead will return low, else high.
Were you expecting source code ready made for you to submit to your professor as the completed project?
thank you for being so nice , im will not submit it to my professor because he is an engineer who doesn t help me and i will submit it to a juri thx for helping
what is a lock maquette ?
lock maquette
I am not sure, but I am guessing you want to control locks for a boat that goes between two bodies of water.
you say 4 doors. is that two gates (with 2 doors) one one pair on each end ?
one pair closes and seals.
the other pair opens and the boat enters.
the second pair closes and seals.
water is allowed to enter (or exit) until the level is equal to the other level ?
it seems that if you can open and close the locks and seal them, then you are mostly done, just the controls.
press button #1, the lower gate closes and seals.
the pump will fill the space between maybe time your pump or have a sensor to know when it is filled
open the second set of gates.
press button #2
close the upper gate
drain the water until they are equal to the lower level.
open the lower gates.
it sounds simple enough. what are you having problems with ?
Its a model of a lock, I would think a canal lock, like in UK and Europe..
Nice project to build, but not for beginners, if its a class project, then I'd be expecting more tutorial support.
Surprised that you have been given project without any instructons in Arduino programming.
ElFixe:
Hello arduino community im a average student making a arduino based project but i don't have any expirience at all . im building a arduino controled lock maquette , made in glass and it has 4 doors controled by servos and 2 water pumps with diferent jobs . the problem is that i want to control 2 diferent actions , the upper movement and the down one , to raise or lower the boat , i want to initialize this two actions with 2 diferent buttons but i only have 2p switches can you guys plz help me i am behind schedules and i am alone at this .
Sorry for bad english
Controlling multiple actions with a single arduino is no problem. You need to define what is to happen and in what sequence, and what state information is required in your program, to "remember" what is currently going on.
My suggestion:
Initial state
Upper door is closed.
Lower door is open, allowing boats into the chamber.
No pump is running
Assuming one pump to fill chamber with water, and one to empty it, since opening the doors probably does not work if water higher on the upper side, with water pressure holding them shut.
Button 1
Press, hold and release to do the following:
if lower door is open, then close it
pump water into chamber, raising water level for as long as button is held
when button is released, open upper door
Button 2
Press, hold and release to perform the following:
if upper door is open, then close it
pump water out of chamber, lowering water level for as long as button is held
when button is released, open lower door
You need to adapt these descriptions to your needs, and take it from there. Best of luck!
ElFixe:
thank you for being so nice , im will not submit it to my professor because he is an engineer who doesn t help me and i will submit it to a juri thx for helping
"nice" has nothing to do with it.
Submitting someone else's work as your own is cheating.
TomGeorge:
Nice project to build, but not for beginners, if its a class project, then I'd be expecting more tutorial support.
Surprised that you have been given project without any instructons in Arduino programming.
Have you ever read a post here that claimed that they were given all the instructions? ? ?
It is always someone else's fault that they never received the proper instructions.
The professor never explained anything, blah blah blah blah.
You can post with code tags rather than attaching. More people will look at your code.
Your code does not compile, and contains several bracket, brace and syntax errors.
If you place each opening { or closing } on a new line, the use of autoformat (Control+t) on your code to help find all the bracket errors.
Here's one thing to fix to get you started. When you define the functions subir and descer the syntax needs(). Compare how check Buttons is set up differently than subir and descir.
void subir {}
void checkButtons() {}
I went through your code and did get it to compile, so if you clean it up and study the bracket arrangements you should be able to do that.
@ElFixe, you have been given several pieces of advice. Act on them and post the resulting code together with the error messages (if it won't compile) or a description of what it actually does if it does not do wht uou want.
Start by fixing the first error message and ignoring the rest. Often, a flood of error messages result from the original error. So fix the first one, many may go away.
Next your missing a closing '}' at the end of the subir() function; add it and compile
} // <---------- ADD
void descer() {
Next your switch in subir() misses a '{'
switch (level)
{ // <---------- ADD
case 1:
Change to the above and compile again
Now you're missing another '}' at the end of subir(). Fix and compile
And lastly your missing a '}' at the end of the descer() function. Fix and complie.
Hint:
Press T in the IDE; it will properly indent the code. You can than easily spot the errors. E.g. function definitions should always start at the beginning of the line (no indents). The closing curly of a function should also be on the first position of the line.
Would be nice if we could get a picture of what you got in that way we can work with our imagination
and give ideas of what you can do and fast.
What you ask is totally basic beginner programming, if you had at least 2 months of experience using
arduino you wouldn't be here
Give us please a full list of components you have/want to use and a picture of your "lock maquette"
or at least a paper hand design if you don't have it yet build (and dimensions).
and personally if I'm in the mood I can make/program you a full project in the next 2 days
(not in materials just paper design/hardware and code)