ATTiny85 and Pot issue when connecting to transistor on external 12v supply.

In short (pun intended maybe?) , all I wanted was a small 12v pump (draws about half an amp) to come on once every 6 hours (ish) and the duration it should be on each time is determined by the value of a potentiometer. Simple right? Well I can not get past the incy problem...

  1. The Pot was working when connected to the Nano USB powered only. I used softwareserial to see it work. Amazing stuff.

  2. I then added a transistor that would come on when pin 5 (Digital 0) is made high. Initially I used the 5v power from the Nano on the collector side. It worked. I could time an LED on for a certain amount of time determined by the Pot.

  3. I now want to remove the Nano (as it was originally for the Serial readout and just for a 5v regulator). Before I pulled it out completely, I attatched a 12v battery to the transistor, joined the GND lines together and thought I would make sure the thing can run a pump.

It can.

So my problem is...the Pot pin (pin 7, Analog 1, A1) always reads 5v regardless of the pot position. This causes my pump to only stay on the maximum time possible.

Why is my pot always at 5v :|?

Well here is my circuit:

|500x363

And my code (PS "minute" is only 1 second (1000 millis) at the moment for testing. D4 was used for a "de-bugging LED" which flashed a number of times depending on the pot position.):

int pump=0;
int sensorPin = A1;    // select the input pin for the potentiometer
int led=4;

int minute=1000;
int sensorValue = 0;  // variable to store the value coming from the sensor
int setting=0;        //a variable to store the mapped value of the sensorValue.

void setup()  
{
  
  pinMode(sensorPin,INPUT); //Connect to A1 or ATtiny physical pin 7.
  pinMode(pump,OUTPUT);    //Goes to transistor base though small resistor. On D0 or physical pin 5.
  pinMode(led,OUTPUT);     //Debugging/Indicator LED. On D4 or physical pin 3.
}

void loop() // run over and over
{
  int i=0;
  
sensorValue=analogRead(sensorPin);      //Get the analog voltage from the pot.
setting=map(sensorValue,0,1023,1,10);    //Map it to a value of 1 to 10.

  for (i=0;i

Any help would be much appreciated!

Either A1 is shorted to Vcc (sloppy soldering around the pins at tiny85 side or near pot), or there's a bad connection on ground side of pot.

Disconnect power and measure resistance from Vcc to A1 with pot near middle. If it's 0, Vcc and A1 are shorted. If it's around 5k, the GND side of the pot is disconnected.

DrAzzy: Either A1 is shorted to Vcc (sloppy soldering around the pins at tiny85 side or near pot), or there's a bad connection on ground side of pot.

Disconnect power and measure resistance from Vcc to A1 with pot near middle. If it's 0, Vcc and A1 are shorted. If it's around 5k, the GND side of the pot is disconnected.

TYVM!

I feel like an idiot ha. There was a 1.5k ohm resistance or lower meaning a kinda short somewhere on the breadboard. It is all on breadboard so at least I now know it works!

PS before I put this on PCB, it looks ok right?

Just replace the 5v from the Nano with a 5v regulator and small smoothing cap?

Is that a 2N2222A transistor?

Johnny010: TYVM!

I feel like an idiot ha. There was a 1.5k ohm resistance or lower meaning a kinda short somewhere on the breadboard. It is all on breadboard so at least I now know it works!

1.5k ohm is within the pot's adjustment range- you haven't found a short, you've shown that there isn't a short between Vcc and the pin. The measured resistance should change as you turn the pot.

What about between the pin and ground? If the high side of the voltage divider is okay (sounds like it), the problem must be on the low side.

You never will see more than ~4volt on the pump with this circuit.

You have drawn an emitter follower. The emitter is always 0.7volt lower than it's base...

The pump has to go in the COLLECTOR line. With a 1N4004 kickback diode. Emitter has to go to ground. And the base resistor has to be 220ohm. Anything lower could damage the output port. And using a 2N2222 is a bad idea. A logic mosfet is the way to go. Second best is a 1-5A NPN power transistor. Or a 2-transistor circuit with high-side switching. Leo..