5 DOF robotic arm using an Arduino Yun, Blynk app as the control interface and Matlab to implement the forward kinematics.
Project tutorial by AerDronix
In Malab, put "pause(2)" immediately after the line "[arduino, serialFlag] = setupSerial(comPort);"
In Arduino sketch, comment out the line "#define BLYNK_PRINT Serial". So Blynk does not write to Serial port. Otherwise, it messes up our transmission.
I think I have the solution for you.
STEP 1. Run only the fist 2 commands from MainScript, which are (use your own COM port):
comPort = 'COM5';
[arduino, serialFlag] = setupSerial(comPort);
and then type in Matlab command window:
Then, you should get something like this:
Serial Port Object : Serial-COM5
STEP 2. Run in your Matlab command window,
Call the command above several times until you get numbers. Because first 2 times I got
Warning: Unsuccessful read: Matching failure in format..
And then after few calls I got the correct answer:
100 90 70 50 120
1. If you have the same first times you call 'readValue', maybe you can add a delay of 2 seconds or more in Matlab after the call of 'setupSerial(comPort)' by using 'pause(2)'.
The delay is necessary to let the connection settle. Because, also Blynk writes on Serial and if you read too fast, then you read their messages, as I got above :)
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
Then it should work.
Can you share your 'MainScript.m' and 'readValue.m'? I will have a look, maybe I can help.
Because it seems that your Arduino outputs the 5 values correctly.
Or connect with your social account:
New here? Create an account