'Goldfish for Picaxe 08m 'Servo on pin4. symbol cycle = b0 'define variable for swim loop symbol direction = b1 'variable for servo position. servo 4,150 'initialise the servo pause 500 main: direction = 150 'set the servo position value. picaxe uses between 75 - 225 gosub swim 'swim subroutine pause 2000 'pause for 2 seconds direction = 85 gosub swim pause 3000 gosub swim direction = 200 gosub swim pause 1500 direction = 110 gosub swim pause 4000 goto main 'start again 'this subroutine gives the goldfish it's swimming movement by adding and then subtracting from the current servo position 'so that the tail moves from side to side. swim: for cycle = 0 to 30 'initialise the for/next loop direction = direction + 9 'add 9 to the current servo position servopos 4,direction 'move the servo pause 150 direction = direction - 9 'minus 9 from the current position. servopos 4,direction pause 150 next cycle 'do it again 30 times. return