What do you have attached to A0 and A1?
Also why do you treat analogRead(A0) and analogRead(A1) as if they're digital values? (I'm referring to this piece of code)
else if (analogRead(A0))//joystick center cutoff
{
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(3, LOW);
digitalWrite(11, LOW);
digitalWrite(5, LOW);
}
else if (analogRead(A1))//joystick center cutoff
{
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(3, LOW);
digitalWrite(11, LOW);
digitalWrite(5, LOW);
}
A0, A1 and A2 are all potentiometers on a joystick (A2 turning/twisting the joystick)
i did this code to kill noise in on the output when the joystick is centered else it would flicker the leds!
however i have cleaned the code quite a bit after that issue so it could possibly be cut out now..
mtnhll:
my bad again, the term im looking for is perhaps outputs?
Now that you know "function" is the wrong word, it would help if you re-write your question so I don't have to guess what you mean. Use the variable names from your code so there is no confusion.
pot 1 and 2 control the outputs in pairs: (9 & 10) and (3 & 11)
pot 3 controls the same outputs but as pairs: (3 & 9) and (10 & 11)
when pots 1-2 is active pot 3 cant be activated
but when pot 3 is input first and then pot 1-2 it adds that output on top off the pot 3 output
there can never be more than 2 outputs (hardware will brake) but as described above i get 3 outputs at once (even 4 if i jiggle a bit in low values of the pots)
everything works besides that i need to kill the pot 3 output when i get pot 1-2 input
all i've tried either does nothing or mess with the pot 1-2 outputs
does this make more sens or just worse?
this code will control a 2 ton chunk and kind of needs to work proper...or things can go bad...
pot 1 and 2 control the outputs in pairs: (9 & 10) and (3 & 11)
pot 3 controls the same outputs but as pairs: (3 & 9) and (10 & 11)
when pots 1-2 is active pot 3 cant be activated
but when pot 3 is input first and then pot 1-2 it adds that output on top off the pot 3 output
there can never be more than 2 outputs (hardware will brake) but as described above i get 3 outputs at once (even 4 if i jiggle a bit in low values of the pots)
everything works besides that i need to kill the pot 3 output when i get pot 1-2 input
all i've tried either does nothing or mess with the pot 1-2 outputs
does this make more sens or just worse?
this code will control a 2 ton chunk and kind of needs to work proper...or things can go bad...
this piece of code prohibits the use of pot 3 (A2) when there is a input from pot1 pwmX(A1) or pot2 pwmY(A0), but it only prohibits you from begining to use pot 3 input!
Robin2:
What do you mean by "is active" and how do you distinguish it from "is not active"
...R
the input and output from pot 3 is supposed to be secondery, mening that if an input comes from pot 1 or 2 it overrides the pot 3 input/output..
ive been trying alot of true/false and other to define that but to no avail...
mtnhll:
this piece of code prohibits the use of pot 3 (A2) when there is a input from pot1 pwmX(A1) or pot2 pwmY(A0), but it only prohibits you from begining to use pot 3 input!
I can't see how that will work the way you want it to.
What it amounts to is that the use of potA is determined by the position that potB is set at. But there is nothing to prevent potB being changed to a different position by the user.
It seems to me that you want a situation where you can waggle potA as you wish and certain things will happen. Then you want to move potA to a special position following which you can waggle potB as you wish and different things will happen. Presumably you need to move potB to its special position before you can go back to waggling potA.
If that is what you want to do I think it would be easy to code. The complicated thing would be to ensure the user put the pot in the correct parking position.
But if you need to be able to use both pots at the same time in either or both circumstances that simple state distinction cannot be made. Something special would have to be done to tell the Arduino it is now in stateA or stateB. That something could be a separate switch. Or maybe it could happen if potA is parked in position1 and potB is parked in position2 for (say) 5 secs. Then to switch to the other state you could put potA in position2 and potB in position1. But that sounds very inconvenient.
Robin2:
It seems to me that you want a situation where you can waggle potA as you wish and certain things will happen. Then you want to move potA to a special position following which you can waggle potB as you wish and different things will happen.
this is indeed what i want, and the code is in fact working like this except:
Waggle potA and then potB (without parking potA), nothing else happens- works great!
Waggle potB and then potA (without parking potB), output becomes potB+potA= the problem..
the pots are spring returned so if you let them go they return to their neutral center position..
Robin2:
Presumably you need to move potB to its special position before you can go back to waggling potA.
this i should achieve by replicating my working code for potA,
BUT what i really would want is not having to park potB, but waggling potA would suspend and surpass potBs actions, however this might not be possible then?? (in a simple way, so even i could do it :)))
mtnhll:
the pots are spring returned so if you let them go they return to their neutral center position
It has taken a long time to get this important piece of information.
What else have you hidden up your sleeve?
Do you consider the neutral position to be the parked position?
I'm conscious that if the neutral position is in the centre the pot will pass through it lots of time during a waggle. How will the Arduino distinguish a passing visit from a "park"?
BUT what i really would want is not having to park potB, but waggling potA would suspend and surpass potBs actions, however this might not be possible then??
The only way I can think of is by keeping track of whether the position is changing. I.e. if the position of potA has not changed for X seconds potB is to be considered the master and while it is the master any movement of potA will be ignored. If you stop moving potB for X seconds then potA would become the master. But I don't know if that is practical in your application and I suspect it would not be reliable - how would the user hold the pot steady for X seconds?