Plot values from Arduino in Matlab with multiple i2c devices
6 次查看(过去 30 天)
显示 更早的评论
I have four i2c sensors attached to an Arduino, Singletact capacitive sensors, where I am making a joystick. I am using the ratio of two sensors to find a value in both the x and y axis.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161696/image.png)
I am wondering how to use Matlab to try to use the live output data to plot where the users finger is pressing. I have tried using the Matlab i2c example but I am unsure how to distinguish between different multiple i2c addresses.
I have attached the Arduino Code which I am running which produces my axis values, I am just wondering how to plot these x and y values produced.
0 个评论
回答(1 个)
justin
2017-3-30
I have been trying to figure out how to read in SingleTact sensor data as well.
Be sure to set the addresses to something other than default in the SingleTactDemo software. First, flash the arduino with their example ino code, plug in the sensor via the I2C pin out, and run the PCExecutable.
In MATLAB, you can use the arduino ToolBox to call in the attached addresses. Then make a device with each address. Then you can use read or readRegister to call the device. This last part I am still struggling with. If you figure out pulling the sensor data, please post here. :)
a = arduino('COM3', 'Uno', 'Libraries', 'I2C');
adds=scanI2CBus(a,0)
% Prints out 00x51 for me, as I set that in the demo code.
dev=i2cdev(a,adds{1})
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!