Data acquisition from Arduino Uno and realtime plotting
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi guys, I have an Arduino Uno board and I want to aquire a signal values from a potentiometer and plot it in realtime, I've found a code to do it as you can se below:
arduino;
line(nan, nan, 'color','blue');
i=0;
while 1
pot = readVoltage(arduino,'A1');
x=get(line, 'xData');
y=get(line, 'yData');
x=[x i];
y=[y pot];
set(line, 'xData', x, 'yData', y);
i=i+0.001;
pause (1);
end
The problem is that is gives some several errors when I run the program such as: "Failed to open serial port COM3 to communicate with Arduino board Uno. Make sure there is no other MATLAB arduino object for this board. For troubleshooting, see Arduino Hardware Troubleshooting."
"Invalid pin format. Pin number must be a scalar integer."
I hope someone can help me
댓글 수: 0
채택된 답변
Menghan
2018년 6월 8일
편집: Hans Scharler
2018년 6월 12일
arduino function creates a connection to the board each time you call it and only one connection to the board can exist at one time. You should change the code to something like this,
a = arduino;
line(nan,nan,...
...
while 1
pot = readVoltage(a, 'A1');
...
...
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!