Contenuto principale

Connect to SPI Device Using Arduino Explorer App

R2026b

Arduino Explorer app lets you configure the Serial Peripheral Interface (SPI) communication interface, which you can then use to read and write data to SPI devices connected to the Arduino hardware.

Open the Arduino Explorer app and connect to your Arduino board. You can launch the app from the MATLAB Apps tab, by entering arduinoExplorer at the MATLAB command prompt, or from the Hardware Manager.

To start setting up an SPI device, once the app is open, click the SPI icon in the Configure section of the app. Use the Set Up SPI Device dialog box to select the chip select pin and configure the SPI communication properties. Specify the bit order required by the SPI device, select the SPI mode that matches the clock timing requirements in the device datasheet, and choose a bit rate supported by both the Arduino board and the SPI device. These settings determine how the Arduino exchanges data with the connected SPI device. Use Reset to restore the default SPI settings for the selected board.

Note

To identify the pins that can be used as chip select pins, see Chip Select Pins.

Set Up SPI Device dialog box showing pin assignments, bit order, SPI mode, and bit rate settings

After you set the values, click OK. The app configures all the pins that support SPI to communicate using that protocol. The Pin explorer lists all this pins in one row.

Pin Explorer showing SPI pins A1, D11, D12, and D13 grouped in a single row with the Pin Configuration panel displaying precision and decode logic options

To control the precision in read and write operations, select the row and set the Precision value in the Pin Configuration panel.

The app updates the values in the Pin Explorer Read Value column.

To write data to the SPI pins, enter a value in the Write Value column. Writing data to the device causes the app to read an equal number of bytes into the Read Value column.

For more information on recording and visualizing data, see Visualize and Record Data from Arduino Pins Using Arduino Explorer App.

See Also

Topics