loop in realtime arduino reading
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
john white
el 22 de Mzo. de 2019
Comentada: john white
el 7 de Abr. de 2019
Hi
I want to read a value of the variable each 0.02 seconds I write this code:
c(1)=readCount(encoder);
for i=2:100
c(i)=readCount(encoder)
pause(0.02)
end
actually I want to read the count of the encoder for the loop (i=2:100)
each 0.02 secound
0 comentarios
Respuesta aceptada
Walter Roberson
el 23 de Mzo. de 2019
Use a timer object with FixedRate . Be sure to pre-allocate c.
You might have some difficulty reaching 50 readings per second over the USB connection, unless you use a bit of code or a sketch on the arduino side to keep sending out the values instead of waiting for general commands. It is not uncommon for people to report they only get about 40 samples per second unless they run more dedicated code on the arduino.
10 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Support Package for Arduino Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!