Reference.DigitalWrite History

Hide minor edits - Show changes to markup

June 07, 2010, at 11:02 PM by Equipo Traduccion -
Changed lines 3-14 from:

Description

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

digitalWrite(pin, value)

to:

Descripción

Escribe un valor HIGH o LOW hacia un pin digital.

Si el pin ha sido configurado como OUTPUT con pinMode(), su voltaje será establecido al correspondiente valor: 5V ( o 3.3V en tarjetas de 3.3V) para HIGH, 0V (tierra) para LOW.

Si el pin es configurado como INPUT, escribir un valor de HIGH con digitalWrite() habilitará una resistencia interna de 20K conectada en pullup (ver el tutorial de pines digitales). Escribir LOW invalidará la resistencia. La resistencia es sufuciente para hacer brillar un LED de forma opaca, si los LEDs aparentan funcionar, pero no muy iluminados, esta puede ser la causa. La solución es establecer el pin como salida con la función pinMode().

NOTA: El pin digital número 13 es más difícil de usar que los otros pines digitales por que tiene un LED y una resistencia adjuntos, los cuales se encuentran soldados a la tarjeta, y la mayoría de las tarjetas se encuentran así. Si habilitas la resistencia interna en pullup, proporcionará 1.7V en vez de los 5V esperados, por que el LED soldado en la tarjeta y resistencias bajan el nivel de voltaje, significando que siempre regresará LOW. Si debes usar el pin número 13 como entrada digital, usa una resistencia externa conectada a pulldown.

Sintaxis

digitalWrite(pin, valor)

Changed lines 16-23 from:

pin: the pin number

value: HIGH or LOW

Returns

none

Example

to:

pin: el número de pin

valor: HIGH o LOW

Devuelve

nada

Ejemplo

Changed lines 25-26 from:

int ledPin = 13; // LED connected to digital pin 13

to:

int ledPin = 13; // LED conectado al pin digital 13

Changed line 29 from:
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
to:
  pinMode(ledPin, OUTPUT);      // establece el pin digital como salida
Changed lines 34-37 from:
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
to:
  digitalWrite(ledPin, HIGH);   // enciende el LED
  delay(1000);                  // espera por un segundo
  digitalWrite(ledPin, LOW);    // apaga el LED
  delay(1000);                  // espera por un segundo
Changed lines 41-47 from:

Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW.

Note

The analog input pins can also be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5).

See also

to:

Establece el pin número 13 a HIGH, hace un retraso con la duración de un segundo, y regresa el pin a LOW.

Nota

Los pines analogicos pueden ser usados como pines digitales con los números 14 (entrada analogica número 0) hasta 19 (entrada analogica número 5).

Ver también

Changed lines 50-51 from:
to:
March 09, 2010, at 04:36 AM by Tom Igoe -
Added lines 10-11:

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.

January 17, 2010, at 06:30 PM by Paul Badger -
Changed lines 8-9 from:

If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor (see the reference page 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.

to:

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.

January 17, 2010, at 06:29 PM by Paul Badger -
Changed lines 8-9 from:

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.

to:

If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal 20K pullup resistor (see the reference page 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.

December 24, 2009, at 04:03 AM by David A. Mellis -
Changed lines 4-9 from:

Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUPUT 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 20K 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.

to:

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.

November 20, 2009, at 08:07 AM by Paul Badger -
Changed lines 6-7 from:

If the pin is configured as an INPUT, writing a HIGH value will enable an internal 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup.

to:

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.

November 20, 2009, at 02:34 AM by Paul Badger -
Changed lines 8-9 from:

The 20K pullup resistor is enough to light an LED dimly, so if LED's 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.

to:

The 20K 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.

November 20, 2009, at 02:33 AM by Paul Badger -
Changed lines 6-7 from:

If the pin is configured as an INPUT, writing a HIGH value will enable an internal 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup.

to:

If the pin is configured as an INPUT, writing a HIGH value will enable an internal 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup.

The 20K pullup resistor is enough to light an LED dimly, so if LED's 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.

February 21, 2009, at 10:23 PM by David A. Mellis -
Changed lines 6-7 from:

If the pin is configured as an INPUT, writing a HIGH value will enable an internal 20K pullup resistor. Writing LOW will disable the pullup.

to:

If the pin is configured as an INPUT, writing a HIGH value will enable an internal 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup.

February 21, 2009, at 10:22 PM by David A. Mellis -
Changed lines 46-47 from:
to:
February 21, 2009, at 10:13 PM by David A. Mellis -
Changed lines 1-3 from:

digitalWrite(pin, value)

to:

digitalWrite()

Added lines 8-10:

Syntax

digitalWrite(pin, value)

Changed lines 12-13 from:

pin: the pin number (int)

to:

pin: the pin number

Changed lines 44-48 from:
to:
December 29, 2008, at 12:58 AM by Paul Badger -
Changed lines 5-8 from:

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 will enable an internal 20K pullup resistor. Writing LOW will disable the pullup.

to:

Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUPUT 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 will enable an internal 20K pullup resistor. Writing LOW will disable the pullup.

October 04, 2008, at 01:46 PM by David A. Mellis -
Changed lines 5-8 from:

Sets a pin configured as OUTPUT to either a HIGH or a LOW state at the specified pin.

The digitalWrite() function is also used to set pullup resistors when a pin is configured as an INPUT.

to:

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 will enable an internal 20K pullup resistor. Writing LOW will disable the pullup.

Changed lines 10-11 from:

pin: the pin number

to:

pin: the pin number (int)

March 31, 2008, at 01:15 PM by Paul Badger -
Changed lines 5-6 from:

Ouputs either HIGH or LOW at a specified pin.

to:

Sets a pin configured as OUTPUT to either a HIGH or a LOW state at the specified pin.

The digitalWrite() function is also used to set pullup resistors when a pin is configured as an INPUT.

February 14, 2008, at 04:29 AM by David A. Mellis -
Changed line 40 from:
  • Description of the pins on an Arduino board
to:
February 02, 2008, at 04:05 PM by Paul Badger -
Changed lines 37-38 from:

The analog input pins can be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5).

to:

The analog input pins can also be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5).

