digitalWrite()
[Digital I/O]
void digitalWrite(unsigned short pin, unsigned char value);
Description
Writes a HIGH
or a LOW
value to a digital
pin.
If the pin has been configured as an output with
pinMode()
, its voltage will be set to the corresponding
value, following the family electronic standards configured with
logicFamily()
.
If the pin is configured as an input, the function will have no effect.
Parameters
pin
: the Custom Element pin.
value
: HIGH
or LOW
Returns
Nothing.
Example Code
The code makes the digital pin 7 an OUTPUT and toggles it by alternating between HIGH and LOW at one second pace.
void setup() {
(7, "OUT"); // sets the pin 7 label to "OUT"
pinLabel(7, OUTPUT); // sets the digital pin 7 as output
pinMode}
void loop() {
(7, HIGH); // sets the digital pin 7 to HIGH
digitalWrite(1000); // waits for a second
delay(7, LOW); // sets the digital pin 7 to LOW
digitalWrite(1000); // waits for a second
delay}
Notes and Warnings
All the pins are set as inputs by default, so they must be configured
as outputs with pinMode()
before using
digitalWrite()
.