/*
Send data from multiple switches through a pair of wires without using a digital protocol
only a program resistor is needed for each switch and an analog voltage from the resistor
is detected and latched
*/
int commandState;
void setup() {
Serial.begin(9600);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
//digitalWrite(11, HIGH);
}
void loop() {
commandState = analogRead(A0);
Serial.println(commandState);
if(commandState == 0 && commandState <20){
digitalWrite(11, HIGH);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
}
else if(commandState > 683 && commandState < 723) {
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
}
else if(commandState > 94 && commandState < 134) {
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
}
else if(commandState > 394 && commandState < 434) {
digitalWrite(11, LOW);
digitalWrite(10, LOW);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
}
delay(50);
}