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

code help

Special_KSpecial_K Posts: 162
edited 2006-02-21 04:12 in BASIC Stamp
I have this little bit of code that swings the Parallax Ping))) sonar to several positions using the servo in the Ping))) mounting kit. The sonar distance is logged in centimeters for each of the 5 positions and is displayed in the debug console. If I get the cm value as part of the main program it displays fine, however if I get the cm value as part of the subroutine all the values are the same as the first reading. I need some help.

Also I was wondering if any one had a link to documentation about the select case statement. I have the Boe-Bot manual and I just need a little more in depth explanation. I·am looking·to use the case statement to get the longest distance.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-21 01:20
    Is the piece of code you posted the non-working version?· Have you seen this piece of code?

    http://www.parallax.com/dl/src/prod/RoamingWithPING-V1.0.bs2

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Special_KSpecial_K Posts: 162
    edited 2006-02-21 01:59
    this is the code that does not work.
    I took a look at that code but I am nout shure I can really use it since I am using Sharp GP2D02 IR Rangers. Or should I use that code as a base and not try to reinvent the wheel.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-21 02:41
    Okay well I guess we're both in trouble since your message above says...
    Special_K said...(trimmed)
    I have this little bit of code that swings the Parallax Ping))) sonar to several positions using the servo in the Ping))) mounting kit. The sonar distance is logged in centimeters for each of the 5 positions and is displayed in the debug console. If I get the cm value as part of the main program it displays fine, however if I get the cm value as part of the subroutine all the values are the same as the first reading. I need some help.

    You did not mention this above...It is now unclear to me exactly what you are using.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Special_KSpecial_K Posts: 162
    edited 2006-02-21 03:34
    Ok let me start from the beginning. I am looking to have the Boe-Bot· roam using IR and Sonar. The IR sensors I am using are the Sharp GP2D02 IR Rangers. I am looking to have the robot roam and collect side distances via the Sharp GP2D02 IR Rangers. If the IR detects an object within a certain distance the measurement is checked by the Ping))) since the Sharp GP2D02 IR Rangers can give an error of a long distances if an object is closer than 4 inches. The Boe-Bot will make corrections and keep roaming. End result will be to solve a maze
    ·
    I have broken the project into smaller sections. The first is a right and left sweep with the Ping))) and logging the longest distance. The problem I am having is that the distances in the debug window are all the same as the first reading that the Ping))) takes.
    I am using the debug display to see the distances and I only see the same number displayed for distances of 5 direction when I know they are different.
  • Special_KSpecial_K Posts: 162
    edited 2006-02-21 04:12
    Found the code error. I users
    pos1 with all the debugs.
    fixed that and I am getting the right values.
    Now on to the distance checks any thoughts. I really do not want to use a lot of IF..THEN statements
Sign In or Register to comment.