5. Dezember 2011
#include #define SERVO_PIN 9 #define POTI_R 1 #define POTI_L 2 Servo myServo; int rValue = 0; int lValue = 0; int roldVal = 0; int loldVal = 0; void setup() { Serial.begin(9600); myServo.attach(SERVO_PIN); myServo.write(90); } void loop(){ rValue = analogRead(POTI_R); rValue = (0.98*roldVal)+(0.02*rValue); roldVal = rValue; // lValue= analogRead(POTI_L); lValue = (0.98*loldVal)+(0.02*lValue); Serial.println(lValue); loldVal = lValue; if(rValue{ myServo.write(map(rValue,1023,0,90,179)); }else if(lValuemyServo.write(map(lValue,1023,0,90,179)); }else{ myServo.write(90); } }