From ee16f406e4ca5cdf65e29f73bbb0ebea11fc08fa Mon Sep 17 00:00:00 2001 From: rra Date: Tue, 22 Sep 2020 12:20:59 +0200 Subject: [PATCH] added a way to tone down the plot spam --- pointlights.ino | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pointlights.ino b/pointlights.ino index 9d474c0..f02e95e 100644 --- a/pointlights.ino +++ b/pointlights.ino @@ -8,13 +8,13 @@ unsigned long currentMillis; int brightness = 0; // our main variable for setting the brightness of the LED float velocity = 1.0; // the speed at which we change the brightness. int ledPin = 9; // we use pin 9 for PWM +int p = 0; // use to keep track how often we plot +int plotFrequency = 3; // how often we plot, every Nth time. void setup() { // put your setup code here, to run once: pinMode(ledPin, OUTPUT); // set ledPin as an output. Serial.begin(9600); // initiate the Serial monitor so we can use the Serial Plotter to graph our patterns - - } void loop() { @@ -90,11 +90,15 @@ void changeState(ledStates newState){ void plot(char *state, int brightness){ // use this function to plot a graph. - // it will normalize the auto-scaling plotter - Serial.print(state); - Serial.print(", "); - Serial.print(brightness); - Serial.println(", 0, 300"); + // it will normalize the auto-scaling plotter + + if ((p % plotFrequency) == 0){ + Serial.print(state); + Serial.print(", "); + Serial.print(brightness); + Serial.println(", 0, 300"); + } + p++; } int increase_brightness (int brightness, float velocity){