Skip to main content
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.
Edgar Bonet's user avatar
  • 45.3k
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()...
ocrdu's user avatar
  • 1,795
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 ...
Juraj's user avatar
  • 18.3k
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')
user12345's user avatar
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 ...
Shaun Rance's user avatar
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 =...
mohamed's user avatar
  • 75
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 ...
Majenko's user avatar
  • 106k
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 ...
Delta_G's user avatar
  • 3,391
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 ...
tim's user avatar
  • 699
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 ...
Duncan C's user avatar
  • 5,752
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 >= ...
Peter Paul Kiefer's user avatar
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 ...
Danish_Anwar's user avatar
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 ...
Luiz Menezes's user avatar
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 = ...
jose can u c's user avatar
  • 6,974
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 ...
dda's user avatar
  • 1,605

Only top scored, non community-wiki answers of a minimum length are eligible