TIP120 transistor is always ON

Hello all!

I'm trying to control power to a 12V pump from a 12V DC source using a TIP120 transistor with Arduino Nano setting the Base pin Low/High. The 12V DC source is also supplying power to the Nano via the Vin pin.

I've written some code that should toggle the pump on when a button is pressed. But when I power up the circuit, the pump stays on regardless.

Is my TIP120 component getting fried? I have tried several and all meet the same fate. Could someone please spot the error(s) in my circuit? Please find the code below and the wiring diagram attached.

int btRxPin = 2;
int btTxPin = 3;
int whiteLedPin = 4;
int blueLedPin = 5;
int pumpPin = 6;
int buttonPin = 7;

bool buttonState;
bool blueLedState;
bool pumpState;

void setup() {
  pinMode(whiteLedPin, OUTPUT);
  pinMode(blueLedPin, OUTPUT);
  pinMode(pumpPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  digitalWrite(blueLedPin, LOW);
  digitalWrite(pumpPin, LOW);
  Serial.begin(9600);
  Serial.println('BUTTON\tBLUE LED\tPUMP');
}

void loop() {
  
  // turn on pump and blue LED if button is pressed
  button_pump_control();
  delay(200);

}

void button_pump_control() {
  // check if the pushbutton is pressed
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
    // turn blue LED on
    digitalWrite(blueLedPin, HIGH);
    // turn pump on
    digitalWrite(pumpPin, HIGH);
  }
  else {
    // turn blue LED off
    digitalWrite(blueLedPin, LOW);
    // turn pump off
    digitalWrite(pumpPin, LOW);
  }
  blueLedState = digitalRead(blueLedPin);
  pumpState = digitalRead(pumpPin);
  Serial.print(buttonState);
  Serial.print('\t');
  Serial.print(blueLedState);
  Serial.print('\t');
  Serial.println(pumpState);
}

Does the LED turn ON/OFF ?

pumpPin = 6;
However your schematic shows pin 4.


The Arduino has no GND connection.


Show us a good image of your ‘actual’ wiring.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0

Also beware of 12 volts to the Arduino.

7 - 10 volts is a better option for the longevity of the board.

+1
A Nano will eventually fry with 12volt on V-in.
And sooner when it has to power a BT module and two LEDs.

The button should be powered from 5volt (assuming a 5volt (16Mhz) Nano), although 3.3volt will work.

An easier way to use a button is to wire it between pin and ground (no resistor).
Then enable internal pull up on the pin in pinMode.
pinMode (buttonPin, INPUT_PULLUP);
Logic is now reversed. The pin is normally HIGH, and LOW when the button is pushed.
Leo..