Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

10 Crazy Machine: Freddy

5. Dezember 2011

YouTube Preview Image

#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);
}
}