Hi Leute
so. es funktioniert jetzt perfekt.
Gelöst via Arduino.
Verwendet habe ich einen Pro Mini 5V 16Hz
Vor dem Arduino befindet sich noch ein kleiner Spannungswandler der mir die Spannung vom 2s LIPO auf genau 5V regelt.
Dahinter stecken jetzt paar Stunden Arbeit und diverses Testen.
Ich stelle den Code hier aber trotzdem mal online, falls jemand was ähnliches nachbauen will
![Smile :-)](./images/smilies/icon_smile.gif)
Denn billiger und flexibler als mit einem Arduino kann man es fast nicht lösen.
Endausschläge und Geschwindigkeit für das jeweilige Servo sind einstellbar.
Die Servoposition an die das Servo geschickt wird, wird per Zufall via Random-Wert generiert.
Video:
https://vimeo.com/113400037
Man benötigt folgende Library sowie unten stehenden Code
Library:
VarSpeedServo.h
kann man hier downloaden:
https://github.com/netlabtoolkit/VarSpeedServo
Code:
#include <VarSpeedServo.h>
#define SERVO_P1 10 // Servo connected to PIN 10
#define SERVO_P2 11 // Servo connected to PIN 11
#define WAIT_I 1000 // wait after init in ms
#define POS_L 20 // left endstop
#define POS_R 160 // right endstop
#define POS_O 20 // oben endstop
#define POS_U 160 // unten endstop
#define WAIT_EN 350 // wait time at endstop in ms
#define WAIT_IN 500 // wait time at each angular increment in ms
VarSpeedServo servo1; // create servo object to control a servo
VarSpeedServo servo2; // Zusatzservo für oben unten
void setup()
{
servo1.attach(SERVO_P1); // attaches the servo on pin 10 to the servo object
servo1.write(POS_L); // tell servo to go to init position
servo2.attach(SERVO_P2); // attaches the servo on pin 11 to the servo object
servo2.write(POS_O); // tell servo to go to init position
delay(WAIT_I); // wait a little bit
}
void loop()
{
int posX = 0; // variable to store the servo position
int posY = 0; // variable to store the servo position
int gotoX = (int) random(POS_L, POS_R);
int gotoY = (int) random(POS_O, POS_U);
servo1.write(gotoX,40); // tell servo to go to position in variable 'pos'
servo2.write(gotoY,10); // tell servo to go to position in variable 'pos'
delay(WAIT_IN); // waits for the servo to reach the position
}