January 19, 2008, at 04:40 PM by David A. Mellis - i'm not sure digitalWrite() needs to link to an explanation of ADCs, etc.
Deleted line 40:
January 18, 2008, at 07:30 PM by Paul Badger -
January 18, 2008, at 05:53 PM by Paul Badger -
Changed lines 37-38 from:

The analog input pins can be used as digital pins w/ numbers 14 (analog input 0) to 19 (analog input 5).

to:

The analog input pins can be used as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5).

January 18, 2008, at 04:14 PM by David A. Mellis -
Deleted lines 9-11:

valid pin numbers on most boards are 0 to 19, valid pin numbers on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite and pinMode commands.

Changed lines 35-38 from:
to:

Note

The analog input pins can be used as digital pins w/ numbers 14 (analog input 0) to 19 (analog input 5).

January 18, 2008, at 06:17 AM by Paul Badger -
Changed lines 11-12 from:

valid pin numbers on most boards are 0 to 19, valid pin numbers on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite, and pinMode commands.

to:

valid pin numbers on most boards are 0 to 19, valid pin numbers on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite and pinMode commands.

January 18, 2008, at 06:16 AM by Paul Badger -
Added line 10:
January 18, 2008, at 06:16 AM by Paul Badger -
Added line 9:
January 18, 2008, at 06:15 AM by Paul Badger -
Changed lines 9-10 from:

valid pin numbers on most boards are 0 to 19, valid pin number on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite, and pinMode commands.

to:

valid pin numbers on most boards are 0 to 19, valid pin numbers on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite, and pinMode commands.

January 18, 2008, at 06:14 AM by Paul Badger -
Changed lines 8-9 from:

pin: the pin number, valid pin numbers on most boards are 0 to 19, valid pin number on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite command.

to:

pin: the pin number
valid pin numbers on most boards are 0 to 19, valid pin number on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite, and pinMode commands.

Added line 39:
January 18, 2008, at 06:11 AM by Paul Badger -
Changed lines 8-9 from:

pin: the pin number

to:

pin: the pin number, valid pin numbers on most boards are 0 to 19, valid pin number on the Mini are 0 to 21. Pins 0 to 13 refer to the digital pins and pins 14 to 19 refer to the analog pins, when using the digitalWrite command.

Deleted line 41:
January 11, 2008, at 06:40 PM by David A. Mellis -
Changed line 37 from:
to:
  • Description of the pins on an Arduino board
January 13, 2006, at 12:37 AM by 82.186.237.10 -
Added lines 40-42:
December 28, 2005, at 10:46 PM by 82.186.237.10 -
Changed lines 1-4 from:

DigitalWrite

What it does

to:

digitalWrite(pin, value)

Description

Changed lines 7-13 from:

What parametres does it take

You need to specify the number of the pin you want to set followed by the word HIGH or LOW.

This function returns

nothing

to:

Parameters

pin: the pin number

value: HIGH or LOW

Returns

none

December 03, 2005, at 07:47 PM by 213.140.6.103 -
Changed lines 5-7 from:

Outputs a series of digital pulses that act like an analogue voltage.

to:

Ouputs either HIGH or LOW at a specified pin.

Changed lines 9-11 from:

you need to specify the number of the pin y ou want to configure followed by the word INPUT or OUTPUT.

to:

You need to specify the number of the pin you want to set followed by the word HIGH or LOW.

Changed lines 32-34 from:

configures pin number 13 to work as an output pin.

to:

Sets pin 13 to HIGH, makes a one-second-long delay, and sets the pin back to LOW.

Changed lines 36-37 from:
to:
December 03, 2005, at 07:42 PM by 213.140.6.103 -
Changed lines 16-17 from:

[@

to:
 [@
Deleted line 18:
Deleted line 19:
Deleted line 20:
Deleted line 21:
Deleted line 24:
Deleted line 25:
Deleted line 26:
Deleted line 27:
Deleted line 28:
Deleted line 29:
December 03, 2005, at 07:40 PM by 213.140.6.103 -
Added line 20:
Added line 22:
Added line 24:
Added line 26:
Added line 30:
Added line 32:
Added line 34:
Added line 36:
Added line 38:
Added line 40:
December 03, 2005, at 07:39 PM by 213.140.6.103 -
Changed lines 16-17 from:

[=

to:

[@

Changed lines 32-33 from:

=]

to:

@]

December 03, 2005, at 07:39 PM by 213.140.6.103 -
Changed lines 16-17 from:

[@

to:

[=

Changed lines 32-33 from:

@]

to:

=]

November 27, 2005, at 05:20 PM by 81.154.199.248 -
Added lines 1-39:

DigitalWrite

What it does

Outputs a series of digital pulses that act like an analogue voltage.

What parametres does it take

you need to specify the number of the pin y ou want to configure followed by the word INPUT or OUTPUT.

This function returns

nothing

Example


int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

configures pin number 13 to work as an output pin.

See also

Share