4
votes
Accepted
Serial.availableForWrite versus Serial.flush
The line
while (Serial.availableForWrite() <= 0) {}
waits until the serial output buffer is not full. Whereas
Serial.flush();
waits until the serial output buffer is empty.
3
votes
The analog read is not giving the correct waveform as that of an oscilloscope
Your sampling rate is far too low for the signals you are looking at; you're not getting enough data points for drawing something that looks like the original signal.
The Arduino library's analogRead()...
2
votes
Serial.availableForWrite versus Serial.flush
https://www.arduino.cc/reference/en/language/functions/communication/serial/availableforwrite/
availableForWrite Get the number of bytes (characters) available for writing in the serial buffer ...
2
votes
Connecting arduino with MATLAB
Using clear command on Octave before executing a=arduino('COM8') will remove this problem.
Use it like this:
clear
a=arduino('COM8')
2
votes
Interfacing MPU6050 with Arduino through Simulink S-function
To add to the answer above, you are limited by the serial speed of the USB, i.e. USB 2.0 is around 12 Mbps, as well as what your hardware can manage. Also, Simulink uses about 25% of each time step ...
2
votes
about receiving float on matlab from ATmega32 Avr
i found the solution for this problem, i set a header before sending the data from ATmega32,and on Matlab i check the frame ,if it received correctly,i receive the data
//ATmega32 code
float x =...
2
votes
Problem on Sending float number and multiple float numbers
Sending numerical values between systems is fraught with difficulty. Not only do you have to ensure that both ends agree on the size of the data (16 bit vs 32 bit ints, float vs double, etc) but that ...
1
vote
Updating the firmware of Arduino Mega2560
https://www.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html
This link has the instructions for connecting the Arduino board. Look right at the first where it ...
1
vote
How to program an Arduino Uno to collect data using a timer interrupt and analyze that data in matlab?
I've configured the timer differently making use of its UserData property. The timer will update the data every fixed period for a specified number of samples.
close all;
clear all;
% Some useful ...
1
vote
Accepted
Taking data from main 120V 50/60Hz power
The Serial output on an Arduino is quite slow. By printing your output, you will slow down the readings so much that it will appear to be nonsense.
You should collect a series of readings into a C ...
1
vote
Accepted
Variable sets to 32767 - MATLAB Arduino
Some findings:
Your for loop iterates over 71 results, but your array has only the length 70.
You may overwrite variables in the memory behind the array.
You can use else instead of else if (i >= ...
1
vote
Accepted
Interfacing MPU6050 with Arduino through Simulink S-function
Measurement sometime lost due to serial communications between Arduino and Simulink. So raw data have some glitches in output values. In order to solve the issue, we have to use state estimation to ...
1
vote
GUI interface with microcontroller to control a device through SPI
I grappled with the same question for a while. Here is how I solved the issue.
1- Find a suitable exchange format and protocol
Here you need to decide what is the most important thing on the ...
1
vote
Arduino and MatLab with OWI Robotic Arm Edge -- Issue with I2C
The documentation in MATLAB for scanI2CBus() notes that the return is a cell array of character vectors
They even give the example:
a = arduino('COM9');
scanI2CBus(a,1)
with result:
ans =
...
1
vote
MATLAB+Arduino+LCD
while answer
fprintf(arduino,'%s',char(answer)); % send answer variable content to arduino
answer=input('Enter led value 1 or 2 (1=ON, 2=OFF, 0=EXIT PROGRAM): ');
% ask user to enter value for ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
matlab × 56arduino-uno × 21
serial × 14
arduino-mega × 6
arduino-due × 6
arduino-ide × 3
sensors × 3
softwareserial × 3
analogread × 3
programming × 2
arduino-nano × 2
c++ × 2
servo × 2
communication × 2
avr × 2
gps × 2
mpu6050 × 2
variables × 2
serial-data × 2
mkr1000 × 2
i2c × 1
bluetooth × 1
lcd × 1
timers × 1
sd-card × 1