Public projects 1

Arduino IoT Robotic Arm

Project tutorial by AerDronix

  • 14,743 views
  • 17 comments
  • 55 respects

Toolbox 1


Respected projects 0

 AerDronix hasn't respected any projects yet.
  • Arduino IoT Robotic Arm over 2 years ago

    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.

  • Arduino IoT Robotic Arm over 2 years ago

    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:

    '>> arduino

    Then, you should get something like this:

    Serial Port Object : Serial-COM5

    Communication Settings
    Port: COM5
    BaudRate: 9600
    Terminator: 'LF'

    Communication State
    Status: open
    RecordStatus: off

    Read/Write State

    TransferStatus: idle
    BytesAvailable: 0
    ValuesReceived: 0
    ValuesSent: 0

    STEP 2. Run in your Matlab command window,

    '>> readValue(arduino,'R')

    Call the command above several times until you get numbers. Because first 2 times I got
    '>> readValue(arduino,'R')
    Warning: Unsuccessful read: Matching failure in format..

    ans =

    [
    4
    3
    7
    9
    8
    5
    ]

    R
    e
    a
    d
    y

    (
    p
    i
    n
    g
    :

    5
    2
    m
    s
    )
    .

    And then after few calls I got the correct answer:

    '>> readValue(arduino,'R')

    ans =

         100        90        70        50           120
    

    Fixes:
    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 :)

    1. Maybe even a better idea is to disable Blynk messages by commenting first line in your sketch, which is:

    #define BLYNK_PRINT Serial // Comment this out to disable prints and save space

    Then it should work.

  • Arduino IoT Robotic Arm over 2 years ago

    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.

Add projectSign up / Login