Shop OBEX P1 Docs P2 Docs Learn Events
BS2e Help lost code — Parallax Forums

BS2e Help lost code

Rutcgr18Rutcgr18 Posts: 47
edited 2005-10-27 20:37 in BASIC Stamp
I am working on a project.· I am a vol firemen and i am trying to use hte BS2e to be my flash pack for my leds that i am making.· My only problem is that i had wrote some code for the BS2e and my hd crashed and lost the code i need to some how get it from the stamp.· I also need to figure out how to have one have a mometary swith on it so when i hit it it changes flash patterns.· Any help would be great.· I wrote most of the code in binary so i could flash more than one pin at a time.· Is there and easier way?
Thanks
Mike

Comments

  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 03:34
    so from what i read i have pretty much lost the code.· Well can someone give me some sample code for flashing pins 1 or more at a time and easy way?
    thanks
    mike
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 03:37
    Download our "StampWorks" book and look at the experiment having to do with simple lighting control (LEDs are used at the output) -- this is just the ticket for what you're wanting to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 03:48
    i will take a look
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 04:23
    can you show me the code in binary to turn on pins 0-3 and i did not use the flash pattern. And give you give me the differnt wasy that ican flash the leds. I really wish i had my other code.
    mike
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 04:40
    I'm a better code writer than mind reader, and since you didn't give me very much information I'm hoping this is what you want.

    Reset:
    · DIRA = %1111

    Main:
    · FOR OUTA = %0000 TO %1111
    ··· PAUSE 1000
    · NEXT
    · GOTO Main

    This displays binary values, %0000 to %1111 on P0..P3, with a one-second delay between changes.· If this isn't what you're looking for then you'll have to be much more SPECIFIC, going so far as to spelling out the sequence you want, e.g.,

    1 - 0000
    2 - 1001
    3 - 0110
    -- back to #1

    As far as different ways to flash the LEDs, I suggested StampWorks earlier because it has an excellent example (even if I do say so myself) of presenting different patterns on LEDs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 10/27/2005 4:43:02 AM GMT
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 04:55
    I dont remeber using that command i jsut remeber the paus thing. But i think i had to set a delay and a pause. I htink i had it so i can tell it how long to keep the led on and how long to keep it off.
    I dont know what the command was bfore the binary
    %0000000001
    I think had something here not sure
    %0000000010

    basicly what ineed to do is i am trying to make flash patterns for these leds i have made for my car. so i will need to lets say flash pin 0 and pin 2 at the same time then flip to pin 1 and to pin 3. I dont knowif you are familer with strobe patterns on a police car. I am basicly making whats on the police cars and fire trucks. I jsut need to make the flash back with the BS2e
    Thanks
    Mike
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-10-27 05:14
    Thats easy, and he pretty much did it for you. You just have to tailor what he did to your situation.


    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    Led1          PIN     0                       ' Led1
    Led2          PIN     1                       ' Led2
    Led3          PIN     2                       ' Led3
    Led4          PIN     3                       ' Led4
    
    
    Main:
    
    DO
         LOW  Led2       'turns Led2 off
         LOW  Led4       'turns Led4 off
         HIGH Led1        'turns Led1 on
         HIGH Led3        'turns Led3 on
         PAUSE 2000      ' waits 2 seconds
    
         HIGH Led2         'turns Led2 on
         HIGH Led4         'turns Led4 on
         LOW  Led1         'turns Led1 off
         LOW  Led3         'turns Led3 off
         PAUSE 2000       ' waits 2 seconds
    
    LOOP                       'repeats untill BS2 is turned off.
    
    




    This is about as simple as it gets.

    Post Edited (BPM) : 10/27/2005 5:21:39 AM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 05:27
    Here's a very simple program I wrote that duplicates the pattern of a police light bar that I saw in my neighborhood near Dallas, TX.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 14:14
    ok thanks for that i am not sure what you have set up in that text. I dont understand the code. Whats this temp stuff. BPM But is that turn the two leds on at the same time?
    thanks
    mike
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 15:42
    If you'll take just a few minutes to study the program you'll see that I'm storing the pattern of the police lights in a table. By using a table and a small "engine" to drive the table the program is much more efficient and ultimately easier to update.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 15:52
    do you have any intro reading on the basic stamp?
    I am new to it all as you cant tell
    thanks
    mike
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 16:03
    TONS. My suggestion is that you download and read our "What's A Microcontroller?" book -- it's an easy read and will get your confidence in Stamp programming built in a very big hurry. About the time you're done with that StampWorks 2.0 (my book) will be out and you can use it to learn "pro" techniques to make your programs really fly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 16:18
    do you have a link for that. I went to the download section could not find it i jsut found the stampworks manual
    thanks
    mike
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 16:30
    On our web site you'll find a link for "Books" under "Products" -- here's the direct link to WAM:

    http://www.parallax.com/detail.asp?product_id=28123

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 16:47
    ok thanks i will get on that
    thank you
  • Rutcgr18Rutcgr18 Posts: 47
    edited 2005-10-27 18:54
    would thisw work so i could change form flash pattern to flash pattern
    FLASH:
    HIGH 0
    PAUSE 500
    LOW 0
    PAUSE 500
    HIGH 2
    PAUSE 500
    LOW 2

    HIGH 1
    PAUSE 500
    LOW 1
    HIGH 3
    PAUSE 500
    LOW 3
    IF IN5 = 0 THEN FLASH:
    IF IN5 = 1 THEN DOUBLE:


    Double:
    HIGH 0
    PAUSE 800
    LOW 0
    PAUSE 500
    HIGH 2
    PAUSE 800
    LOW 2

    HIGH 1
    PAUSE 800
    LOW 1
    HIGH 3
    PAUSE 800
    LOW 3
    IF IN5 = 0 THEN DOUBLE:
    IF IN5 = 1 THEN TRIPLE:

    Triple:
  • Clock LoopClock Loop Posts: 2,069
    edited 2005-10-27 20:37
    Rutcgr18 said...
    ok thanks for that i am not sure what you have set up in that text. I dont understand the code. Whats this temp stuff. BPM But is that turn the two leds on at the same time?
    thanks
    mike

    Yes, the best way to start understanding the stamp, is to hook it up and try it out.

    Definetly read the WAM... I would do that first before trying to program the BS2
Sign In or Register to comment.