I fixed the = to ==. How does it look now?
``/*
Project_Code_7
*/
#include <Servo.h>
Servo myservo; // Define the servo name
int togglePin2 = 2; // toggle switch is connected to pin 2 -- for sitting ('on' for two-way toggle)
int togglePin3 = 3; // toggle switch is connected to pin 3 -- for ascending stairs ('C' for three-way toggle)
int togglePin4 = 4; // toggle switch is connected to pin 4 -- for descending stairs ('G' for three-way toggle)
int buttonPin5 = 5; // button switch is connected to pin 5 -- for general walking
int val2; // variable for reading toggle2 status
int val3; // variable for reading toggle3 status
int val4; // variable for reading toggle4 status
int val5; // varialbe for reading button5 status
int toggleState2; // variable to hold last toggle2 state
int toggleState3; // variable to hold last toggle3 state
int toggleState4; // variable to hold last toggle4 state
int buttonState5; // variable to hold last button5 state
void setup()
{
myservo.attach(10); // servo is on digital pin 10
pinMode(togglePin2, INPUT_PULLUP); // set toggle2 as input
pinMode(togglePin3, INPUT_PULLUP); // set toggle3 as input
pinMode(togglePin4, INPUT_PULLUP); // set toggle4 as input
pinMode(buttonPin5, INPUT_PULLUP); // set button5 as input
}
void loop() {
val2 = digitalRead(togglePin2); // read input value of toggle2 and store it in val2
val3 = digitalRead(togglePin3); // read input value of toggle3 and store it in val3
val4 = digitalRead(togglePin4); // read input value of toggle4 and store it in val4
val5 = digitalRead(buttonPin5); // read input value of button5 and store it in val5
if (val2 == LOW) {
myservo.write(200);
delay(30);
}
if (val3 == LOW) {
myservo.write(200);
delay(3000);
myservo.write(0);
delay(3000);
}
if (val4 == LOW) {
myservo.write(180);
delay(3000);
myservo.write(0);
delay(3000);
}
if (val5 == LOW) {
myservo.write(135);
delay(2000);
myservo.write(0);
delay(2000);
}
if (val2 == HIGH && val3 == HIGH && val4 == HIGH && val5 == HIGH) {
myservo.write(0);
}
}``