barf
@ -1 +1 @@
|
||||
Subproject commit 41b4df6326afbad64aa5dc00ac5d3dc854e8096f
|
||||
Subproject commit 498755ef0e4cadfe3784363e5eb0ec1aff016631
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 172 B |
After Width: | Height: | Size: 174 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 161 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 129 B |
After Width: | Height: | Size: 137 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 162 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 169 B |
After Width: | Height: | Size: 172 B |
After Width: | Height: | Size: 176 B |
After Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 5.1 KiB |
@ -0,0 +1,137 @@
|
||||
// Generally, you should use "unsigned long" for variables that hold time
|
||||
// The value will quickly become too large for an int to store
|
||||
unsigned long previousMillis = 0; // will store last time LED was updated
|
||||
|
||||
// constants won't change:
|
||||
const long interval = 500; // interval at which to blink (milliseconds)
|
||||
|
||||
int pushButton1 = 2;
|
||||
int pushButton2 = 4;
|
||||
int pushButton3 = 6;
|
||||
int pushButton4 = 11;
|
||||
|
||||
int buttons[4] = {
|
||||
pushButton1,
|
||||
pushButton2,
|
||||
pushButton3,
|
||||
pushButton4
|
||||
};
|
||||
|
||||
void setup() {
|
||||
// set the digital pin as output:
|
||||
Serial.begin(9600);
|
||||
pinMode(pushButton1, OUTPUT);
|
||||
digitalWrite(pushButton1, LOW);
|
||||
pinMode(pushButton2, INPUT_PULLUP);
|
||||
pinMode(pushButton3, INPUT_PULLUP);
|
||||
pinMode(pushButton4, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
bool testConnection2(int A, int B) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i == A) {
|
||||
pinMode(buttons[i], OUTPUT);
|
||||
digitalWrite(buttons[i], LOW);
|
||||
} else {
|
||||
// digitalWrite(buttons[i], HIGH);
|
||||
pinMode(buttons[i], INPUT_PULLUP);
|
||||
}
|
||||
}
|
||||
// delay(10);
|
||||
|
||||
if (!digitalRead(buttons[B])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool testConnection(int A, int B) {
|
||||
return testConnection2(A, B) && testConnection2(B, A);
|
||||
}
|
||||
|
||||
// int lastNumber = -1;
|
||||
|
||||
void loop() {
|
||||
|
||||
if (testConnection(0, 1)) {
|
||||
// if (lastNumber != 01) {
|
||||
// lastNumber = 01;
|
||||
Serial.println("0011");
|
||||
// }
|
||||
} else if (testConnection(0, 2)) {
|
||||
// if (lastNumber != 02) {
|
||||
// lastNumber = 02;
|
||||
Serial.println("0101");
|
||||
// }
|
||||
} else if (testConnection(0, 3)) {
|
||||
// if (lastNumber != 03) {
|
||||
// lastNumber = 03;
|
||||
Serial.println("1001");
|
||||
// }
|
||||
} else if (testConnection(1, 2)) {
|
||||
// if (lastNumber != 12) {
|
||||
// lastNumber = 12;
|
||||
Serial.println("0110");
|
||||
// }
|
||||
} else if (testConnection(1, 3)) {
|
||||
// if (lastNumber != 13) {
|
||||
// lastNumber = 13;
|
||||
Serial.println("1010");
|
||||
// }
|
||||
} else if (testConnection(2, 3)) {
|
||||
// if (lastNumber != 23) {
|
||||
// lastNumber = 23;
|
||||
Serial.println("1100");
|
||||
// }
|
||||
// } else {
|
||||
// if (lastNumber != 0) {
|
||||
// lastNumber = 0;
|
||||
// Serial.println("0000");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
for (int ii = 0; ii < 4; ii++)
|
||||
{
|
||||
for (int jj = 0; jj < 4; jj++)
|
||||
{
|
||||
if (jj == ii)
|
||||
{
|
||||
pinMode(buttons[jj], OUTPUT);
|
||||
digitalWrite(buttons[jj], LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
pinMode(buttons[jj], INPUT_PULLUP);
|
||||
}
|
||||
}
|
||||
for (int jj = ii; jj < 4; jj++)
|
||||
{
|
||||
if (!(ii == jj) && !digitalRead(buttons[jj]))
|
||||
{
|
||||
for (int kk = 3; kk >= 0; kk--)
|
||||
{
|
||||
if (kk == ii || kk == jj)
|
||||
{
|
||||
Serial.print(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print(0);
|
||||
}
|
||||
}
|
||||
Serial.print("\n");
|
||||
received_input = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if (received_input)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
*/
|