Welding the parts together? Interesting…
I’m sorry about the code, it is quite confusing but I learnt a lot about programming from the first kit I purchased from Lynxmotion - the Biped BRAT.
I just went through the Basic Micro syntax manual and they give you a list of the different commands with some examples (the manual can be downloaded from the Basic Micro website). I’ll try to explain some of the code so that it makes some sense :mrgreen: :
[code]main
command = 5
gosub move
pause 2500
command = 2
for xx = 1 to 3
gosub move
next[/code]
The command “main” means that you are now in the main part of the code where you will have all the commands. The part where it says “command = 5” just means that it is executing the command number 5 (which I’ll talk about in a minute) and then the “gosub move” gets the data (which in this case are angles) from command number 5 and does them. You can probably guess the “pause” command means wait for a specified amount of time which in this case is 2500ms or 2.5s.
The part where it says “for xx = 1 to 3” simply means repeat command number 2, 3 times (so xx = 1 to 5 would mean repeat the command 5 times).
move:
if(command = 1) then ;WALK FORWARDS
;First Step - Top Right and Bottom Left
hservo [p0\2000\200,p1\3000\200,p2\3000\200,p3\-2000\200,p4\0,p5\0,p6\-2000\200,p7\0,p8\0,p9\2000\200,p10\-3000\200,p11\-3000\200,p12\1500\200,p13\6500\50]
pause 175
hservo [p0\4000\200,p1\3000\200,p2\3000\200,p3\-2000\200,p4\0,p5\0,p6\-2000\200,p7\0,p8\0,p9\-4000\200,p10\-3000\200,p11\-3000\200,p12\-1500\200,p13\6500\50]
pause 175
hservo [p0\4000\200,p1\1000\200,p2\0,p3\-2000\200,p4\0,p5\0,p6\-2000\200,p7\0,p8\0,p9\-4000\200,p10\-1000\200,p11\0,p12\1500\200,p13\6500\50]
pause 50
The command “move” just means that you are moving with respect to these angles. Also, anything text with a semi-colon (
before it means that it is just text and it won’t affect the code (sort of like a memo or a note). The part where it says “if(command = 1) then” just allows the IC to know what to do when that command is called. The command “hservo” tells the IC that you are now dealing with servos. You then have to check which servos are connected to what pins and then type in the number of degrees that you want it to turn (e.g. if a servo connected to pin 0 (p0) was to be turned by 35 degrees, then you would type in the following line of code:
hservo [p0\3500\200]
- the first number is the angle and the second is the speed (how fast you want it to rotate). As for all the brackets ] and and the \, they are just syntax things so you just have to stick them in where required. For a negative angle, you just stick a - sign in front of the angle). That’s the basics more or less for a very simple level of programming!
I hope this was helpful (and didn’t confuse you too much)! 