Shop OBEX P1 Docs P2 Docs Learn Events
Scribbler 1 Following Routine — Parallax Forums

Scribbler 1 Following Routine

ercoerco Posts: 20,255
edited 2014-12-20 13:27 in Robotics
I was PM'ed asking how to get Scribblers to follow each other as shown at https://www.youtube.com/watch?v=seQXPRXzHtQ . The simplest code to follow a slow-moving white target (or your hand) is sinfully simple:
' {$STAMP BS2}
 ' {$PBASIC 2.5}
 PAUSE 500
 DO
 FREQOUT 14, 1, 38500 ' send right IR pulse
 B0=IN6
 IF B0=0 THEN PULSOUT 12, 2000 ELSE PULSOUT 12, 2400
 FREQOUT 15, 1, 38500 ' send left IR pulse
 B0=IN6
 IF B0=0 THEN PULSOUT 13, 2000 ELSE PULSOUT 13, 2400
 PAUSE 50
 LOOP

Comments

  • ElectrodudeElectrodude Posts: 1,644
    edited 2014-12-17 12:19
    I haven't programmed a Stamp in a while, but why is the
    B0=IN6
    IF B0=0 THEN
    
    necessary? What's wrong with
    IF IN6=0 THEN
    
    ?
  • ercoerco Posts: 20,255
    edited 2014-12-17 16:55
    Right you are, Electrodude! Good catch, the code can be condensed exactly as you suggest.

    TTYTT, the code I posted was hastily edited from longer code which had some additional IF checks to switch on the green LEDs, as shown in the video. I stored the value of IN6 in case it changed between IF checks.
  • WhitWhit Posts: 4,191
    edited 2014-12-19 06:39
    erco - Brilliant and simple as always Pal! Thanks for posting this.
  • ercoerco Posts: 20,255
    edited 2014-12-20 13:27
    Old Blue is still plenty capable, ands I have a few more S1 tricks up my sleeve. It can do anything a Boebot can.
Sign In or Register to comment.