You've already forked BitBox
Updates
This commit is contained in:
8
BitBox/.theia/launch.json
Normal file
8
BitBox/.theia/launch.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
]
|
||||
}
|
||||
@@ -30,6 +30,15 @@ const int bit8pin = A8;
|
||||
const int bit9pin = A9;
|
||||
|
||||
// Floats for ADC voltage & Input voltage
|
||||
float bit1pin_voltage = 0.0;
|
||||
float bit2pin_voltage = 0.0;
|
||||
float bit3pin_voltage = 0.0;
|
||||
float bit4pin_voltage = 0.0;
|
||||
float bit5pin_voltage = 0.0;
|
||||
float bit6pin_voltage = 0.0;
|
||||
float bit7pin_voltage = 0.0;
|
||||
float bit8pin_voltage = 0.0;
|
||||
float bit9pin_voltage = 0.0;
|
||||
float adc_voltage = 0.0;
|
||||
float in_voltage = 0.0;
|
||||
|
||||
@@ -108,163 +117,176 @@ void setup() {
|
||||
display.setSegments(rdy);
|
||||
delay(2000);
|
||||
display.showNumberDec(0);
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit1pin);
|
||||
// checkSenseLoop();
|
||||
// Serial.println(ref_voltage);
|
||||
// Serial.println(adc_value);
|
||||
// Serial.println(adc_voltage);
|
||||
// Serial.println(in_voltage);
|
||||
// voltageOutput();
|
||||
}
|
||||
|
||||
void resetSenseLoop() {
|
||||
adc_voltage = 0.0;
|
||||
in_voltage <= 2.0;
|
||||
|
||||
R1 = 30000.0;
|
||||
R2 = 7500.0;
|
||||
|
||||
ref_voltage = 5.0;
|
||||
|
||||
adc_value = 0;
|
||||
void testVoltage() {
|
||||
in_voltage = adc_value * (5.0 / 1023.0);
|
||||
// voltageOutput();
|
||||
}
|
||||
|
||||
void checkSenseLoop() {
|
||||
// Determine voltage at ADC input
|
||||
adc_voltage = (adc_value * ref_voltage) / 1024.0;
|
||||
// void resetSenseLoop() {
|
||||
// adc_voltage = 0.0;
|
||||
// in_voltage <= 2.0;
|
||||
|
||||
// Calculate voltage at divider input
|
||||
in_voltage = adc_voltage / (R2 / (R1 + R2)) ;
|
||||
}
|
||||
// R1 = 30000.0;
|
||||
// R2 = 7500.0;
|
||||
|
||||
// ref_voltage = 5.0;
|
||||
|
||||
// adc_value = 0;
|
||||
// }
|
||||
|
||||
// void checkSenseLoop() {
|
||||
// // Determine voltage at ADC input
|
||||
// adc_voltage = (adc_value * ref_voltage) / 1024.0;
|
||||
|
||||
// // Calculate voltage at divider input
|
||||
// in_voltage = adc_voltage / (R2 / (R1 + R2)) ;
|
||||
// }
|
||||
|
||||
void voltageOutput() {
|
||||
Serial.print(in_voltage);
|
||||
delay(10);
|
||||
Serial.println(in_voltage);
|
||||
// delay(1000);
|
||||
}
|
||||
|
||||
void updateDisplay() {
|
||||
// Updates display if number chnaged
|
||||
display.showNumberDec(denary);
|
||||
//delay(10);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
void loop() {
|
||||
// Checks if bit 1 is active
|
||||
resetSenseLoop();
|
||||
// resetSenseLoop();
|
||||
adc_value = analogRead(bit1pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit1 == false)) {
|
||||
denary += 1;
|
||||
testVoltage();
|
||||
if ((in_voltage > 1) && (bit1 == false)) {
|
||||
bit1 = true;
|
||||
denary += 1;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit1 == true)) {
|
||||
denary -= 1;
|
||||
} else if ((in_voltage <= 1) && (bit1 == true)) {
|
||||
bit1 = false;
|
||||
denary -= 1;
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
// Checks if bit 2 is active
|
||||
resetSenseLoop();
|
||||
// resetSenseLoop();
|
||||
adc_value = analogRead(bit2pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit2 == false)) {
|
||||
testVoltage();
|
||||
if ((in_voltage > 1) && (bit2 == false)) {
|
||||
denary += 2;
|
||||
bit2 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit2 == true)) {
|
||||
} else if ((in_voltage <= 1) && (bit2 == true)) {
|
||||
denary -= 2;
|
||||
bit2 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
}}
|
||||
|
||||
// Checks if bit 3 is active
|
||||
resetSenseLoop();
|
||||
adc_value = analogRead(bit3pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit3 == false)) {
|
||||
denary += 4;
|
||||
bit3 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit3 == true)) {
|
||||
denary -= 4;
|
||||
bit3 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
// // Checks if bit 3 is active
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit3pin);
|
||||
// checkSenseLoop();
|
||||
// if ((in_voltage > 5) && (bit3 == false)) {
|
||||
// denary += 4;
|
||||
// bit3 = true;
|
||||
// updateDisplay();
|
||||
// } else if ((in_voltage <= 5) && (bit3 == true)) {
|
||||
// denary -= 4;
|
||||
// bit3 = false;
|
||||
// updateDisplay();
|
||||
// }
|
||||
|
||||
// Checks if bit 4 is active
|
||||
resetSenseLoop();
|
||||
adc_value = analogRead(bit4pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit4 == false)) {
|
||||
denary += 8;
|
||||
bit4 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit4 == true)) {
|
||||
denary -= 8;
|
||||
bit4 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
// // Checks if bit 4 is active
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit4pin);
|
||||
// checkSenseLoop();
|
||||
// if ((in_voltage > 5) && (bit4 == false)) {
|
||||
// denary += 8;
|
||||
// bit4 = true;
|
||||
// updateDisplay();
|
||||
// } else if ((in_voltage <= 5) && (bit4 == true)) {
|
||||
// denary -= 8;
|
||||
// bit4 = false;
|
||||
// updateDisplay();
|
||||
// }
|
||||
|
||||
// Checks if bit 5 is active
|
||||
resetSenseLoop();
|
||||
adc_value = analogRead(bit5pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit5 == false)) {
|
||||
denary += 16;
|
||||
bit5 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit5 == true)) {
|
||||
denary -= 16;
|
||||
bit5 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
// // Checks if bit 5 is active
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit5pin);
|
||||
// checkSenseLoop();
|
||||
// if ((in_voltage > 5) && (bit5 == false)) {
|
||||
// denary += 16;
|
||||
// bit5 = true;
|
||||
// updateDisplay();
|
||||
// } else if ((in_voltage <= 5) && (bit5 == true)) {
|
||||
// denary -= 16;
|
||||
// bit5 = false;
|
||||
// updateDisplay();
|
||||
// }
|
||||
|
||||
// Checks if bit 6 is active
|
||||
resetSenseLoop();
|
||||
adc_value = analogRead(bit6pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit6 == false)) {
|
||||
denary += 32;
|
||||
bit6 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit6 == true)) {
|
||||
denary -= 32;
|
||||
bit6 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
// // Checks if bit 6 is active
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit6pin);
|
||||
// checkSenseLoop();
|
||||
// if ((in_voltage > 5) && (bit6 == false)) {
|
||||
// denary += 32;
|
||||
// bit6 = true;
|
||||
// updateDisplay();
|
||||
// } else if ((in_voltage <= 5) && (bit6 == true)) {
|
||||
// denary -= 32;
|
||||
// bit6 = false;
|
||||
// updateDisplay();
|
||||
// }
|
||||
|
||||
// Checks if bit 7 is active
|
||||
resetSenseLoop();
|
||||
adc_value = analogRead(bit7pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit7 == false)) {
|
||||
denary += 64;
|
||||
bit7 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit7 == true)) {
|
||||
denary -= 64;
|
||||
bit7 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
// // Checks if bit 7 is active
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit7pin);
|
||||
// checkSenseLoop();
|
||||
// if ((in_voltage > 5) && (bit7 == false)) {
|
||||
// denary += 64;
|
||||
// bit7 = true;
|
||||
// updateDisplay();
|
||||
// } else if ((in_voltage <= 5) && (bit7 == true)) {
|
||||
// denary -= 64;
|
||||
// bit7 = false;
|
||||
// updateDisplay();
|
||||
// }
|
||||
|
||||
// Checks if bit 8 is active
|
||||
resetSenseLoop();
|
||||
adc_value = analogRead(bit8pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit8 == false)) {
|
||||
denary += 128;
|
||||
bit8 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit8 == true)) {
|
||||
denary -= 128;
|
||||
bit8 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
// // Checks if bit 8 is active
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit8pin);
|
||||
// checkSenseLoop();
|
||||
// if ((in_voltage > 5) && (bit8 == false)) {
|
||||
// denary += 128;
|
||||
// bit8 = true;
|
||||
// updateDisplay();
|
||||
// } else if ((in_voltage <= 5) && (bit8 == true)) {
|
||||
// denary -= 128;
|
||||
// bit8 = false;
|
||||
// updateDisplay();
|
||||
// }
|
||||
|
||||
// Checks if bit 9 is active
|
||||
resetSenseLoop();
|
||||
adc_value = analogRead(bit9pin);
|
||||
checkSenseLoop();
|
||||
if ((in_voltage > 2) && (bit9 == false)) {
|
||||
denary += 256;
|
||||
bit9 = true;
|
||||
updateDisplay();
|
||||
} else if ((in_voltage <= 2) && (bit9 == true)) {
|
||||
denary -= 256;
|
||||
bit9 = false;
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
// // Checks if bit 9 is active
|
||||
// resetSenseLoop();
|
||||
// adc_value = analogRead(bit9pin);
|
||||
// checkSenseLoop();
|
||||
// if ((in_voltage > 5) && (bit9 == false)) {
|
||||
// denary += 256;
|
||||
// bit9 = true;
|
||||
// updateDisplay();
|
||||
// } else if ((in_voltage <= 5) && (bit9 == true)) {
|
||||
// denary -= 256;
|
||||
// bit9 = false;
|
||||
// updateDisplay();
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user