Shop OBEX P1 Docs P2 Docs Learn Events
Making a digital level — Parallax Forums

Making a digital level

DietrichDietrich Posts: 5
edited 2008-01-16 03:57 in Learn with BlocklyProp
I was wondering if there was any information out there on making a digital level that would simply turn on an led light when it was level.· I know that this is probably an extremely easy project, but I have never tried any of these projects and was interested in making this level.

Thanks for the help

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-12-27 17:49
    Dietrich -

    Almost any solid state accelerometer can be used as a tilt sensor, which is essentially what you're looking for. They come in 1-axis, 2-axis and 3-axis models, so you can be level in more than one plane if you so choose. As I remember Parallax sells them in the Sensors section of their web site.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • DietrichDietrich Posts: 5
    edited 2007-12-27 18:41
    Bruce,

    I appreciate the help, I was wondering though if anyone had done this before because I don't know where to begin. I had the accelerometer figured out, but I don't know where to go for there. I was trying to find a good source of information on the subject and haven't really found one. Any additional help would be appreciated.

    Thanks,

    Dietrich
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-12-27 19:08
    Dietrich -

    I can only presume you didn't check the Parallax web site for such information. Below is a link to the Memsic Two Axis Accelerometer which Parallax sells. Along with the data sheet and other pertinent documents, you will also find sample programs. That should at least get you started.

    Here is the Parallax web site link:
    http://www.parallax.com/Store/Sensors/AccelerationTilt/tabid/172/CategoryID/47/List/0/Level/a/ProductID/93/Default.aspx?SortField=ProductName,ProductName

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • edited 2007-12-27 20:19
    Here is a link to the Smart Sensors and Applications kit page. When you get there, find the link to the full PDF version of the Smart Sensors and Applications text and download it. You'll find all the tilt measurement basics with the Memsic 2125 accelerometer in Chapter 3.

    http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/List/1/ProductID/418/Default.aspx?txtSearch=Smart+Sensors+and+Applications&SortField=ProductName%2cProductName

    You can probably modify the first example program in Chapter 3 (SimpleTilt.bs2) with an IF...THEN statement to get your project to work on one axis. For example, if you have an LED circuit connected to i/o pin P14 on the BASIC Stamp 2, you could simply add this IF...THEN statement:

    IF x > 2475 and x < 2525 THEN HIGH 14 ELSE LOW 14

    This will give you a level indicator light for the accelerometer's x-axis. You can add another LED circuit and a similar IF...THEN statement for the y-axis too.

    BTW, chapters 5 and 6 have lots more entertaining and useful Memsic 2125 accelerometer applications.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
  • DietrichDietrich Posts: 5
    edited 2007-12-27 20:34
    Andy,

    If I were to want to design this level and light system without the BASIC stamp module (for size purposes) how should I approach that. Is there some sort of processor that I would need to get, or simply some sort of relay that would read the output from the accelerometer. Again, I have never done any of this and am trying to gain a better understanding of how the system works.


    Thanks for all of the help.
  • edited 2007-12-28 00:52
    The SX chip is a smaller and less expensive processor with a programming language called SX/B that is similar to the BASIC Stamp's PBASIC programming language. Here is a link to the SX Tech Toolkit:

    http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/ProductID/364/List/1/Default.aspx?SortField=ProductName,ProductName

    For gaining an initial understanding of automating an invention with a processor and electronics, a good starting point for BASIC Stamps is the BASIC Stamp Activity Kit:

    http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/List/1/ProductID/313/Default.aspx?txtSearch=BASIC+Stamp+Activity+Kit&SortField=ProductName%2cProductName

    The BASIC Stamp Activity Kit has lots of examples on how to combine circuits with the BASIC Stamp Microcontroller and some programming to prototype products.· Hands-on examples that you get to try include: controlling LEDs indicator lights, monitoring pushbuttons, controlling servos, monitoring dials, making tones with speakers, simple LED digit displays, monitoring light sensors, controlling integrated circuits... It's also really nice to·get started, and it makes the SX Tech Toolkit more familiar territory.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 12/28/2007 1:00:51 AM GMT
  • DietrichDietrich Posts: 5
    edited 2008-01-16 00:42
    I got all of the stuff to do the program to make the digital level. I am trying to make the led light come on when the accelerometer is level, but I can't make the code work. It keeps telling me that it expects a label after the If Then statement. I am lost and need some more of your help. Thanks again for everything

    ' {$STAMP BS2}
    ' {$PBASIC 2.0}
    'simpletilt2.bs2
    'measure tilt

    x VAR Word

    MAIN:

    DO

    PULSIN 8, 1, X

    DEBUG CLS, ? X

    PAUSE 100

    IF (X > 2475) AND (X < 2525)THEN

    HIGH 14

    ELSE

    LOW 14

    LOOP
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-16 01:25
    Change your PBASIC designator from 2.0 to 2.5. Then add an ENDIF just before the LOOP. Also, if you post your code here between [noparse][[/noparse]code] and [noparse][[/noparse]/code] tags, your indentation will be preserved, and it will be easier to read.

    -Phil
  • DietrichDietrich Posts: 5
    edited 2008-01-16 03:57
    Thanks for the help, that worked wonderfully. Now I just have to get the range that I am looking for to turn on the led. Thanks to everyone for the help
Sign In or Register to comment.