From 83fe6d5d7d3330f11ea3532b0c0ca22a61fc4c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Uribe=20Stengel?= Date: Mon, 22 Jun 2020 16:18:22 +0200 Subject: [PATCH] Reformat code so that serial.begin and delays are in header file. --- Smart_Garden.ino | 2 ++ capacitiveSoilMoistureSensor.ino | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Smart_Garden.ino b/Smart_Garden.ino index 568f35d..f683cae 100644 --- a/Smart_Garden.ino +++ b/Smart_Garden.ino @@ -3,9 +3,11 @@ */ void setup() { + Serial.begin(9600); setupCapacitiveSoilMoistureSensor(); } void loop() { loopCapacitiveSoilMoistureSensor(); + delay(1); // delay in between reads for stability } diff --git a/capacitiveSoilMoistureSensor.ino b/capacitiveSoilMoistureSensor.ino index c0ca634..e3b6924 100644 --- a/capacitiveSoilMoistureSensor.ino +++ b/capacitiveSoilMoistureSensor.ino @@ -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 }