Shop OBEX P1 Docs P2 Docs Learn Events
Will this code work in a BS1 — Parallax Forums

Will this code work in a BS1

studiomagic1studiomagic1 Posts: 25
edited 2009-06-03 20:58 in BASIC Stamp
counter VAR Word

' ' '' ' '' ' ' before eyes move dead pin for 30 second delay ' ' '' ' '' ' '' ' '
FOR counter = 1 TO 20
PULSOUT 13, 690
·PAUSE 5
·PULSOUT 12, 415
·PAUSE 5
·NEXT
GOTO Main:
Main:
DO
IF IN2 = 1 THEN
GOTO Blink1:
ENDIF
IF IN4 = 1 THEN·
GOTO Blink2:
ENDIF
IF IN1 = 1 THEN
GOTO Blink3:
ENDIF

LOOP
' ' '' ' '' ' 'pushbutton ' '' ' '' ' '' ' '
· Blink2:

FOR counter = 1 TO 10
PULSOUT 13, 690
·PAUSE 15
·PULSOUT 12, 415
·PAUSE 15
·NEXT

·FOR counter = 1 TO 15
·PULSOUT 13, 300
·PAUSE 14
·PULSOUT 12, 840
·PAUSE 14
NEXT
GOTO Main:


··· Blink1:·· ''''''Starting routine
··· PAUSE 20000
FOR counter = 1 TO 15
·PULSOUT 13, 300
·PAUSE 10
·PULSOUT 12, 840
·PAUSE 8
NEXT
PAUSE 2000
FOR counter = 1 TO 10
PULSOUT 13, 690
·PAUSE 10
·PULSOUT 12, 415
·PAUSE 10
·NEXT
·FOR counter = 1 TO 15
·PULSOUT 13, 300
·PAUSE 10
·PULSOUT 12, 840
·PAUSE 10
NEXT
FOR counter = 1 TO 15
PULSOUT 13, 690
·PAUSE 10
·PULSOUT 12, 415
·PAUSE 10
·NEXT
· FOR counter = 1 TO 15
·PULSOUT 13, 300
·PAUSE 20
·PULSOUT 12, 840
·PAUSE 20
NEXT
·PAUSE 2500
FOR counter = 1 TO 15
PULSOUT 13, 690
·PAUSE 8
·PULSOUT 12, 415
·PAUSE 8
·NEXT
·FOR counter = 1 TO 10
·PULSOUT 13, 375
·PAUSE 7
·PULSOUT 12, 840
·PAUSE 9
NEXT
GOTO Main:


Blink3: ''''''ending
·PAUSE 5000
·FOR counter = 1 TO 20
PULSOUT 13, 690
·PAUSE 5
·PULSOUT 12, 415
·PAUSE 5
·NEXT
·PAUSE 10000
·FOR counter = 1 TO 10
·PULSOUT 13, 300
·PAUSE 10
·PULSOUT 12, 840
·PAUSE 5
NEXT
·PAUSE 3000
· FOR counter = 1 TO 20
PULSOUT 13, 690
·PAUSE 5
·PULSOUT 12, 415
·PAUSE 5
·NEXT
·PAUSE 4000
FOR counter = 1 TO 10
·PULSOUT 12, 840
·PAUSE 15
·NEXT
·PAUSE 1000
·FOR counter = 1 TO 15
·PULSOUT 12, 415
·PAUSE 20
·NEXT
·PAUSE 4000
FOR counter = 1 TO 10
PULSOUT 13, 300
·PAUSE 15
·NEXT
·PAUSE 1000
·FOR counter = 1 TO 15
·PULSOUT 13, 690
·PAUSE 20
·NEXT
·PAUSE 4000
·FOR counter = 1 TO 10
·PULSOUT 13, 300
·PAUSE 10
·PULSOUT 12, 840
·PAUSE 5
NEXT
PAUSE 5000
· FOR counter = 1 TO 20
PULSOUT 13, 690
·PAUSE 5
·PULSOUT 12, 415
·PAUSE 5
·NEXT
·PAUSE 4000
·FOR counter = 1 TO 15
·PULSOUT 13, 300
·PAUSE 10
·PULSOUT 12, 840
·PAUSE 8
NEXT
PAUSE 3000
FOR counter = 1 TO 15
·PULSOUT 13, 690
·PAUSE 5
·NEXT
PAUSE 500
·FOR counter = 1 TO 10
PULSOUT 13, 300
·PAUSE 5
·NEXT
PAUSE 2000
·FOR counter = 1 TO 10
PULSOUT 13, 690
·PAUSE 15
·PULSOUT 12, 415
·PAUSE 15
·NEXT

·FOR counter = 1 TO 15
·PULSOUT 13, 300
·PAUSE 14
·PULSOUT 12, 840
·PAUSE 14
NEXT
FOR counter = 1 TO 10
PULSOUT 13, 690
·PAUSE 15
·PULSOUT 12, 415
·PAUSE 15
·NEXT
·GOTO Main:

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-03 01:22
    I don't think the program will fit into the BS1's memory which is quite small. It may be possible to use subroutines or DATA / READ statements to make the program table driven and shorten it that way. I do see a lot of movements that repeat, so you may be able to simplify the program by making movements more uniform, then making them into a few subroutines. Most of your loops should be of the form:
    for counter = 1 to <limit>
    PULSOUT 13,<width1>
    PULSOUT 12,<width2>
    PAUSE 20
    NEXT
    


    You can produce both servo pulses, one after the other, then pause for 20ms so you get around 50 pulses per second.

    The BS1 does have a relatively small limit on the number of GOSUBs allowed.· Check the·manual for that.· It may be a limiting factor as well as memory size.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2009-06-03 20:58
    Check out EFX-TEk.com . They have alot of BS1 programming examples. Like this:

    http://www.efx-tek.com/downloads/prop-1_programming_basics.pdf

    Also the BS1 doesn't support DO..Loop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Shawn Lowe


    When all else fails.....procrastinate!
Sign In or Register to comment.