PowerBoard AC updates (#1129)

PowerBoard AC updates (#1129)

* AC_OK is on pin 11.
* BAT_LOW is on pin 12.
* AC_OK and BAT_LOW are set as `INPUT_PULLUP` so should be wired from Arduino to Meanwell to Ground.
* `battery_low` removed from json output for now as it hasn't been tested and isn't clearly working.

--- resources/arduino/PowerBoard/PowerBoard.ino
+++ resources/arduino/PowerBoard/PowerBoard.ino
@@ -5,12 +5,12 @@
 const char BOARD_NAME[] = "power_board";

 // Meanwell UPS AC and Battery pins.
-const int AC_OK = 12;
-const int BAT_LOW = 11;
-
-/******************************************/
-/* Shouldn't need to change anything below.
-/******************************************/
+const int AC_OK = 11;
+const int BAT_LOW = 12;
+
+/*******************************************/
+/* Shouldn't need to change anything below.*/
+/*******************************************/

 // Set initial states for each relay. Change as needed.
 const bool DEFAULT_START_0 = HIGH;
@@ -58,8 +58,8 @@
   pinMode(IS_2, INPUT);

   // Setup AC and Battery pins
-  pinMode(AC_OK, INPUT);
-  pinMode(BAT_LOW, INPUT);
+  pinMode(AC_OK, INPUT_PULLUP);
+  pinMode(BAT_LOW, INPUT_PULLUP);

   // Setup diagnosis enable pins
   pinMode(DEN_0, OUTPUT);
@@ -145,8 +145,8 @@

   StaticJsonDocument<192> doc;

-  doc["ac_ok"] = digitalRead(AC_OK);
-  doc["battery_low"] = digitalRead(BAT_LOW);
+  // Because the pinup is set to pullup we read high for off.
+  doc["ac_ok"] = !digitalRead(AC_OK);

   JsonArray relays = doc.createNestedArray("relays");
   relays.add(is_relay_on(RELAY_0));
@@ -199,9 +199,9 @@
 }

-/************************************
-  Utility Methods
-*************************************/
+/*************************************/
+/*  Utility Methods                  */
+/*************************************/

 bool is_relay_on(int pin_num) {
   return digitalRead(pin_num) != LOW;


Stop transmitting (in a hackish way) when the TX is done.

--- examples/AFSK-Send/AFSK-Send.ino
+++ examples/AFSK-Send/AFSK-Send.ino
@@ -58,6 +58,14 @@
       }
     // Wait 2 seconds before we send our beacon again.
     Serial.println("tick");
+    // Wait up to 2.5 seconds to finish sending, and stop transmitter.
+    // TODO: This is hackery.
+    for(int i = 0; i < 500; i++) {
+      if(!radio.afsk.isSending())
+         break;
+      delay(50);
+    }
+    radio.setModeReceive();
     delay(2000);
 }


added pin schematic

added pin schematic

--- examples/DigitTest/DigitTest.ino
+++ examples/DigitTest/DigitTest.ino
@@ -3,9 +3,28 @@

 /* How to use:

-(1) Solder up board
-(2) Download TLC5940.h library
-(3) Change number of TLCs in tlc_config.h to 2
+(1) Solder up board. Use a 3.3K resistor and 0.1uF capacitor in the appropriate places. Use plenty of flux on the SMD bit.
+(2) Download TLC5940 library (see README for link)
+(3) Change number of TLCs in Tlc5940/tlc_config.h to 2
+(4) Plug in board as follows:
+
+    Basic Pin setup:
+    ------------
+    ARDUINO   13|-> CL
+              12|
+              11|-> IN
+              10|-> BL
+               9|-> XL
+               8|
+               7|
+               6|
+               5|
+               4|
+               3|
+               2|
+               1|
+               0|
+    ------------

 */

@@ -35,4 +54,3 @@

-


Sync menu with Pano object before showing Pano Info page

Otherwise, we see the "old" data in the Navigator

--- examples/Navigator/Navigator.ino
+++ examples/Navigator/Navigator.ino
@@ -361,6 +361,7 @@
  * Menu callback for displaying last pano info
  */
 int onPanoInfo(int __){
+    setPanoParams();
     displayPanoStatus(true);
     hid->waitAnyKey();
     return __;


Updating arduino example

Updating arduino example

--- arduino/mqtt/mqtt.ino
+++ arduino/mqtt/mqtt.ino
@@ -37,32 +37,44 @@

   setup_wifi();
   mqttClient.setServer(MQTT_HOST, 52122);
+  mqttClient.setCallback(onMessageReceived);
 }

 void loop() {
   if (!mqttClient.connected()) {
     reconnect();
+    mqttClient.publish(ONLINE_TOPIC, "1", true);
+    publishStatus();
+    mqttClient.subscribe("/boat/meetup/#");
   }
+
   mqttClient.loop();
+}

-  long now = millis();
-  if (now - lastMsg > 10000) {
-    lastMsg = now;
+void onMessageReceived(char* topic, byte* payload, unsigned int length) {
+  Serial.print("Got topic \"");
+  Serial.print(topic);
+  Serial.print("\" with payload \"");
+  for (int i=0;i<length;i++) {
+    Serial.print((char)payload[i]);
+  }
+  Serial.println("\"");
+}

-    Serial.println("Building payload message");
-    sprintf(payload, PAYLOAD_TEMPLATE, message, millis());
-    Serial.println(payload);
+void publishStatus() {
+  Serial.println("Building payload message");
+  sprintf(payload, PAYLOAD_TEMPLATE, message, millis());
+  Serial.println(payload);

-    Serial.print("Publishing status to ");
-    Serial.print(STATUS_TOPIC);
-    Serial.print("...");
-
-    success = mqttClient.publish(STATUS_TOPIC, payload, true);
-    if(success) {
-      Serial.println("published!");
-    } else {
-      Serial.println("failed! Make sure your message is under the max length.");
-    }
+  Serial.print("Publishing status to ");
+  Serial.print(STATUS_TOPIC);
+  Serial.print("...");
+
+  success = mqttClient.publish(STATUS_TOPIC, payload, true);
+  if(success) {
+    Serial.println("published!");
+  } else {
+    Serial.println("failed! Make sure your message is under the max length.");
   }
 }

@@ -93,7 +105,6 @@
     // Attempt to connect
     if (mqttClient.connect(UID, MQTT_USERNAME, MQTT_PASSWORD, ONLINE_TOPIC, 1, true, "0")) {
       Serial.println("connected");
-      mqttClient.publish(ONLINE_TOPIC, "1", true);
     } else {
       Serial.print("failed, rc=");
       Serial.print(mqttClient.state());


Change on Serial stuff to show data

Change on Serial stuff to show data

--- Arduino-code/two-sensors-test/two-sensors-test.ino
+++ Arduino-code/two-sensors-test/two-sensors-test.ino
@@ -12,6 +12,7 @@

 long duration, distance;
 void setup() {
+  Serial.begin(9600);
   /*
   Setup of the echo & trig of everysensor.
   */
@@ -24,16 +25,19 @@
 }

 void loop() {
-  printReadings("Testing",0);
+  printString("Testing");
   estimateDistance(S1trig, S1echo);
-  delayMicroseconds(1000);
+  delay(10000);
 }

 void printReadings(String label, long value){
   String phrase = label+": "+value;
-  Serial.print(phrase);
+  printString(phrase);
 }
-
+void printString(String phrase){
+  Serial.println(phrase);
+  Serial.println(" ");
+}
 /*
 Estimate the distance received from the ultrasonic sensor.
 */
@@ -46,7 +50,7 @@

   digitalWrite(trig,LOW);

-  //Claculate Duration of pulse.
+  //Calculate Duration of pulse.
   duration = pulseIn(echo,HIGH);
   printReadings("Duration", duration);


Fixed protocol parsing

Fixed protocol parsing

--- Twisted_Python_Server_Serial/workingPythonSerialMotorControl_v2/workingPythonSerialMotorControl_v2/workingPythonSerialMotorControl_v2.ino
+++ Twisted_Python_Server_Serial/workingPythonSerialMotorControl_v2/workingPythonSerialMotorControl_v2/workingPythonSerialMotorControl_v2.ino
@@ -9,7 +9,7 @@
 void setup() {
   car.begin(); //initialize the car using the encoders and the gyro
   Serial.begin(9600);
-
+
 }

 void loop() {
@@ -18,12 +18,12 @@

     car.setSpeed(speed);
     car.setAngle(angle);
-
+

     commandComplete = false;
   }
-
+
 }

 /*
@@ -34,15 +34,42 @@
  */
 void serialEvent() {
   int i = 0;
+  int speed
+  byte tmp;
+  byte byteArray[7];
   while (Serial.available()) {
+
+    byte b = Serial.read();
+
+    byteArray[i] = b;
+    if (b == 0x0d){
+      tmp = 0x0d;
+    }
+    if(b == 0x0a && tmp == 0x0d){
+       Serial.println("got CRLF");
+       handleMsg(byteArray);
+     }
     i++;
-    byte bytearray[7] = (byte)Serial.read();
-    Serial.println();
-
-
-
-    if (bytearray[i] == '\n') {
-      commandComplete = true;
-    }
   }
 }
+
+void handleMsg(byte arr[])
+{
+    if(arr[1] == 0x46)
+    {
+      speed = arr[3];
+    }
+    else if(arr[1] == 0x42)
+    {
+      speed = -arr[1];
+    }
+    if(arr[2] == 0x52)
+    {
+      angle = arr[4];
+    }
+    else if(arr[2] == 0x4c)
+    {
+      angle = -arr[4];
+    }
+    commandComplete = true;
+}


updated RPM decay

updated RPM decay


Functional AddKey + Reset Button

Functional AddKey + Reset Button

--- intel_curie/flash_serial_example/flash_serial_example.ino
+++ intel_curie/flash_serial_example/flash_serial_example.ino
@@ -7,6 +7,7 @@

 #define FSIZE 256
 #define ledPin 13
+#define buttonPin 10

 const char *filename = "rfidble.txt";
 #define CONTENT_SIZE 153
@@ -15,6 +16,7 @@
   Serial.begin(9600);
   debugMessage("Setup() BEGIN!");
   pinMode(ledPin, OUTPUT);
+  pinMode(buttonPin, INPUT);
   parpadear (3, 1000);
   delay(1000);// wait for Arduino Serial Monitor
   parpadear (3, 500);
@@ -29,8 +31,8 @@
 /*----------------------------------------------------------------------------------*/
 /*----------------------------------------------------------------------------------*/
 bool executedOnce = false;
+bool addKeyMode = false;
 void loop() {
-  debugMessage("loop() BEGIN!");
   if (!executedOnce) {
     debugMessage("loop() executing... reading file...");
     String fileContent = readFile();
@@ -53,16 +55,76 @@
       executedOnce = true;
     }
   }
-
-  parpadear (2, 200);
+  processButtonCase();
+
+}
+
+void processDemoCase() {
+  parpadear(2, 200);
   delay(1000);
 }
