#include const int lsrPin = 0; const int potPin = 1; const int recordPin = 4; const int btnPin = 5; const int relayPin = 12; const int servoPin = 9; const int ledPin = 13; int lsrValue = 0; int potValue = 0; int servoValue = 0; const int TPM = 16; int count = 0; int beats[TPM] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0}; boolean recMode = false; Servo myservo; void setup() { Serial.begin(9600); myservo.attach(servoPin); pinMode(relayPin, OUTPUT); pinMode(ledPin, OUTPUT); pinMode(recordPin, INPUT); digitalWrite(recordPin, HIGH); pinMode(btnPin, INPUT); digitalWrite(btnPin, HIGH); } void loop() { count = count % TPM; digitalWrite(ledPin, HIGH); if (digitalRead(recordPin) == LOW) { beats[count] = digitalRead(btnPin) ? 0 : 1; } digitalWrite(relayPin, beats[count]); potValue = analogRead(potPin); lsrValue = analogRead(lsrPin); servoValue = map(lsrValue, 150, 700, 0, 255); myservo.write(servoValue); Serial.print("lsr = " ); Serial.print(lsrValue); Serial.print("\t servo = "); Serial.println(servoValue); digitalWrite(relayPin, LOW); digitalWrite(ledPin, LOW); delay(potValue / 2 + 50); count ++; }