Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myservo; // create servo object to control a servo
- // a maximum of eight servo objects can be created
- int pos = 0;
- void setup(){
- pinMode(12,OUTPUT);
- pinMode(13,OUTPUT);
- myservo.attach(5);
- }
- void loop(){
- for(int i = 0;i<6; i++){
- digitalWrite(9,LOW);
- digitalWrite(8,LOW);
- digitalWrite(12,LOW);
- digitalWrite(13,HIGH);
- //high komt overeen met '1'
- //high = forward, low = back
- analogWrite(3,255);
- analogWrite(11,255);
- delay(1000);
- analogWrite(3,80);
- analogWrite(11,80);
- delay(1000);
- digitalWrite(9,HIGH);
- digitalWrite(8,HIGH);
- myservo.write(0); // tell servo to go to position in variable 'pos'
- delay(random(100,500)); // waits 15ms for the servo to reach the position
- myservo.write(90); // tell servo to go to position in variable 'pos'
- delay(random(500,1500)); // waits 15ms for the servo to reach the position
- }
- for(int i= 0; i<5; i++){
- digitalWrite(9,LOW);
- digitalWrite(8,LOW);
- digitalWrite(12,HIGH);
- digitalWrite(13,LOW);
- //Draaisnelheid 0 = 0%, 255 = 100%
- analogWrite(3,255);
- analogWrite(11,255);
- delay(1000);
- analogWrite(3,80);
- analogWrite(11,80);
- delay(1000);
- digitalWrite(9,HIGH);
- digitalWrite(8,HIGH);
- myservo.write(0); // tell servo to go to position in variable 'pos'
- delay(random(100,500)); // waits 15ms for the servo to reach the position
- myservo.write(90); // tell servo to go to position in variable 'pos'
- delay(random(500,1500)); // waits 15ms for the servo to reach the position
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement