Hi there, I have connected the air pump, solenoid valve, NPN transistor, 1N4001 diode to create a very simple circuit to make the air pump inflates for 2s and then deflate for 2s, and loop. However, when I run connects to the power, the air pump keeps running and seems the solenoid also doesn't turn on and off. I have no idea what's the problem with it. I attached my code. Any help would be appreciated.
int inflateTime = 2000;
int deflateTime = 2000;
int pump = 1;
int valve = 0;
void setup() {
pinMode(pump,OUTPUT);
pinMode(valve,OUTPUT);
}
void loop() {
digitalWrite(pump,HIGH); // Turns on the pump
//digitalWrite(valve,LOW); //Closes the valve
delay(inflateTime);
digitalWrite(pump,LOW); //Turns off the pump
//digitalWrite(valve,HIGH); //Opens the valve
delay(deflateTime);
}