Arduino seems to set digital pin to HIGH on startup.


I’m attempting to control a simple DC motor via a transistor (NTE2395) and digital pin. The transistor’s specs are fine with the motor’s power needs. I can seem to control it alright, except that when the Arduino powers on the motor runs for about 2-3 seconds before entering the loop. Here’s some simple code that does this.

#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

const int pumpPin = 10;

int buttons;

void setup() {
  pinMode(pumpPin, OUTPUT);
  digitalWrite(pumpPin, LOW);
  Serial.println("Pump should not be on.");


void loop() {
  buttons = lcd.readButtons();
    if(buttons & BUTTON_UP){
      analogWrite(pumpPin, 255);
      Serial.println("Pump turned on.");
    if(buttons & BUTTON_DOWN){
      analogWrite(pumpPin, LOW);
      Serial.println("Pump turned off.");


It would seem the Arduino is setting the pin to HIGH when it sets it as an OUTPUT before digitalWrite(pumpPin, LOW), but maybe not?

Note that the serial print “Pump should not be on.” in the setup only prints after the pump turns off. I’ve confirmed that it only does this after, not before or during. Just in case it’s relevant, I have two shields, an LCD Shield and RTC Shield both from Adafruit that use the I2C stuff through pins 4 and 5 (not really too familiar with it).

Please let me know if you any questions.

As I was uploading an old version of a different program to the Arduino, one that didn't even include anything about the pumpPin, I noticed it still did the motor turning on thing. I'm very stumped!

Is there any reason as to why the Arduino would set digital pin 10 to HIGH for a discreet period of time?

When Arduino starts up (before entering setup), the pin is set as INPUT (floating, high impedance). In this state, the voltage level at the pin could easily drift to a level that turns on the MOSFET. To prevent this, all you need to do is install a pull-down resistor from pin 10 to GND. A good value would be 10K.

1 Like