Multiple commands at the same time
amazingprogrammer
Posts: 1
So I'm new to the PBasic editor. I was wondering if I could run multiple programs or commands at the same time on the stamp. For example: In my class we have to make an LED light show and music is optional. What I would like to do is have a song playing during the light show. Here's an example of what I would like:
GOTO song [Also] GOTO lights
song:
freqout pin, duration, frequency
code
code
etc.
GOTO song
lights:
HIGH 1
PAUSE 250
LOW 1
HIGH 2
HIGH 3
PAUSE 1000
Etc.
GOTO lights
This is just an idea of what I want. Is it even possible to have multiple commands going at once? If there is, I would appreciate it if you would tell me the correct syntax. Thanks in advance.
GOTO song [Also] GOTO lights
song:
freqout pin, duration, frequency
code
code
etc.
GOTO song
lights:
HIGH 1
PAUSE 250
LOW 1
HIGH 2
HIGH 3
PAUSE 1000
Etc.
GOTO lights
This is just an idea of what I want. Is it even possible to have multiple commands going at once? If there is, I would appreciate it if you would tell me the correct syntax. Thanks in advance.
Comments
However, sometimes you can make it seem like it is doing multiple things at a time by multiplexing, that is doing several things after each other repeatedly and doing them fast enough so it seems they happen at the same time.
Instead of PAUSE 250 you could play a short tone. You can play a long tone instead of PAUSE 1000 or play several.
Do you have a copy of the BASIC Stamp Reference Manual or What's a Microcontroller?
Chapter 8 of What's a Microcontroller is on sounds and music.
Look up the RANDOM command.
You can find BS2 command online here:
http://www.parallax.com/go/PBASICHelp/