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() {
pinLabel(7, "OUT"); // sets the pin 7 label to "OUT"
pinMode(7, OUTPUT); // sets the digital pin 7 as output
}
void loop() {
digitalWrite(7, HIGH); // sets the digital pin 7 to HIGH
delay(1000); // waits for a second
digitalWrite(7, LOW); // sets the digital pin 7 to LOW
delay(1000); // waits for a second
}Notes and Warnings
All the pins are set as inputs by default, so they must be configured
as outputs with pinMode() before using
digitalWrite().
