ADXL335 Accelerometer to MATLAB through Arduino

5 ビュー (過去 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 件のコメント
MAYANK JOSHI
MAYANK JOSHI 2017 年 7 月 11 日
connect Vin to 3.3v n not to analog pin 5

サインインしてコメントする。

回答 (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 Center および File ExchangeMATLAB 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