Arduino.ru
Подает HIGH или LOW значение на цифровой вход/выход (pin).
Если вход/выход (pin) был установлен в режим выход (OUTPUT) функцией pinMode(), то для значение HIGH напряжение на соответствующем вход/выходе (pin) будет 5В (3.3В для 3.3V плат), и 0В(земля) для LOW.
Если вход/выход (pin) был установлен в режим вход (INPUT), то функция digitalWrite со значением HIGH будет активировать внутренний 20K нагрузочный резистор. Подача LOW в свою очередь отключает этот резистор. Нагрузочного резистра достаточно чтобы светодиод, подключенный к входу, светил тускло. Если вдруг светодиод работает, но очень тускло, возможно необходимо установить режим выход (OUTPUT) функцией pinMode().
Замечание. Вход/выход 13 сложнее использовать как цифровой вход, т.к. он имеет встроенный в плату резистор и светодиод. Если вы активируете еще внутренний нагрузочный резистор 20K, то напряжение на этом входе будет около 1.7В, вместо ожидаемых 5В, т.к. светодиод и добавочный резистор снижает напряжение, т.е. Вы всегда будете получать LOW. Если же Вам все же необходимо использовать 13ый вход/выход, то используйте внешний нагрузочный резистор.
Синтаксис
Параметры
- pin: номер вход/выхода(pin)
- value: значение HIGH или LOW
Возвращаемое значение
Пример
Примечание
Аналоговые входы (analog pins) могут быть использованы как цифровые вход/выходы (digital pins). Обращение к ним идет по номерам от 14 (для аналогового входа 0) до 19 (для аналогового входа 5).
Для чего нужна команда digitalwrite
Write 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: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup. The pullup resistor is enough to light an LED dimly, so if LEDs appear to work, but very dimly, this is a likely cause. The remedy is to set the pin to an output with the pinMode() function.
NOTE: Digital pin 13 is harder to use as a digital input than the other digital pins because it has an LED and resistor attached to it that’s soldered to the board on most boards. If you enable its internal 20k pull-up resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor pull the voltage level down, meaning it always returns LOW. If you must use pin 13 as a digital input, use an external pull down resistor.
Syntax
Parameters
pin: the pin number
Returns
Example
Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW.
The analog input pins can be used as digital pins, referred to as A0, A1, etc.
See also
Corrections, suggestions, and new documentation should be posted to the Forum.
The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
digitalWrite()
If the pin has been configured as an OUTPUT with 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 configured as an INPUT , digitalWrite() will enable ( HIGH ) or disable ( LOW ) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial for more information.
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.
Arduino
Устанавливает режим работы пина (вход/выход). Значение по-умолчанию для цифровых пинов — INPUT , его устанавливать не нужно.
Синтаксис
Параметры
pin — номера пина
mode — режим. Одно из двух значений: INPUT или OUTPUT (вход и выход соответственно)
Возвращаемое значение
Пример
Функция digitalWrite()
Описание
Подает на цифровой пин значение HIGH (включено) или LOW (выключено).
Синтаксис
Параметры
pin — номера пина
value — значение HIGH или LOW
Возвращаемое значение
Пример
Если установлен режим пина INPUT , то функция digitalWrite() включает или выключает нагрузочный резистор.
