Reformat code so that serial.begin and delays are in header file.

This commit is contained in:
Andrés Uribe Stengel 2020-06-22 16:18:22 +02:00
parent 566fcda0cc
commit 83fe6d5d7d
2 changed files with 2 additions and 4 deletions

View File

@ -3,9 +3,11 @@
*/
void setup() {
Serial.begin(9600);
setupCapacitiveSoilMoistureSensor();
}
void loop() {
loopCapacitiveSoilMoistureSensor();
delay(1); // delay in between reads for stability
}

View File

@ -12,9 +12,6 @@ int average = 0; // the average
int inputPin = 12;
void setupCapacitiveSoilMoistureSensor() {
Serial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
@ -39,5 +36,4 @@ void loopCapacitiveSoilMoistureSensor() {
// calculate the average:
average = total / numReadings;
Serial.println(average);
delay(1); // delay in between reads for stability
}