Advertisement
Guest User

Arduino code double slit experiment

a guest
Jun 23rd, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Adjusted from Sweep example by Stijn van der Lippe
  2.  
  3. #include <Servo.h>
  4.  
  5. Servo myservo;                      // create servo object to control a servo
  6.                                     // twelve servo objects can be created on most boards
  7.  
  8. int pos = 90;                       // variable to store the servo position, starts at 90 degrees
  9.  
  10. void setup() {
  11.   myservo.attach(9);                // attaches the servo on pin 9 to the servo object
  12. }
  13.  
  14. void loop() {
  15.   myservo.write(pos);               // tell servo to go to position in variable 'pos'
  16.   delay(2);                         // waits 2ms for the servo to reach the position
  17.   pos += 5;                          // set position variable forward 5 degrees
  18.   myservo.write(pos);               // tell servo to go to position in variable 'pos'
  19.   delay(2);                         // waits 2ms for the servo to reach the position
  20.   pos -= 5;                          // set position variable back 5 degrees
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement