#include Servo myservo; // create servo object to control a servo const int touchsens = D4; //attacht touch const int minPos = 0; // define the step size const int maxPos = 180; // maximum servo angle const int Pos = 0; // maximum servo angle void setup() { myservo.attach(D5); // attaches the servo on pin 9 to the servo object myservo.write(pos); pinMode(touchsens,INPUT); //set touch sensor as input } void loop() { int val = digitalRead(touchsens); //save the value of touch sensor if (val == HIGH){ //if pressed for (pos = 0; pos <= 180; pos += 30) { myservo.write(pos); delay(500); } } }