Shop OBEX P1 Docs P2 Docs Learn Events
bs1 to sx code — Parallax Forums

bs1 to sx code

Blackbird455Blackbird455 Posts: 124
edited 2007-07-15 11:45 in General Discussion
Can someone help me convert this code from BS1 to SX?:



' {$STAMP BS1}
' {$PBASIC 1.0}

SYMBOL· reps··· = W1··················· ' FOR...NEXT loop counter
Main:
FOR reps = 0 TO 65535 STEP 3000······ ' each loop add 3000
HIGH 1
PAUSE 40
LOW 1
PAUSE 40
HIGH 1
PAUSE 40
LOW 1
PAUSE 40
HIGH 1
PAUSE 40
LOW 1
PAUSE 40
HIGH 1
PAUSE 40
LOW 1
HIGH 7
PAUSE 40
LOW 7
PAUSE 40
HIGH 7
PAUSE 40
LOW 7
PAUSE 40
HIGH 7
PAUSE 40
LOW 7
PAUSE 40
HIGH 7
PAUSE 40
LOW 7
NEXT·

Comments

  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-07-05 19:15
    While it's not the most efficient use of SX code space, you can translate almost directly. I've attached your code that runs on the SX28.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2007-07-05 19:49
    How about this:
    For reps=0 to 65535 step 3000
    For x=0 to 3
    high 1
    pause 40
    low 1
    next
    For x=0 to 7
    high 7
    pause 40
    low 7
    Next
    Next

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


    My last words shall be - "NOT YET!!!"
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-07-05 19:56
    That doesn't work, Shawn, because you don't have any delay time between the LOW pin and HIGH pin commands when running in the x loops -- the output will not flash as intended because it would be for for mere microseconds when running on an SX.

    Your approach, however, is sound and I've uploaded a "more professional" version of that program that encapsulates PAUSE in a subroutine to save code space.

    Post Edited (JonnyMac) : 7/5/2007 8:03:59 PM GMT
  • Blackbird455Blackbird455 Posts: 124
    edited 2007-07-15 05:13
    Ok I know this is off topic kinda, is there a more efficient way to write this code for the bs1? I am self taught, so I know very little, yet enough to get it done.
  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-07-15 11:45
    You should post your specific question in the BASIC Stamp forum.
Sign In or Register to comment.