-
+void processButtonCase() {
+  heartBeat();
+
+  checkButton();
+
+  if (addKeyMode) {
+    addKey("1234");
+    addKey("5678");
+    addKey("91011");
+    addKey("121314");
+    addKey("151617");
+    addKeyMode=false;
+  }
+}
+
+unsigned long nextHeartBeat = 0;
+void heartBeat() {
+  if (millis() > nextHeartBeat) {
+    debugMessage("Heartbeat!");
+    parpadear (2, 200);
+    nextHeartBeat = millis() + 2000;
+  }
+}
+
+/******************************
+   INTERACTION LAYER
+ ******************************/
+
+
+bool didResetMode = false;
+void checkButton() {
+  if (digitalRead(buttonPin) == LOW) {
+    debugMessage("checkButton() Button is low!");
+    long lowDetectionMillis = millis();
+
+    while (digitalRead(buttonPin) == LOW) {
+      long timeInLow = millis() - lowDetectionMillis;
+      if (timeInLow > 3000) {
+        debugMessage("checkButton() button was low for more than 3 seconds! Initializing File...");
+        initFile();
+        didResetMode = true;
+        break;
+      }
+    }
+    if (!didResetMode) {
+      debugMessage("checkButton() Switching to addKey mode...");
+      addKeyMode = true;
+    }
+
+    didResetMode = false;
+  }
+  //debugMessage("checkButton() END!");
+}
+
+/*****************************
+   DEBUG LAYER
+ *****************************/
 void test_addKey() {
   debugMessage("test_addKey() BEGIN!");
   String newKey = "2097876";
   debugMessage("test_addKey() Key to add: " + newKey);
-
+
   bool newKeyAlreadyFound = findKey(newKey);
   if (newKeyAlreadyFound) {
     debugMessage("test_addKey() WRONG: Key was not expected, but found. " + newKey);
@@ -86,7 +148,7 @@
   debugMessage("test_removeKey() BEGIN!");
   String keyToRemove = "2097876";
   debugMessage("test_removeKey() Key to remove: " + keyToRemove);
-
+
   bool keyToRemovePresent = findKey(keyToRemove);
   if (keyToRemovePresent) {
     debugMessage("test_removeKey() CORRECT: Key to remove is present as expected. " + keyToRemove);
@@ -106,7 +168,6 @@
 }
 void parpadear(int times, int milliseconds) {
   for (int i = 0; i < times; i++) {
-    if(times > 1) debugMessage("Heartbeat!");
     digitalWrite(ledPin, HIGH);
     delay(milliseconds);
     digitalWrite(ledPin, LOW);
@@ -146,9 +207,9 @@
   }
 }

-bool verifySize(String fileContent){
+bool verifySize(String fileContent) {
   debugMessage("verifySize() BEGIN!");
-  if(fileContent.length()==CONTENT_SIZE){
+  if (fileContent.length() == CONTENT_SIZE) {
     debugMessage("verifySize() CORRECT!");
     return true;
   } else {
@@ -171,7 +232,9 @@
 }

-
+/******************************************
+   BUSINESS LAYER
+ ******************************************/

 bool findKey(String key) {
   debugMessage("findKey(): " + key);
@@ -240,10 +303,6 @@

 }

-
-
-
-
 /**
    This function initializes file with raw content.
 */
@@ -255,6 +314,11 @@

   debugMessage("initFile() DONE!");
 }
+
+
+/********************
+   DATA ACCESS LAYER
+ ********************/

 /**
    This function reads file content into an string. Implements full debugging mechanism


git-svn-id: svn://192.168.1.10/public/Zimodem@14868 0d6f1817-ed0e-0410-87c9-987e46238f29

--- zimodem/zcommand.ino
+++ zimodem/zcommand.ino
@@ -357,6 +357,8 @@
 {
   if(vlen == 0)
   {
+    if(logFileOpen)
+      logFile.printf("ConnCheck: CURRENT\r\n");
     if(strlen(dmodifiers)>0)
       return ZERROR;
     if(current == null)
@@ -374,7 +376,12 @@
   else
   if((vval >= 0)&&(isNumber))
   {
-    if(strlen(dmodifiers)>0)
+    if(logFileOpen)
+      if(vval == 0)
+        logFile.printf("ConnList0:\r\n");
+      else
+        logFile.printf("ConnSwitchTo: %d\r\n",vval);
+    if(strlen(dmodifiers)>0) // would be nice to allow petscii/telnet changes here, but need more flags
       return ZERROR;
     WiFiClientNode *c=conns;
     if(vval > 0)
@@ -415,6 +422,8 @@
   }
   else
   {
+    if(logFileOpen)
+        logFile.printf("Connnect-Start:\r\n");
     char *colon=strstr((char *)vbuf,":");
     int port=23;
     if(colon != null)
@@ -423,14 +432,20 @@
       port=atoi((char *)(++colon));
     }
     int flagsBitmap = makeStreamFlagsBitmap(dmodifiers);
+    if(logFileOpen)
+        logFile.printf("Connnecting: %s %d %d\r\n",(char *)vbuf,port,flagsBitmap);
     WiFiClientNode *c = new WiFiClientNode((char *)vbuf,port,flagsBitmap);
     if(!c->isConnected())
     {
+      if(logFileOpen)
+          logFile.printf("Connnect: FAIL\r\n");
       delete c;
       return ZERROR;
     }
     else
     {
+      if(logFileOpen)
+          logFile.printf("Connnect: SUCCESS: %d\r\n",c->id);
       current=c;
       setCharArray(&(c->delimiters),tempDelimiters);
       setCharArray(&(c->maskOuts),tempMaskOuts);
@@ -1230,6 +1245,8 @@
       case ZOK:
         if(index >= len)
         {
+          if(logFileOpen)
+              logFile.printf("Response: OK\r\n");
           if(numericResponses)
             Serial.print("0");
           else
@@ -1238,6 +1255,8 @@
         }
         break;
       case ZERROR:
+        if(logFileOpen)
+            logFile.printf("Response: ERROR\r\n");
         if(numericResponses)
           Serial.print("4");
         else
@@ -1246,6 +1265,8 @@
         // on error, cut and run
         return ZERROR;
       case ZCONNECT:
+        if(logFileOpen)
+            logFile.printf("Response: Connected\r\n");
         sendConnectionNotice((current == null) ? baudRate : current->id);
         break;
       default:
@@ -1253,7 +1274,6 @@
       }
     }
   }
-
   return result;
 }


Restoring the build date.

Restoring the build date.

git-svn-id: d8bfcd070c2c81762cca1b3912331324182919ba@17106 0d6f1817-ed0e-0410-87c9-987e46238f29

--- zimodem/zcommand.ino
+++ zimodem/zcommand.ino
@@ -2457,9 +2457,9 @@
 #endif
   HWSerial.setTimeout(60000);
   serial.prints(ZIMODEM_VERSION);
-  //serial.prints(" (");
-  //serial.prints(compile_date);
-  //serial.prints(")");
+  serial.prints(" (");
+  serial.prints(compile_date);
+  serial.prints(")");
   serial.prints(commandMode.EOLN);
   char s[100];
 #ifdef ZIMODEM_ESP32


Improved sample reading strings and numbers

--- examples/ReadNumberString/ReadNumberString.ino
+++ examples/ReadNumberString/ReadNumberString.ino
@@ -6,7 +6,8 @@
 || * 8-ohm speaker on digital pin 5
 ||
 || @description
-|| |    Debug/test of generic buffer
+|| |    This sketch gives an example of how to read integers,
+|| | floats, longs and strings with the Keypad library.
 || |
 || #
 */
@@ -52,9 +53,12 @@
   kpd.addEventListener(key_event_handler);
 }

+/*** Declaration of some float, int, long and char[] that are gonna be read ***/
 float f, oldf=0;
 int i, oldi=0;
 long l, oldl=0;
+char str[buffer_length+1], oldstr[buffer_length+1];
+/*** old* are intended to contain the previous value and avoid printing the same value twice ***/

 void loop() {
   kpd.getKey();
@@ -81,10 +85,16 @@
     Serial.print("\r\n");
   }

+  if(kpd.readQueue(TYPE_STRING, str) && strncmp(str, oldstr, buffer_length)!=0) {
+    strncpy(oldstr, str, buffer_length);
+    Serial.print("str = \"");
+    Serial.print(str);
+    Serial.print("\"\r\n");
+  }
+
   /* Below we make the buffer expiring after 4 seconds of inactivity */
   if(lastPress + 4000 < millis()) {
     kpd.resetKeysInQueue();
+    Serial.print("Queue cleared for inactivity\r\n");
   }
-
-  //Serial.print("Sum = "); Serial.print(sum); Serial.print("\r\n");
 }


ignore mqtt msg BETWEEN_RELAY_ACTIVE time

--- _70-homekit-accessories-light/_70-homekit-accessories-light.ino
+++ _70-homekit-accessories-light/_70-homekit-accessories-light.ino
@@ -17,7 +17,7 @@
 #define RELAY_PIN 12
 #define LED_PIN 13

-#define BETWEEN_RELAY_ACTIVE 1000
+#define BETWEEN_RELAY_ACTIVE 3000
 #define REPORT_INTERVAL 5000 // in msec

 IPAddress mqtt_server = MQTT_SERVER;
@@ -130,17 +130,20 @@
     if (root.containsKey("cmd"))
     {
       const char* mqtt_relay_state = root["cmd"];
-      if ( String(mqtt_relay_state) == "on")
-      {
-        Serial.println("call on");
-        bRelayState = HIGH;
-      }
-      else
-      {
-        Serial.println("call off");
-        bRelayState = LOW;
-      }
-      bUpdated = true;
+      if (bRelayReady)
+      {
+        if ( String(mqtt_relay_state) == "on")
+        {
+          Serial.println("call on");
+          bRelayState = HIGH;
+        }
+        else
+        {
+          Serial.println("call off");
+          bRelayState = LOW;
+        }
+        bUpdated = true;
+     }
     }
   }
 }


Add files via upload

Add files via upload

added code to read the raw of the device

--- arduino/tempLogger/tempLogger.ino
+++ arduino/tempLogger/tempLogger.ino
@@ -44,15 +44,15 @@
 #include "Wire.h"
 #include <avr/sleep.h>  //sleep library
 #include <DS3231.h> //clock
+
 #define DEBUG 1
 #define DEBUG_TO_SD 0
 #define POWA 4    // pin 4 supplies power to microSD card breakout and temp sensor
-
-//Clock var's
 #define DS3231_I2C_ADDRESS 0x68 //default address for DS3231
 #define wakePin 3
 unsigned int timeToSleep = 1; //use this to control the value going to the clock register. Set it to the # minutes desired to log
 int timeCount = 0; //don't modify this
+float temperature = -12345;

 SPISettings mySettings;
 DS3231 clock;
@@ -61,6 +61,13 @@
 int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
 OneWire ds(DS18S20_Pin); // on digital pin 2

+
+#define NUM_SAMPLES 10
+
+//voltage divider stuff
+int sum = 0;                    // sum of samples taken
+unsigned char sample_count = 0; // current sample number
+float voltage = 0.0;            // calculated voltage

 // Convert normal decimal numbers to binary coded decimal
 byte decToBcd(byte val)
@@ -85,24 +92,30 @@
   if ( !ds.search(addr)) {
     //no more sensors on chain, reset search
     ds.reset_search();
+#if DEBUG
     Serial.println("Cannot find an address for temp sensor");
+#endif
     return -1000;
   }

   if ( OneWire::crc8( addr, 7) != addr[7]) {
+#if DEBUG
     Serial.println("CRC is not valid!");
+#endif
     return -1001;
   }

   if ( addr[0] != 0x10 && addr[0] != 0x28) {
+#if DEBUG
     Serial.print("Device is not recognized");
+#endif
     return -1002;
   }

   ds.reset();
   ds.select(addr);
   ds.write(0x44, 1); // start conversion, with parasite power on at the end
-
+
   byte present = ds.reset();
   ds.select(addr);
   ds.write(0xBE); // Read Scratchpad
@@ -147,7 +160,9 @@

   // see if the card is present and can be initialized:
   if (!SD.begin(chipSelect)) {
+#if DEBUG
     Serial.println("Card failed, or not present");
+#endif
     // don't do anything more:
     return;
   }
@@ -193,7 +208,7 @@
   // retrieve data from DS3231
   readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
   &year);
-
+#if DEBUG
   // print to the serial port:
   //yyyy-mm-dd hh:mm:ss
   Serial.print(year);
@@ -207,7 +222,7 @@
   Serial.print(minute);
   Serial.print(":");
   Serial.print(second);
-
+#endif
 }

 /*
@@ -225,8 +240,9 @@
     dataFile.close();
   }
   else{
-
+#if DEBUG
     Serial.println("error writing text to disk data.txt");
+#endif
   }
 }

@@ -314,7 +330,9 @@
   }
   // if the file isn't open, pop up an error:
   else {
+#if DEBUG
     Serial.println("error opening data.txt");
+#endif
   }
 }

@@ -369,8 +387,8 @@
   // set pin 4 (POWA) to output so that we can control the
   //power of the sd reader and the temp sensor
   pinMode(POWA, OUTPUT);
-
-  // turn on SD card and temp sensor
+  // turn on SD card and temp sensor
+
   digitalWrite(POWA, HIGH);

   // give some delay to ensure RTC and SD are initialized properly
@@ -422,7 +440,7 @@
 #if DEBUG
     printTime();
 #endif
-#if 0
+#if DEBUG
     Serial.print("timeCount is ");
     Serial.println(timeCount);
     Serial.println("isAlarm() is: " + String(clock.isAlarm1(false)));
@@ -430,7 +448,7 @@

    //update until we hit the specified number of minutes to run

-#if 0
+#if DEBUG
   Serial.print("clock.isAlarm1() " + String(clock.isAlarm1(false)) + " && (timeCount < (timeToSleep - 1)) : ");
   Serial.println(clock.isAlarm1(false) && (timeCount < (timeToSleep - 1)));
 #endif
@@ -445,6 +463,30 @@
   //processor and the alarm flag is set. Clear the flag and
   //handle whatever we need to do.
   else {
+
+     /*get voltage*/
+    // take a number of analog samples and add them up
+    while (sample_count < NUM_SAMPLES) {
+        sum += analogRead(A3);
+        sample_count++;
+        delay(10);
+    }
+    // calculate the voltage
+    // use 5.0 for a 5.0V ADC reference voltage
+    // 5.015V is the calibrated reference voltage
+    voltage = ((float)sum / (float)NUM_SAMPLES * 5.05) / 1024.0;
+    // send voltage for display on Serial Monitor
+    // voltage multiplied by 11 when using voltage divider that
+    // divides by 11. 11.132 is the calibrated voltage divide
+    // value
+#if DEBUG
+    Serial.print(voltage * 11.133);
+    Serial.println (" V");
+#endif
+    sample_count = 0;
+    sum = 0;
+    append_to_disk(voltage);
+
 #if DEBUG_TO_SD
   write_Text_To_Disk("data.txt","Woke up, logging");
 #endif
@@ -457,13 +499,18 @@
     //we finally hit the specified number of minutes to run, reset and log
     timeCount = 0;

-    float temperature = getTemp();
+    temperature = getTemp();
     delay(5);
     append_to_disk(temperature);
