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


in short (pun intended maybe?) , wanted small 12v pump (draws half amp) come on once every 6 hours (ish) , duration should on each time determined value of potentiometer. simple right? can not past incy problem...

1. pot working when connected nano usb powered only. used softwareserial see work. amazing stuff.

2. added transistor come on when pin 5 (digital 0) made high. used 5v power nano on collector side. worked. time led on amount of time determined pot.

3. want remove nano (as serial readout , 5v regulator).
    before pulled out completely, attatched 12v battery transistor, joined gnd lines , thought make sure thing can run pump.

it can.

so problem is...the pot pin (pin 7, analog 1, a1) reads 5v regardless of pot position. causes pump stay on maximum time possible.

why pot @ 5v :|?


well here circuit:



and code (ps "minute" 1 second (1000 millis) @ moment testing. d4 used "de-bugging led" flashed number of times depending on pot position.):

code: [select]



int pump=0;
int sensorpin = a1;    // select input pin potentiometer
int led=4;

int minute=1000;
int sensorvalue = 0;  // variable store value coming sensor
int setting=0;        //a variable store mapped value of sensorvalue.

void setup() 
{
 
  pinmode(sensorpin,input); //connect a1 or attiny physical pin 7.
  pinmode(pump,output);    //goes 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 on , over
{
  int i=0;
 
sensorvalue=analogread(sensorpin);      //get analog voltage pot.
setting=map(sensorvalue,0,1023,1,10);    //map value of 1 10.

  (i=0;i<setting;i++){              //flash led number of times setting is.
    digitalwrite (led,high);
    delay(1000);
    digitalwrite(led,low);
    delay(1000);
  }
  digitalwrite(pump,high);        //now set pump turn on setting time * minutes.
  delay(setting*minute);
  digitalwrite(pump,low);
 
  delay(5*minute);              //an "6 hour delay" before watering occurs again.
 

}


any appreciated!

either a1 shorted vcc (sloppy soldering around pins @ tiny85 side or near pot), or there's bad connection on ground side of pot.

disconnect power , measure resistance vcc a1 pot near middle. if it's 0, vcc , a1 shorted. if it's around 5k, gnd side of pot disconnected.


Arduino Forum > Using Arduino > General Electronics > ATTiny85 and Pot issue when connecting to transistor on external 12v supply.


arduino

Comments