[vcf-midatlantic] If anyone's interested: latest robot program

Evan Koblentz evan at vcfed.org
Sun Feb 19 20:41:29 EST 2017


Here is my new-and-improved Lego robotic forklift program. Special 
thanks this time to Paul Hagstrom for his helpful suggestion that I 
detect all the joystick direction options, save the active one to a 
variable, and then POKE once as needed vs. trying to detect/POKE after 
each possible case.


----------

  10  GOSUB 1000: REM  INIT LEGO
  20  POKE L,0: REM  ALL OFF
  30  GOSUB 2000: REM  NAVIGATION
  40  GOSUB 3000: REM  BUTTONS
  50  GOTO 30
  60  END
  1000 S = 7:L = 49280 + S * 16
  1010  POKE L + 3,1
  1020  POKE L + 2,63
  1030  POKE L + 1,0
  1040  POKE L,0
  1050  RETURN
  2000  REM  NAVIGATION
  2010 FB =  PDL (1):LR =  PDL (0)
  2020 M = 0
  2030  IF FB < 75 THEN M = 5
  2040  IF FB > 180 THEN M = 10
  2050  IF LR < 75 THEN M = 9
  2060  IF LR > 180 THEN M = 6
  2070  POKE L,M
  2080  IF M = 10 THEN  CALL  - 198: FOR W = 1 TO 500: NEXT W
  2090  RETURN
  3000  REM  FORLIFT
  3010  IF  PEEK (49249) > 127 THEN  POKE L,16: GOTO 3010
  3020  IF  PEEK (49250) > 127 THEN  POKE L,32: GOTO 3020
  3030  RETURN

Real simple: Lines 10-60 are the main program, 1000-1050 are the 
required Lego initialization, 2000-2090 are the robot control (front - 
back - left - right), and 3000-3030 make the forklift go up/down.

Hey Jeff and Dan, I think I've graduated from spaghetti code. :)

As I told Dan already, the next thing I'll add is a Lego sensor to 
prevent the forklift from trying to continue going up/down when it 
reaches its mechanical limit. This did not work on my previous robot (to 
detect the limits of rack-and-pinion steering and disable the relevant 
motor) because the motor moved too fast. Not a problem with the 
forklift: it intentionally moves veeeeeeeeeery slow.

I also ordered mini banana plugs so I can make new connecting wires 
between the Lego interface box and the motors, lights, and sensors. The 
30-year-old wires from Lego are badly worn out. The difference when I 
connected a motor using these old wires vs. using modern alligator clips 
was palpable.

Jeff B., all I have to do to dominate your Capsella robot is corner it, 
get the forklift under its drive wheels, and press the up button before 
you escape. :)

Then your robot will be (ahem) forked.

________________________________
Evan Koblentz, director
Vintage Computer Federation
a 501(c)3 educational non-profit

evan at vcfed.org
(646) 546-9999

www.vcfed.org
facebook.com/vcfederation
twitter.com/vcfederation



More information about the vcf-midatlantic mailing list