Programmed Pump

by Erla in Circuits > Arduino

250 Views, 0 Favorites, 0 Comments

Programmed Pump

Screenshot 2022-09-26 at 15.24.14.png
Screenshot 2022-09-26 at 15.24.05.png

We programmed a pump to drop few drops every 30 seconds.


Supplies

mini_pump.jpg

Pump. Wires. Soldering supplies. Arduino board. Arduino top. Button. Tube.

download.jpg

Solder the wires together. Connect to power supply to make sure the pump works.

www.ubuy.jpg

Program the Arduino. Connect to button and to the pump.

void setup() {

 Serial.begin(9600);      // set up Serial library at 9600 bps

 Serial.println("Adafruit Motorshield v2 - DC Motor test!");


 if (!AFMS.begin()) {     // create with the default frequency 1.6KHz

 // if (!AFMS.begin(1000)) { // OR with a different frequency, say 1KHz

  Serial.println("Could not find Motor Shield. Check wiring.");

  while (1);

 }

 Serial.println("Motor Shield found.");


 // Set the speed to start, from 0 (off) to 255 (max speed)

 myMotor->setSpeed(50);

 myMotor->run(FORWARD);

 // turn on motor

 myMotor->run(RELEASE);


 pinMode(2, INPUT);

}


void loop() {


 int buttonState = digitalRead(2);

 Serial.println(buttonState);

 delay(1);  


  

 if (buttonState == 1) {

   

   myMotor->run(FORWARD);

   myMotor->setSpeed(50);

   delay(4000);

   

   

 }


 else {

   myMotor->run(RELEASE);

   delay(200);

 }

  


}