diff --git a/ino/BadUSB_TestSwitches.ino b/ino/BadUSB_TestSwitches.ino new file mode 100644 index 0000000..5eec3b7 --- /dev/null +++ b/ino/BadUSB_TestSwitches.ino @@ -0,0 +1,51 @@ +bool Ro[8]; + +void setup() { + Serial.begin(115200); + pinMode(2, INPUT_PULLUP); + pinMode(3, INPUT_PULLUP); + pinMode(4, INPUT_PULLUP); + pinMode(5, INPUT_PULLUP); + pinMode(6, INPUT_PULLUP); + pinMode(7, INPUT_PULLUP); + pinMode(8, INPUT_PULLUP); + pinMode(9, INPUT_PULLUP); + delay(100); +} + +void loop() { + Ro[0]=!digitalRead(2); // SW 1 + Ro[1]=!digitalRead(3); // SW 2 + Ro[2]=!digitalRead(4); // SW 3 + Ro[3]=!digitalRead(5); // SW 4 + Ro[4]=!digitalRead(6); // SW 5 + Ro[5]=!digitalRead(7); // SW 6 + Ro[6]=!digitalRead(8); // SW 7 + Ro[7]=!digitalRead(9); // SW 8 + Serial.print(Ro[0]); + Serial.print(" "); + Serial.print(Ro[1]); + Serial.print(" "); + Serial.print(Ro[2]); + Serial.print(" "); + Serial.print(Ro[3]); + Serial.print(" "); + Serial.print(Ro[4]); + Serial.print(" "); + Serial.print(Ro[5]); + Serial.print(" "); + Serial.print(Ro[6]); + Serial.print(" "); + Serial.print(Ro[7]); + Serial.print(" "); + Serial.println(); + + byte value = 0; + for (int i = 7; i > 1; i--) { + if (Ro[i]) + value |= (1 << (7-i)); + } + + Serial.println(value); + delay(3000); +}