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;
|
const int bit9pin = A9;
|
||||||
|
|
||||||
// Floats for ADC voltage & Input voltage
|
// 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 adc_voltage = 0.0;
|
||||||
float in_voltage = 0.0;
|
float in_voltage = 0.0;
|
||||||
|
|
||||||
@@ -108,163 +117,176 @@ void setup() {
|
|||||||
display.setSegments(rdy);
|
display.setSegments(rdy);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
display.showNumberDec(0);
|
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() {
|
void testVoltage() {
|
||||||
adc_voltage = 0.0;
|
in_voltage = adc_value * (5.0 / 1023.0);
|
||||||
in_voltage <= 2.0;
|
// voltageOutput();
|
||||||
|
|
||||||
R1 = 30000.0;
|
|
||||||
R2 = 7500.0;
|
|
||||||
|
|
||||||
ref_voltage = 5.0;
|
|
||||||
|
|
||||||
adc_value = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkSenseLoop() {
|
// void resetSenseLoop() {
|
||||||
// Determine voltage at ADC input
|
// adc_voltage = 0.0;
|
||||||
adc_voltage = (adc_value * ref_voltage) / 1024.0;
|
// in_voltage <= 2.0;
|
||||||
|
|
||||||
// Calculate voltage at divider input
|
// R1 = 30000.0;
|
||||||
in_voltage = adc_voltage / (R2 / (R1 + R2)) ;
|
// 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() {
|
void voltageOutput() {
|
||||||
Serial.print(in_voltage);
|
Serial.println(in_voltage);
|
||||||
delay(10);
|
// delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateDisplay() {
|
void updateDisplay() {
|
||||||
// Updates display if number chnaged
|
// Updates display if number chnaged
|
||||||
display.showNumberDec(denary);
|
display.showNumberDec(denary);
|
||||||
//delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// Checks if bit 1 is active
|
// Checks if bit 1 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit1pin);
|
adc_value = analogRead(bit1pin);
|
||||||
checkSenseLoop();
|
testVoltage();
|
||||||
if ((in_voltage > 2) && (bit1 == false)) {
|
if ((in_voltage > 1) && (bit1 == false)) {
|
||||||
denary += 1;
|
|
||||||
bit1 = true;
|
bit1 = true;
|
||||||
|
denary += 1;
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit1 == true)) {
|
} else if ((in_voltage <= 1) && (bit1 == true)) {
|
||||||
denary -= 1;
|
|
||||||
bit1 = false;
|
bit1 = false;
|
||||||
|
denary -= 1;
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if bit 2 is active
|
// Checks if bit 2 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit2pin);
|
adc_value = analogRead(bit2pin);
|
||||||
checkSenseLoop();
|
testVoltage();
|
||||||
if ((in_voltage > 2) && (bit2 == false)) {
|
if ((in_voltage > 1) && (bit2 == false)) {
|
||||||
denary += 2;
|
denary += 2;
|
||||||
bit2 = true;
|
bit2 = true;
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit2 == true)) {
|
} else if ((in_voltage <= 1) && (bit2 == true)) {
|
||||||
denary -= 2;
|
denary -= 2;
|
||||||
bit2 = false;
|
bit2 = false;
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}}
|
||||||
|
|
||||||
// Checks if bit 3 is active
|
// // Checks if bit 3 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit3pin);
|
// adc_value = analogRead(bit3pin);
|
||||||
checkSenseLoop();
|
// checkSenseLoop();
|
||||||
if ((in_voltage > 2) && (bit3 == false)) {
|
// if ((in_voltage > 5) && (bit3 == false)) {
|
||||||
denary += 4;
|
// denary += 4;
|
||||||
bit3 = true;
|
// bit3 = true;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit3 == true)) {
|
// } else if ((in_voltage <= 5) && (bit3 == true)) {
|
||||||
denary -= 4;
|
// denary -= 4;
|
||||||
bit3 = false;
|
// bit3 = false;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Checks if bit 4 is active
|
// // Checks if bit 4 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit4pin);
|
// adc_value = analogRead(bit4pin);
|
||||||
checkSenseLoop();
|
// checkSenseLoop();
|
||||||
if ((in_voltage > 2) && (bit4 == false)) {
|
// if ((in_voltage > 5) && (bit4 == false)) {
|
||||||
denary += 8;
|
// denary += 8;
|
||||||
bit4 = true;
|
// bit4 = true;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit4 == true)) {
|
// } else if ((in_voltage <= 5) && (bit4 == true)) {
|
||||||
denary -= 8;
|
// denary -= 8;
|
||||||
bit4 = false;
|
// bit4 = false;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Checks if bit 5 is active
|
// // Checks if bit 5 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit5pin);
|
// adc_value = analogRead(bit5pin);
|
||||||
checkSenseLoop();
|
// checkSenseLoop();
|
||||||
if ((in_voltage > 2) && (bit5 == false)) {
|
// if ((in_voltage > 5) && (bit5 == false)) {
|
||||||
denary += 16;
|
// denary += 16;
|
||||||
bit5 = true;
|
// bit5 = true;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit5 == true)) {
|
// } else if ((in_voltage <= 5) && (bit5 == true)) {
|
||||||
denary -= 16;
|
// denary -= 16;
|
||||||
bit5 = false;
|
// bit5 = false;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Checks if bit 6 is active
|
// // Checks if bit 6 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit6pin);
|
// adc_value = analogRead(bit6pin);
|
||||||
checkSenseLoop();
|
// checkSenseLoop();
|
||||||
if ((in_voltage > 2) && (bit6 == false)) {
|
// if ((in_voltage > 5) && (bit6 == false)) {
|
||||||
denary += 32;
|
// denary += 32;
|
||||||
bit6 = true;
|
// bit6 = true;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit6 == true)) {
|
// } else if ((in_voltage <= 5) && (bit6 == true)) {
|
||||||
denary -= 32;
|
// denary -= 32;
|
||||||
bit6 = false;
|
// bit6 = false;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Checks if bit 7 is active
|
// // Checks if bit 7 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit7pin);
|
// adc_value = analogRead(bit7pin);
|
||||||
checkSenseLoop();
|
// checkSenseLoop();
|
||||||
if ((in_voltage > 2) && (bit7 == false)) {
|
// if ((in_voltage > 5) && (bit7 == false)) {
|
||||||
denary += 64;
|
// denary += 64;
|
||||||
bit7 = true;
|
// bit7 = true;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit7 == true)) {
|
// } else if ((in_voltage <= 5) && (bit7 == true)) {
|
||||||
denary -= 64;
|
// denary -= 64;
|
||||||
bit7 = false;
|
// bit7 = false;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Checks if bit 8 is active
|
// // Checks if bit 8 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit8pin);
|
// adc_value = analogRead(bit8pin);
|
||||||
checkSenseLoop();
|
// checkSenseLoop();
|
||||||
if ((in_voltage > 2) && (bit8 == false)) {
|
// if ((in_voltage > 5) && (bit8 == false)) {
|
||||||
denary += 128;
|
// denary += 128;
|
||||||
bit8 = true;
|
// bit8 = true;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit8 == true)) {
|
// } else if ((in_voltage <= 5) && (bit8 == true)) {
|
||||||
denary -= 128;
|
// denary -= 128;
|
||||||
bit8 = false;
|
// bit8 = false;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Checks if bit 9 is active
|
// // Checks if bit 9 is active
|
||||||
resetSenseLoop();
|
// resetSenseLoop();
|
||||||
adc_value = analogRead(bit9pin);
|
// adc_value = analogRead(bit9pin);
|
||||||
checkSenseLoop();
|
// checkSenseLoop();
|
||||||
if ((in_voltage > 2) && (bit9 == false)) {
|
// if ((in_voltage > 5) && (bit9 == false)) {
|
||||||
denary += 256;
|
// denary += 256;
|
||||||
bit9 = true;
|
// bit9 = true;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
} else if ((in_voltage <= 2) && (bit9 == true)) {
|
// } else if ((in_voltage <= 5) && (bit9 == true)) {
|
||||||
denary -= 256;
|
// denary -= 256;
|
||||||
bit9 = false;
|
// bit9 = false;
|
||||||
updateDisplay();
|
// updateDisplay();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Reference in New Issue
Block a user