All,
I can’t figure out why this code works great while I have it connected to the Maestro control center and flat out doesn’t work except for the 1st subroutine when it is disconnected from control center.
The servo motor will “jerk” for a quick second while my had is over the IR sensor and the program will return to the main loop. All sensors, switches and servos function properly when manually toggled in the control center. I’m using the 6 channel micro Maestro with the following code:
#0 Servo :Door Servo
#1 Input :Lower Micro Switch
#2 Input :Upper Micro Switch
#3 Input :Inside IR Sensor
#4 Input :Outside IR Sensor
### Main Sequence ###
6000 0 servo
Main:
Begin
3 get_position #Monitor inside IR sensor for activity
360 greater_than #Open door if IR sensor is made
If
Open_Door
Stop_Motor
2000 delay
Close_Door
Stop_Motor
Endif
4 get_position #Monitor outside IR sensor for activity
360 greater_than #Open door if IR sensor is made
If
Open_Door
Stop_Motor
2000 delay
Close_Door
Stop_Motor
Endif
Repeat
Quit
#----------------Subroutines-----------------#
# Open Door
sub Open_Door
8000 0 servo #Rotates motor Clock Wise (opens door)
50 delay
begin
2 get_position #Check if upper switch is made
100 delay
40 less_than
If
return
Endif
repeat
return
# Close Door
sub Close_Door
5000 0 servo #Rotates motor Counter Clock Wise (lowers door)
50 delay
begin
1 get_position #Check if lower switch is made
100 delay
40 less_than
If
return
Endif
repeat
return
# Stop Motor
sub Stop_Motor
50 delay
6000 0 servo #Stops motor
return
Settings Advanced pulse control:
servos avaliable: 6
Period (ms): 32
UART fixed baud rate = 9600
Please any help would be much appreciated! Thanks!
-Jp-