You are on page 1of 48

7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

(https://howtomechatronics.com)

 WHAT'S NEW?  Best Budget Friendly 3D Printers for Beginners and Hobbyists (https:…

(https://www.youtube.com/user/DejanNedelkovski)

 (https://plus.google.com/+Howtomechatronics)
 (https://www.facebook.com/howtomechatronics/)
Follow me on: ()

Home (https://howtomechatronics.com) 
Tutorials (https://howtomechatronics.com/category/tutorials/)  Arduino Tutorials

(https://howtomechatronics.com/category/tutorials/arduino/)

Arduino Range Measurer and Digital Spirit Level Project


 Dejan (https://howtomechatronics.com/author/howtom12_wp/)

 Arduino Tutorials (https://howtomechatronics.com/category/tutorials/arduino/)

 18 (https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-
project/#comments)

In this tutorial we will learn how to make an Arduino range measurer and a digital spirit
level. You can watch the following video or read the written tutorial below.

Arduino Range Measurer and Digital Spirit Level Project

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 1/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Overview

The device features an ultrasonic sensor for measuring the distance to the nearest object, an
accelerometer for measuring the angle with respect to the ground, an LCD display for showing
the results and a custom designed PCB on which all components are connected.

We can operate the device with just a single button. Once we power the device we need to select
the unit of measurement.

By pressing the button we can toggle through the units, and if we press and hold the button for
a while we will get into the rst program. Here we can measure the distance and also have the
ability to store the last two measurements.
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 2/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

For getting into the second program, again we have to press and hold the button for a while. In
this program we can measure a square area by taking two perpendicular distance
measurements.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 3/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

The next program is the digital spirit level and here we can measure the angle with respect to
the ground.

Using the button we can toggle between the two axes or we can measure either the Pitch or the
Roll.

Circuit Schematic

Here’s the circuit schematic of this Arduino project.


This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 4/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

(https://howtomechatronics.com/wp-content/uploads/2018/05/Arduino-DIY-Digital-Range-
Measurer-and-Spirit-Level-Circuit-Schematic.png)

Note that I already have detailed tutorials on how each of these modules work, and you can
check them on the following links: Ultrasonic sensor tutorial
(https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/), LCD tutorial
(https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/), MEMS accelerometer tutorial
(https://howtomechatronics.com/how-it-works/electrical-engineering/mems-accelerometer-
gyrocope-magnetometer-arduino/).

You can get the components needed for this project from the links below:

Ultrasonic Sensor HC-SR04……………………………… Amazon (https://amzn.to/2KnoHSg) /


Banggood (https://howtomechatronics.com/recommends/ultrasonic-sensor-hc-sr04-
banggood/)

MPU6050 3 Axis Gyroscope Accelerometer……… Amazon (https://amzn.to/2AGFG2p) /


Banggood (https://howtomechatronics.com/recommends/mpu6050-banggood/)

16×2 Character LCD………………………………………… Amazon (https://amzn.to/2M1WUeV) /


This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
Banggood (https://howtomechatronics.com/recommends/16x2-lcd-banggood/)
Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 5/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Arduino Nano………………………………………………… Amazon (https://amzn.to/2FZo3tX) /


Banggood (https://howtomechatronics.com/recommends/arduino-nano-banggood/)

*Please note: These are a liate links. I may make a commission if you buy the components through
these links. I would appreciate your support in this way!

Custom design PCB

According to the circuit schematic we need to design the custom PCB and I did that using the
EasyEDA (https://easyeda.com/) free online circuit design software.

(https://howtomechatronics.com/wp-content/uploads/2018/05/EasyEDA-PCB-design-
process.png)

Once we nished the design here, we can simply export the Gerber le which is used for
manufacturing the PCB. You can check the EasyEDA project les of this project here
(https://easyeda.com/editor#id=8ccbee68f04e4a2ba810bfcb04f3e353).

Then we can order our PCB from JLCPCB (https://jlcpcb.com/), which is actually the sponsor of
this project.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 6/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Here we can simply drag and drop the Gerber le. Once uploaded we can review our PCB in the
Gerber viewer. If everything is all right then we can go on, select the properties that we want for
our PCB, and then we can order our PCB at a reasonable price. Note that if it’s your rst order
from JLCPCB, you can get up to 10 PCBs for only $2.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 7/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Assembling the Device

Nevertheless, after several days the PCBs have arrived. The quality of the PCBs is great and
everything is exactly the same as in the design.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 8/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Ok, now we can start assembling the electronics for this project. I started by soldering pin
headers on the PCB. In this way we can easily connect and disconnect the components when
needed.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 9/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Then I inserted and soldered the three resistors. Two of them are for the voltage divider for the
contrast of LCD. The 1k resistor should be placed at R1 and the 220 ohms at R2. The third one is
a pull-up resistor for the button.

Next I moved on with making the case for the device. I decided to use transparent acrylic
because I wanted the beauty of all electronics components to be visible. I had some 5mm tick
acrylic from an old project, and I used a circular for cutting it to size.

Then I had to make an opening for the LCD on the top side of the case, which is actually 4mm
tick because it will t better with the LCD. So rst I made a two hole with a drill and then inserted
a hacksaw through them. Using the hacksaw I roughly made the opening and then using a rasp I
made ne straight lines so that the LCD can tightly t.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 10/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Then using a forstner bit I made the openings for the power switch, the control button and the
ultrasonic sensor.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 11/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Once I had all pieces ready I used a 5 minutes epoxy to assembly to case. As for the top, I
inserted and glued two bolts through which the top panel can be inserted and secured using
some nuts on top of it.

The case is now ready and so I continued with soldering pin headers to the LCD so I can easily
attach it to the PCB. I also soldered pin headers or jump wires to the power switch, the button
and the battery connector.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 12/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Finaly, I had everything ready to assembly the device. I started with inserting the ultrasonic
sensor on the PCB, and then through the holes on the side panel. Next was the Arduino board,
the accelerometer module as well as the battery connector.

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 13/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

On the top panel, I secured the LCD, the power switch and the button, and then connected them
to the PCB. Lastly I inserted the 9V battery to the connector and secured the top panel with the
nuts.

And that’s it, the project is done but what’s left in this video is to explain how the program works,
so let’s take a look at the Arduino code.

Arduino Range Measurer and Digital Spirit Level Source Code

As the code is a bit longer, for better understanding, I will post the source code of the program
in sections withuses
This website description for each
cookies to improve section.
user AndBy
experience. atusing
the end of this you
our website, article
agreeI will post
to our use the
of cookies.
complete source code.Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 14/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

So rst we need to include the Wire.h library for the I2C communication of the accelerometer, as
well as the LiquidCrystal.h library for controlling the LCD.  Then we need to de ne the LCD, the
I2C address of the accelerometer module, the ultrasonic sensor pins, as well as some variables
needed for the program below.

1. #include<Wire.h> // I2C communication library


2. #include <LiquidCrystal.h> // includes the LiquidCrystal Library
3.
4. LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // Creates an LCD object. Parameters: (rs, enable, d4,
d5, d6, d7)
5. const int MPU = 0x68; // I2C address of the MPU6050 accelerometer
6.
7. #define trigPin 8
8. #define echoPin 9
9. #define selectButton 10
10.
11. int16_t AcX, AcY, AcZ;
12. long duration;
13. float distance;
14. int program = 0;
15. float d = 0;
16. float d1 = 0;
17. float d2 = 0;
18. float area = 0;
19. int axis = 0;
20. int angle = 0;
21. int unitSelect = 0;
22. String unit = "cm";

In the setup section we need to initialize both the I2C interface of the accelerometer and the
liquid crystal display, as well as de ne the pin modes for the ultrasonic sensor trigger and echo
pins, and the button pin.

1. void setup() {
2. // Initialize interface to the MPU6050
3. Wire.begin();
4. Wire.beginTransmission(MPU);
5. Wire.write(0x6B);
6. Wire.write(0);
7. Wire.endTransmission(true);
8.
9. lcd.begin(16, 2); // Initializes the interface to the LCD screen
10.
11. pinMode(trigPin, OUTPUT);
12. pinMode(echoPin, INPUT);
13. pinMode(selectButton, INPUT_PULLUP);
14.This}website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 15/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

In the main loop section we have a switch statements through which we can toggle between the
di erent programs of our device. In the rst, or case number 0, we select the unit of
measurement. Using the lcd.print() function we print the text on the LCD and using the if
statements we toggle through the four unit of measurements.

1. switch (program) { // Switch between different programs


2. case 0: // Select unit of measurement
3. lcd.setCursor(0, 0); // Sets the location at which subsequent text written to the LCD
will be displayed
4. lcd.print("Select Unit: ");
5. lcd.setCursor(13, 0);
6. lcd.print(unit);
7. lcd.print(" ");
8. delay(10);
9. // If button is pressed - change unit
10. if (digitalRead(selectButton) == 0) {
11. if (unitSelect == 0) {
12. unit = "in";
13. unitSelect = 1;
14. }
15. else if (unitSelect == 1) {
16. unit = "m";
17. unitSelect = 2;
18. }
19. else if (unitSelect == 2) {
20. unit = "ft";
21. unitSelect = 3;
22. }
23. else if (unitSelect == 3) {
24. unit = "cm";
25. unitSelect = 0;
26. }
27. // If button is held longer then half a second - change program
28. delay(500);
29. if (digitalRead(selectButton) == 0) {
30. program = 1;
31. lcd.clear();
32. delay(500);
33. }
34. }
35. break;

We should note here that the unitSelect variable takes action in the getDistance() cunstom
function, where it actually tells to which unit we should convert the basic cm unit that we are
getting from the ultrasonic sensor.

1.This/website uses cookies


Converting to improve user experience. By using our website, you agree to our use of cookies.
the units
2. if (unitSelect
Ok == 1)Read
{ more (https://howtomechatronics.com/privacy-policy-page/)
3. distance = distance; // cm to cm
https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 16/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

4. unit = "cm";
5. }
6. else if (unitSelect == 2) {
7. distance = distance * 0.393701; // cm to in
8. unit = "in";
9. }
10. else if (unitSelect == 3) {
11. distance = distance * 0.01; // cm to m
12. unit = "m";
13. }
14. else if (unitSelect == 0) {
15. distance = distance * 0.0328; // cm to ft
16. unit = "ft";
17. }

In order to selecting the unit of measurement and also get in the rst program of the device we
just have to hold the press button longer than half a second.

1. // If button is held longer then half a second - change program


2. delay(500);
3. if (digitalRead(selectButton) == 0) {
4. program = 1;
5. lcd.clear();
6. delay(500);
7. }
8. }
9. break;

In case number 1 or in the distance measuring program rst we get the distance to the nearest
object using the getDistance() custom function.

1. case 1: // Distance measuring program


2. distance = getDistance(); // Distance to the nearest object
3. lcd.setCursor(0, 0);
4. lcd.print("Dist: ");
5. lcd.print(distance); // Prints the distance value from the sensor
6. lcd.print(" ");
7. lcd.setCursor(14, 0);
8. lcd.print(unit);
9. delay(10);
10. lcd.setCursor(0, 1);
11. lcd.print("d:");
12. lcd.setCursor(8, 1);
13. lcd.print("d:");
14. delay(200);
15. // Save distance 1
16. if (digitalRead(selectButton) == 0) {
17.This website uses
if (dcookies
== 0)to{improve user experience. By using our website, you agree to our use of cookies.
18. lcd.setCursor(0, 1);
Ok Read more (https://howtomechatronics.com/privacy-policy-page/)
19. lcd.print("d: ");
https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 17/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

20. lcd.setCursor(2, 1);


21. lcd.print(distance);
22. d = 1;
23. delay(100);
24. }
25. // Save distance 2
26. else if (d == 1) {
27. lcd.setCursor(8, 1);
28. lcd.print("d: ");
29. lcd.setCursor(10, 1);
30. lcd.print(distance);
31. d = 0;
32. delay(100);
33. }
34. // If button is held longer then half sencond change program
35. delay(500);
36. if (digitalRead(selectButton) == 0) {
37. program = 2;
38. d = 0;
39. lcd.clear();
40. delay(500);
41. }
42. }
43. break;

Let’s see how this function works.

1. //===== getDistance - Custom Function


2. float getDistance() {
3. // Clears the trigPin
4. digitalWrite(trigPin, LOW);
5. // Sets the trigPin on HIGH state for 10 micro seconds
6. digitalWrite(trigPin, HIGH);
7. delayMicroseconds(10);
8. digitalWrite(trigPin, LOW);
9. // Reads the echoPin, returns the sound wave travel time in microseconds
10. duration = pulseIn(echoPin, HIGH);
11. // Calculating the distance
12. distance = duration * 0.034 / 2; // distance in cm
13.
14. // Converting the units
15. if (unitSelect == 1) {
16. distance = distance; // cm to cm
17. unit = "cm";
18. }
19. else if (unitSelect == 2) {
20. distance = distance * 0.393701; // cm to in
21. unit = "in";
22. }
23. else if (unitSelect == 3) {
24.This website uses cookies
distance to improve
= distance user//
* 0.01; experience.
cm to m By using our website, you agree to our use of cookies.
25. unit = "m";Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 18/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics
26. }
27. else if (unitSelect == 0) {
28. distance = distance * 0.0328; // cm to ft
29. unit = "ft";
30. }
31. return distance;
32. }

Here using the trigger pin we tell sensor to generate an ultrasonic sound wave.

Then using the echo pin and the pulseIn() function we measure the duration the wave traveled
from the sensor to the object and back. Considering the speed of sound and the travel time we
can easily calculate the distance. So we print the measured distance along with some text on the
LCD and using the “if” statements, if we press the button, we print or save last two
measurements.

Next is the program for calculating area in which we are using similar methods. We need to take
two perpendicular measurements and simply multiply them in order to get the area of the
square that they form.

1. case 2: // Area measuring program


2. distance = getDistance();
3. lcd.setCursor(0, 0);
4. lcd.print("Area: ");
5.This website uses cookies to improve
lcd.print(area); user experience.
// Prints By using
the calculated ourfrom
area website,
theyou
twoagree to our use of cookies.
measurements
6. lcd.setCursor(12,
Ok 0);more (https://howtomechatronics.com/privacy-policy-page/)
Read

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 19/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics
7. lcd.print(unit); // Prints the selected unit and the square sign below
8. lcd.print("^2");
9. delay(200);
10. if ( d == 0) {
11. lcd.setCursor(0, 1);
12. lcd.print("d1: ");
13. lcd.setCursor(3, 1);
14. lcd.print(distance);
15. delay(200);
16. }
17. else if (d == 1) {
18. lcd.setCursor(9, 1);
19. lcd.print("d2: ");
20. lcd.setCursor(12, 1);
21. lcd.print(distance);
22. delay(200);
23. }
24. else if (d == 2) {
25. lcd.setCursor(6, 0);
26. lcd.print(area);
27. delay(200);
28. }
29. // Save distance 1
30. if (digitalRead(selectButton) == 0) {
31. if (d == 0) {
32. lcd.setCursor(0, 1);
33. lcd.print("d1: ");
34. lcd.setCursor(3, 1);
35. lcd.print(distance);
36. d = 1;
37. d1 = distance;
38. delay(100);
39. }
40. // Save distance 2
41. else if (d == 1) {
42. lcd.setCursor(9, 1);
43. lcd.print("d2: ");
44. lcd.setCursor(12, 1);
45. lcd.print(distance);
46. d = 2;
47. d2 = distance;
48. area = d1 * d2; // Calculate the area
49. delay(100);
50. }
51. else if (d == 2) {
52. lcd.clear();
53. d = 0;
54. area = 0;
55. delay(100);
56. }
57. // If button is held longer then half sencond change program
58. delay(500);
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
59. if (digitalRead(selectButton) == 0) {
60. Ok = 3;Read more (https://howtomechatronics.com/privacy-policy-page/)
program

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 20/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics
61. d = 0;
62. lcd.clear();
63. delay(500);
64. }
65. }
66. break;

The last case, is the angle measuring program. Here we need to read the accelerometer data
which is actually the strength of the Earth’s gravitational eld in three di erent axes, X,Y, and
Z. The value of each axis is stored in 2 registers, so we need to read total of 6 registers and
combine them in order to get the right value.

1. case 3: // Angle measuring program


2. // Read the accelerometer data
3. Wire.beginTransmission(MPU);
4. Wire.write(0x3B); // Start with register 0x3B (ACCEL_XOUT_H)
5. Wire.endTransmission(false);
6. Wire.requestFrom(MPU, 6, true); // Read 6 registers total, each axis value is stored
in 2 registers
7. AcX = Wire.read() << 8 | Wire.read(); // X-axis value
8. AcY = Wire.read() << 8 | Wire.read(); // Y-axis value
9. AcZ = Wire.read() << 8 | Wire.read(); // Z-axis value
10.
11. if ( axis == 0) {
12. // Calculating the Pitch angle (rotation around Y-axis)
13. angle = atan(-1 * AcX / sqrt(pow(AcY, 2) + pow(AcZ, 2))) * 180 / PI;
14. lcd.setCursor(0, 0);
15. lcd.print("Pitch");
16. }
17. else if (axis == 1) {
18. // Calculating the Roll angle (rotation around X-axis)
19. angle = atan(-1 * AcY / sqrt(pow(AcX, 2) + pow(AcZ, 2))) * 180 / PI;
20. lcd.setCursor(0, 0);
21. lcd.print("Roll ");
22. }
23. lcd.setCursor(0, 1);
24. lcd.print("Angle: ");
25. lcd.print(abs(angle));
26. lcd.print(" ");
27. lcd.setCursor(10, 1);
28. lcd.print("deg");
29. delay(200);
30.
31. // Change axis
32. if (digitalRead(selectButton) == 0) {
33. if (axis == 0) {
34. axis = 1;
35. delay(100);
36. }
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
37. // Save distance 2
38. else ifOk(axis Read
== 1)more
{ (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 21/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics
39. axis = 0;
40. delay(100);
41. }
42. // If button is held longer then half sencond change program
43. delay(500);
44. if (digitalRead(selectButton) == 0) {
45. program = 0;
46. lcd.clear();
47. delay(500);
48. }
49. }
50. break;

Once we have the X,Y and Z values of the accelerometer we can calculate the Pitch angle, or
rotation around the Y-axis, as well as the Roll angle, or rotation around the X-axis, using the the
two equations. You can nd more details about these equations on Freescale Semiconductor
application note, Tilt Sensing Using a Three-Axis Accelerometer
(https://www.nxp.com/docs/en/application-note/AN3461.pdf). So after that we print the values
along with some text on the LCD, and by pressing the button we change what we show on the
LCD, whether the Pitch or the Roll angle.

Here’s the complete source code:

1. /*
2. DIY Digital Range Measurer and Spirit Level
3.
4. by Dejan Nedelkovski,
5. www.HowToMechatronics.com
6.
7. */
8. #include<Wire.h> // I2C communication library
9. #include <LiquidCrystal.h> // includes the LiquidCrystal Library
10.
11. LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // Creates an LCD object. Parameters: (rs, enable, d4,
d5, d6, d7)
12. const int MPU = 0x68; // I2C address of the MPU6050 accelerometer
13.
14. #define trigPin 8
15. #define echoPin 9
16. #define selectButton 10
17.
18. int16_t AcX, AcY, AcZ;
19. long duration;
20. float distance;
21. int program = 0;
22. float d = 0;
23. float d1 = 0;
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
24. float d2 = 0;
25. float area = 0;Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 22/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

26. int axis = 0;


27. int angle = 0;
28. int unitSelect = 0;
29. String unit = "cm";
30.
31. void setup() {
32. // Initialize interface to the MPU6050
33. Wire.begin();
34. Wire.beginTransmission(MPU);
35. Wire.write(0x6B);
36. Wire.write(0);
37. Wire.endTransmission(true);
38.
39. lcd.begin(16, 2); // Initializes the interface to the LCD screen
40.
41. pinMode(trigPin, OUTPUT);
42. pinMode(echoPin, INPUT);
43. pinMode(selectButton, INPUT_PULLUP);
44. }
45. void loop() {
46. switch (program) { // Switch between different programs
47. case 0: // Select unit of measurement
48. lcd.setCursor(0, 0); // Sets the location at which subsequent text written to the LCD
will be displayed
49. lcd.print("Select Unit: ");
50. lcd.setCursor(13, 0);
51. lcd.print(unit);
52. lcd.print(" ");
53. delay(10);
54. // If button is pressed - change unit
55. if (digitalRead(selectButton) == 0) {
56. if (unitSelect == 0) {
57. unit = "in";
58. unitSelect = 1;
59. }
60. else if (unitSelect == 1) {
61. unit = "m";
62. unitSelect = 2;
63. }
64. else if (unitSelect == 2) {
65. unit = "ft";
66. unitSelect = 3;
67. }
68. else if (unitSelect == 3) {
69. unit = "cm";
70. unitSelect = 0;
71. }
72. // If button is held longer then half a second - change program
73. delay(500);
74. if (digitalRead(selectButton) == 0) {
75. program = 1;
76. lcd.clear();
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
77. delay(500);
78. } Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 23/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

79. }
80. break;
81.
82. case 1: // Distance measuring program
83. distance = getDistance(); // Distance to the nearest object
84. lcd.setCursor(0, 0);
85. lcd.print("Dist: ");
86. lcd.print(distance); // Prints the distance value from the sensor
87. lcd.print(" ");
88. lcd.setCursor(14, 0);
89. lcd.print(unit);
90. delay(10);
91. lcd.setCursor(0, 1);
92. lcd.print("d:");
93. lcd.setCursor(8, 1);
94. lcd.print("d:");
95. delay(200);
96. // Save distance 1
97. if (digitalRead(selectButton) == 0) {
98. if (d == 0) {
99. lcd.setCursor(0, 1);
100. lcd.print("d: ");
101. lcd.setCursor(2, 1);
102. lcd.print(distance);
103. d = 1;
104. delay(100);
105. }
106. // Save distance 2
107. else if (d == 1) {
108. lcd.setCursor(8, 1);
109. lcd.print("d: ");
110. lcd.setCursor(10, 1);
111. lcd.print(distance);
112. d = 0;
113. delay(100);
114. }
115. // If button is held longer then half sencond change program
116. delay(500);
117. if (digitalRead(selectButton) == 0) {
118. program = 2;
119. d = 0;
120. lcd.clear();
121. delay(500);
122. }
123. }
124. break;
125.
126. case 2: // Area measuring program
127. distance = getDistance();
128. lcd.setCursor(0, 0);
129. lcd.print("Area: ");
130. lcd.print(area);
This website // Prints
uses cookies to improve the calculated
user experience. area
By using ourfrom theyou
website, twoagree
measurements
to our use of cookies.
131. lcd.setCursor(12, 0);
132. Ok
lcd.print(unit);Read more (https://howtomechatronics.com/privacy-policy-page/)
// Prints the selected unit and the square sign below

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 24/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

133. lcd.print("^2");
134. delay(200);
135. if ( d == 0) {
136. lcd.setCursor(0, 1);
137. lcd.print("d1: ");
138. lcd.setCursor(3, 1);
139. lcd.print(distance);
140. delay(200);
141. }
142. else if (d == 1) {
143. lcd.setCursor(9, 1);
144. lcd.print("d2: ");
145. lcd.setCursor(12, 1);
146. lcd.print(distance);
147. delay(200);
148. }
149. else if (d == 2) {
150. lcd.setCursor(6, 0);
151. lcd.print(area);
152. delay(200);
153. }
154. // Save distance 1
155. if (digitalRead(selectButton) == 0) {
156. if (d == 0) {
157. lcd.setCursor(0, 1);
158. lcd.print("d1: ");
159. lcd.setCursor(3, 1);
160. lcd.print(distance);
161. d = 1;
162. d1 = distance;
163. delay(100);
164. }
165. // Save distance 2
166. else if (d == 1) {
167. lcd.setCursor(9, 1);
168. lcd.print("d2: ");
169. lcd.setCursor(12, 1);
170. lcd.print(distance);
171. d = 2;
172. d2 = distance;
173. area = d1 * d2; // Calculate the area
174. delay(100);
175. }
176. else if (d == 2) {
177. lcd.clear();
178. d = 0;
179. area = 0;
180. delay(100);
181. }
182. // If button is held longer then half sencond change program
183. delay(500);
184. if (digitalRead(selectButton)
This website uses == 0)By{ using our website, you agree to our use of cookies.
cookies to improve user experience.
185. program = 3;
186. Ok
d = 0; Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 25/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

187. lcd.clear();
188. delay(500);
189. }
190. }
191. break;
192.
193. case 3: // Angle measuring program
194. // Read the accelerometer data
195. Wire.beginTransmission(MPU);
196. Wire.write(0x3B); // Start with register 0x3B (ACCEL_XOUT_H)
197. Wire.endTransmission(false);
198. Wire.requestFrom(MPU, 6, true); // Read 6 registers total, each axis value is stored
in 2 registers
199. AcX = Wire.read() << 8 | Wire.read(); // X-axis value
200. AcY = Wire.read() << 8 | Wire.read(); // Y-axis value
201. AcZ = Wire.read() << 8 | Wire.read(); // Z-axis value
202.
203. if ( axis == 0) {
204. // Calculating the Pitch angle (rotation around Y-axis)
205. angle = atan(-1 * AcX / sqrt(pow(AcY, 2) + pow(AcZ, 2))) * 180 / PI;
206. lcd.setCursor(0, 0);
207. lcd.print("Pitch");
208. }
209. else if (axis == 1) {
210. // Calculating the Roll angle (rotation around X-axis)
211. angle = atan(-1 * AcY / sqrt(pow(AcX, 2) + pow(AcZ, 2))) * 180 / PI;
212. lcd.setCursor(0, 0);
213. lcd.print("Roll ");
214. }
215. lcd.setCursor(0, 1);
216. lcd.print("Angle: ");
217. lcd.print(abs(angle));
218. lcd.print(" ");
219. lcd.setCursor(10, 1);
220. lcd.print("deg");
221. delay(200);
222.
223. // Change axis
224. if (digitalRead(selectButton) == 0) {
225. if (axis == 0) {
226. axis = 1;
227. delay(100);
228. }
229. // Save distance 2
230. else if (axis == 1) {
231. axis = 0;
232. delay(100);
233. }
234. // If button is held longer then half sencond change program
235. delay(500);
236. if (digitalRead(selectButton) == 0) {
237. program = 0;
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
238. lcd.clear();
239. Ok
delay(500); Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 26/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

240. }
241. }
242. break;
243. }
244. }
245.
246. //===== getDistance - Custom Function
247. float getDistance() {
248. // Clears the trigPin
249. digitalWrite(trigPin, LOW);
250. // Sets the trigPin on HIGH state for 10 micro seconds
251. digitalWrite(trigPin, HIGH);
252. delayMicroseconds(10);
253. digitalWrite(trigPin, LOW);
254. // Reads the echoPin, returns the sound wave travel time in microseconds
255. duration = pulseIn(echoPin, HIGH);
256. // Calculating the distance
257. distance = duration * 0.034 / 2; // distance in cm
258.
259. // Converting the units
260. if (unitSelect == 1) {
261. distance = distance; // cm to cm
262. unit = "cm";
263. }
264. else if (unitSelect == 2) {
265. distance = distance * 0.393701; // cm to in
266. unit = "in";
267. }
268. else if (unitSelect == 3) {
269. distance = distance * 0.01; // cm to m
270. unit = "m";
271. }
272. else if (unitSelect == 0) {
273. distance = distance * 0.0328; // cm to ft
274. unit = "ft";
275. }
276. return distance;
277. }

So that would be all, I hope you enjoyed this Arduino project


(https://howtomechatronics.com/arduino-projects/) and learned something new. Feel free to ask
any question in the comments section below.

JLCPCB – Prototype PCBs for $2 (For Any Color) & 24-Hour Lead Time
(https://jlcpcb.com)
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 27/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
(https://jlcpcb.com)

See Why JLCPCB Is So Popular: https://jlcpcb.com (https://www.youtube.com/watch?


v=_XCznQFV-Mw)

Arduino (https://howtomechatronics.com/tag/arduino/)

Arduino Project (https://howtomechatronics.com/tag/arduino-project/)

LCD (https://howtomechatronics.com/tag/lcd/) MEMS (https://howtomechatronics.com/tag/mems/)

Ultrasonic Sensor (https://howtomechatronics.com/tag/ultrasonic-sensor/)

SHARE ON:

Like 76

(//pinterest.com/pin/create/button/?
url=https%3A%2F%2Fhowtomechatronics.com%2Ftutorials%2Farduino%2Farduino-
range-measurer-and-digital-spirit-level-
project%2F&media=https%3A%2F%2Fhowtomechatronics.com%2Fwp-
content%2Fuploads%2F2018%2F05%2FArduino-Range-Measurer-and-Digital-Spirit-Level-
Project-
Featured.jpg&description=Arduino+Range+Measurer+and+Digital+Spirit+Level+Project)

Tweet (https://twitter.com/share)

R E L AT E D P O S T S

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 28/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

ARDUINO TUTORIAL 07: MATLAB (HTTPS://HOWTOMECHATRONICS.COM/TUTORIALS/ARDUINO/MATLAB/)

 Dejan (https://howtomechatronics.com/author/howtom12_wp/)

 3 (https://howtomechatronics.com/tutorials/arduino/matlab/#comments)
(https://howtomechatronics.com/tutorials/arduino/matlab/)

HOW TO USE A RGB LED WITH ARDUINO | TUTORIAL


(HTTPS://HOWTOMECHATRONICS.COM/TUTORIALS/ARDUINO/HOW-TO-USE-A-RGB-LED-WITH-ARDUINO/)

 Dejan (https://howtomechatronics.com/author/howtom12_wp/)
(https://howtomechatronics.com/tutorials/arduino/how-to-use-a-rgb-led-with-arduino/)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 29/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

ARDUINO WIRELESS COMMUNICATION – NRF24L01 TUTORIAL


(HTTPS://HOWTOMECHATRONICS.COM/TUTORIALS/ARDUINO/ARDUINO-WIRELESS-COMMUNICATION-NRF24L01-
TUTORIAL/)

 Dejan (https://howtomechatronics.com/author/howtom12_wp/)

 72 (https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-
(https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-
tutorial/#comments)
tutorial/)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 30/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

8×8 LED MATRIX MAX7219 TUTORIAL WITH SCROLLING TEXT & ANDROID CONTROL VIA BLUETOOTH
(HTTPS://HOWTOMECHATRONICS.COM/TUTORIALS/ARDUINO/8X8-LED-MATRIX-MAX7219-TUTORIAL-SCROLLING-
TEXT-ANDROID-CONTROL-VIA-BLUETOOTH/)

 Dejan (https://howtomechatronics.com/author/howtom12_wp/)

 34 (https://howtomechatronics.com/tutorials/arduino/8x8-led-matrix-max7219-tutorial-scrolling-text-android-
(https://howtomechatronics.com/tutorials/arduino/8x8-led-matrix-max7219-tutorial-scrolling-
control-via-bluetooth/#comments)
text-android-control-via-bluetooth/)

18 RESPONSES

Pranav Desai May 19, 2018 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-3653)

Cool!
An interesting project!
I’m gonna make it now!
Thanks, for your hard work putting together this website. It is really one of the best I’ve found
for Arduino projects.

R E Pwebsite
This LY uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 31/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Dejan Nedelkovski (https://howtomechatronics.com) May 20, 2018


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-
spirit-level-project/#comment-3658)

Thank you!

REPLY

Arya Gajjar May 26, 2018 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-3698)

Awesome project
I made it Was amazing but i have problem in sprit level because sometimes turn o when,I
switch to the sprit level option but other thing are working nicely.

REPLY

Ajith July 23, 2018 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-3985)

sir any suggestions for an additional thing that we can add to the existing project?

REPLY

Dejan Nedelkovski (https://howtomechatronics.com) July 28, 2018


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
spirit-level-project/#comment-4000)
Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 32/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Maybe shrink the project down, using smaller display like 0.96″ OLED, add compensation
for measuring from the back side of the case, add laser pointer to know the exact direction
of what you measure ect.

REPLY

Mohammed Almazroey October 15, 2018


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-
level-project/#comment-4449)

Hello. thank you for the amazing project that you did. I did the project, but I am having issues
and I need your assistance.

after doing all the connection and uploading the code, the project will work, but in a Loop. I
can’t control it. hope you can help. Thank You.

REPLY

Alfonso December 17, 2018 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-4965)

Good morning.
When exporting the le, the DRC error detector detects 2 errors:
1-track to pad from sensor trig to D8.
2-track to pado from echo to D9.
Will it give trouble when mounting it?
Thanks

REPLY

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 33/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Dejan (https://howtomechatronics.com) December 19, 2018


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-
spirit-level-project/#comment-4983)

Hey, you won’t have any problem, but still I updated the project le and xed those errors.

REPLY

dipanshu January 22, 2019 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-5340)

hello sir,
can you please suggest if i can use arduino uno instead of arduino nano.

REPLY

Dejan (https://howtomechatronics.com) January 24, 2019


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-
spirit-level-project/#comment-5358)

Sure you can use Arduino Uno for this project.

REPLY

Leo Rosman February 23, 2019 (https://howtomechatronics.com/tutorials/arduino/arduino-


range-measurer-and-digital-spirit-level-project/#comment-5677)

Hello,
I am attempting
This website usesto do this
cookies projectuser
to improve for experience.
my class activity
By usingand I had some
our website, questions
you agree regarding
to our use of cookies.the
materials. Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 34/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Do the pins connectors come with the PCB? Or I will have to buy them separately.

REPLY

Dejan (https://howtomechatronics.com) February 23, 2019


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-
spirit-level-project/#comment-5691)

Hey, the pins connectors or headers are don’t come with the PCB, you need to get them
separate.

REPLY

tom luken May 30, 2019 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-6629)

hello dejan
great project…i made it work. did not build the box, just mounted the switches on the pcb and
super glued a 9 v to the back. one question though, the scematic shows r 2 going to ground
but it dead ends on the pcb…works ne though…what the purpose of r 2 and should i wire it
to ground?
thanks again for a great project

REPLY

Dejan (https://howtomechatronics.com) June 1, 2019


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-
spirit-level-project/#comment-6668)
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 35/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Hey, thanks! Well R2 is used for the voltage divider for setting the contrast of the LCD. Yes,
it should be connected to GND.

REPLY

tom luken (http://none) June 2, 2019


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-
level-project/#comment-6681)

hay dejan
really great project, thanks. i made it and it works..i did not build the box (im lazy) just put the
switches on the board and glued the 9v to the back… but the r2 in schematic goes to ground
but the pcb dead ends, should i connect the end of r2 to ground? it works now but i dont like
to violate your schematic
again , great project ,,,works ne
regards
tom

REPLY

Alfonso June 10, 2019 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-6767)

Hello, is there any template to make the housing, or 3D design to print?


Thanks in advance

REPLY

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 36/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Mathew June 30, 2019 (https://howtomechatronics.com/tutorials/arduino/arduino-range-


measurer-and-digital-spirit-level-project/#comment-6941)

Hi, absolutly geart projekts. I want to do this with my pupils in school. What is the ohm of R3
Resistor? Thanks

REPLY

Dejan (https://howtomechatronics.com) June 30, 2019


(https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-
spirit-level-project/#comment-6948)

Thanks! R3 can be anything from 1K to 100K.

REPLY

L E A V E A R E P LY

Your email address will not be published.

Comment

Name* Email*

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 37/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

Website

S U B MIT

(https://jlcpcb.com/)

L AT E S T

DIY ARDUINO ROBOT ARM WITH SMARTPHONE PLATFORM AUTOMATIC OPERATION


CONTROL (HTTPS://HOWTOMECHATRONICS.COM/PROJECTS/ARDUIN
(HTTPS://HOWTOMECHATRONICS.COM/TUTORIALS/ARDU ROBOT-ARM-AND-MECANUM-WHEELS-PLATFORM-
ARDUINO-ROBOT-ARM-WITH-SMARTPHONE-CONTROL/) AUTOMATIC-OPERATION/)

 Dejan  Dejan

(https://howtomechatronics.com/author/howtom12_wp/) (https://howtomechatronics.com/author/howtom12_wp/)

 77 3
(https://howtomechatronics.com/tutorials/arduino/diy- (https://howtomechatronics.com/projects/arduino-
arduino-robot-arm-with-smar tphone- robot-arm-and-mecanum-wheels-platform-automatic-
control/#comments) operation/#comments)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 38/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

POPULAR

Ultrasonic Sensor HC-SR04 and Arduino Tutorial (https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/)


 Dejan (https://howtomechatronics.com/author/howtom12_wp/)

 94 (https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/#comments)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 39/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

(https://howtomechatronics.com/tutorials/arduino/ultrasonic-sensor-hc-sr04/)

Arduino Radar Project


(https://howtomechatro
radar-project/)
 Dejan
(https://howtomechatr

 354
(https://howtomechatr
radar-project/#comme

(https://howtomechatronics.com/projects/arduino-radar-project/)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 40/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

(https://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-
driver-and-arduino/)

Arduino and HC-05 Bluetooth Module Tutorial (https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-


module-tutorial/)
 Dejan (https://howtomechatronics.com/author/howtom12_wp/)

 34 (https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-tutorial/#comments)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 41/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

(https://howtomechatronics.com/tutorials/arduino/arduino-and-hc-05-bluetooth-module-
tutorial/)

Arduino TFT LCD Touch Screen Tutorial (https://howtomechatronics.com/tutorials/arduino/arduino-tft-lcd-touch-screen-tutorial/)


 Dejan (https://howtomechatronics.com/author/howtom12_wp/)

 162 (https://howtomechatronics.com/tutorials/arduino/arduino-tft-lcd-touch-screen-tutorial/#comments)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 42/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

(https://howtomechatronics.com/tutorials/arduino/arduino-tft-lcd-touch-screen-tutorial/)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 43/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

F O L LO W M E !

Join My Newsletter!

Get noti ed when I publish new projects and tutorials straight to your inbox.

Enter you email

SUBSCRIBE
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 44/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

How To Mechatronics
24,868 likes

Like Page Send Message

Subscribe to my YouTube channel!

How To Mechatronics

YouTube 293K

C R E AT I V IT Y H E R O P R O J E CT

(https://creativityhero.com/diy-projects/diy-interactive-led-co ee-table/)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 45/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

MY R E C O M M E N D AT I O N S

BEST ENTRY LEVEL OSCILLOSCOPES FOR BEGINNERS BEST BUDGET FRIENDLY 3D PRINTERS FOR BEGINNERS
AND HOBBYISTS 2019 AND HOBBYISTS

(HTTPS://HOWTOMECHATRONICS.COM/TOOLS/BEST-
ENTRY-LEVEL-OSCILLOSCOPES-FOR-BEGINNERS-AND-
(HTTPS://HOWTOMECHATRONICS.COM/TOOLS/BEST-
BUDGET-FRIENDLY-3D-PRINTERS-FOR-BEGINNERS-AND-  (H
HOBBYISTS-2019/) HOBBYISTS/) M

 Dejan  Dejan
(https://howtomechatronics.com/author/howtom12_wp/) (https://howtomechatronics.com/author/howtom12_wp/)

BANGGOOD PRIME SALE

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 46/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

(https://howtomechatronics.com/recommends/banggood-prime-sale/)

H O W T O M E C H AT R O N I C S

HowToMechatronics is an education website in the area of Mechanical, Electrical and Computer


Engineering. Tutorials, Tips, Tricks, How It Works, Projects, Examples, Source Codes, Download
les and much more can be found here.

F O L LO W H O W T O M E C H AT R O N I C S O N S O C I A L M E D I A

(https://www.facebook.com/howtomechatronics)
(https://plus.google.com/+Howtomechatronics)
(https://www.youtube.com/user/DejanNed

D I S C LO S U R E

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 47/48
7/13/2019 Arduino Range Measurer and Digital Spirit Level Project - HowToMechatronics

HowToMechatronics is a participant in the Amazon Services LLC Associates Program, an a liate


advertising program designed to provide a means for sites to earn advertising fees by
advertising and linking to Amazon.com

Copyright © 2019 HowToMechatronics.com. All rights reserved. Terms and Conditions


(https://howtomechatronics.com/disclaimer/) | Privacy Policy (https://howtomechatronics.com/privacy-policy-page/)

This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.

Ok Read more (https://howtomechatronics.com/privacy-policy-page/)

https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 48/48

You might also like