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...
The Pot was working when connected to the Nano USB powered only. I used softwareserial to see it work. Amazing stuff.
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.
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:
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!