DigitalWrite()

From Microduino Wiki
Revision as of 05:50, 12 August 2016 by Fengfeng (talk) (Created page with "<pre style="color:green"> void digitalWrite (uint8_t pin, uint8_t value) </pre> Write the digital pin.<br> Write the digital pin, corresponding to the high and low level...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

void digitalWrite (uint8_t pin, uint8_t value)

Write the digital pin.

Write the digital pin, corresponding to the high and low level of the pin. Before writing the pin, you need to set the mode of the pin as OUTPUT.

  • Parameter:

pin number of the pin

value HIGH or LOW

  • 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);   //Light LED
  delay(1000);                  // Wait for 1s
  digitalWrite(ledPin, LOW);    // switch off
  delay(1000);                  // waits for a second
}
  • Note:

Analog pin can be used as digital pin, and the number is from 14 (corresponding the analog pin 0) to 19 (corresponding to the analog pin 5).

[Return to Arduino Syntax Manual]