Tuesday, 16 November 2010

Method of Dropping substance with Pipette

Using a servo this system can flick a pipette and drop an acidic substance onto an image.


Code:

#include <Servo.h>
Servo myservo;                 // declares servo
int pos = 0;

int inputPin = 3;             // assigns input (button) to pin number
int val = 0;                 

void setup() {
  myservo.attach(2);          //assigns servo to pin number
  pinMode(inputPin, INPUT);   // declares button as input
}

void loop()  {
  val = digitalRead(inputPin);
  if (val == LOW) {                        //if input (button value is 0
    for(pos = 0; pos < 180; pos += 1);     // this will happen
 {
   myservo.write(pos);
   delay(3);
 }
 for(pos = 180; pos>=1; pos-=1)
 {
   myservo.write(pos);
   delay(3);
 }

  }

 else {                              // else, nothing
  
}

}

No comments:

Post a Comment