+
 #if DEBUG
     Serial.println(temperature);
 #endif

+
+    temperature = -54321; //set to this so we dont get the same temp reading each time
+    //if something is wrong with sensor
+
     //clear alarm flag and update time To sleep
     clock.clearAlarm1();


Inner loop support is done and ready for next run

Hopefully nothing will break

There are failsafe features I wanted to add just in case but decided not to add because I'm afraid those features may actually break the controller in a very specific and hard way to debug. See line 397 and line 400 for more comments.

--- gcn_controller_v5/gcn_controller_v5.ino
+++ gcn_controller_v5/gcn_controller_v5.ino
@@ -188,7 +188,6 @@
 void setup()
 {
   Serial.begin(baudRate);
-  Serial.println("Starting");

   pinMode(motorInput, INPUT);
   pinMode(turboLed, INPUT);
@@ -207,7 +206,7 @@
   }
   digitalWrite(latchPin, HIGH);

-  // Press the buttons X, Y and Start for 3 seconds to reset the controller,
+  // Press the buttons X, Y and Start for 2 seconds to reset the controller,
   // this is a built in controller feature to make it easier to reset analog sticks and
   // triggers without having to unplug the controller, thanks Nintendo, this feature is very useful!
   inputStatus[buttonX] = LOW;
@@ -223,9 +222,9 @@
   }
   digitalWrite(latchPin, HIGH);

-  delay(3000);
-
-  // Now we release the buttons X, Y and Start after 3 seconds have passed
+  delay(2000);
+
+  // Now we release the buttons X, Y and Start after 2 seconds have passed
   inputStatus[buttonX] = HIGH;
   inputStatus[buttonY] = HIGH;
   inputStatus[buttonStart] = HIGH;
@@ -278,14 +277,6 @@
   old_macro_input[9] = 0x00;
   old_macro_input[10] = 0x00;
   old_macro_input[11] = 0x00;
-
-  Serial.println(startingMacroIndex);
-  Serial.println(endingMacroIndex);
-  Serial.println(macroBufferSize);
-  Serial.println(startingMacroMetadataIndex);
-  Serial.println(endingMacroMetadataIndex);
-  Serial.println(macroMetadataSize);
-  Serial.println("Ready to go");
 }

 void loop()
@@ -334,7 +325,6 @@
           macroIndex = serial_rx_buffer[0] - startingMacroIndex;
           for (uint8_t macroInputIndex = 0; macroInputIndex < sizeof(serial_rx_buffer); macroInputIndex++) {
             macro_buffer[macroIndex][macroInputIndex] = serial_rx_buffer[macroInputIndex];
-            //Serial.println(macro_buffer[macroIndex][macroInputIndex]);
           }
         }
       }
@@ -360,44 +350,24 @@
       howManyInnerLoopsMacroHas = serial_rx_buffer[6]; // >0 if there are, <=0 if there aren't
       // The block below resets all inner loop metadata counters
       if (howManyInnerLoopsMacroHas > 0) {
-        Serial.println("TEST ABC");
         macroMetadataIndex = 0;
         // Check if the first inner loop metadata is valid, if it is, use that, if not, disregard and don't do anything
         if (inner_loop_metadata[0][1] > 0 && inner_loop_metadata[0][3] > 0) {
           // Accept inner loop metadata if first inner loop metadata is valid
-          Serial.println("TEST DEF");
           macroMetadataIndex = 0;
           for (uint8_t macroMetadataIndexInner = 0; macroMetadataIndexInner < howManyInnerLoopsMacroHas; macroMetadataIndexInner++) {
-            Serial.print("BEFORE macroMetadataIndexInner = ");
-            Serial.println(macroMetadataIndexInner);
             inner_loop_metadata[macroMetadataIndexInner][2] = 0; // Reset current input index for inner loop
             inner_loop_metadata[macroMetadataIndexInner][4] = 0; // Reset current repeat counter for inner loop
-            Serial.print("AFTER macroMetadataIndexInner = ");
-            Serial.println(macroMetadataIndexInner);
           }
         }
         if (inner_loop_metadata[0][1] <= 0 || inner_loop_metadata[0][3] <= 0) {
           // Clear all inner loop metadata if first inner loop metadata is invalid
           macroMetadataIndex = 0;
           howManyInnerLoopsMacroHas = 0;
-          Serial.println("TEST GHI");
           for (uint8_t macroMetadataIndexInner = 0; macroMetadataIndexInner < macroMetadataSize; macroMetadataIndexInner++) {
-            Serial.print("BEFORE macroMetadataIndexInner = ");
-            Serial.println(macroMetadataIndexInner);
-            inner_loop_metadata[macroMetadataIndexInner][0] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][1] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][2] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][3] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][4] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][5] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][6] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][7] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][8] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][9] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][10] = 0;
-            inner_loop_metadata[macroMetadataIndexInner][11] = 0;
-            Serial.print("AFTER macroMetadataIndexInner = ");
-            Serial.println(macroMetadataIndexInner);
+            for (uint8_t innerLoopMetadataIndex = 0; innerLoopMetadataIndex < sizeof(inner_loop_metadata[0]); innerLoopMetadataIndex++) {
+              inner_loop_metadata[macroMetadataIndexInner][innerLoopMetadataIndex] = 0;
+            }
           }
         }
       }
@@ -407,8 +377,6 @@
     if ((serial_rx_buffer[0] >= startingMacroMetadataIndex) && (serial_rx_buffer[11] >= startingMacroMetadataIndex)) {
       if ((serial_rx_buffer[0] < endingMacroMetadataIndex) && (serial_rx_buffer[11] < endingMacroMetadataIndex)) {
         if (serial_rx_buffer[0] == serial_rx_buffer[11]) {
-          //Serial.print("Received loop metadata 1 info at index ");
-          //Serial.println(serial_rx_buffer[0]);
           // Stop the current loop when we receive a new macro
           macroIndex = 0;
           currentMacroIndexRunning = 0;
@@ -426,29 +394,19 @@
             inner_loop_metadata[macroMetadataIndex][2] = 0; // Current input index
             inner_loop_metadata[macroMetadataIndex][3] = 0; // Times to repeat (number of times this inner loop should be executed, before going to the next inner loop, if any)
             inner_loop_metadata[macroMetadataIndex][4] = 0; // Repeat counter (number of times this inner loop was executed)
-            inner_loop_metadata[macroMetadataIndex][5] = 0; // Where is the next inner loop's first input (index 0 input for the next inner loop, aka the index for the input in the macro_buffer array) (Continue normally if value is 0, or do nothing if there are no more inputs to be executed) // Current unused, apply logic to this // Is this really needed? (maybe for as a failsafe?)
+            inner_loop_metadata[macroMetadataIndex][5] = 0; // Where is the next inner loop's first input (index 0 input for the next inner loop, aka the index for the input in the macro_buffer array) (Continue normally if value is 0, or do nothing if there are no more inputs to be executed) // Current unused, apply logic to this // Is this really needed? (maybe as a failsafe?) (I will not use this variable for anything because I'm scared it'll break things during an actual run)
             inner_loop_metadata[macroMetadataIndex][6] = 0; // Where to start (index of the starting input) (Inclusive)
             inner_loop_metadata[macroMetadataIndex][7] = 0; // Where to end (index of the ending input) (Inclusive)
-            inner_loop_metadata[macroMetadataIndex][8] = 0; // How many inner loops that should be executed after this (if <=0, don't execute inner loops any inner loops after this, and move on as normal, if there are normal inputs to be exeucuted, execute those, if there's nothing else to do, go back to the beginning of the larger loop, if > 0, execute n inner loops after this) // Currently unused, apply logic to this // Is this really needed? (maybe for as a failsafe?)
+            inner_loop_metadata[macroMetadataIndex][8] = 0; // How many inner loops that should be executed after this (if <=0, don't execute inner loops any inner loops after this, and move on as normal, if there are normal inputs to be exeucuted, execute those, if there's nothing else to do, go back to the beginning of the larger loop, if > 0, execute n inner loops after this) // Currently unused, apply logic to this // Is this really needed? (maybe as a failsafe?) (I will not use this variable for anything because I'm scared it'll break things during an actual run)
             inner_loop_metadata[macroMetadataIndex][9] = 0; // Unused?
             inner_loop_metadata[macroMetadataIndex][10] = 0; // Unused?
             inner_loop_metadata[macroMetadataIndex][11] = 0; // Postamble
           */
           for (uint8_t macroInputMetadataIndex = 0; macroInputMetadataIndex < sizeof(serial_rx_buffer); macroInputMetadataIndex++) {
             inner_loop_metadata[macroMetadataIndex][macroInputMetadataIndex] = serial_rx_buffer[macroInputMetadataIndex];
-            //Serial.print("macroMetadataIndex = ");
-            //Serial.println(macroMetadataIndex);
-            //Serial.print("macroInputMetadataIndex = ");
-            //Serial.println(macroInputMetadataIndex);
-            Serial.println(inner_loop_metadata[macroMetadataIndex][macroInputMetadataIndex]);
-          }
-          //Serial.println("");
+          }
         }
       }
-    }
-    if ((serial_rx_buffer[0] == endingMacroMetadataIndex) && (serial_rx_buffer[11] == endingMacroMetadataIndex)) {
-      //Serial.print("Received loop metadata 2 info at index ");
-      //Serial.println(serial_rx_buffer[0]);
     }
   }
   runMacro();
@@ -464,65 +422,6 @@
         if (loopCounter <= timesToLoop) {
           for (uint8_t currentInputIndex = 0; currentInputIndex < sizeof(serial_rx_buffer); currentInputIndex++) {
             current_macro_input[currentInputIndex] = macro_buffer[currentMacroIndexRunning][currentInputIndex];
-            //Serial.println(current_macro_input[currentInputIndex]);
-            //Serial.print("currentMacroIndexRunning = ");
-            //Serial.println(currentMacroIndexRunning);
-          }
-          //Serial.print("currentMacroIndexRunning = ");
-          //Serial.println(currentMacroIndexRunning);
-          if (howManyInnerLoopsMacroHas <= 0) {
-            //Serial.println("\r\nTEST A");
-            /*
-              currentMacroMetadataIndexRunning = currentMacroIndexRunning + startingMacroMetadataIndex;
-              Serial.print("currentMacroMetadataIndexRunning = ");
-              Serial.println(currentMacroMetadataIndexRunning);
-            */
-            //
-            /*
-              Serial.println("");
-              Serial.print("howManyInnerLoopsMacroHas = ");
-              Serial.println(howManyInnerLoopsMacroHas);
-              Serial.print(" , currentMacroIndexRunning = ");
-              Serial.println(currentMacroIndexRunning);
-              Serial.println("");
-            */
-          }
-          if (howManyInnerLoopsMacroHas > 0) {
-            //Serial.println("\r\nTEST B");
-            //
-            currentMacroMetadataIndexRunning = currentMacroIndexRunning + startingMacroMetadataIndex;
-            if (inner_loop_metadata[currentMacroIndexRunning][2] == currentMacroMetadataIndexRunning) {
-              //Serial.println("");
-              //Serial.println("YEAH 2");
-              //Serial.println("");
-            }
-            if (inner_loop_metadata[currentMacroIndexRunning][2] == currentMacroIndexRunning) {
-              //Serial.println("");
-              //Serial.print("currentMacroMetadataIndexRunning = ");
-              //Serial.println(currentMacroMetadataIndexRunning);
-              //Serial.println("YEAH");
-              //Serial.println("");
-            }
-
-            /*
-              Serial.print("startingMacroMetadataIndex = ");
-              Serial.println(startingMacroMetadataIndex);
-              Serial.print("currentMacroIndexRunning = ");
-              Serial.println(currentMacroIndexRunning);
-              Serial.print("inner_loop_metadata[currentMacroIndexRunning][2] = ");
-              Serial.println(inner_loop_metadata[currentMacroIndexRunning][2]);
-              Serial.print("currentMacroMetadataIndexRunning = ");
-              Serial.println(currentMacroMetadataIndexRunning);
-            */
-
-            /*
-              Serial.println("");
-              Serial.print("howManyInnerLoopsMacroHas = ");
-              Serial.println(howManyInnerLoopsMacroHas);
-              Serial.print(" , currentMacroIndexRunning = ");
-              Serial.println(currentMacroIndexRunning);
-              Serial.println("");
-            */
           }
           // Make the button presses actually work
           isInputting = true;
@@ -530,147 +429,84 @@
         }
       }
       if (currentMacroIndexRunning < macroInputsToRun) {
-        //Serial.print("A BEFORE currentMacroIndexRunning = ");
-        //Serial.println(currentMacroIndexRunning);
         if (howManyInnerLoopsMacroHas <= macroMetadataIndex) {
           // Do stuff normally
-          Serial.println("This macro does not have inner loops OR we reached the end of inner loops");
+          // This macro does not have inner loops OR we reached the end of inner loops
           currentMacroIndexRunning++;
         }
         if (howManyInnerLoopsMacroHas > macroMetadataIndex) {
           // This is where inner loop logic goes
-          Serial.println("This macro has inner loops");
+          // This macro has inner loops
           if (inner_loop_metadata[macroMetadataIndex][1] > 0 && inner_loop_metadata[macroMetadataIndex][3] > 0) {
             // Do something
-            Serial.println("This inner loop metadata is valid");
-            Serial.print("A currentMacroIndexRunning  = ");
-            Serial.println(currentMacroIndexRunning);
+            // This inner loop metadata is valid
             if (inner_loop_metadata[macroMetadataIndex][3] > 0 && inner_loop_metadata[macroMetadataIndex][4] <= inner_loop_metadata[macroMetadataIndex][3]) {
-              Serial.println("TEST");
+              for (uint8_t innerLoopMetadataIndex = 0; innerLoopMetadataIndex < sizeof(inner_loop_metadata[macroMetadataIndex]); innerLoopMetadataIndex++) {
+                Serial.write(inner_loop_metadata[macroMetadataIndex][innerLoopMetadataIndex]);
+              }
               if (inner_loop_metadata[macroMetadataIndex][2] < inner_loop_metadata[macroMetadataIndex][6]) {
                 // Current input index is lower than starting index, fix this
-                // Write inner loop metadata back to PC here
-                Serial.println("Current input index for current inner loop is below what it is supposed to be, fix that!");
-                Serial.print("B currentMacroIndexRunning  = ");
-                Serial.println(currentMacroIndexRunning);
+                // Current input index for current inner loop is below what it is supposed to be, fix that!
                 inner_loop_metadata[macroMetadataIndex][2] = inner_loop_metadata[macroMetadataIndex][6];
                 currentMacroIndexRunning = inner_loop_metadata[macroMetadataIndex][6];
-                Serial.print("C currentMacroIndexRunning  = ");
-                Serial.println(currentMacroIndexRunning);
-                // Write inner loop metadata back to PC here
               }
               if (inner_loop_metadata[macroMetadataIndex][2] >= inner_loop_metadata[macroMetadataIndex][6] && currentMacroIndexRunning <= inner_loop_metadata[macroMetadataIndex][7]) {
                 // Current input index is valid
-                // Write inner loop metadata back to PC here
-                Serial.println("Current input index for current inner loop is in the valid range!");
-                Serial.print("D currentMacroIndexRunning  = ");
-                Serial.println(currentMacroIndexRunning);
+                // Current input index for current inner loop is in the valid range!
                 currentMacroIndexRunning++;
                 inner_loop_metadata[macroMetadataIndex][2]++;
-                Serial.print("E currentMacroIndexRunning  = ");
-                Serial.println(currentMacroIndexRunning);
-                // Write inner loop metadata back to PC here
               }
               if (inner_loop_metadata[macroMetadataIndex][2] > inner_loop_metadata[macroMetadataIndex][7]) {
                 // Inner loop ended?
                 // Write inner loop metadata back to PC here
-                Serial.println("Inner loop ended");
-                Serial.print("F currentMacroIndexRunning  = ");
-                Serial.println(currentMacroIndexRunning);
                 currentMacroIndexRunning = inner_loop_metadata[macroMetadataIndex][6];
                 inner_loop_metadata[macroMetadataIndex][2] = inner_loop_metadata[macroMetadataIndex][6];
                 inner_loop_metadata[macroMetadataIndex][4]++;
-                Serial.print("inner_loop_metadata[macroMetadataIndex][4] = ");
-                Serial.println(inner_loop_metadata[macroMetadataIndex][4]);
-                Serial.print("G currentMacroIndexRunning  = ");
-                Serial.println(currentMacroIndexRunning);
-                // Write inner loop metadata back to PC here
+              }
+              for (uint8_t innerLoopMetadataIndex = 0; innerLoopMetadataIndex < sizeof(inner_loop_metadata[macroMetadataIndex]); innerLoopMetadataIndex++) {
+                Serial.write(inner_loop_metadata[macroMetadataIndex][innerLoopMetadataIndex]);
               }
             }
             if (inner_loop_metadata[macroMetadataIndex][3] > 0 && inner_loop_metadata[macroMetadataIndex][4] > inner_loop_metadata[macroMetadataIndex][3]) {
-              Serial.println("Broke out from inner loop?");
-              Serial.print("H currentMacroIndexRunning  = ");
-              Serial.println(currentMacroIndexRunning);
-              //currentMacroIndexRunning = inner_loop_metadata[macroMetadataIndex][7] + 1;
+              // Broke out from inner loop?
               macroMetadataIndex++;
-              Serial.print("I currentMacroIndexRunning  = ");
-              Serial.println(currentMacroIndexRunning);
             }
-            Serial.print("J currentMacroIndexRunning  = ");
-            Serial.println(currentMacroIndexRunning);
           }
           if (inner_loop_metadata[macroMetadataIndex][1] <= 0 || inner_loop_metadata[macroMetadataIndex][3] <= 0) {
             // Ignore this inner loop, it is not valid
-            Serial.println("This inner loop metadata is not valid");
-            Serial.print("K currentMacroIndexRunning  = ");
-            Serial.println(currentMacroIndexRunning);
+            // This inner loop metadata is not valid
             currentMacroIndexRunning++;
-            Serial.print("L currentMacroIndexRunning  = ");
-            Serial.println(currentMacroIndexRunning);
           }
         }
-        //Serial.print("B AFTER currentMacroIndexRunning = ");
-        //Serial.println(currentMacroIndexRunning);
       }
       if (loopMacro > 0) {
         if (currentMacroIndexRunning >= macroInputsToRun) {
-          //Serial.print("C BEFORE currentMacroIndexRunning = ");
-          //Serial.println(currentMacroIndexRunning);
           currentMacroIndexRunning = 0;
-          //Serial.print("D AFTER currentMacroIndexRunning = ");
-          //Serial.println(currentMacroIndexRunning);
-          /*
-            if (timesToLoop <= 0) {
-            //
-            }
-          */
           // The block below resets all inner loop metadata counters
           if (howManyInnerLoopsMacroHas > 0) {
-            Serial.println("TEST ABC");
             macroMetadataIndex = 0;
             // Check if the first inner loop metadata is valid, if it is, use that, if not, disregard and don't do anything
             if (inner_loop_metadata[0][1] > 0 && inner_loop_metadata[0][3] > 0) {
               // Accept inner loop metadata if first inner loop metadata is valid
-              Serial.println("TEST DEF");
               macroMetadataIndex = 0;
               for (uint8_t macroMetadataIndexInner = 0; macroMetadataIndexInner < howManyInnerLoopsMacroHas; macroMetadataIndexInner++) {
-                Serial.print("BEFORE macroMetadataIndexInner = ");
-                Serial.println(macroMetadataIndexInner);
                 inner_loop_metadata[macroMetadataIndexInner][2] = 0; // Reset current input index for inner loop
                 inner_loop_metadata[macroMetadataIndexInner][4] = 0; // Reset current repeat counter for inner loop
-                Serial.print("AFTER macroMetadataIndexInner = ");
-                Serial.println(macroMetadataIndexInner);
               }
             }
             if (inner_loop_metadata[0][1] <= 0 || inner_loop_metadata[0][3] <= 0) {
               // Clear all inner loop metadata if first inner loop metadata is invalid
               macroMetadataIndex = 0;
               howManyInnerLoopsMacroHas = 0;
-              Serial.println("TEST GHI");
               for (uint8_t macroMetadataIndexInner = 0; macroMetadataIndexInner < macroMetadataSize; macroMetadataIndexInner++) {
-                Serial.print("BEFORE macroMetadataIndexInner = ");
-                Serial.println(macroMetadataIndexInner);
-                inner_loop_metadata[macroMetadataIndexInner][0] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][1] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][2] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][3] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][4] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][5] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][6] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][7] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][8] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][9] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][10] = 0;
-                inner_loop_metadata[macroMetadataIndexInner][11] = 0;
-                Serial.print("AFTER macroMetadataIndexInner = ");
-                Serial.println(macroMetadataIndexInner);
+                for (uint8_t innerLoopMetadataIndex = 0; innerLoopMetadataIndex < sizeof(inner_loop_metadata[0]); innerLoopMetadataIndex++) {
+                  inner_loop_metadata[macroMetadataIndexInner][innerLoopMetadataIndex] = 0;
+                }
               }
             }
           }
           if (timesToLoop > 0 && loopCounter <= timesToLoop) {
             // Sending this block for redundancy sake, will comment this block if something goes wrong (it shouldn't)
-            Serial.print("M BEFORE loopCounter = ");
-            Serial.println(loopCounter);
             Serial.write(endingMacroIndex);
             Serial.write(macroInputsToRun);
             Serial.write(loopMacro);
@@ -696,8 +532,6 @@
             Serial.write(0x00);
             Serial.write(0x00);
             Serial.write(endingMacroIndex);
-            Serial.print("N AFTER loopCounter = ");
-            Serial.println(loopCounter);
           }
         }
       }
@@ -741,15 +575,7 @@
       for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
         // Send only data back if it has changed, I don't know how to do this without having two loops
         Serial.write(current_macro_input[currentByteIndex]);
-        //Serial.println(current_macro_input[currentByteIndex]);
-        //Serial.println("TEST");
-      }
-      /*
-        if (current_macro_input[2] == inner_loop_metadata[currentMacroIndexRunning][2]) {
-        //
-        //Serial.println("TEST");
-        }
-      */
+      }
     }
     Serial.flush();
     //  Press Button
@@ -948,8 +774,7 @@
             }
             for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
               // Send only data back if it has changed, I don't know how to do this without having two loops
-              Serial.write(current_macro_input[currentByteIndex]);
-              //Serial.println(current_macro_input[currentByteIndex]);
+              Serial.write(current_macro_input[currentByteIndex]);;
             }
           }
           Serial.flush();
@@ -1072,9 +897,7 @@
           inputStatus[buttonMode] = !(current_macro_input[7] & B00000001);
           // Sometimes buttons are considered as released by the console between inputs, the pieces of code below will hopefully make it so buttons are only released at the end of the final iteration of a loopable macro, or released at the final input of a non-loopable macro, or released at the end of a basic input
           if (loopMacro <= 0) {
-            //Serial.println("TEST A");
             if (currentMacroIndexRunning == macroInputsToRun) {
-              //Serial.println("TEST B");
               // Reset all variables related to macro to stop the arduino from running useless code
               macroIndex = 0;
               macroInputsToRun = 0;
@@ -1094,9 +917,7 @@
             }
           }
           if (loopMacro > 0) {
-            //Serial.println("TEST C");
             if (loopCounter > timesToLoop) {
-              //Serial.println("TEST D");
               // Reset all variables related to macro to stop the arduino from running useless code
               macroIndex = 0;
               macroInputsToRun = 0;
@@ -1115,7 +936,6 @@
               digitalWrite(latchPin, HIGH);
             }
           }
-
           //  Buffer Array Element 8 is unused in this code, but is existing in case changes are needed
           isInputtingDelayed = false;
           isInputting = false;


Delete esp32LightServerRGB.ino

Delete esp32LightServerRGB.ino

--- esp32LightServerRGB.ino
+++ esp32LightServerRGB.ino
@@ -1,839 +0,0 @@
-#include <WiFi.h>
-#include <DNSServer.h>
-#include <WebServer.h>
-#include <WiFiManager.h>
-#include <WiFiMulti.h>
-#include <HTTPClient.h>
-#include <Preferences.h>
-
-Preferences preferences;
-
-// sensors stuff
-#include <Wire.h>
-#include <DallasTemperature.h>
-#include <DHT.h>
-#include <ESPmDNS.h>
-#define ONE_WIRE_BUS 5
-#define DHTPIN 15
-#define DHTTYPE DHT11
-DHT dht(DHTPIN, DHTTYPE);
-OneWire oneWire(ONE_WIRE_BUS);
-DallasTemperature sensors(&oneWire);
-// end of sensors
-
-// Settings you should check/change
-const String resetpass = "YourResetPassword"; // password to reset wifimanager when allready connected
-const String thingkey = "YOURTHINKSPEAKKEY"; //your thingspeak API key
-const String thingchanel = "123456"; //your thingspeak Chanel #
-const long interval = 60000; // interval in ms for sending temperature data to thingspeak
-const String liens = "Acceuil - Température - Version - Reset - Temp stats\n"; // html/links shown at bottom of pages
-String dernadd = "Fraichement booté"; //variable for ip logging (you can put your fresh boot mesage here in text/html)
-// led pins
-uint8_t pinRouge = 12;
-uint8_t pinVerte = 14; // internally pulled up
-uint8_t pinBleu = 13;
-// end of settings you should check/change
-
-// internally used vars
-WebServer server(80);
-String derncoul = "#000000";
-long r = 0;
-long g = 0;
-long b = 0;
-int rouge = 0;
-int vert = 0;
-int bleu = 0;
-unsigned long previousMillis = 0;
-unsigned long previousMillisr = 0;
-unsigned long previousMillisg = 0;
-unsigned long previousMillisb = 0;
-unsigned long previousMillisf = 0;
-int attendR = 70;
-int attendG = 70;
-int attendB = 70;
-int attendF = 700;
-unsigned long flashfois = 0;
-unsigned long flashrendu = 0;
-int roulepastusuite = 0;
-int flashoufade = 0;
-int tstrouteur = 0;
-String logs[51];
-// end of internally used vars
-
-// stylesheet for web pages
-const String css = "\n";
-// end of stylesheet for web pages
-
-// functions used internally
-
-// used to flash leds
-void flashfunk() {
-  if (flashrendu <= flashfois) {
-    flashrendu++;
-    if (rouge == r) {
-      ledcWrite(1, 0);
-      rouge = 0;
-    } else {
-      ledcWrite(1, r);
-      rouge = r;
-    }
-    if (vert == g) {
-      ledcWrite(2, 0);
-      vert = 0;
-    } else {
-      ledcWrite(2, g);
-      vert = g;
-    }
-    if (bleu == b) {
-      ledcWrite(3, 0);
-      bleu = 0;
-    } else {
-      ledcWrite(3, b);
-      bleu = b;
-    }
-  } else {
-    r = rouge;
-    b = bleu;
-    g = vert;
-    flashoufade = 0;
-    flashrendu = 0;
-    Serial.println("Flash fini");
-  }
-}
-
-// used to fade red
-void fadeR() {
-  if (rouge < r) {
-    rouge++;
-    ledcWrite(1, rouge);
-  } else if (rouge > r) {
-    rouge--;
-    ledcWrite(1, rouge);
-  }
-}
-
-// used to fade green
-void fadeG() {
-  if (vert < g) {
-    vert++;
-    ledcWrite(2, vert);
-  } else if (vert > g) {
-    vert--;
-    ledcWrite(2, vert);
-  }
-}
-
-// used to fade blue
-void fadeB() {
-  if (bleu  b) {
-    bleu--;
-    ledcWrite(3, bleu);
-  }
-}
-
-// log rotator
-void logtourne() {
-  for (int i = 49; i > 0; i--) {
-    int l = i;
-    l = l + 1;
-    logs[l] = logs[i];
-  }
-}
-
-// web page to handle flashing of leds (color/delay/number of flashes)
-void handleLog() {
-  String addy = server.client().remoteIP().toString();
-  String contenu = "";
-  for (int i = 1; i < 51; i++) {
-    if (logs[i] != "♥ vide") {
-      contenu += logs[i];
-      contenu += "\n
";
-    }
-  }
-  server.send(200, "text/plain", contenu);
-  Serial.println("");
-  Serial.println(addy);
-  Serial.println("Logs");
-  videCoeur();
-}
-
-// web page to handle flashing of leds (color/delay/number of flashes)
-void handleFlash() {
-  String addy = server.client().remoteIP().toString();
-  String testteu = server.arg("COULEUR");
-  String attend = server.arg("DELAIS");
-  attendF = attend.toInt();
-  String flashnombre = server.arg("FOIS");
-  flashfois = flashnombre.toInt();
-  flashfois = flashfois * 2;
-  Serial.println("");
-  Serial.println(addy);
-  Serial.println("Flash");
-  Serial.println(testteu);
-  Serial.print("Delais - ");
-  Serial.println(attendF);
-  Serial.print("Fois - ");
-  Serial.println(flashfois / 2);
-  if (testteu != 0) {
-    derncoul = testteu;
-    long number = strtol( &testteu[1], NULL, 16);
-    r = number >> 16;
-    g = number >> 8 & 0xFF;
-    b = number & 0xFF;
-    preferences.putString("derncoul", derncoul);
-    preferences.putUInt("r", r);
-    preferences.putUInt("g", g);
-    preferences.putUInt("b", b);
-    Serial.print("Rouge = ");
-    Serial.println(r);
-    Serial.print("Vert = ");
-    Serial.println(g);
-    Serial.print("Bleu = ");
-    Serial.println(b);
-    dernadd = addy;
-    flashoufade = 1;
-    flashrendu = 0;
-    ledcWrite(1, 0);
-    ledcWrite(2, 0);
-    ledcWrite(3, 0);
-    rouge = 0;
-    bleu = 0;
-    vert = 0;
-  }
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta http-equiv=\"refresh\" content=\"0;url=/party\" />\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere soit</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n\n"
-             "Merci\n";
-  server.send(200, "text/html", contenu);
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : Flash : Couleur=";
-  logs[1] += testteu;
-  logs[1] += " : Delais=";
-  logs[1] += attend;
-  logs[1] += " : Fois=";
-  logs[1] += flashnombre;
-  logs[1].replace("<", "</"); //prevent html tags in logs so hackers cant code in log page lol
-}
-
-// web page for flash mode
-void handlePitoune() {
-  String addy = server.client().remoteIP().toString();
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere log</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n";
-  contenu += "\n\n"
-             "
\n"
-             "
Les visiteurs
\n"
-             "

\nDernier IP à avoir changé la couleur : ";
-  contenu += dernadd;
-  contenu += "
\n";
-  contenu += liens;
-  contenu += "\n"
-             "
\n";
-  server.send(200, "text/html", contenu);
-  Serial.println("");
-  Serial.println(addy);
-  Serial.println("Page logs");
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : Page logs";
-}
-
-void handleClignote() {
-  String addy = server.client().remoteIP().toString();
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere flash</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n";
-  contenu += "\n\n"
-             "
\n"
-             "<form id=\"laforme\" action=\"/flash\" method=\"post\">\n"
-             "
Change la couleur de mon bureau:
"
-             "<input id=\"colorpad\" type=\"color\" name=\"COULEUR\" class=\"color\" value=\"" + derncoul + "\">
\n"
-             "Fois: <input id=\"fois\" type=\"number\" name=\"FOIS\" class=\"numbers\"> "
-             "Delais(ms): <input id=\"delais\" type=\"number\" name=\"DELAIS\" class=\"numbers\">
\n"
-             "<input type=\"submit\" class=\"button1\" value=\"Changer\">\n"
-             "</form>\n"
-             "<button onclick=\"disco()\">Hazard</button>
\n"
-             "<button onclick=\"startDisco()\">Auto Disco</button>
\n"
-             "Dernier IP à avoir changé la couleur : ";
-  contenu += dernadd;
-  contenu += "
\n";
-  contenu += liens;
-  contenu += "\n"
-             "
\n";
-  server.send(200, "text/html", contenu);
-  Serial.println("");
-  Serial.println(addy);
-  Serial.println("Page flash");
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : Page Flash";
-}
-
-// web page to handle leds fading
-void handleLeds() {
-  String addy = server.client().remoteIP().toString();
-  Serial.println("");
-  Serial.println(addy);
-  String testteu = server.arg("COULEUR");
-  Serial.println(testteu);
-  if (testteu != 0) {
-    derncoul = testteu;
-    long number = strtol( &testteu[1], NULL, 16);
-    r = number >> 16;
-    g = number >> 8 & 0xFF;
-    b = number & 0xFF;
-    preferences.putString("derncoul", derncoul);
-    preferences.putUInt("r", r);
-    preferences.putUInt("g", g);
-    preferences.putUInt("b", b);
-    if (r != rouge) {
-      Serial.print("Rouge = ");
-      Serial.println(r);
-      dernadd = addy;
-      flashoufade = 0;
-    }
-    if (g != vert) {
-      Serial.print("Vert = ");
-      Serial.println(g);
-      dernadd = addy;
-      flashoufade = 0;
-    }
-    if (b != bleu) {
-      Serial.print("Bleu = ");
-      Serial.println(b);
-      dernadd = addy;
-      flashoufade = 0;
-    }
-  }
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta http-equiv=\"refresh\" content=\"0;url=/\" />\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere soit</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n\n"
-             "Merci\n";
-  server.send(200, "text/html", contenu);
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : Fade : Couleur=";
-  logs[1] += testteu;
-  logs[1].replace("<", "</"); //prevent html tags in logs so hackers cant code in log page lol
-}
-
-// index page
-void handleRoot() {
-  String addy = server.client().remoteIP().toString();
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere soit</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n";
-  contenu += "\n\n"
-             "
\n"
-             "<form id=\"laforme\" action=\"/leds\" method=\"post\">\n"
-             "
Change la couleur de mon bureau:
"
-             "<input id=\"colorpad\" type=\"color\" name=\"COULEUR\" class=\"color\" value=\"" + derncoul + "\">
\n"
-             "<input type=\"submit\" class=\"button1\" value=\"Changer\">\n"
-             "</form>\n"
-             "<button onclick=\"disco()\">Hazard</button>
\n"
-             "<button onclick=\"startDisco()\">Auto Disco</button>
\n"
-             "Dernier IP à avoir changé la couleur : ";
-  contenu += dernadd;
-  contenu += "
\n";
-  contenu += liens;
-  contenu += "\n"
-             "
\n";
-  server.send(200, "text/html", contenu);
-  Serial.println("");
-  Serial.println(addy);
-  Serial.println("Page acceuil");
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : Acceuil";
-}
-
-//reset page
-void handleReset() {
-  int ouireset = 0;
-  String addy = server.client().remoteIP().toString();
-  Serial.println("");
-  Serial.println(addy);
-  Serial.println("!!! RESET PAGE !!!");
-  String testteu = server.arg("RESET");
-  String passme = server.arg("PASSME");
-  if (testteu == "OUI") {
-    if (passme == resetpass) {
-      ouireset = 1;
-    } else {
-      ouireset = 2;
-    }
-  }
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Que la lumiere se RESET</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n\n"
-             "
\n";
-  if (!ouireset) {
-    contenu += "<form action=\"/reset\" method=\"post\">\n"
-               "
Tu veux resetter le wifi network pour reconfigurer ?
"
-               "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
-               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
-               "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
-               "</form>\n";
-  } else if (ouireset != 1) {
-    contenu += "<form action=\"/reset\" method=\"post\">\n"
-               "
Tu veux resetter le wifi network pour reconfigurer ?
"
-               "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
-               "<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
-               "
!!! MAUVAIS PASSWORD !!!

\n"
-               "<input type=\"submit\" class=\"button1\" value=\"Reset Wifi Network\">\n"
-               "</form>\n";
-    Serial.print("BAD PASSWORD : ");
-    Serial.println(passme);
-  } else if (ouireset == 1) {
-    contenu += "
Reset Dans 10 Secondes
\n";
-  }
-  contenu += "
Dernier IP à avoir changé la couleur :";
-  contenu += dernadd;
-  contenu += "\n
";
-  contenu += liens;
-  contenu += "\n

\n";
-  server.send(200, "text/html", contenu);
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : Reset : Password=";
-  logs[1] += passme;
-  logs[1].replace("<", "</"); //prevent html tags in logs so hackers cant code in log page lol
-  if (ouireset == 1) {
-    Serial.println("Reset dans 10 secondes");
-    delay(10000);
-    WiFiManager wifiManager;
-    wifiManager.resetSettings();
-    ESP.restart();
-  }
-}
-
-// 404 not found page
-void handleNotFound() {
-  String addy = server.client().remoteIP().toString();
-  Serial.println("");
-  Serial.println(addy);
-  String htmlmessage = "<!DOCTYPE html>\n\n\n";
-  htmlmessage += "<meta charset=\"UTF-8\" />\n<title>404 Not found</title>\n"
-                 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  htmlmessage += css;
-  htmlmessage += "\n\n"
-                 "
\n";
-  htmlmessage += "
404 File Not Found

\n";
-  htmlmessage += "URI: ";
-  htmlmessage += server.uri();
-  htmlmessage += "
\nMethod: ";
-  htmlmessage += (server.method() == HTTP_GET) ? "GET" : "POST";
-  htmlmessage += "
\nArguments: ";
-  htmlmessage += server.args();
-  htmlmessage += "
\n";
-  for (uint8_t i = 0; i < server.args(); i++) {
-    htmlmessage += " " + server.argName(i) + ": " + server.arg(i) + "
\n";
-  }
-  htmlmessage += "
\n";
-  htmlmessage += liens;
-  htmlmessage += "
\n
\n";
-  server.send(404, "text/html", htmlmessage);
-  String message = "404 File Not Found\n";
-  message += "URI: ";
-  String uriL = server.uri();
-  message += uriL;
-  message += "\nMethod: ";
-  String methodeL = (server.method() == HTTP_GET) ? "GET" : "POST";
-  message += methodeL;
-  message += "\nArguments: ";
-  message += server.args();
-  message += "\n";
-  String argsL;
-  for (uint8_t i = 0; i < server.args(); i++) {
-    argsL += ": " + server.argName(i) + "=" + server.arg(i) + " ";
-    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
-  }
-  Serial.print(message);
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : 404 : URI=";
-  logs[1] += uriL;
-  logs[1] += " : Methode=";
-  logs[1] += methodeL;
-  logs[1] += " ";
-  logs[1] += argsL;
-  logs[1].replace("<", "</"); //prevent html tags in logs so hackers cant code in log page lol
-}
-
-// function executed in main loop every minute to update sensors data to thingspeak.com
-void latemp() {
-  sensors.requestTemperatures();
-  float thetemp = sensors.getTempCByIndex(0);
-  char buffer[10];
-  String tempC = dtostrf(thetemp, 5, 2, buffer);
-  float h = dht.readHumidity();
-  float t = dht.readTemperature();
-  if (tempC != "-127.00") {
-    if (tempC != "85.00") {
-      Serial.print("Envoi de temperature et humidite: ");
-      Serial.print(tempC);
-      Serial.print(" - ");
-      HTTPClient http;
-      String webadd = "http://api.thingspeak.com/update?key=";
-      webadd += thingkey;
-      webadd += "&field1=";
-      webadd += tempC;
-      if (h == h) { // to prevent NaN
-        webadd += "&field2=";
-        webadd += h;
-        Serial.print(h);
-        webadd += "&field3=";
-        webadd += t;
-      }
-      Serial.println("");
-      http.begin(webadd);
-      int httpCode = http.GET();//Send the request
-      if (httpCode > 0) {
-        Serial.println("Envoit reussit !");
-        tstrouteur = 0;
-      } else {
-        if (tstrouteur == 10) {
-          Serial.println("10 Erreur envoit ! REBOOT !");
-          ESP.restart();
-        } else {
-          Serial.println("Erreur envoit !");
-          tstrouteur++;
-        }
-      }
-      http.end();   //Close connection
-    }
-  }
-}
-
-// web page for showing sensors data
-void handleTemp() {
-  sensors.requestTemperatures();
-  float latemp = sensors.getTempCByIndex(0);
-  float h = dht.readHumidity();
-  while (latemp == -127.00) {
-    sensors.requestTemperatures();
-    latemp = sensors.getTempCByIndex(0);
-  }
-  String addy = server.client().remoteIP().toString();
-  String contenu = "<!DOCTYPE html>\n\n\n";
-  contenu += "<meta charset=\"UTF-8\" />\n<title>Quel chaleur</title>\n"
-             "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
-  contenu += css;
-  contenu += "\n\n"
-             "
\n";
-  contenu += "<form action=\"/\" method=\"get\">\n"
-             "
Voici la temperature
"
-             "
";
-  contenu += latemp;
-  contenu += "°C Humidité : ";
-  contenu += h;
-  contenu += "

\n"
-             ""
-             ""
-             "<input type=\"submit\" class=\"button1\" value=\"Acceuil\">\n"
-             "</form>\n"
-             "
Dernier IP à avoir changé la couleur :";
-  contenu += dernadd;
-  contenu += "\n
";
-  contenu += liens;
-  contenu += "\n

\n";
-  server.send(200, "text/html", contenu);
-  Serial.println("");
-  Serial.println(addy);
-  Serial.print("Temperature : ");
-  Serial.println(latemp);
-  Serial.print("Humidite : ");
-  Serial.println(h);
-  logtourne();
-  logs[1] = addy;
-  logs[1] += " : Temp : Temp=";
-  logs[1] += latemp;
-  logs[1] += " : Humidite=";
-  logs[1] += h;
-}
-
-int fadecomment(int claire) {
-  int combien = 70;
-  if (claire > 0)
-    combien = 90;
-  if (claire > 40)
-    combien = 80;
-  if (claire > 80)
-    combien = 60;
-  if (claire > 100)
-    combien = 40;
-  if (claire > 120)
-    combien = 30;
-  if (claire > 140)
-    combien = 20;
-  if (claire > 180)
-    combien = 9;
-  return combien;
-}
-
-void videCoeur() {
-  for (int i = 50; i > 0; i--) {
-    logs[i] = "♥ vide";
-  }
-}
-
-void setup() {
-  preferences.begin("lumiere", false);
-  videCoeur();
-  Serial.begin(115200);
-  dht.begin();
-  ledcAttachPin(pinRouge, 1); // assign RGB led pins to channels
-  ledcAttachPin(pinVerte, 2);
-  ledcAttachPin(pinBleu, 3);
-  pinMode(pinRouge, OUTPUT);
-  pinMode(pinVerte, OUTPUT);
-  pinMode(pinBleu, OUTPUT);
-  digitalWrite(pinRouge, LOW);
-  digitalWrite(pinBleu, LOW);
-  digitalWrite(pinVerte, LOW);
-  ledcSetup(1, 12000, 8); // 12 kHz PWM, 8-bit resolution
-  ledcSetup(2, 12000, 8);
-  ledcSetup(3, 12000, 8);
-  derncoul = preferences.getString("derncoul", "#000000");
-  r = preferences.getUInt("r", 0);
-  g = preferences.getUInt("g", 0);
-  b = preferences.getUInt("b", 0);
-  //rouge = r;
-  //vert = g;
-  //bleu = b;
-  //ledcWrite(1, r);
-  //ledcWrite(2, g);
-  //ledcWrite(3, b);
-
-  WiFiManager wifiManager;
-  wifiManager.setTimeout(240);
-  if (!wifiManager.autoConnect()) {
-    delay(3000);
-    ESP.restart();
-    delay(5000);
-  }
-  MDNS.begin("lumiere");
-  server.on("/", handleRoot);
-  server.on("/leds", handleLeds);
-  server.on("/flash", handleFlash);
-  server.on("/reset", handleReset);
-  server.on("/logs", handleLog);
-  server.on("/log", handlePitoune);
-  server.on("/temp", handleTemp);
-  server.on("/party", handleClignote);
-  server.on("/version", []() {
-    String addy = server.client().remoteIP().toString();
-    server.send(200, "text/html", "V2.4, Steve Olmstead sansillusion@gmail.com\n\n

"
-                "Added fader function\nRemoved connection watchdog (better have good signal)\n
"
-                "Removed mDns (did not work anyway)\n\n

"
-                "Added smoother fading\n\n

"
-                "Added AutoConect WifiManager !\n\n

"
-                "Added basic last IP logging\n
"
-                "Added /reset page to reset wifiManager connection settings\n\n

"
-                "Added /temp (temperature sensor read of ky-001)\n\n

"
-                "Added thingspeak support to send temperature each minute
\n\n
"
-                "Major rewrite for RGB led trip usin mosfet
\n"
-                "Removed serial to free resources for software pwm (still flikers but less than before)
\n\n
"
-                "Seperated LEDs handling page from index\n
"
-                "Added jQuery to load settings without reloading page\n
"
-                "Added random color selection button\n\n

"
-                "Added disco mode script and buttons\n\n

"
-                "Removed mDNS (does not work with esp32)\n
"
-                "        (Re-aded mDNS in 2.0 for esp32 but does not seem to work yet)\n
"
-                "Rewrite of code (removed Ticker and changed a few libraries) for esp32 !!!\n\n

"
-                "Changed fader functions for smoother fade\n
"
-                "Cleaned code\n\n

"
-                "Added Flashing function and page for smart widget usage\n
"
-                "Added var to show your thingspeak channel in /temp iframes\n\n

"
-                "Added /party page for easy control of flash mode\n\n

"
-                "Added /log page to see latest ~50 visits\n\n

"
-                "Added reboot if unable to connect to internet more than 10 times to send wheather data.\n\n

"
-                "Added color persistance trough reboot using esp32 Preferences\n\n

" + liens);
-    Serial.println("");
-    Serial.println(addy);
-    Serial.println("Version request");
-    logtourne();
-    logs[1] = addy;
-    logs[1] += " : Version request";
-  });
-  server.onNotFound(handleNotFound);
-  server.begin();
-  Serial.println("HTTP server started");
-  delay(100);
-  MDNS.addService("http", "tcp", 80);
-  sensors.begin();
-}
-
-void loop() {
-  server.handleClient();
-  unsigned long currentMillis = millis();
-  if (currentMillis - previousMillis >= interval) {
-    previousMillis = currentMillis;
-    latemp();
-  }
-  if (flashoufade == 1) {
-    currentMillis = millis();
-    if (currentMillis - previousMillisf >= attendF) {
-      flashfunk();
-      previousMillisf = currentMillis;
-    }
-  } else {
-    if (r != rouge) {
-      currentMillis = millis();
-      if (currentMillis - previousMillisr >= attendR) {
-        fadeR();
-        previousMillisr = currentMillis;
-        attendR = fadecomment(rouge);
-      }
-    }
-    if (g != vert) {
-      currentMillis = millis();
-      if (currentMillis - previousMillisg >= attendG) {
-        fadeG();
-        previousMillisg = currentMillis;
-        attendG = fadecomment(vert);
-      }
-    }
-    if (b != bleu) {
-      currentMillis = millis();
-      if (currentMillis - previousMillisb >= attendB) {
-        fadeB();
-        previousMillisb = currentMillis;
-        attendB = fadecomment(bleu);
-      }
-    }
-  }
-}


addition of a condition to avoid issues with TX

--- examples/Advanced/Advanced.ino
+++ examples/Advanced/Advanced.ino
@@ -20,7 +20,11 @@
 #include "Maxbotix.h"

 Maxbotix rangeSensorPW(8, Maxbotix::PW, Maxbotix::LV, Maxbotix::BEST);
-Maxbotix rangeSensorTX(6, Maxbotix::TX, Maxbotix::LV, Maxbotix::MEDIAN);
+
+#ifdef MAXBOTIX_WITH_SOFTWARE_SERIAL
+  Maxbotix rangeSensorTX(6, Maxbotix::TX, Maxbotix::LV, Maxbotix::MEDIAN);
+#endif
+
 Maxbotix rangeSensorAD(A0, Maxbotix::AN, Maxbotix::LV, Maxbotix::BEST, 9);

 void setup()
@@ -54,23 +58,25 @@
   Serial.print(rangeSensorPW.getSampleBest());
   Serial.println();

-  // TX
-  start = millis();
-  Serial.print("TX (MEDIAN): ");
-  Serial.print(rangeSensorTX.getRange());
-  Serial.print("cm - ");
-  Serial.print(millis() - start);
-  Serial.print("ms - ");
-  printArray(rangeSensorTX.getSample(), rangeSensorTX.getSampleSize());
-  Serial.print(" - Highest Mode: ");
-  Serial.print(rangeSensorTX.getSampleMode(true));
-  Serial.print(" - Lowest Mode: ");
-  Serial.print(rangeSensorTX.getSampleMode(false));
-  Serial.print(" - Median: ");
-  Serial.print(rangeSensorTX.getSampleMedian());
-  Serial.print(" - Best: ");
-  Serial.print(rangeSensorTX.getSampleBest());
-  Serial.println();
+  #ifdef MAXBOTIX_WITH_SOFTWARE_SERIAL
+    // TX
+    start = millis();
+    Serial.print("TX (MEDIAN): ");
+    Serial.print(rangeSensorTX.getRange());
+    Serial.print("cm - ");
+    Serial.print(millis() - start);
+    Serial.print("ms - ");
+    printArray(rangeSensorTX.getSample(), rangeSensorTX.getSampleSize());
+    Serial.print(" - Highest Mode: ");
+    Serial.print(rangeSensorTX.getSampleMode(true));
+    Serial.print(" - Lowest Mode: ");
+    Serial.print(rangeSensorTX.getSampleMode(false));
+    Serial.print(" - Median: ");
+    Serial.print(rangeSensorTX.getSampleMedian());
+    Serial.print(" - Best: ");
+    Serial.print(rangeSensorTX.getSampleBest());
+    Serial.println();
+  #endif

   // AD
   start = millis();
@@ -103,4 +109,4 @@
     }
   }
   Serial.print("]");
-}+}


update example

update example

--- examples/Fast2Dev/Fast2Dev.ino
+++ examples/Fast2Dev/Fast2Dev.ino
@@ -38,16 +38,19 @@
 // Hardware SPI - .652ms for an 86 led frame @8Mhz (3.1Mbps?), .913ms @4Mhz 1.434ms @2Mhz
 // Hardware SPIr2 - .539ms @8Mhz, .799 @4Mhz, 1.315ms @2Mhz
 // With the wait ordering reversed,  .520ms at 8Mhz, .779ms @4Mhz, 1.3ms @2Mhz
-LPD8806Controller<11, 13, 10> LED;
+// LPD8806Controller<11, 13, 10> LED;
+// LPD8806Controller<2, 1, 0> LED; // teensy pins

 // Same Port, non-hardware SPI - 1.2ms for an 86 led frame, 1.12ms with large switch
 // r2 - .939ms without large switch  .823ms with large switch
 // r3 - .824ms removing 0 balancing nop, .823 with large switch removing balancing
-// LPD8806Controller<12, 13, 10> LED;
+//LPD8806Controller<12, 13, 10> LED;
+LPD8806Controller<14, 1, 10> LED; // teensy pins

 // Different Port, non-hardware SPI - 1.47ms for an 86 led frame
 // Different PortR2, non-hardware SPI - 1.07ms for an 86 led frame
 // LPD8806Controller<7, 13, 10> LED;
+// LPD8806Controller<8, 1, 10> LED;

 // Hardware SPI - .652ms for an 86 led frame @8Mhz (3.1Mbps?), .913ms @4Mhz 1.434ms @2Mhz
 // With the wait ordering reversed,  .520ms at 8Mhz, .779ms @4Mhz, 1.3ms @2Mhz
