I'm making a project about automatic watering for plants! But i don't understand my problem:
When I connect the water pump to 5v and gnd, it works perfectly, but when i use a digital or analogic pin with 5v (measured with a polimeter), it doesn't work. I tried reprogramming the code, but it still isn't the problem.
const int dry = 595; // value for dry sensor
const int wet = 239; // value for wet sensor
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorVal = analogRead(A5);
int percentageHumididy = map(sensorVal, wet, dry, 100, 0);
Serial.print(percentageHumididy);
Serial.println("%");
if(percentageHumididy <= 60){
analogWrite(A0, 600);
} else if(percentageHumididy >= 90){
analogWrite(A0, 0);
}
}
if you are using an Arduino UNO R3 ...
A0 ist NOT a PWM output pin.
Your pump will not work without any other circuit on an Arduino Pin because it draws to much CURRENT.
If you are using a basic Water Pump Like for Small Projects it would usually take around 50mA of current. Use PWM Pins of Arduino To send PWM Signals. This --> "~" type of marks would be beside the PWM Pins !
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
How are you driving the pump, directly from the controller output?
If so then STOP.
The output of the controller will not be enough to power the pump, and you can damage the controller.
Can you please post some picture of your project?
So we can see your component layout.
Can you please post a link to specs/data of the pump?