Main Content

writeDigitalPin

Write data to digital pin on Arduino hardware

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

Description

example

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

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.

Digital pin number on the hardware, specified as a character vector.

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

Code Generation Using MATLAB Function Block

  • Use writeDigitalPin in a MATLAB® Function block with the Simulink® Support Package for Arduino Hardware to generate code that can be deployed on Arduino Hardware.

  • Configure the Arduino peripherals to the appropriate mode using configurePin before using writeDigitalPin in the MATLAB Function block.

Version History

Introduced in R2014b