Introduction
digitalWrite() lets you turn a pin on or off to control things like lights or motors.
Jump into concepts and practice - no test required
digitalWrite() lets you turn a pin on or off to control things like lights or motors.
digitalWrite(pin, value);
pin is the number of the pin you want to control.
value can be HIGH (on) or LOW (off).
digitalWrite(13, HIGH);digitalWrite(8, LOW);digitalWrite(5, HIGH);This program makes the built-in LED on pin 13 blink on and off every second.
void setup() {
pinMode(13, OUTPUT); // Set pin 13 as output
}
void loop() {
digitalWrite(13, HIGH); // Turn LED on
delay(1000); // Wait 1 second
digitalWrite(13, LOW); // Turn LED off
delay(1000); // Wait 1 second
}Always set the pin mode to OUTPUT before using digitalWrite().
Use delay() to create pauses between turning pins on and off.
Pin numbers depend on your Arduino board model.
digitalWrite() controls a pin's voltage: HIGH for on, LOW for off.
Use it to turn devices like LEDs and motors on or off.
Remember to set the pin as OUTPUT first with pinMode().
digitalWrite() function do in Arduino programming?digitalWrite()?pinMode(8, OUTPUT); digitalWrite(8, LOW); digitalWrite(8, HIGH); digitalWrite(8, LOW);
digitalWrite(12, HIGH); pinMode(12, OUTPUT);
digitalWrite() inside the loop() function to achieve this?