Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myservo1; // licht aan,licht uit
- Servo myservo2; // hand zwaait
- int pos = 0;
- #include <AFMotor.h>
- AF_Stepper motor(50, 2); // zwaai arm omhoog en omlaag
- const int LED = 3;
- void setup(){
- Serial.println("Licht aan");
- myservo1.attach(9); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo1.write(pos); // tell servo to go to position in variable 'pos'
- delay(15); // waits 15ms for the servo to reach the position
- }
- for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo1.write(pos); // tell servo to go to position in variable 'pos'
- delay(15); // waits 15ms for the servo to reach the position
- }
- Serial.begin(9600); // set up Serial library at 9600 bps
- Serial.println("Zwaai arm beweegt omhoog");
- motor.setSpeed(10); // 10 rpm
- motor.step(10, FORWARD,SINGLE);
- delay(50);
- Serial.println("Hand zwaait");
- {
- myservo1.attach(9); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo1.write(pos); // tell servo to go to position in variable 'pos'
- delay(15); // waits 15ms for the servo to reach the position
- }
- for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo1.write(pos); // tell servo to go to position in variable 'pos'
- delay(15); // waits 15ms for the servo to reach the position
- }
- {
- }
- myservo2.attach(10); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- myservo2.attach(10); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- myservo2.attach(10); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- } myservo2.attach(10); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- for(pos = 190; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo2.write(pos); // tell servo to go to position in variable 'pos'
- delay(5); // waits 15ms for the servo to reach the position
- }
- Serial.begin(9600); // set up Serial library at 9600 bps
- Serial.println("Zwaai arm beweegt omlaag");
- motor.setSpeed(10); // 10 rpm
- motor.step(10, BACKWARD, SINGLE);
- delay(50);
- }{
- myservo1.attach(9); // attaches the servo on pin 9 to the servo object
- for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 180 degrees
- { // in steps of 1 degree
- myservo1.write(pos); // tell servo to go to position in variable 'pos'
- delay(15); // waits 15ms for the servo to reach the position
- }
- for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
- {
- myservo1.write(pos); // tell servo to go to position in variable 'pos'
- delay(15); // waits 15ms for the servo to reach the position
- }
- }
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement