LinkIt One Leveler

by robo10302 in Circuits > Microcontrollers

516 Views, 4 Favorites, 0 Comments

LinkIt One Leveler

IMG_0050.jpg
IMG_0053.jpg
IMG_0054.jpg

Introduction: Hello builders! In this project you will learn how to make a Flat Surface Detector. Whenever you're making something like a table or a desk you need to check if the surface is not tilted at an angle and is sitting flat on the ground. Unless you're into a tilted desk and you like it for some weird reason this tool can be quite handy. Now off course you can get the same thing on your phones but lets just make it cause we are creative :). This project is made with the LinkIt One Board Microcontroller which is a very powerful tool to control virtually anything electronic. Also this project uses an gyroscoping to measure its tilt and yaw to know whether or not it is on a flat surface. Lets get into the parts needed for this project.

Parts

IMG_0002.jpg
IMG_0003.jpg
IMG_0005.jpg
IMG_0006.jpg
IMG_0021.jpg

Level: Easy

1. LinkIt One board

2. Usb Cable

3. 3 axis Gyroscope/Accelerometer

4. 2 LED's ( Green and Red )

5. Perf Board

Tools:

1. Soldering Iron

2. Hot Glue

Solder Gyroscope

IMG_0007.jpg
IMG_0011.jpg
IMG_0015.jpg
IMG_0018.jpg
IMG_0020.jpg

1. Solder red wires on to the Gyroscope's pins( X, Y, Z)

2. Solder power wires to the VCC and GND.

Make sure that none of the pins are bridged in the connections and then move on.

Solder the LED

IMG_0023.jpg
IMG_0024.jpg
IMG_0026.jpg
IMG_0027.jpg
IMG_0028.jpg
IMG_0029.jpg

In this step we will solder the LED's on to a perf board so that they can indicate if the surface is laying down untilted.

1. Cut the LED's legs short

2. Put the LED's in the perf board

3. Solder the leds onto the Board.

4. On solder wires on to the leds.

Check

IMG_0030.jpg
IMG_0031.jpg

Now check that you have the Gyroscope, the led board soldered and the LinkIt One Board. Once you have all these you are ready to program. So lets code it.

Code

IMG_0001.jpg

This code will allow you to keep the board on a surface and know whether or not the surface is leveled. Make sure to change the numbers in the if statement according to your readings or this will not work.

int GreenLed = 13; // LED's
int RedLed = 12;

int xaxis = A0; // pins of the Accelerometer

int yaxis = A1;

int zaxis = A2;

int oval;

int oval;

int zval;

void setup() {

pinMode(GreenLed, OUTPUT);

pinMode(RedLed, OUTPUT);

pinMode(xaxis, INPUT);

pinMode(yaxis, INPUT);

pinMode(zaxis, INPUT); }

void loop() {

int xval = analogRead(xaxis);

int yval = analogRead(yaxis);

int zval = analogRead(zaxis);

if (xval == 0 && yval == 0 && zval == 0 ) // change the 0's here to the numbers you see when your accelerometer is sitting down flat

{ digitalWrite(GreenLed, HIGH);

digitalWrite(RedLed, LOW);

}

else

{

digitalWrite(RedLed, HIGH);

digitalWrite(GreenLed,LOW);

}

}

Wire It

IMG_0032.jpg
IMG_0033.jpg
IMG_0034.jpg
IMG_0036.jpg

In this step we will take the programmed board and wire it up.

1. First connect the GND of the leds to GND of the board.

2. Connect the Green LED to pin 13

3. Connect the Red LED to pin 12

4. Connect the Accelerometers wires (x,y,z) to (A0,A1,A2)

5. Connect the VCC of the Accelerometer to 5v and GND to GND.

And thats it you're basically done except its not pretty... yet so lets make it pretty by enclosing it in a small compact box.

Box It

IMG_0037.jpg
IMG_0038.jpg
IMG_0041.jpg
IMG_0042.jpg
IMG_0043.jpg
IMG_0044.jpg
IMG_0046.jpg
IMG_0049.jpg
IMG_0048.jpg
IMG_0051.jpg

Find yourself a small cardboard board that is big enough to enclose the Microcontroller as that is the biggest component in the box.

1. Put a dab of hot glue at the bottom of the box.

2. Stick the Accelerometer flat to the bottom.

3. Then put in the MicroController on top

4. Make a hole for the leds to seek through and hot glue it there.

5. Make a hole for the USB cable

6. Close the box and thats it

Testing and Conclusion

IMG_0054.jpg

Now plug in the board to usb power and pick it up.

If you did everything right it should now be glowing red, and after keeping it on something not titled(table) it should be green.

In conclusion this project is fun and simple but if you want a level detector you can also use the one in your phone. If you have any questions feel free to ask me in the comments. Have fun building:)