Arnov Sharma
Published © MIT

DC PUMP DRIVER With Custom PCB Breadboard

Simple MOSFET-Driven DC Pump Driver

BeginnerFull instructions provided1 hour43

Things used in this project

Story

Read more

Schematics

SCH

Code

code

C/C++
const int mosfetPin = 17;   // GPIO17
const int ledPin    = D9;   // LED
const int buttonPin = 27;  // Button
bool active = false;
unsigned long startTime = 0;
const unsigned long onTime = 5000; // 5 seconds
void setup() {
pinMode(mosfetPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
digitalWrite(mosfetPin, LOW);
digitalWrite(ledPin, LOW);
}
void loop() {
// Button pressed (LOW)
if (!active && digitalRead(buttonPin) == LOW) {
active = true;
startTime = millis();
digitalWrite(mosfetPin, HIGH); // MOSFET ON
digitalWrite(ledPin, HIGH);    // LED ON
}
// After 5 seconds
if (active && millis() - startTime >= onTime) {
digitalWrite(mosfetPin, LOW);  // MOSFET OFF
digitalWrite(ledPin, LOW);     // LED OFF
active = false;
}
}

Credits

Arnov Sharma
371 projects • 381 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.

Comments