Read data from multiple analog inputs via Arduino-Computer serial link

조회 수: 3 (최근 30일)
Jon Schofield
Jon Schofield 2018년 1월 4일
답변: Milton 2018년 1월 12일
I've configured the serialRunOnArduino and serialRunOnPC models to allow me to record data from an analog sensor on pin A0 of an Arduino Mega. However, I need to read data from two analog sensors, plot separately and save data to the workspace.
I'm struggling to do this so any help would be appreciated.
Here are some screenshots of the serial link models as it stands, including my attempt to add a second serial transmit block.
Best,
Jon

채택된 답변

Milton
Milton 2018년 1월 12일
If you are using two serial output on Mega, then TX0/RX0 and TX1/RX1 are used.
You can check the schematic of Mega. You will find TX0/RX0(PE1/PE0) are connected to USB.
Thus, you will find TX1/RX1 are Pin 18&19. You need to connect this to PI to a TTL to USB board so that you computer can read.
If you just want to use the existing USB from Mega, you need to 'Byte Pack' block to packet two signal together then send it out. From you PC part, you will use 'Byte Unpack' to separate this two signal.
These two blocks are introduced in R2016b

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by