Professional Documents
Culture Documents
(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/)
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.
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
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.
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.
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
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:
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
*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!
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
In case number 1 or in the distance measuring program rst we get the distance to the nearest
object using the getDistance() custom function.
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.
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.
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.
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
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. }
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.
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)
Arduino (https://howtomechatronics.com/tag/arduino/)
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.
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
Dejan (https://howtomechatronics.com/author/howtom12_wp/)
3 (https://howtomechatronics.com/tutorials/arduino/matlab/#comments)
(https://howtomechatronics.com/tutorials/arduino/matlab/)
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.
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
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.
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
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.
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
Thank you!
REPLY
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
sir any suggestions for an additional thing that we can add to the existing project?
REPLY
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
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
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.
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
Hey, you won’t have any problem, but still I updated the project le and xed those errors.
REPLY
hello sir,
can you please suggest if i can use arduino uno instead of arduino nano.
REPLY
REPLY
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
Hey, the pins connectors or headers are don’t come with the PCB, you need to get them
separate.
REPLY
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
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
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
REPLY
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
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
Hi, absolutly geart projekts. I want to do this with my pupils in school. What is the ohm of R3
Resistor? Thanks
REPLY
REPLY
L E A V E A R E P LY
Comment
Name* Email*
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
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
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.
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
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.
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/)
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.
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/)
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.
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/)
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.
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.
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.
SUBSCRIBE
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
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
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.
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/)
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
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
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.
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
This website uses cookies to improve user experience. By using our website, you agree to our use of cookies.
https://howtomechatronics.com/tutorials/arduino/arduino-range-measurer-and-digital-spirit-level-project/ 48/48