Beruflich Dokumente
Kultur Dokumente
Goal: To develop an instrument similar to a spirit level indicator using an Arduino Board
(interfaced with 16x2 LCD Display and 3-axis accelerometer
Parts Required
1. Arduino board
2. USB Cable
3. LCD 16X2
4. ADXL335, 3-axis Accelerometer
5. Wires
Procedure:
a. 3-Axis Accelerometer
eselabs@seas.upenn.edu Page 1 of 4
Figure 3: Interfacing ADXL335, 3-Axis Accelerometer, with the Arduino Board
1 1 1 1 1
LCD 1 2 3 4 5 6 7 8 9 15 16
0 1 2 3 4
Arduin
GN +5 GN 1 GN 1 +5 GN
o - - - - 5 4 3 2
D V D 2 D 1 V D
Board
eselabs@seas.upenn.edu Page 2 of 4
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>
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();
Serial.print(avalue);
lcd.print('.');
eselabs@seas.upenn.edu Page 3 of 4
lcd.setCursor((15 - lcd_Cursor_Position), 0);
lcd.print('.');
delay(100);
e. Questions:
i. Explain how do you measure/calculate the following using the Arduino Board?
a) X-Axis Acceleration(Vin)
ii. What is the degree of accuracy of the spirit level?
iii. Can you display the spirit level using other characters apart from .?
iv. Can you make the spirit level indicator . move in the direction of the acceleration?
v. Can you make one spirit level indicator ., move in opposite direction to the other?
eselabs@seas.upenn.edu Page 4 of 4