Last active
April 16, 2016 21:20
-
-
Save micw/f781a2db40db94589095ee407bf7284c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* https://www.youtube.com/watch?v=s8a6txkGqOI */ | |
#include <Servo.h> | |
Servo servoDreh; | |
Servo servoHochRunter; | |
int DREH_UBER_BECHER=170; | |
int HOCHRUNTER_IN_BECHER=140; | |
int HOCHRUNTER_UBER_BECHER1=100; | |
int HOCHRUNTER_UBER_BECHER2=80; | |
int DREH_VOR_GEBLAESE=35; | |
int HOCHRUNTER_VOR_GEBLAESE=80; | |
void moveTo(Servo servo, int dest, int delayMs) { | |
int ist=servo.read(); | |
int dir=(ist>dest)?-1:1; | |
while (ist!=dest) { | |
ist+=dir; | |
servo.write(ist); | |
delay(delayMs); | |
} | |
} | |
void setup() { | |
pinMode(3, OUTPUT); | |
digitalWrite(3, 0); | |
servoHochRunter.attach(5); | |
servoHochRunter.write(90); | |
delay(1000); | |
servoDreh.attach(4); | |
servoDreh.write(DREH_UBER_BECHER); | |
delay(1000); | |
} | |
void loop() { | |
moveTo(servoDreh,DREH_UBER_BECHER,5); | |
// Eintauchen | |
moveTo(servoHochRunter,HOCHRUNTER_IN_BECHER,10); | |
delay(1000); | |
// Abtropfen | |
moveTo(servoHochRunter,HOCHRUNTER_UBER_BECHER2,10); | |
delay(1000); | |
// Abschütteln | |
for (int i=0;i<5;i++) { | |
servoHochRunter.write(HOCHRUNTER_UBER_BECHER1); | |
delay(20); | |
moveTo(servoHochRunter,HOCHRUNTER_UBER_BECHER2,10); | |
} | |
delay(1000); | |
// Gebläse | |
moveTo(servoHochRunter,HOCHRUNTER_VOR_GEBLAESE,10); | |
digitalWrite(3, 1); // An | |
moveTo(servoDreh,DREH_VOR_GEBLAESE,10); | |
delay(5000); | |
digitalWrite(3, 0); // Aus | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment