re-add accidentially removed logic
This commit is contained in:
parent
2470935e11
commit
9ad1857a64
1 changed files with 18 additions and 8 deletions
22
drop.ino
22
drop.ino
|
|
@ -16,6 +16,17 @@ void setup() {
|
|||
|
||||
pinMode(PUMP_LED_PIN, OUTPUT);
|
||||
pinMode(PUMP_PIN, OUTPUT);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
// link pots to their config
|
||||
for (unsigned int i = 0; i < POT_COUNT; i++) {
|
||||
Pot *pot = &pots[i];
|
||||
|
||||
pot->config = &POT_CONFIGS[i];
|
||||
|
||||
pinMode(pot->config->valve_pin, OUTPUT);
|
||||
pinMode(pot->config->led_pin, OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
|
@ -33,11 +44,6 @@ void loop() {
|
|||
|
||||
void per_pot(Pot &pot) {
|
||||
int percentage = get_humidity(pot.config->sensor);
|
||||
if (percentage < 0) {
|
||||
Serial.println(F("sensor not connected"));
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print(percentage);
|
||||
Serial.println(F("%"));
|
||||
|
||||
|
|
@ -57,6 +63,8 @@ void per_pot(Pot &pot) {
|
|||
}
|
||||
|
||||
void water_pot(Pot &pot) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
|
||||
digitalWrite(pot.config->led_pin, HIGH);
|
||||
|
||||
set_valve(pot.config->valve_pin, HIGH);
|
||||
|
|
@ -69,6 +77,8 @@ void water_pot(Pot &pot) {
|
|||
set_valve(pot.config->valve_pin, LOW);
|
||||
|
||||
digitalWrite(pot.config->led_pin, LOW);
|
||||
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
}
|
||||
|
||||
/// get humidity sensor value as a percentage
|
||||
|
|
@ -81,7 +91,7 @@ int get_humidity(Sensor &sensor) {
|
|||
delay(MEASUREMENT_DELAY);
|
||||
}
|
||||
|
||||
sensorVal /= MEASUREMENT_COUNT;
|
||||
sensorVal /= MEASUREMENT_COUNT;
|
||||
|
||||
// Sensor has a range of e.g. 236 to 520
|
||||
// We want to translate this to a scale or 0% to 100%
|
||||
|
|
|
|||
Loading…
Reference in a new issue