const byte LEDOUT = 10;
const byte CLKIN = 2;
const byte CLKOUT = 5;
const byte RPTIN = 3;
const byte RPTOUT = 4;
const byte MSET = 6;
const byte LSET = 7;
bool isMaster;
bool isLast;
void setup() {
pinMode(CLKIN, INPUT_PULLUP);
pinMode(MSET, INPUT_PULLUP);
pinMode(LSET, INPUT_PULLUP);
pinMode(RPTIN, INPUT_PULLUP);
pinMode(RPTOUT, OUTPUT);
pinMode(CLKOUT, OUTPUT);
pinMode(LEDOUT, OUTPUT);
isMaster = (digitalRead(MSET) == LOW);
isLast = (digitalRead(LSET) == LOW);
digitalWrite(RPTOUT, HIGH);
digitalWrite(CLKOUT, HIGH);
digitalWrite(LEDOUT, LOW);
if (isMaster) { // start of sequence
digitalWrite(LEDOUT, HIGH);
delay(1000);
digitalWrite(LEDOUT, LOW);
digitalWrite(CLKOUT, LOW);
delay(100);
digitalWrite(CLKOUT, HIGH);
}
}
void loop() {
if (digitalRead(CLKIN) == LOW) {
digitalWrite(LEDOUT, HIGH);
delay(1000);
digitalWrite(LEDOUT, LOW);
digitalWrite(CLKOUT, LOW);
delay(100);
digitalWrite(CLKOUT, HIGH);
}
if(!isMaster && !isLast) {
digitalWrite(RPTOUT, digitalRead(RPTIN));
}
}