Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
net
electronicsblog.net
Just another electronics blog
HOME
ABOUT
CONTACT
CATEGORIES
Arduino (15)
ARM (1)
67 Comments
Atmega328 (1)
Atmega8 (1)
ATtiny13 (1)
Other (1)
Software (1)
Uncategorized (2)
TAGS
7 segments 16
bit
Arduino
interrupt LCD
High Voltage
Tester AC|DC
manual and automatic HiPot
testers perfect technology and
https://www.electronicsblog.net/simple-angle-meter-using-adxl335-accelerometer-arduino/[4/19/2015 10:48:03 AM]
RECENT COMMENTS
good prices
Darius on Simple angle meter
using ADXL335 accelerometer
[Arduino]
Dale. on Simple angle meter
using ADXL335 accelerometer
[Arduino]
[Arduino]
Shashank on Simple angle
accelerometer [Arduino]
Darius on Reading
temperature from LM92 digital
can be supplied from the 3.3 V output at Arduino board, however then
midpoint voltage and sensitivity is different from specified at datasheet. I
used 3.0 V supply voltage, it came from voltage regulator LM317.
RECENT POSTS
LINKS
#define
#define
#define
#define
#define
#define
#define
ADC_ref 2.56
zero_x 1.569
zero_y 1.569
zero_z 1.569
sensitivity_x 0.3
sensitivity_y 0.3
sensitivity_z 0.3
void setup() {
analogReference(INTERNAL2V56);
Serial.begin(256000);
value_x = analogRead(0);
value_y = analogRead(1);
value_z = analogRead(2);
xv=(value_x/1024.0*ADC_ref-zero_x)/sensitivity_x;
angle_z =atan2(-yv,-xv)*57.2957795+180;
float xv;
float yv;
float zv;
float angle_x;
float angle_y;
float angle_z;
void setup() {
analogReference(INTERNAL2V56);
Serial.begin(256000);
void loop() {
value_x = analogRead(0);
value_y = analogRead(1);
value_z = analogRead(2);
xv=(value_x/1024.0*ADC_ref-zero_x)/sensitivity_x;
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
Serial.print (xv);
Serial.print(" g ");
yv=(value_y/1024.0*ADC_ref-zero_y)/sensitivity_y;
zv=(value_z/1024.0*ADC_ref-zero_z)/sensitivity_z;
Serial.print("\n");
Serial.print("Rotation ");
Serial.print("x= ");
angle_x =atan2(-yv,-zv)*57.2957795+180;
Serial.print(angle_x);
Serial.print(" deg");
Serial.print(" ");
Serial.print("y= ");
angle_y =atan2(-xv,-zv)*57.2957795+180;
Serial.print(angle_y);
Serial.print(" deg");
Serial.print(" ");
Serial.print("z= ");
angle_z =atan2(-yv,-xv)*57.2957795+180;
Serial.print(angle_z);
Serial.print(" deg");
Serial.print("\n");
delay(1000);
delay(1000);
}
This entry was posted in Arduino and tagged A/D, ADXL335, Arduino on July
17, 2011.