Shop OBEX P1 Docs P2 Docs Learn Events
Need help again. — Parallax Forums

Need help again.

meburnemeburne Posts: 5
edited 2007-05-28 16:17 in Robotics
If this is not the right fourm please provide the best fourm to use.

I am new to Basic Stamp and have been playing with·a Boe Bot.

I can get it to move forward and back and turn. I can also get an LED to flash.

Now what I want·is to·start the led flashing·at the·begining of·movement commands and then stop it at the end of all the movement commands.

I have read about if statements do - loop statements but I don't think that is where I need to be.

Any help would be great.

·Cheers Mark

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-28 14:55
    That's actually a bit complicated because the Stamp strictly speaking can only do one thing at a time (It's a "single threaded" processor). There's no direct way to start an LED to flashing, go do something else, then come back and stop the LED. Typically, this sort of thing is done by making use of the fact that controlling a servo (or several servos) leaves some processing time in-between when the servo pulses have to be "issued".

    Basically, servos need a pulse about every 20ms and the width of the pulse (0.5-2.5ms max) controls the direction and speed or the position of the servo. Typically, a Stamp program sits in a loop and every (roughly) 20ms, it puts out a pulse for each servo, reads its sensors, and decides how it's going to move on the next 20ms cycle. You could add a little bit of code to each cycle that decides whether the LED needs to be on or off for that cycle (maybe stays on for 10-20 cycles, then off for 10-20 cycles to give a blink rate of 1/2 to 1 second). You'll need a counter that gets incremented on each cycle and a subroutine to do the bookkeeping.
  • meburnemeburne Posts: 5
    edited 2007-05-28 15:48
    Thanks Mike.

    Sounds possible but not at this point for me. (my level).

    Now that I know it is a single thread I see things a bit differantly, and thats ok. Lots to learn and having fun.

    Do you know of any online training classes to help with programing or am I better to just keep creating challanges and try to solve them.

    Thanks for the help and I am sure we will talk again.

    Mark
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-28 16:17
    The Stamps in Class tutorials (downloadable here: www.parallax.com/html_pages/downloads/siccurriculum/documentation_sic_curriculum.asp) have lots of examples and exercises to do. Also have a look at the Nuts and Volts columns for ideas (here: www.parallax.com/html_pages/downloads/nvcolumns/Nuts_Volts_Downloads.asp).

    There aren't any on-line courses that I've heard of, but there's a tremendous amount of educational material on the Stamps available, mostly from Parallax for free in downloadable form (and inexpensively in paper form).

    Also check out Tracy Allen's website: www.emesystems.com.
Sign In or Register to comment.