Main Content

writeDigitalPin

Write data to a specified pin on Arduino hardware

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

Description

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 pin will be configured 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

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