 //   Serial.println("CurrentSecond: " + String(currentSecond));
   if(currentSecond != previousSecond)
   {
-      setPixels(pulseCount);
-      pulseCount = 0;
+      setPixels(instantPulseCount);
+      instantPulseCount = 0;
       previousSecond = currentSecond;
   }
   
 //   Serial.println(pinName + ":" + String(*pinValue));
 }
 
-void setPixels(int pulseCount)
+void setPixels(int instantPulseCount)
 {
     strip.setPixelColor(0, strip.Color(0, 0, 0));
     strip.setPixelColor(1, strip.Color(0, 0, 0));
     strip.setPixelColor(2, strip.Color(0, 0, 0));
     strip.setPixelColor(3, strip.Color(0, 0, 0));
     strip.setPixelColor(4, strip.Color(0, 0, 0));
-    Serial.println("PulseCount: " + String(pulseCount));
-    if(pulseCount > 0)
+    // Serial.println("PulseCount: " + String(instantPulseCount));
+    if(instantPulseCount > 0)
     strip.setPixelColor(0, strip.Color(0, 255, 0));
-    if(pulseCount > 100)
+    if(instantPulseCount > 100)
     strip.setPixelColor(1, strip.Color(0, 255, 0));
-    if(pulseCount > 200)
+    if(instantPulseCount > 200)
     strip.setPixelColor(2, strip.Color(255, 165, 0));
-    if(pulseCount > 300)
+    if(instantPulseCount > 300)
     strip.setPixelColor(3, strip.Color(255, 165, 0));
-    if(pulseCount > 400)
+    if(instantPulseCount > 400)
     strip.setPixelColor(4, strip.Color(255, 0, 0));
     strip.show();
 }
+
+String* stringSplit(String s, char delim)
+{
+    int arrcnt = 0;
+    String token = "";
+    for(uint8_t i=0; i<s.length(); i++)
+    {
+        char c = s.charAt(i);
+        if(c == delim)
+        {
+            strArr[arrcnt] = token;
+            arrcnt++;
+            token = "";
+        }
+        else
+        {
+            token.concat(String(c));
+        }
+    }
+    strArr[arrcnt] = token;
+    return strArr;
+}

// This #include statement was automatically added by the Particle IDE.
#include "neopixel/neopixel.h"

#define PIXEL_PIN D2
#define PIXEL_TYPE WS2812B
#define PIXEL_COUNT 5
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int ledPin = D7;

  pinVal(pin6, &pin6Value, pin6Name);
    //  analogVal(pin6, &pin6Value, pin6Name);
//   delay(100);
  EEPROM.update(EEPROM_ADDR_PULSE_COUNT, pulseCount);
  float percent = (float)pulseCount / (float)maxPulseCount;
  percentFull = (int)(percent * 100.0f);
  EEPROM.update(EEPROM_ADDR_PERCENT_FULL, percentFull);
}

int getPulseCount()
{
  return pulseCount;
}

int resetPulseCount()
{
  pulseCount = 0;
  EEPROM.update(EEPROM_ADDR_PULSE_COUNT, pulseCount);
  return 1;
}

int setCalibration(int val)
{
  maxPulseCount = val;
  EEPROM.update(EEPROM_ADDR_MAX_PULSE_COUNT, maxPulseCount);
}

void analogVal(int pin, int* pinValue, String pinName)
{
    *pinValue = analogRead(pin);  // read the input pin
    // Serial.println(pinName + ":" + String(*pinValue));
    digitalWrite(ledPin, *pinValue/16);
