So it's supposed to power the pump for a certain amount of time every time the sensor gets a movement, but the pump won't start. The pump by itself works but when I want to manage it via the driver, it make a little sounds when it's supposed to start or stop, but doesn't move the slightest.
The pump is supposed to be 12V, but I only have 9V batteries so I wired two for 18V and the driver can support up to 36V.
int dir1(1),dir2(2);
int pumpPin(10);
int pumpSPD(255);
int capteurPin(6);
void setup()
{
pinMode(dir1,OUTPUT);
pinMode(dir2,OUTPUT);
pinMode(pumpPin,OUTPUT);
pinMode(13,OUTPUT);
pinMode(capteurPin,INPUT);
}
void loop()
{
digitalWrite(dir1,LOW);
digitalWrite(dir2,HIGH);
if (digitalRead(capteurPin)==HIGH)
{
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
analogWrite(pumpPin,pumpSPD);
delay(200);
analogWrite(pumpPin,0);
delay(2000);
}
}
Sorry if it's something obvious I'm just starting with those things.
9v batteries are incapable of provide large amounts of current to motors.
Pin one is TX pin on an UNO, avoid using it, try a different pin.
What is the resistance of the motor ?
18v powering the sensor might be wrong, show us a link to the sensor; you may be damaging the UNO if the sensor outputs 18v to the UNO input pin.
What is this about ?
int dir1(1),dir2(2);
int pumpPin(10);
int pumpSPD(255);
int capteurPin(6);
LarryD:
9v batteries are incapable of provide large amounts of current to motors.
Pin one is TX pin on an UNO, avoid using it, try a different pin.
What is the resistance of the motor ?
18v powering the sensor might be wrong, show us a link to the sensor; you may be damaging the UNO if the sensor outputs 18v to the UNO input pin.
Thanks for your answer
I changed the pin according to your suggestion, but I have no idea what the motor's resistance is.
here's the link to the sensor
The link says Voltage range: 3V-5V .
18v will kill it.
Am i supposed to put a resistor ? if yes which one
Your sensor link says it needs 5v for power.
You have connected it to 18v.
If you have not damaged the sensor , it should be connected to 5v.
Do you have a link to the pump ?
i rewired it so that its connected to the arduino 5v
i checked if it still works with a led and its working
here's a link to the pump
Caractéristiques: 1. Fabriqué en matériau de haute qualité, durable et longue durée de vie. 2. La taille du moteur est 32x23mm, facile à installer et à enlever. 3. Disponible en trois styles au choix. 4. Le sens d'écoulement de la pompe...
26,23€
What is written on the pump ?
i'm using a dc motor driver ( L293D ) to command the pump, and the two dir are to define the direction of rotation , pump pin is just the pin from where is send the speed command to the driver an pumpSPD is the max speed of the pump. capteurPin is the input to receive the sensor's signal
only thing written on the pump is GROTHEN 12V 3x5
LarryD
May 16, 2021, 5:49pm
11
Should be:
int dir1 = 1; // not recommended to use pin 1, use a different pin
int dir2 = 2;
int pumpPin = 10;
int pumpSPD = 255 ;
int capteurPin = 6;
Pin 16 of the L293D needs to be connected to 5v.
Fixed typos in the code offered above.
but if the vcc pin of the L293D is on 5v won't the motor be on 5v too ?
because it doesn't move under 12v
LarryD
May 16, 2021, 5:55pm
13
No.
5v is for the logic components inside the I.C.
12v is the voltage applied to the power driver for the motor.
You need both 5v and 12v.
I think the motor will need 500mA to work properly. 9v batteries will not last.
so i wire the 5v pin of the arduino to breadborad and then to the vcc (8th pin) of the l293d and it should work ?
LarryD
May 16, 2021, 6:17pm
15
Pin 16 of the L293D to Arduino 5v header pin.
Pin 18 of the L293D to +12v motor supply. there is no pin 18
Should be Pin 8 of the L293D to +12v motor supply.
GND of the Arduino must be connected to the GND of the motor 12v supply.
If you have not already damaged any components things should be close to working, however, let’s see the code you have now.
In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch .
Use the </> icon from the ‘reply menu’ to attach the copied sketch.
/* INIT PINS */
int dir1(1), dir2(2);
int pumpPin(10);
int pumpSPD(255);
int capteurPin(6);
int tries(0);
void setup()
{
pinMode(dir1, OUTPUT);
pinMode(dir2, OUTPUT);
pinMode(pumpPin, OUTPUT);
pinMode(capteurPin, INPUT);
}
void loop()
{
digitalWrite(dir1, LOW);
digitalWrite(dir2, HIGH);
digitalWrite(13, LOW);
if (digitalRead(capteurPin) == HIGH)
{
delay(1000);
analogWrite(pumpPin, pumpSPD);
delay(1250);
analogWrite(pumpPin, 0);
delay(1000);
}
}
also there's only 16 pin on the l293d so i'm confused
LarryD
May 16, 2021, 6:23pm
18
Please make the changes shown to you in post #11 , but do not use pin 1 on the Arduino.
LarryD
May 16, 2021, 6:25pm
19
Sorry.
Should be Pin 8 of the L293D to +12v motor supply.
that's what i've been doing
i'll send u another schematic of what i have now
sorry for the delay the account is new and i had to wait 24 h