Arduino support from MATLAB

The MATLAB Support Package for Arduino Hardware lets you use MATLAB to communicate with Arduino boards over a USB cable. You can learn more, see examples, and install the support package here:

The support package is available on 32-bit and 64-bit Windows, 64-bit Mac OS, and 64-bit Linux.

As an example, you can instantiate an Arduino object from MATLAB using:

>> a = arduino('COM5');

and then do stuff like:

>> av = readVoltage(a,5);

>> writeDigitalPin(a,13,1);

>> delete(a)

or if you have an Adafruit motor shield V2:

>> a = arduino('com5','Uno','libraries','Adafruit\MotorshieldV2');

>> shield = addon(a,'Adafruit\MotorshieldV2')

>> s = servo(shield,1);

>> writePosition(s,0.5)

>> dcm = dcmotor(shield,1);

>> start(dcm)

>> pause(4)

>> stop(dcm)

>> sm = stepper(shield,1,200,'RPM',10)

>> move(sm,10)

Arduino support from Simulink

You can use Simulink to design, simulate, and test algorithms and then automatically program the Arduino with the click of a button. You can learn more, see examples, and install the Simulink Support Package for Arduino Hardware here:

The support package includes a library of Simulink blocks that connect to Arduino I/O, such as digital input and output, analog input and output, serial receive and transmit, and servo read and write. It also includes additional blocks for UDP send and receive, TCP/IP send and receive, and ThingSpeak write (requires Ethernet or Wifi Shield).