Skip to content

Arduino digitalWrite Not Changing Pin State

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about Arduino digitalWrite Not Changing Pin State. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

digitalWrite() does not change the pin output state as expected.

Quick Fix

Wrong

pinMode(13, INPUT);  // Wrong mode
digitalWrite(13, HIGH);
Pin 13 stays low or shows unexpected behavior.
int ledPin = 13;
void setup() {
  pinMode(ledPin, OUTPUT);  // Must be OUTPUT
}
void loop() {
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
}
LED blinks on/off every second.

Prevention

Always set pinMode() to OUTPUT before calling digitalWrite(). Using INPUT mode disables the output driver. Use constants HIGH/LOW (not 1/0). On some pins (e.g., 6,7 on some boards), PWM may interfere with digitalWrite.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### Can I use digitalWrite on any pin?

Yes, but some pins have restrictions. Pins used for serial (0,1 on Uno), SPI, or I2C may conflict. Check the board pinout.

What voltage does digitalWrite(HIGH) output?

5V on 5V boards (Uno, Mega), 3.3V on 3.3V boards (Due, Zero). Never apply more than the board VCC to a pin.

Does digitalWrite work on analog pins?

Yes. Analog pins (A0-A5) can be used as digital GPIO. Use the pin number (14-19 on Uno) or the constant (A0).

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro