0

include

Servo myservo;

void setup(){ myservo.attach(8); pinMode(buttonPin, INPUT); }

void loop() { myservo.write(0); delay(3); myservo.write(90); delay(3); } const int inPin=8; const int outPin = 9; int currentState = LOW; currentState = digitalRead (inPin); if (currentState== HIGH) digitalWrite (outPin,HIGH); else digitalWrite (outPin,HIGH); delay(10); }

0
0

Do NOT use two loop() and setup() function.

You can refer to a similar combination between Servo Motor code and Potentiometer code here.

1
  • Thanks for the wonderful website
    – Lea
    Nov 11 '19 at 10:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.