Arduino - DigitalWrite
Arduino - DigitalWrite
digitalWrite()
Description
Write a HIGH (//www.arduino.cc/en/Reference/Constants) or a LOW
(//www.arduino.cc/en/Reference/Constants) value to a digital pin.
If the pin has been congured as an OUTPUT with pinMode
(//www.arduino.cc/en/Reference/PinMode)(), its voltage will be set to the corresponding value:
5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
If the pin is congured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal
pullup on the input pin. It is recommended to set the pinMode
(//www.arduino.cc/en/Reference/PinMode)() to INPUT_PULLUP
(//www.arduino.cc/en/Reference/Constants) to enable the internal pull-up resistor. See the digital
pins tutorial (//www.arduino.cc/en/Tutorial/DigitalPins) for more information.
NOTE: If you do not set the pinMode() to OUTPUT, and connect an LED to a pin, when calling
digitalWrite(HIGH), the LED may appear dim. Without explicitly setting pinMode(), digitalWrite()
will have enabled the internal pull-up resistor, which acts like a large current-limiting resistor.
Syntax
digitalWrite(pin, value)
Parameters
pin: the pin number
//
//
//
//
Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW.
Note
The analog input pins can be used as digital pins, referred to as A0, A1, etc.
See also
-
pinMode (//www.arduino.cc/en/Reference/PinMode)()
digitalRead (//www.arduino.cc/en/Reference/DigitalRead)()
Share
NEWSLETTER
2016 Arduino
Contact us (//www.arduino.cc/en/Main/ContactUs)
About us (//www.arduino.cc/en/Main/AboutUs)
Careers (//www.arduino.cc/Careers)
(https://twitter.com/arduino)
(https://plus.google.com/+Arduino)
(https://youtube.com/arduinoteam)
(https://www.facebook.com/ocial.arduino)
(https://www.ickr.com/photos/arduino_cc)