Need to add second button and motor. Please help

#include <Servo.h>

Servo myservo1;
int value;
double angle;

void setup()
{
Serial.begin(9600);
myservo1.attach(9);
}

void loop()
{
value = digitalRead(7);
if(value==HIGH) {
angle = 90;
} else {
angle = 0;
}
Serial.println(angle);
myservo1.write(angle);
delay(100);
}
//================================================================

Servo myservo2;
int value;
double angle;

void setup()
{
Serial.begin(9600);
myservo2.attach(10);
}

void loop()
{
value = digitalRead(4);
if(value==HIGH) {
angle = 90;
} else {
angle = 0;
}
Serial.println(angle);
myservo2.write(angle);
delay(100);

Your sketch can have only one setup() function and one loop() function. You need to merge the contents of these functions.

You might find this page helpful as it contains step by step instructions about joining two codes together.
http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.