|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#7
|
|||
|
|||
|
Re: How to code limit switch to stop movement
We're actually doing something similar. Our launcher is lifted using two motors (LifterA and Lifter B), and we wired our limit switches so that the upper is 1 when depressed and the lower is 1 when open. The upper limit becomes open onces the ramp reaches the furthest up we want it to go, while the lower limit becomes closed when it goes the furthest down we want it to go. Our code looks something like this:
if(stick.GetRawButton(4) && UpperLimit.Get() == 1) // if button 4 is pressed and upper limit is pressed, lifter goes up { LifterA.Set(0.4); LifterB.Set(0.4); } else if(stick.GetRawButton(5) && LowerLimit.Get() == 1) // if button 5 is pressed and lower limit is not pressed, lifter goes down { LifterA.Set(-0.4); LifterB.Set(-0.4); } else { LifterA.Set(0.0); LifterB.Set(0.0); } |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|