ArduinoLevelIndicator v1
ArduinoLevelIndicator v1
Arduino board
USB Cable
LCD 16X2
ADXL335, 3-axis Accelerometer
Wires
Procedure:
a. 3-Axis Accelerometer
Page 1 of 4
7 8 9
1
0
1
1
1
2
1
3
1
4
15
16
GN
D
+5
V
GN
D
1
2
GN
D
1
1
+5
V
GN
D
Page 2 of 4
LCD Display library functions are used interface the Digital I/O pins of the Arduino board with
the LCD Display. lcd.print(xxxxx) function is used to display the measured values. Refer to
the above code.
d. Compile and download the working code to the Arduino Board
Compile the following code in Arduino IDE and download it to the Arduino Board.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int groundpin = 14;
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop() {
int avalue = 0;
int lcd_Cursor_Position = 0;
lcd.clear();
avalue = analogRead(xpin);
lcd_Cursor_Position = 46 - avalue/13;
Page 3 of 4
Serial.print(avalue);
lcd.setCursor((15 - lcd_Cursor_Position), 1);
lcd.print('.');
lcd.setCursor((15 - lcd_Cursor_Position), 0);
lcd.print('.');
delay(100);
}
e. Questions:
i.
ii.
iii.
iv.
v.
Explain how do you measure/calculate the following using the Arduino Board?
a) X-Axis Acceleration(Vin)
What is the degree of accuracy of the spirit level?
Can you display the spirit level using other characters apart from .?
Can you make the spirit level indicator . move in the direction of the acceleration?
Can you make one spirit level indicator ., move in opposite direction to the other?
Figure 5:
Aruduino based
level indicator
GOOD LUCK!
f. Questions:
i.
Using a sound buzzer, play any musical note, if the level indicator is stationary in a
particular position for more than 10 seconds.
Page 4 of 4