필터 지우기
필터 지우기

How can I read the actual analog read?

조회 수: 54 (최근 30일)
SyukriY
SyukriY 2016년 12월 5일
답변: SyukriY 2016년 12월 15일
Hi, MathWorks communities.
I have a question regarding the "readVoltage(a, ' ') command. When I run my code it shows a voltage data. But when I try to find the maximum or minimum value it shows something else. Can anyone tell me why it happens like that?
clear all;
a = arduino();
for r = 1:10
H(1,r) = readVoltage(a , 'A0')
pause(1);
end
ts = timeseries(H(1,:),1:length(H)); %(data)(time)
save('ardu1','ts','-v7.3')
This is the answer from command window.
H =
Columns 1 through 6
0.2639 0.2639 0.2639 0.2639 0.2639 0.2639
Columns 7 through 10
0.2639 0.2639 0.2688 0.2639
>> maximum = max('ardu1')
maximum =
117
>> minimum = min('ardu1')
minimum =
49
  댓글 수: 1
SyukriY
SyukriY 2016년 12월 5일
Because I want to calculate the temperature using the LM35 sensor. So, the calculation is like this.
temp = (5.0 * analogRead(A0) * 100.0) / 1024;
because the value from the analog read is like this somehow.
169 296 300 299 302

댓글을 달려면 로그인하십시오.

채택된 답변

SyukriY
SyukriY 2016년 12월 15일
You can actually read the analog value using readVoltage.
You just need to make some calculation.
analog = readVoltage * (1023 / 5);

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 12월 5일
max('ardu1') means to apply max() to the vector that is the character string 'a', 'r', 'd', 'u', '1'.
There is no MATLAB operator for finding the max() of a .mat file.
Consider max(H)
  댓글 수: 4
SyukriY
SyukriY 2016년 12월 5일
The data is stored in H. But the value is from 'readVoltage'. In the arduino, I get the analog value such as this [169 296 300 299 302]. But by reading the readVoltage the value is not the same. What should I do to get or (maybe convert the readVoltage value) to become the analog value.
SyukriY
SyukriY 2016년 12월 5일
Because I noticed the value is not the same and with that, I cannot proceed with my thermistor calculation to get temperature value.

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by