Shop OBEX P1 Docs P2 Docs Learn Events
Serious code help — Parallax Forums

Serious code help

joey146joey146 Posts: 4
edited 2008-01-25 20:52 in BASIC Stamp
please someone help me.

i have science fair due Saturday morning, and i have no idea what im doing.

i have a BASIC stamp discovery kit.

i have assembled the speaker and the ping ultrasonic sensor.

i need helping making an "if then" code.

i need my speaker to go off when my sensors recognize something within two feet.

pleaseeee help me

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-25 00:48
    You have a lot of work to do in a day or so.

    1) You need to get the sample programs to work with your PING))) so you can see on the debug screen the distance detected by the PING))).

    2) You need to get the speaker to "go off" based on the sample code in the manual in the discovery kit.

    3) In the PING))) sample program, you use an IF statement like "IF distance > 2000 THEN" or something like that and follow that with the other code from the sample program for the speaker that makes it "go off" and you'll need an "ENDIF" after the noisemaking code.

    We won't write the program for you, but will be happy to help you over rough spots and places where you don't understand what the manual says.

    You really have to work through the examples in the discovery kit to understand what you're doing.
  • JedJed Posts: 107
    edited 2008-01-25 01:29
    Look on the product page for the PING))) Ultrasonic sensor. There are example codes there you can download.
  • joey146joey146 Posts: 4
    edited 2008-01-25 03:10
    in what part of the code do i put the IF THEN statement?

    and thank you very much
  • FranklinFranklin Posts: 4,747
    edited 2008-01-25 03:21
    Joey, go to your other post and delete is. Click the red X in the upper right of the blue box.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-25 05:23
    joey146,
    You need to figure out how the sample code works. If you don't understand where you will need to put the IF THEN, you need to study what the PING))) sample program (PING_Demo.bs2) does and it should become clear.
  • joey146joey146 Posts: 4
    edited 2008-01-25 13:34
    i have the Ping code working, i just do not understand whether to put the IFTHEN above or below the code. and when i put the IFTHEN in, what speaker code to use
  • JedJed Posts: 107
    edited 2008-01-25 15:22
    Try this, page 81 - for IF/THEN/ELSE read the section titled: "Programming Pushbutton Control":
    www.parallax.com/Portals/0/Downloads/docs/books/edu/Wamv2_2.pdf

    For speaker control code start reading on page 219.

    Post Edited (Jed) : 1/25/2008 4:36:14 PM GMT
  • joey146joey146 Posts: 4
    edited 2008-01-25 20:52
    thanks everyone, i got it figured out (:
Sign In or Register to comment.