Shop OBEX P1 Docs P2 Docs Learn Events
basic stamp problem — Parallax Forums

basic stamp problem

patwinpatwin Posts: 1
edited 2013-11-20 09:05 in BASIC Stamp
how to combine these 2 programs into one

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-11-18 07:43
    You can't just combine complex programs like these. What you do is add some of the functionality of one program to the other using the first program as a model. Depending on what you're trying to do, this might work or it might not.

    It looks like the first program controls a robot's movement based on readings from an IR distance sensor that produces an analog voltage based on the distance measured. The second program reads some kind of IR remote signal consisting of 5 pulses, decodes the pulses, and signals a servo controller based on the received signal from the remote control.

    First of all, combining the two functions may not work well. The Stamps do only one thing at a time. If you combine two functions, they're done one at a time. When the second program is reading the remote control signal, it's ignoring the distance measurements. When it's processing the distance measurements, it's not listening for remote control signals. That may not be acceptable.

    Start with getting the variable and constant names used in the two programs so that there are no duplicates except where that's intended (like Sdat, Baud, and ra), then add all the variables and constants definitions from one program (say IR for Arm) to the other (boustrophedon).

    Next step is to look at boustrophedon. Notice that there's a DO / LOOP loop that is the main cycle that reads the distance, makes a decision, and changes the servo settings based on the distance reading. You might try putting the 5 PULSIN statements just before the first GOSUB in the loop and see what values you get when you send a remote control signal to it.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-11-20 09:05
    Here are 2 YouTube videos that will hopefully help you with this task:

    http://www.youtube.com/watch?v=Xgue6nWtUfs

    http://www.youtube.com/watch?v=mkTi6IDIHik
Sign In or Register to comment.