Shop OBEX P1 Docs P2 Docs Learn Events
Bstamp new student — Parallax Forums

Bstamp new student

student1student1 Posts: 3
edited 2009-02-02 05:42 in BASIC Stamp
· I am trying to write a simple program that will turn 3 different leds on and off at different times. the program should make the red led come on, flash a green led 5 times at 1 second intervals,flash a yellow led 10 times at .3 second intervalsand then turn off red led.

· i have the stamp working and am able to wink the leds but i can not figure out how to get them to function at··rates at the same time.
· please help
·

Comments

  • UghaUgha Posts: 543
    edited 2009-02-02 01:01
    Can you please attach the code you currently have so we can help you learn to correct it?

    Also do you have the LEDs connected through current limiting resistors?
  • SRLMSRLM Posts: 5,045
    edited 2009-02-02 01:18
    So you (potentially) want all three led's on at the same time? If so, this basically boils down to a math problem. Here's some psuedo code that should work

    counter VAR byte
    turn red led on

    While counter < 50
    if counter % 10 then toggle green led
    if counter % 3 and counter < 30 toggle yellow
    LOOP

    turn all leds off
  • student1student1 Posts: 3
    edited 2009-02-02 01:48
    yes i have resisters in place and i can turn the leds on and off. i can't figure out how to program stamp so each light will do something different at the same time
  • FranklinFranklin Posts: 4,747
    edited 2009-02-02 01:54
    As Ugha asked. Could you attach the code as you have it now? (use the attachment manager)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • student1student1 Posts: 3
    edited 2009-02-02 04:55
    this is the actual class question

    develop a flowchart that shows the following pseudo-code.

    1)start
    2)turn on the red LED
    3)flash the green LEDs 5 times at 1 second intervals.
    4)FLash the Yellow LED 10 times at 0.3 second intervals.
    5)turn off the red LED
    6)stop


    write the program to perform these functions

    I do not need help with the flow chart, but I don't have a clue how to write this program.

    HELP!!!
  • SRLMSRLM Posts: 5,045
    edited 2009-02-02 05:11
    So that's slightly different from what you posted. Instead of doing things simultaneously, you are doing them sequentially. What you need to figure out is

    a) How to turn an LED on/off
    b) How to keep time on the stamp

    For a), might I suggest that you look up the commands HIGH, LOW, and TOGGLE
    for b), take a look at PAUSE.

    You can look in the Basic Stamp Syntax and Reference Manual for specific commands, and take a look at What's a Microcontroller for general programming information, including information on how to work with LEDs.

    BTW, posting homework the night before it is due is almost a double sin...
  • EzsynnEzsynn Posts: 119
    edited 2009-02-02 05:42
    Read the Instruction Manuals that are downloadable from the Parallax website.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    BWIN ON DA POWAH WIFIN U!!!
Sign In or Register to comment.