#include "Servo.h"
const int N = 5;
Servo servo [N];
const byte PinServo [N] = { A0, A1, A2, A3, A4 };
const byte PinButNorm [N] = { 13, 12, 11, 10, 9 };
const byte PinButRev [N] = { 4, 5, 6, 7, 8 };
int angNorm [N] = { 40, 130, 40, 130, 40 };
int angRev [N] = { 120, 60, 120, 60, 120 };
void setup() {
Serial.begin(115200);
Serial.println("button-servo");
for (int n = 0; n < N; n++) {
pinMode (PinButNorm [n], INPUT_PULLUP);
pinMode (PinButRev [n], INPUT_PULLUP);
servo [n].attach (PinServo [n]);
servo [n].write (angNorm [n]);
}
}
void loop() {
for (int n = 0; n < N; n++) {
if (LOW == digitalRead(PinButNorm [n])) {
servo [n].write (angNorm [n]);
Serial.println("up");
}
if (LOW == digitalRead(PinButRev [n])) {
servo [n].write (angRev [n]);
Serial.println("dn");
}
}
}