Hard Part Over – Swetha

I finally got my peristaltic pump from adafruit to work! I’m in the process of adjusting to code so that I can add a stop/start button and a potentiameter to determine the speed of the pump.

Code:


int motorPin1 = 9;
int buttonPin = 2;
int buttonState = 0;
boolean turnMoterOn = true;

void setup() {
  pinMode(motorPin1, OUTPUT);
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);


  analogWrite(motorPin1, 0);
}

void loop() {
   buttonState = digitalRead(buttonPin);
   Serial.println( buttonState);
   if(buttonState == LOW){
     turnMoterOn = !turnMoterOn;
   }
   if( turnMoterOn == false){
       pinMode(motorPin1, INPUT);
       Serial.print("off");
   }
   delay(3000);
     

  analogWrite(motorPin1, 0);
}

 

Fritzing:

I used a 9V battery for this diagram, and although the 9V works, a 12V works the best!

fritzingSketch_bb

Comments are closed.