Code example for Sonar (distance sensor)?

Discussion in 'Assembly Language Programming (ALP) Forum' started by mark_76, May 31, 2009.

  1. mark_76

    mark_76 New Member

    May 31, 2009
    Likes Received:
    Trophy Points:
    0 EZ0 sensor

    Above is a simple distance sensor I bought.
    I want to turn on LED's for a distance to a wall warning device.

    RED = stop!
    Amber = Warning prepare to stop
    Green = ok to drive

    I will simulate using a Dragon 12+ plus microcontroller board and debug 12.

    I need code for this in Assembler language.

    Once I have it I want to consider sounds such that:
    RED led = constant warning chime
    Yellow = slow beep
    Green = no beep
    Flashing red LED = you are closer than 1.0 feet to a wall and are about to hit.

    I will use the AN analog o/p of the maxbotix sensor.
    The device turns out a voltage corresponding to the distance.

    So, when you are at 5 feet or greater from a wall we should turn on a green LED.

    If we are at 2.5 to 4.9 feet we should turn on a Yellow led.

    If we are at 2.4 feet to 1.5 feet = red.

    I have the idea that anything under 1.4 to 0 feet should flash a red led!!!

    I have no clue in ASL programming. Please send what you would do and that alt least gives me a start. I have my own scopes, and DMM's at home and bought this Dragon12+plus board on the internet as a hobby. The guy who sold it to me said a user of ASL could do this in .5 hour.
    So for me maybe a Week?? I have not a clue!

    Please do not send me comments like: Do it yourself "b%#head".

    This is a simulation I am doing. The next step I actually want to implement it. I have an old art deco stop lamp and was going to install it in my garage. That is not in the scope of my initial ide here.
    Please advise.
  2. xpi0t0s

    xpi0t0s Mentor

    Aug 6, 2004
    Likes Received:
    Trophy Points:
    Senior Support Engineer
    > Please send what you would do

    OK. I've recently started playing with's PIC devices, and so I started with a couple of basic modules - the Vellemann K8048 and another one; quickly outgrew those and now have a MikroElektronika board (LV24-33a).

    I've done a shedload of RTFM and toying with simple programs, flashing LEDs, writing to the LCD, interfacing with external boards.

    As I'm multiplexing this along with a full time job and a load of other hobbies it's taking time, but I'm getting there.

    Other things I would need to do if I were tackling your project would be to familiarise myself with the analog sampling of the Dragon, e.g. by hooking up a simple variable resistor to the input pin, twiddling the knob and seeing what the results are. Then the output signal of the sensor needs looking at, will it need amplifying and that sort of stuff. See what the sensor outputs for the distances you've specified and if you can match a reading from what is presumably an ADC to those value.

    > Please do not send me comments like: Do it yourself "b%#head".

    Well, I've tried to be a bit more helpful than that but what's the point of someone else doing it for you?

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice