From 974894f1ee039bfe76b70708ef76eecf2269cfeb Mon Sep 17 00:00:00 2001 From: Wilhelm Westermark Date: Sat, 24 Nov 2018 19:51:04 +0100 Subject: [PATCH] Average code on serial available --- scale/scale.ino | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scale/scale.ino b/scale/scale.ino index a9b171a..8d90c47 100644 --- a/scale/scale.ino +++ b/scale/scale.ino @@ -1,4 +1,5 @@ -#include "HX711.h" +#include + HX711 scale; @@ -48,12 +49,14 @@ void setup() { } void loop() { - Serial.print("one reading:\t"); - Serial.print(scale.get_units(), 1); - Serial.print("\t| average:\t"); - Serial.println(scale.get_units(10), 1); - - scale.power_down(); // put the ADC in sleep mode - delay(500); - scale.power_up(); + //Serial.print("one reading:\t"); + //Serial.print(scale.get_units(), 1); + //Serial.print("\t| average:\t"); + if (Serial.available() > 0) { + Serial.println(scale.get_units(10), 1); + + scale.power_down(); // put the ADC in sleep mode + delay(100); + scale.power_up(); + } }