#include Servo Motor; const int buttonPin = 2; int buttonState = 0; boolean change = true; boolean stopped = false; int speed = 95; int stopSpeed = 95; void setup() { pinMode(buttonPin, INPUT); Motor.attach(12); Serial.begin(9600); } void loop() { buttonState = digitalRead(buttonPin); int sensorValue = analogRead(A0); speed = map(sensorValue, 0, 1023, 20, 160); delay(1); if(change){ if(buttonState == 1){ change = false; Serial.println(change); stopped = !stopped; } } if(!change){ if( buttonState != 1){ change = true; } } if(stopped){ speed = stopSpeed; }else{ speed = map(sensorValue, 0, 1023, 20, 160); } Motor.write(speed); } //Kristjan, Mait, Siim