주요 콘텐츠

writeDigitalPin

R2026b

Write data to a specified pin on Arduino hardware

Description

Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.

writeDigitalPin(a,pin,value) writes the specified value to the specified pin on the Arduino® hardware in the connection a.

example

Examples

collapse all

Write a value to digital pin 5 with an LED to turn it on.

a = arduino();
writeDigitalPin(a,'D5',1);

Input Arguments

collapse all

Arduino hardware connection created using arduino, specified as an object.

Pin number on the hardware, specified as a character vector.

Note

If you are using an analog pin to write a digital value, the function configures the pin in DigitalOutput mode.

Value of digital data to write to the specified pin on hardware, specified as a logical value of 0 and 1 or true and false.

More About

collapse all

Alternative Functionality

App

Use the Pin Explorer pane and Pin Configuration panel in the Arduino Explorer to write data to a specified pin on Arduino or any other supported hardware in MATLAB and MATLAB Online™. In the Pin Explorer pane, click the row corresponding to the pin that you want to configure. The Pin Configuration panel displays the options you can use to configure the selected pin. In the Pin Configuration panel, set the Mode as Digital Output (Write) and if required specify a Label to uniquely identify the pin. For more information, see Configure Read and Write for GPIO Pins Using Arduino Explorer App.

Version History

Introduced in R2014b

expand all