#include <Servo.h> 

Servo servo; 

int tasterred = 2;
int tasterstatusred = 0;
int tasterblue = 3;
int tasterstatusblue = 0;
int eingang = A0;
int sensorwert = 0;
int step = 0;

float pos = 0;


void setup()
{
servo.attach(9); 
servo.write(pos);
pinMode(tasterred, INPUT_PULLUP);
pinMode(tasterblue, INPUT_PULLUP);
Serial.begin(9600);
}

 

void loop()
{ 
sensorwert =analogRead(eingang);
  step=map(sensorwert, 0, 1023, 1.0, 10.0);
Serial.println(step);
tasterstatusred = digitalRead(tasterred);
   if (tasterstatusred == LOW)
   {
     if (pos>0)
     {
       servo.write(pos); 
      pos-=step; 
      delay(5);
     }

   }

   tasterstatusblue = digitalRead(tasterblue);
   if (tasterstatusblue == LOW)
   {
      if (pos<180)
    {
      servo.write(pos); 
      pos+=step; 
      delay(5); 
    }
   }
}