Advertisement
Guest User

Dripper

a guest
Jan 30th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. Servo myservo; // create servo object to control a servo
  4. // a maximum of eight servo objects can be created
  5.  
  6. int pos = 0;
  7. void setup(){
  8. pinMode(12,OUTPUT);
  9. pinMode(13,OUTPUT);
  10. myservo.attach(5);
  11. }
  12. void loop(){
  13.  
  14. for(int i = 0;i<6; i++){
  15.  
  16.  
  17. digitalWrite(9,LOW);
  18. digitalWrite(8,LOW);
  19.  
  20. digitalWrite(12,LOW);
  21. digitalWrite(13,HIGH);
  22. //high komt overeen met '1'
  23. //high = forward, low = back
  24. analogWrite(3,255);
  25. analogWrite(11,255);
  26. delay(1000);
  27. analogWrite(3,80);
  28. analogWrite(11,80);
  29. delay(1000);
  30. digitalWrite(9,HIGH);
  31. digitalWrite(8,HIGH);
  32.  
  33. myservo.write(0); // tell servo to go to position in variable 'pos'
  34. delay(random(100,500)); // waits 15ms for the servo to reach the position
  35. myservo.write(90); // tell servo to go to position in variable 'pos'
  36. delay(random(500,1500)); // waits 15ms for the servo to reach the position
  37. }
  38. for(int i= 0; i<5; i++){
  39.  
  40.  
  41. digitalWrite(9,LOW);
  42. digitalWrite(8,LOW);
  43. digitalWrite(12,HIGH);
  44. digitalWrite(13,LOW);
  45. //Draaisnelheid 0 = 0%, 255 = 100%
  46. analogWrite(3,255);
  47. analogWrite(11,255);
  48. delay(1000);
  49. analogWrite(3,80);
  50. analogWrite(11,80);
  51. delay(1000);
  52. digitalWrite(9,HIGH);
  53. digitalWrite(8,HIGH);
  54.  
  55. myservo.write(0); // tell servo to go to position in variable 'pos'
  56. delay(random(100,500)); // waits 15ms for the servo to reach the position
  57. myservo.write(90); // tell servo to go to position in variable 'pos'
  58. delay(random(500,1500)); // waits 15ms for the servo to reach the position
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement