Saving voltage reads from sensors in queue from Arduino to an excel file?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I am trying to collect voltage data from a sensor that is connected to an Arduino in three analog inputs (the sensor gives voltage in X direction, Y direction, Z direction)
I have written code to acquire the data such that there is a dash after each value so I know when data is read from the next analog input.
example:
voltage = "1.96_" %this is from analog input 1
voltage = "1.3_" %then this is collected from analog input 2
voltage = "1.2_" %then after the second analog input, this is read from analog input 3
I want to store these values, but "voltage" keeps getting overwritten and when I pause the code, it only provides the most recent voltage acquired.
How can I store all of the read values in a matrix and print to an excel file?
Thanks! (new to matlab here)
Here is what I have so far:
%device=serialport("COM26",9600)
param=1
while param > 0
for i = 1:3
voltage = read(device,4,"string")
pause(0.1)
writematrix(voltage)
end
flush(device);
pause(0.1);
end
0 comentarios
Respuestas (1)
Anshika Chourasia
el 20 de Jun. de 2022
Hi Isabella,
I understand you want to store all the read values in a matrix and save it to an excel file.
You can use “writematrix” function to write data to a file and use Name-Value pair argument ('WriteMode','append') to append the data below existing data in a spreadsheet. Please refer to the following link for "writematrix” function details:
I hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!