Hexapod
Code listing: "Robo-Push ups"
Here is an OOPic program to make a Lynxmotion's Hexapod do Push-Ups. It uses an array of 6 oServo Objects.
Dim Leg(6) As New oServo   'Make 6 oServos Objects named Leg(1) - Leg(6) 
Dim x As New oByte         'Make a oByte Object 
Const Up = 63              'Set up a constant value called "UP" 
Const Down = 0             'Set up a constant value called "Down" 

Sub Main() 
 Call Setup                'Go do the "Setup" routine 
 Do                        'Set up a loop 
  Call GetUp               'Go do the "GetUp" routine 
  Call Delay               'Go do the "Delay" routine 
  Call LayDown             'Go do the "LayDown" routine 
  Call Delay               'Go do the "Delay" routine 
 Loop                      'Go back to the "Do" command. 
End Sub 

Sub GetUp() 
 For x = 1 to 6 
  Leg(x) = Up              'Position each servo to the "Up" location 
 Next x 
End Sub 

Sub LayDown() 
 For x = 1 to 6 
  Leg(x) = Down            'Position each servo to the "Down" location 
 Next x 
End Sub 

Sub Delay() 
 For x = 0 to 254 
  x = x                    'Just waistin' time. 
 Next x 
End Sub 

Sub SetUp() 
 Leg(2).InvertOut = cvTrue 'The servos on the right side 
 Leg(4).InvertOut = cvTrue ' need to turn in reverse. 
 Leg(6).InvertOut = cvTrue 
 Leg(1).Center = 18        'Adjust the servo center for 
 Leg(2).Center = 18        ' mechanical differences in each servo. 
 Leg(3).Center = 18        'Note: These will need to be 
 Leg(4).Center = 18        ' customized for each robot. 
 Leg(5).Center = 18 
 Leg(6).Center = 18 
 For x = 1 to 6 
  Leg(x).IOLine = 15 + x   'Connect the servos to I/O Lines. 
  Leg(x).Operate = cvTrue  'Turn the servos on. 
 Next x 
End Sub 

Home   Send mail and comments to: Savage Innovations.