Micro Maestro - 1 input impacts 4 servo's

Brandon See below code after the ## . Will this code work where 1 analog input controls all 4 wheels on a RC Truck. Its ok if front and back move up and down together

# Set the servo to 4000, 6000, or 8000 depending on an analog input, with hysteresis.
begin
  4000 0 433 servo_range
  6000 0 433 servo_range
  8000 0 433 servo_range
repeat
 
# usage: <pos> <low> <high> servo_range
# If the pot is in the range specified by low and high,
# keeps servo 0 at pos until the pot moves out of this
# range, with hysteresis.
sub servo_range
  pot 2 pick less_than logical_not    # >= low
  pot 2 pick greater_than logical_not # <= high
  logical_and
  if
    begin
      pot 2 pick 10 minus less_than logical_not   # >= low - 10
      pot 2 pick 10 plus greater_than logical_not # <= high + 10
      logical_and

## Brandon Supplied Code - Does this code use ch1 as input Then uses ch1 input to control (servo1 through servo4)??------ 
while
      2 pick dup 0 servo #add 'dup' here to duplicate the target position before setting servo channel 1

      dup 2 servo #duplicate the target value and set servo channel 2 to the same position
      dup 3 servo #duplicate the target value and set servo channel 3 to the same position
      4 servo #set servo channel 4 to the duplicated position

    repeat
	
## Question for Brandon = Will this work ion a 4 wheel RC Truck with 4 wheels LR wheel RR wheel LF wheel RF wheel- ----------------------------------- 
  
  endif
  drop drop drop
  return
 
sub pot
  1 get_position
  return
1 Like

A post was merged into an existing topic: Maestro