Need help multiple safety switches and trigger buttons mini Maestro 18

Hello Everyone,
I have a custom project with hatches and doors moving using a Mini Maestro 18 channel and a High Powered 18v25 motor controller in which one 12v Linear actuator, 2 Hi tech servers and 2 mini actuator are connected. This project requires each movement to be triggered once the servos or actuators reach their full position. The setup is also designed with safety in mind as each movement must be fully engaged/extended or checked to see if its in position. I’ve tried so many different script combinations, frames, timing, etc and realized that the simple multiple button script example baseline was the best starting point. The script below would have been great, but it seem to loop on the last down (lift2)sequence in which I couldn’t figure out why. Is it possible for someone to look over my script(s) to help streamline or provide suggestions? any help will be appreciated!

Channel 0 - mini linear actuator
Channel 1 - mini linear actuator
Channel 2 - Hi tech servo
Channel 3 - Hi tech servo
Channel 12 - Up Button
Channel 13 - Down Button
Channel 14 - LCD Safety Button - Hi tech servo switches - must be fully rotated either direction
Channel 15 - Lift Safety Button - for 12v linear actuator safety switch - must be fully extended
Channel 16 - Hatch Safety Button - mini linear actuator - for hatch - must be fully opened
Channel 17 - 12v Linear actuator *** This is connected to High Powered 18v25 motor controller via rc connection

High Powered 18v25 motor controller
RC Channel 1 - up/dwn
Analog Ch. 1 - Kill switch - both are also connected as safety
Analog Ch. 2 - Kill switch

These safety buttons are used for precaution as the 12v linear actuator is powerful and will not stop once sequence starts. Only with the Kill switches will it stop the 12v linear actuator, and the safety switch prevent it from moving if the hatch or the servos are out of place.


begin
button_up if sequence_up endif   # REMOTE CONTROL uP 
button_dwn if sequence_dwn endif    # REMOTE CONTROL DOWN 
Repeat

###############################################   SAFETY BUTTONS/SWITCHES  ########################################################

sub button_up
12 get_position 500 less_than 			# UP Button
return

sub button_dwn
13 get_position 500 less_than 			#DOWN button
return

sub button_sidesopened				#SAFETY SWITCH TO ENGAGE UP MOTION - WHEN ENGAGED NEXT MOTION IS TRIGGERED - BOTH SWITCHES MUST BE ENGAGED! NEXT MOTION IS THE LIFT.
16 get_position 500 less_than
return

sub button_lift					#SWITCH TO ENGAGE LCD MOTION - ONCE LIFT IS COMPLETELY EXTENDED - SAFTEY SWITCH IS TRIGGERED AND NEXT MOTION IS LCD MOVEMENT.
15 get_position 500 less_than
return

sub button_lcd					#SAFETY SWITCH			
14 get_position 500 greater_than
return

sub button_lift0					# CHECKS IF LIFT IS AT THE MAXIMUM POSITION IF NOT IT WILL MOVE TO UPPER POSITION TO ENGAGE SWITCH
15 get_position 500 greater_than
return

sub button_lcd1					#
14 get_position 500 less_than
return

sub button_lift2					
15 get_position 500 greater_than
return

# #################################################  UP MOVEMENT   ###################################################

sub sequence_up
8000 0 servo 500 delay                    # This moves mini linear actuators 0 & 1 fully to open hatch after fully extended switch on actuator activates button 16 or sidedopened, only if both sides are engaged.
8000 1 servo 800 delay 				# If the sides are not engaged it start over,  if both side are good then it continues to sub sequence_side opened
0 0 servo 500 delay
0 1 servo 500 delay
button_sidesopened if sequence_sidesopened endif 
return

sub sequence_sidesopened
8000 2 servo 500 delay
4000 3 servo 500 delay				#Hold position
button_lcd if sequence_liftservo17 endif	#SAFETY SWITCH			
14 get_position 500 greater_than
return

sub sequence_liftservo17
8000 17 servo 10000 delay
button_lift if sequence_lift endif
return

sub sequence_lift
5 3 speed
5 2 speed
4000 3 servo 500 delay
8000 2 servo 5000 delay
button_lcd if sequence_lcd endif
return

sub sequence_lcd
8000 3 servo 200 delay
4000 2 servo 9000 delay
0 3 servo 500 delay
0 2 servo 800 delay
4000 0 servo 500 delay
4000 1 servo 800 delay
0 0 servo 500 delay
0 1 servo 500 delay
return


# ################################################    DOWN MOVEMENT   ###################################################

sub sequence_dwn						
8000 0 servo 500 delay
8000 1 servo 800 delay
button_lift if sequence_lift1 endif
button_lift0 if sequence_lift0 endif
return

sub sequence_lift0						# CHECKS IF LIFT IS AT THE MAXIMUM POSITION IF NOT IT WILL MOVE TO UPPER POSITION TO ENGAGE SWITCH
8000 17 servo 500 delay
return

sub sequence_lift1
button_lcd1 if sequence_lcd1 endif
return


sub sequence_lcd1
8000 3 servo 500 delay
4000 2 servo 5000 delay
5 3 speed
5 2 speed
4000 3 servo 200 delay
8000 2 servo 9000 delay
button_lcd if sequence_lcd2 endif
sub sequence_lcd2
button_lift if sequence_lift2 endif
return


sub sequence_lift2
4000 17 servo 10000 delay
0 3 servo 500 delay
0 2 servo 5000 delay
4000 0 servo 500 delay
4000 1 servo 800 delay
0 0 servo 500 delay
0 1 servo 500 delay
drop
return

Hello.

I looked at your code briefly and noticed that you are missing a return command at the end of your sequence_lcd1 subroutine, which is probably contributing to your loop issue.

If you continue to have trouble with your script, I recommend that you try to simplify your script to the simplest thing that should work but does not, and post it here along with a description of what you expect the code to do and what the code is actually doing.

By the way, you might find the “Step Script” button in the “Script” tab of the Maestro Control Center helpful for debugging and understanding how the code works.

- Amanda