Advertisement
Guest User

Untitled

a guest
Dec 5th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.50 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3. Servo myservo1; // licht aan,licht uit
  4. Servo myservo2; // hand zwaait
  5.  
  6. int pos = 0;
  7.  
  8. #include <AFMotor.h>
  9.  
  10. AF_Stepper motor(50, 2); // zwaai arm omhoog en omlaag
  11.  
  12.  
  13.  
  14. const int LED = 3;
  15.  
  16.  
  17. void setup(){
  18.  
  19. Serial.println("Licht aan");
  20. myservo1.attach(9); // attaches the servo on pin 9 to the servo object
  21. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  22. { // in steps of 1 degree
  23. myservo1.write(pos); // tell servo to go to position in variable 'pos'
  24. delay(15); // waits 15ms for the servo to reach the position
  25. }
  26. for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  27. {
  28. myservo1.write(pos); // tell servo to go to position in variable 'pos'
  29. delay(15); // waits 15ms for the servo to reach the position
  30. }
  31.  
  32. Serial.begin(9600); // set up Serial library at 9600 bps
  33. Serial.println("Zwaai arm beweegt omhoog");
  34.  
  35. motor.setSpeed(10); // 10 rpm
  36. motor.step(10, FORWARD,SINGLE);
  37. delay(50);
  38.  
  39. Serial.println("Hand zwaait");
  40. {
  41. myservo1.attach(9); // attaches the servo on pin 9 to the servo object
  42. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  43. { // in steps of 1 degree
  44. myservo1.write(pos); // tell servo to go to position in variable 'pos'
  45. delay(15); // waits 15ms for the servo to reach the position
  46. }
  47. for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  48. {
  49. myservo1.write(pos); // tell servo to go to position in variable 'pos'
  50. delay(15); // waits 15ms for the servo to reach the position
  51. }
  52. {
  53. }
  54. myservo2.attach(10); // attaches the servo on pin 9 to the servo object
  55. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  56. { // in steps of 1 degree
  57. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  58. delay(5); // waits 15ms for the servo to reach the position
  59. }
  60. for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  61. {
  62. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  63. delay(5); // waits 15ms for the servo to reach the position
  64. }
  65. myservo2.attach(10); // attaches the servo on pin 9 to the servo object
  66. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  67. { // in steps of 1 degree
  68. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  69. delay(5); // waits 15ms for the servo to reach the position
  70. }
  71. for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  72. {
  73. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  74. delay(5); // waits 15ms for the servo to reach the position
  75. }
  76. myservo2.attach(10); // attaches the servo on pin 9 to the servo object
  77. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  78. { // in steps of 1 degree
  79. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  80. delay(5); // waits 15ms for the servo to reach the position
  81. }
  82. for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  83. {
  84. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  85. delay(5); // waits 15ms for the servo to reach the position
  86. } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
  87. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  88. { // in steps of 1 degree
  89. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  90. delay(5); // waits 15ms for the servo to reach the position
  91. }
  92. for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  93. {
  94. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  95. delay(5); // waits 15ms for the servo to reach the position
  96. } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
  97. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  98. { // in steps of 1 degree
  99. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  100. delay(5); // waits 15ms for the servo to reach the position
  101. }
  102. for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  103. {
  104. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  105. delay(5); // waits 15ms for the servo to reach the position
  106. } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
  107. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  108. { // in steps of 1 degree
  109. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  110. delay(5); // waits 15ms for the servo to reach the position
  111. }
  112. for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  113. {
  114. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  115. delay(5); // waits 15ms for the servo to reach the position
  116. } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
  117. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  118. { // in steps of 1 degree
  119. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  120. delay(5); // waits 15ms for the servo to reach the position
  121. }
  122. for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  123. {
  124. myservo2.write(pos); // tell servo to go to position in variable 'pos'
  125. delay(5); // waits 15ms for the servo to reach the position
  126. }
  127.  
  128. Serial.begin(9600); // set up Serial library at 9600 bps
  129. Serial.println("Zwaai arm beweegt omlaag");
  130.  
  131. motor.setSpeed(10); // 10 rpm
  132.  
  133. motor.step(10, BACKWARD, SINGLE);
  134. delay(50);
  135. }{
  136. myservo1.attach(9); // attaches the servo on pin 9 to the servo object
  137. for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
  138. { // in steps of 1 degree
  139. myservo1.write(pos); // tell servo to go to position in variable 'pos'
  140. delay(15); // waits 15ms for the servo to reach the position
  141. }
  142. for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
  143. {
  144. myservo1.write(pos); // tell servo to go to position in variable 'pos'
  145. delay(15); // waits 15ms for the servo to reach the position
  146. }
  147. }
  148.  
  149. }
  150. void loop()
  151. {
  152.  
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement