ADXL335 Accelerometer to MATLAB through Arduino

조회 수: 7 (최근 30일)
Andrew Nashed
Andrew Nashed 2015년 3월 5일
답변: Dariusz Szalejko 2019년 2월 5일
I am working on a project of connecting an ADXL335 Accelerometer to an Arduino UNO then reading the data in Matlab. So far whenever a reading is done movement shows at about the same height on every axis. So if I move the accelerometer only in the y-axis where the same movement is seen on the z and x-axis. I am not sure what is wrong please help!! See code below
It is connected as follows: Analog Pin 1: Z Analog Pin 2: Y Analog Pin 3: X Analog Pin 4: Ground Analog Pin 5: Vin
This code is used along with the Arduino Package for Matlab: a = arduino('COM4')
a.pinMode(15,'input'); a.pinMode(16,'input'); a.pinMode(17,'input'); %%%% a.pinMode(18,'output'); a.pinMode(19,'output'); a.digitalWrite(18,0); a.digitalWrite(19,1); %%%%
xval = zeros(); yval = zeros(); zval = zeros();
for i = 1:500 zval(i) = a.analogRead(1); yval(i) = a.analogRead(2); xval(i) = a.analogRead(3);
subplot(3,1,1) plot(xval, 'b'); title('x');
subplot(3,1,2) plot(yval, 'r'); title('y');
subplot(3,1,3) plot(zval, 'g'); title('z'); pause(0.01); end

답변 (1개)

Dariusz Szalejko
Dariusz Szalejko 2019년 2월 5일
3D USB ACCELEROMETER ? https://bit.ly/2I35Vn4 ? ?easure ?cceleration ? in your PC / Raspberry Pi / Linux / Windows !! Use in ✔MATLAB ✔ Python or any other programming language!

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by