@@ -86,6 +89,11 @@

 void setup() {

+	aPin.hi();
+	aPin.lo();
+	Pin<2>::hi();
+	Pin<2>::lo();
+
 #ifdef DEBUG
     Serial.begin(38400);
     Serial.println("resetting!");
@@ -104,34 +112,27 @@
 }

 void loop() {
-	memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
-	LED.showRGB((byte*)leds, NUM_LEDS);
-	// ledset++;
-	// if(ledset > 4) { ledset = 0; }
-	// ledset = 0;
-	// // memset( leds, 128, NUM_LEDS * sizeof(struct CRGB));
-	// // show();
-	// for(int i = 0; i < 3; i++) {
-	// 	for(int iLed = 0; iLed < NUM_LEDS; iLed++) {
-	// 		memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB));
-	// 		switch(i) {
-	// 		 	case 0: leds[iLed].r = 128; break;
-	// 		 	case 1: leds[iLed].g = 128; break;
-	// 		 	case 2: leds[iLed].b = 128; break;
-	// 		 }
+	for(int i = 0; i < 3; i++) {
+		for(int iLed = 0; iLed < NUM_LEDS; iLed++) {
+			memset(leds, 0,  NUM_LEDS * sizeof(struct CRGB));
+			switch(i) {
+			 	case 0: leds[iLed].r = 128; break;
+			 	case 1: leds[iLed].g = 128; break;
+			 	case 2: leds[iLed].b = 128; break;
+			 }

-	// 		show();
-	// 		// delay(20);
-	// 	}
-	// }
+			LED.showRGB((byte*)leds, NUM_LEDS);;
+			delay(20);
+		}
+	}
 	// for(int i = 0; i < 64; i++) {
 	//  	memset(leds, i, NUM_LEDS * 3);
-	//  	show();
+	// 	LED.showRGB((byte*)leds, NUM_LEDS);;
 	//  	delay(20);
 	// }
 	// for(int i = 64; i >= 0; i--) {
 	//  	memset(leds, i, NUM_LEDS * 3);
-	//  	show();
+	// 	LED.showRGB((byte*)leds, NUM_LEDS);;
 	//  	delay(20);
 	// }
 }


horloge_cycles_ultradiens

--- files/horloge_cycles_ultradiens/horloge_cycles_ultradiens.ino
+++ files/horloge_cycles_ultradiens/horloge_cycles_ultradiens.ino
@@ -202,6 +202,7 @@
   // ****
   // Calculs du pourcentage du cycle d’attention (cycleAtt)
   // et du temps équivalent en 1/16e de jour exprimé en pixels (frac16eJourPx)
+  // Temps d’exécution sur l’ATmega328P ≅ 1.3 ms
   // **

   // lecture de l’heure actuelle
@@ -234,6 +235,7 @@

   // ****
   //  Affichage des résultats
+  // Temps d’exécution sur l’ATmega328P ≅ 69 ms
   // **

   // Effacement de l’écran
@@ -241,9 +243,12 @@

   // Préparation de l’affichage de la date
   display.setTextSize( 1 );
-  display.setCursor( 0, 0 );
+  if( now.day() < 10 )
+    { display.setCursor( 6, 0 ); }
+  else
+    { display.setCursor( 0, 0 ); }
   display.print( now.day() );
-  display.print( " " );
+  display.setCursor( 15, 0 );
   switch( now.month() )
   {
     case  1: display.print( F( "JAN"  ) ); break;
@@ -259,19 +264,29 @@
     case 11: display.print( F( "NOV"  ) ); break;
     case 12: display.print( F( "DEC"  ) );
   }
-  display.setCursor( 0, 9 );
+  display.setCursor( 15, 9 );
   display.print( now.year() );

-  // Préparation de l’affichage de l’heure et des minutes
+  // Préparation de l’affichage de l’heure
   char texteAffichage[ 5 ];
-  sprintf( texteAffichage, "%2d:%02d", now.hour(), now.minute() );
   display.setTextSize( 2 );
-  display.setCursor( 49, 0 );
+  display.setCursor( 54, 0 );
+  sprintf( texteAffichage, "%2d", now.hour() );
   display.print( texteAffichage );

+  // Préparation de l’affichage du séparateur
+  display.setCursor( 76, 0 );
+  display.print( ":" );
+
+  // Préparation de l’affichage des minutes
+  display.setCursor( 86, 0 );
+  sprintf( texteAffichage, "%2d", now.minute() );
+  display.print( texteAffichage );
+
   // Préparation de l’affichage des secondes
-  sprintf( texteAffichage, ":%02d", now.second() );
   display.setTextSize( 1 );
+  display.setCursor( 112, 0 );
+  sprintf( texteAffichage, "%02d", now.second() );
   display.print( texteAffichage );

   // Préparation de l’affichage du pourcentage du cycle
@@ -286,10 +301,13 @@
     else
       { display.setCursor( 42, 21 ); display.print( cycleAtt, 0 ); }
   #else // Affichage sans décimales pour l’utilisation normale
-    if( cycleAtt < 9.5 )       { display.setCursor( 54, 21 ); }
-    else if( cycleAtt < 99.5 ) { display.setCursor( 49, 21 ); }
-    else                       { display.setCursor( 42, 21 ); }
+    int16_t tx;
+    if( cycleAtt < 9.5 )       { tx = 52; }
+    else if( cycleAtt < 99.5 ) { tx = 47; }
+    else                       { tx = 41; }
+    display.setCursor( tx, 21 );
     display.print( cycleAtt, 0 );
+    display.setCursor( display.getCursorX() + 3, 21 );
   #endif
   display.print( char( 37 ) ); // signe %


rewrite for new relay. optimized a bit

rewrite for new relay. optimized a bit

--- timedWaterTest/timedWaterTest.ino
+++ timedWaterTest/timedWaterTest.ino
@@ -31,11 +31,11 @@
 unsigned long last_fill_start;

 int OVERFLOW_PIN = 2;
-bool shitscreek = false;

 void setup()
 {
   pinMode(PUMP_PIN, OUTPUT);
+  digitalWrite(PUMP_PIN, HIGH);
   pinMode(OVERFLOW_PIN, INPUT);

   // LCD Setup
@@ -62,7 +62,7 @@
 }

 void  loop(){
-  checkOverflow();
+  CheckWaterOn();
   digitalClockDisplay();
   Alarm.delay(1000); // wait one second between clock display
 }
@@ -79,9 +79,9 @@
 }

 void WaterOn(){
-  if (!WATERON){
+  if (digitalRead(PUMP_PIN)){
     lcd.setCursor(0, 1);
-    digitalWrite(PUMP_PIN, HIGH);
+    digitalWrite(PUMP_PIN, LOW);
     last_fill_start = millis();
     Alarm.timerOnce(0, FILLTIME_HALF_MINUTES, 0, WaterOff);
     WATERON = true;
@@ -90,59 +90,41 @@
 }

 void WaterOff(){
-  if (WATERON){
-    Serial.println("Water OFF");
-    digitalWrite(PUMP_PIN, LOW);
-    WATERON = false;
-  }
-  lcd.setCursor(0, 1);
-  lcd.print("Water OFF       ");
+  Serial.println("Water OFF");
+  digitalWrite(PUMP_PIN, HIGH);
+  WATERON = false;
 }

 void CheckWaterOn(){
   unsigned long diff = millis() - last_fill_start;
   lcd.setCursor(0, 1);
-  bool state = digitalRead(PUMP_PIN);
+  bool pumping = !digitalRead(PUMP_PIN);
+  bool overflowing = !digitalRead(OVERFLOW_PIN);

-  if (state && diff > FILLTIME_MILLIS){
+  if (overflowing) {
+    lcd.print("WATER OVERFLOW!!");
+    digitalWrite(PUMP_PIN, HIGH);
+  }
+  else if (pumping && diff > FILLTIME_MILLIS){
     lcd.print("Water too long  ");
     Serial.print("Water on passed fill time ");
     Serial.println(diff);
     Serial.println(FILLTIME_MILLIS);
     WaterOff();
   }
-  else if (state && diff < FILLTIME_MILLIS) {
+  else if (pumping && diff < FILLTIME_MILLIS) {
     lcd.print("Within fill, OK ");
     Serial.println("Within fill cycle, all OK");
   }
-  else if (!state && !shitscreek && WATERON && diff < FILLTIME_MILLIS) {
+  else if (!pumping && WATERON && diff < FILLTIME_MILLIS) {
     lcd.print("Resume fill, OK ");
     Serial.println("Within fill cycle, resume OK");
-    digitalWrite(PUMP_PIN, HIGH);
-    WATERON = true;
+    digitalWrite(PUMP_PIN, LOW);
   }
   else {
+    WaterOff();
     lcd.print("Water off, OK   ");
     Serial.println("Water off, all OK");
-    WaterOff();
-  }
-}
-
-void checkOverflow()
-{
-  Serial.println(digitalRead(OVERFLOW_PIN));
-  lcd.setCursor(0, 1);
-  if (digitalRead(OVERFLOW_PIN) == LOW) {
-    shitscreek = true;
-    lcd.print("WATER OVERFLOW!!");
-    digitalWrite(PUMP_PIN, LOW);
-    //WaterOff();
-  }
-  else {
-    if (shitscreek == true) {
-      shitscreek = false;
-      CheckWaterOn();
-    }
   }
 }


Delete IR_Breakbeam.ino

Delete IR_Breakbeam.ino

--- IR_Breakbeam.ino
+++ IR_Breakbeam.ino
@@ -1,92 +0,0 @@
-#define LED_SMALL_PIN 14
-#define LED_LARGE_PIN 15
-#define IR_SENSOR_PIN_1 2
-#define IR_SENSOR_PIN_2 3
-
-bool IR_Sensor1;
-bool IR_Sensor2;
-
-struct Features {
-  bool lt_10in;
-};
-
-Features Feature_Extraction() {
-  Features features;
-
-  IR_Sensor1 = digitalRead(IR_SENSOR_PIN_1);
-  IR_Sensor2 = digitalRead(IR_SENSOR_PIN_2);
-
-  if(IR_Sensor1 == LOW && IR_Sensor2 == LOW) {
-    features.lt_10in = false;
-  }
-  //If one beam is broken
-  else if(IR_Sensor1 == LOW && IR_Sensor2 == HIGH) {
-    features.lt_10in = true;
-  }
-  else if(IR_Sensor1 == HIGH && IR_Sensor2 == LOW) {
-    features.lt_10in = true;
-  }
-  //If neither beam is broken
-  else {
-    //box_size = "None";
-    features.lt_10in = true;
-  }
-
-  return features;
-}
-
-String Pattern_Recognition(Features features) {
-  String box_size;
-
-  //If both beams are broken
-  if(features.lt_10in) {
-    box_size = "Less than 10 inches.";
-  }
-  else {
-    box_size = "Greater than 10 inches.";
-  }
-  return box_size;
-}
-
-void Actuation(String box_size) {
-  Serial.println(box_size);
-  if(box_size == "Less than 10 inches.") {
-    digitalWrite(LED_SMALL_PIN, HIGH);
-  }
-  else if(box_size == "Greater than 10 inches.") {
-    digitalWrite(LED_LARGE_PIN, HIGH);
-  }
-  else if(box_size == "None") {
-    //Both LEDs are off
-  }
-}
-
-void setup() {
-  pinMode(LED_SMALL_PIN, OUTPUT);
-  pinMode(LED_LARGE_PIN, OUTPUT);
-
-  pinMode(IR_SENSOR_PIN_1, INPUT);
-  digitalWrite(IR_SENSOR_PIN_1, HIGH);
-  pinMode(IR_SENSOR_PIN_2, INPUT);
-  digitalWrite(IR_SENSOR_PIN_2, HIGH);
-
-  Serial.begin(9600);
-}
-
-void loop() {
-  //Turns both LEDs off before each reading
-  digitalWrite(LED_SMALL_PIN, LOW);
-  digitalWrite(LED_LARGE_PIN, LOW);
-
-  //Should put feature extraction and pattern recognition in one multi-second for loop to
-    //give the box time to go through the sensors.
-  Features feature_states;
-  feature_states = Feature_Extraction();
-
-  String pattern_size;
-  pattern_size = Pattern_Recognition(feature_states);
-
-  Actuation(pattern_size);
-
-  delay(1000);
-}


add standard connect function to time example

--- examples/adafruitio_time_esp8266/adafruitio_time_esp8266.ino
+++ examples/adafruitio_time_esp8266/adafruitio_time_esp8266.ino
@@ -1,3 +1,21 @@
+/***************************************************
+  Adafruit MQTT Library ESP8266 Adafruit IO SSL/TLS example
+
+  Must use the latest version of ESP8266 Arduino from:
+    https://github.com/esp8266/Arduino
+
+  Works great with Adafruit's Huzzah ESP board & Feather
+  ----> https://www.adafruit.com/product/2471
+  ----> https://www.adafruit.com/products/2821
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Tony DiCola for Adafruit Industries.
+  Time additions by Todd Treece for Adafruit Industries.
+  MIT license, all text above must be included in any redistribution
+ ****************************************************/
 #include <ESP8266WiFi.h>
 #include "Adafruit_MQTT.h"
 #include "Adafruit_MQTT_Client.h"
@@ -61,21 +79,44 @@

 void loop() {

-  int8_t code;
+  // Ensure the connection to the MQTT server is alive (this will make the first
+  // connection and automatically reconnect when disconnected).  See the MQTT_connect
+  // function definition further below.
+  MQTT_connect();

-  // connect to adafruit io if not connected
-  if(! mqtt.connected()) {
+  // wait 10 seconds for subscription messages
+  // since we have no other tasks in this example.
+  mqtt.processPackets(10000);

-    Serial.print("Connecting to Adafruit IO... ");
-    if((code = mqtt.connect()) != 0) {
-      Serial.println(mqtt.connectErrorString(code));
-      while(1);
-    }
-    Serial.println("connected!");
-
-  }
-
-  mqtt.processPackets(1000);
+  // keep the connection alive
   mqtt.ping();

 }
+
+// Function to connect and reconnect as necessary to the MQTT server.
+// Should be called in the loop function and it will take care if connecting.
+void MQTT_connect() {
+  int8_t ret;
+
+  // Stop if already connected.
+  if (mqtt.connected()) {
+    return;
+  }
+
+  Serial.print("Connecting to MQTT... ");
+
+  uint8_t retries = 3;
+  while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
+       Serial.println(mqtt.connectErrorString(ret));
+       Serial.println("Retrying MQTT connection in 5 seconds...");
+       mqtt.disconnect();
+       delay(5000);  // wait 5 seconds
+       retries--;
+       if (retries == 0) {
+         // basically die and wait for WDT to reset me
+         while (1);
+       }
+  }
+
+  Serial.println("MQTT Connected!");
+}


add sleep multiplier, remove nextcycle()

--- first_one/first_one.ino
+++ first_one/first_one.ino
@@ -32,12 +32,13 @@
 bool HW_DEBUG = true;
 bool SYS_DEBUG = true;

+#define MORSE_UNIT_TIME SLEEP_250MS
+
 unsigned long arTime = millis();
 unsigned long reset = millis();
-unsigned int timeMultiplier = 1; // x1
-unsigned int MORSE_UNIT_TIME = 250*timeMultiplier;
-unsigned int wait = 150*timeMultiplier;
-unsigned int waitLynch = 33*timeMultiplier;
+unsigned int TIME_MULTIPLIER = 1; // x1
+unsigned int WAIT = 150*TIME_MULTIPLIER;
+unsigned int waitLynch = 33*TIME_MULTIPLIER;
 unsigned int actualPin = 2;

 int LDR = 0;
@@ -121,7 +122,7 @@
         }
         LEDSOFF();
         // Enter power down state for 8 s with ADC and BOD module disabled
-        LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
+        doPowerDown(SLEEP_8S, TIME_MULTIPLIER);
       }
     }

@@ -146,7 +147,8 @@
       actualCycle++;
     }else{
       actualCycle = 1;
-      nextStep();
+      actualStep++;
+      if (actualStep > 5) actualStep = 1;
     }
   }

