Hi,
my school has an engineering course. in this course we have to create a project, program it and build it .
The program that i have written so far is to make a servo turn when a pushbutton is pressed. It is in the void loop. When the button is pressed the servo turns 180 degrees. when it is not being pressed it goes back to 0 degrees. what i need help with is the programming this project so that only when 9 buttons are all pushed at the same time the servo will turn and when all of them are not being pushed it turns back to 0 degrees.
here is the program i have written so far:
int pushButton2 = 2;
#include <Servo.h>
Servo myservo;
void setup() {
Serial.begin(9600);
pinMode(pushButton2 ,INPUT);
myservo.attach(9);
}
void loop() {
int buttonState2 = digitalRead (pushButton2);
Serial.println(buttonState2);
if (digitalRead(pushButton2) == true)
{
myservo.write(180);
}
if (digitalRead(pushButton2) == false)
{
myservo.write(0);
}
delay(15);
}
Thanks so much for the help