@@ -169,18 +171,10 @@
     default:
       actualStep = 1;
       LEDSOFF();
-      LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
+      doPowerDown(SLEEP_8S, TIME_MULTIPLIER);
     break;
   }

-}
-
-void nextStep(){
-  if(actualStep <= 5){
-    actualStep++;
-  }else{
-    actualStep = 1;
-  }
 }

 /*
@@ -195,7 +189,7 @@
     }
   }

-  if(arTime-reset > wait){
+  if(arTime-reset > WAIT){
     reset = millis();
     if(actualPin < 10){
       actualPin++;
@@ -223,7 +217,7 @@
     }
   }

-  if(arTime-reset > wait){
+  if(arTime-reset > WAIT){
     reset = millis();
     if(batteryCounter < cycles){
       batteryCounter++;
@@ -231,9 +225,22 @@
       endCycle = true;
       batteryCounter = 1;
       LEDSOFF();
-      LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
-    }
-  }
+      doPowerDown(SLEEP_4S, TIME_MULTIPLIER);
+
+    }
+  }
+}
+
+
+/*
+ * Power down auxiliary function
+ *
+ */
+void doPowerDown(uint8_t sleepTime, uint8_t sleepCount) {
+        do {
+          LowPower.powerDown(sleepTime, ADC_OFF, BOD_OFF);
+          sleepCount--;
+        } while (sleepCount > 0);
 }

 /*
@@ -250,7 +257,7 @@
     }
   }

-  if(arTime-reset > wait){
+  if(arTime-reset > WAIT){
     reset = millis();
     if(binaryCounter < 512){
       binaryCounter++;
@@ -258,7 +265,7 @@
       endCycle = true;
       binaryCounter = 0;
       LEDSOFF();
-      LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
+      doPowerDown(SLEEP_4S, TIME_MULTIPLIER);
     }
   }
 }
@@ -277,7 +284,7 @@
     }
   }

-  if(arTime-reset > wait){
+  if(arTime-reset > WAIT){
     reset = millis();
     if(binaryCounter < 512){
       binaryCounter++;
@@ -286,7 +293,7 @@
       binaryCounter = 0;
       LEDSOFF();
       shuffleLEDS();
-      LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
+      doPowerDown(SLEEP_4S, TIME_MULTIPLIER);
     }
   }
 }
@@ -314,9 +321,9 @@
       lynchCounter = 1;
       randomSeed(analogRead(1));
       int rr = random(0,9);
-      waitLynch = lynchFlicks[rr]*timeMultiplier;
+      waitLynch = lynchFlicks[rr]*TIME_MULTIPLIER;
       LEDSOFF();
-      LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
+      doPowerDown(SLEEP_4S, TIME_MULTIPLIER);
     }
   }
 }
@@ -330,18 +337,16 @@
     switch( message[i] ){
       case '.': // dit
         LEDSON();
-        delay( MORSE_UNIT_TIME );
+        doPowerDown(MORSE_UNIT_TIME, TIME_MULTIPLIER);
         LEDSOFF();
-        delay( MORSE_UNIT_TIME );
-
+        doPowerDown(MORSE_UNIT_TIME, TIME_MULTIPLIER);
         break;

       case '-': // dah
         LEDSON();
-        delay( MORSE_UNIT_TIME*3 );
+        doPowerDown(MORSE_UNIT_TIME, 3*TIME_MULTIPLIER);
         LEDSOFF();
-        delay( MORSE_UNIT_TIME );
-
+        doPowerDown(MORSE_UNIT_TIME, TIME_MULTIPLIER);
         break;

       case ' ': //gap
@@ -355,7 +360,7 @@
     endCycle = true;
     morseCounter = 1;
     LEDSOFF();
-    LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
+    doPowerDown(SLEEP_4S, TIME_MULTIPLIER);
   }

 }
@@ -426,4 +431,3 @@
     digitalWriteFast(ledPins[i], HIGH);
   }
 }
-


Add files via upload

Add files via upload

Fixed base connection led to blink. That line was a leftover.

--- simu_buttonreader_teensy_base/simu_buttonreader_teensy_base.ino
+++ simu_buttonreader_teensy_base/simu_buttonreader_teensy_base.ino
@@ -78,7 +78,6 @@
     digitalWriteFast(connectionLed, HIGH);
     btConnected = true;
   } else {
-    digitalWriteFast(connectionLed, LOW);
     btConnected = false;
   }


Removing EEPROM_mgr code from the sketch for now

--- Examples/RobobrrdLibDemo/RobobrrdLibDemo.ino
+++ Examples/RobobrrdLibDemo/RobobrrdLibDemo.ino
@@ -11,13 +11,12 @@

 #include <Arduino.h>
-#include <EEPROM_mgr.h>
 #include <Servo.h>
 #include <Streaming.h>
 #include "RobobrrdLib.h"

-EEPROM_item<RoboBrrd::Values> settings(RoboBrrd::DefaultValues);
+RoboBrrd::Values settings(RoboBrrd::DefaultValues);
 RoboBrrd robobrrd(RoboBrrd::DefaultPins, settings);

@@ -29,14 +28,6 @@
   Serial << "Hello from RoboBrrd! SQUAWK! CHIRP! "
     "Beginning initialization... beep beep" << endl;

-  // At this point, the settings contain the default values.
-  // If you wish, you can retrieve the calibrated values from the
-  // EEPROM inside the Arduino by using EEPROM_mgr::RetrieveAll, but
-  // only if you stored them there at least once, of course!
-  //
-  // See the calibration example program for more information.
-  //EEPROM_mgr::RetrieveAll();
-
   // Set up all the pins but don't attach the servos yet
   // otherwise they may move suddenly. They're also noisy while they're
   // attached, so this keeps the brrd quiet until we start moving


Fix DHT sensor setup

Fix DHT sensor setup

--- arduinoApp/gardenSketch/gardenSketch.ino
+++ arduinoApp/gardenSketch/gardenSketch.ino
@@ -2,6 +2,7 @@
 Arduino based self regulating kitchen garden

  */
+

 #include <DHT.h>

@@ -9,8 +10,8 @@
 #define DHTPIN 2        // Humidity and temperature sensor pin
 #define DHTTYPE DHT22   // Model DHT 22 (AM2302)
 DHT airSensor(DHTPIN, DHTTYPE); // setup DHT sensor
-float airHumidity = dht.readHumidity(); // read humidity from DHT
-float airTemperature = dht.readTemperature(); // read temperature from DHT
+float airHumidity;
+float airTemperature;

 // light related setup
 int lightSensorPin = 3; // Set to whereever light sensor is connected


Added comments explaining some functionality

--- frontdesk/frontdesk.ino
+++ frontdesk/frontdesk.ino
@@ -49,12 +49,14 @@
 			Serial.print(newTime%60);
 			Serial.println(F(" seconds"));
 			existingTime = newTime;
+			// Reset timer on card and disable authorization
 			sendCommand(CMD_WRITE, blockID, machineID, keyA, 0, 0);
 			delay(waitforWriteResponse);
 		}
 		digitalWrite(ledPin, HIGH);
 	}

+	// Reset timer on card and enable authorization if button has been pressed
 	if (buttonState) {
 		digitalWrite(ledPin, LOW);
 		delay(waitForFlush);


updates runs well

updates runs well

--- BitController/BitController.ino
+++ BitController/BitController.ino
@@ -54,6 +54,8 @@
 int l1_motor = 11;
 int l2_motor = 10;

+int move_threshold = 30;
+
 void setup()
 {
   Serial.begin(115200);
@@ -234,7 +236,7 @@
 {
   printSensors();
   //lcd.setCursor(0,3);
-  if(sensorVals[n] > 130 || sensorVals[w] > 130 || sensorVals[e] > 130)
+  if(sensorVals[n] > move_threshold || sensorVals[w] > move_threshold || sensorVals[e] > move_threshold)
   {
   if ((sensorVals[n]*.6) > sensorVals[e])
   {
@@ -309,9 +311,9 @@
   {
     if (abs(sensorVals[w]-sensorVals[e]) < 50)
     {
-      analogWrite(l1_motor, 200);
+      analogWrite(l1_motor, 230);
       analogWrite(l2_motor, 0);
-      analogWrite(r1_motor, 200);
+      analogWrite(r1_motor, 230);
       analogWrite(r2_motor, 0);
       //lcd.println("head north");
       Serial.println("head north");
@@ -319,9 +321,9 @@
     }
     else if (sensorVals[w]*1.2 >= sensorVals[e]*1.2)
     {
-      analogWrite(l1_motor, 50);
+      analogWrite(l1_motor, 100);
       analogWrite(l2_motor, 0);
-      analogWrite(r1_motor, 200);
+      analogWrite(r1_motor, 230);
       analogWrite(r2_motor, 0);
       //lcd.println("head north-west");
       Serial.println("head north-west");
@@ -329,9 +331,9 @@
     }
     else if (sensorVals[e]*1.2 >= sensorVals[w]*1.2)
     {
-      analogWrite(l1_motor, 200);
+      analogWrite(l1_motor, 230);
       analogWrite(l2_motor, 0);
-      analogWrite(r1_motor, 50);
+      analogWrite(r1_motor, 100);
       analogWrite(r2_motor, 0);
       //lcd.println("head north-east");
       Serial.println("head north-east");
@@ -349,10 +351,10 @@
   else if ((sensorVals[e]*.65) > sensorVals[n] && sensorVals[e]*.9 > sensorVals[w])
   //else if ((sensorVals[e]*.65) > sensorVals[n] && sensorVals[e] > 100)
   {
-      analogWrite(l1_motor, 200);
+      analogWrite(l1_motor, 230);
       analogWrite(l2_motor, 0);
       analogWrite(r1_motor, 0);
-      analogWrite(r2_motor, 200);
+      analogWrite(r2_motor, 230);
     Serial.println("head east");
     BT.println("head east");
 //    if (abs(sensorVals[n]-sensorVals[s]) < 50)
@@ -386,8 +388,8 @@
   //else if ((sensorVals[w]*.65) > sensorVals[n]  && sensorVals[w > 100)
   {
       analogWrite(l1_motor, 0);
-      analogWrite(l2_motor, 200);
-      analogWrite(r1_motor, 200);
+      analogWrite(l2_motor, 230);
+      analogWrite(r1_motor, 230);
       analogWrite(r2_motor, 0);
      Serial.println("head west");
      BT.println("head west");