basic time display completed

basic time display completed

--- arduino/src/myletterclock.ino
+++ arduino/src/myletterclock.ino
@@ -20,7 +20,14 @@

 unsigned int i = 0;

-/* volatile DateTime now; */
+typedef uint32_t Color;
+Color cBlack = 0;
+Color cWhite = 0;
+Color cRed = 0;
+Color cGreen = 0;
+Color cBlue = 0;
+
+/* void lightHalb(Color color); */

 void setup ()
 {
@@ -44,6 +51,13 @@
     }
     strip.begin();                  // Initialize NeoPixel object
     strip.show();                   // Initialize all pixels to '}ff'
+
+    // define global colors
+    cBlack = strip.Color(0,0,0);
+    cWhite = strip.Color(127,127,127);
+    cRed = strip.Color(127,0,0);
+    cGreen = strip.Color(0,127,0);
+    cBlue = strip.Color(0,0,127);
 }

 void loop ()
@@ -126,4 +140,407 @@
     int minute = now.minute();
     int minutemod5 = minute % 5;
     int second = now.second();
-}
+    Color cBackground = cBlack;
+    Color cForeground = cWhite;
+    for(int j = 0; j < NUMPIXEL; j++)
+    {
+        strip.setPixelColor(j,cBackground);
+    }
+    lightEs(cForeground);
+    if((minutemod5 == 1 || minutemod5 == 2) && (minute != 0))
+    {
+        lightWar(cForeground);
+    }
+    if(minutemod5 == 0 || minutemod5 == 3 || minutemod5 == 4)
+    {
+        lightIst(cForeground);
+    }
+    if(minutemod5 == 3 || minutemod5 == 4)
+    {
+        lightGleich(cForeground);
+    }
+    if(minute == 0)
+    {
+        lightGenau(cForeground);
+    }
+    if((minutemod5 == 0 || minutemod5 == 1 || minutemod5 == 2) && (minute != 0))
+    {
+        lightGerade(cForeground);
+    }
+    if((minute >= 3 && minute <= 7) ||
+            (minute >= 23 && minute <= 27) ||
+            (minute >= 33 && minute <= 37) ||
+            (minute >= 53 && minute <= 57))
+    {
+        lightFuenf1(cForeground);
+    }
+    if((minute >= 13 && minute <= 17) ||
+            (minute >= 43 && minute <= 47))
+    {
+        lightViertel(cForeground);
+    }
+    if((minute >= 8 && minute <= 12) ||
+            (minute >= 48 && minute <= 52))
+    {
+        lightZehn1(cForeground);
+    }
+    if((minute >= 18 && minute <= 22) ||
+            (minute >= 38 && minute <= 42))
+    {
+        lightZwanzig(cForeground);
+    }
+    if((minute >= 3 && minute <= 22) ||
+            (minute >= 33 && minute <= 37))
+    {
+        lightNach1(cForeground);
+    }
+    if((minute >= 23 && minute <= 27) ||
+            (minute >= 38 && minute <= 57))
+    {
+        lightVor1(cForeground);
+    }
+    if(minute >= 23 && minute <= 37)
+    {
+        lightHalb(cForeground);
+    }
+    if(((hour ==  1 || hour == 13) && minute <= 22) ||
+            ((hour ==  0 || hour == 12) && minute >= 23))
+    {
+        lightEins(cForeground);
+    }
+    if(((hour ==  2 || hour == 14) && minute <= 22) ||
+            ((hour ==  1 || hour == 13) && minute >= 23))
+    {
+        lightZwei(cForeground);
+    }
+    if(((hour ==  3 || hour == 15) && minute <= 22) ||
+            ((hour ==  2 || hour == 14) && minute >= 23))
+    {
+        lightDrei(cForeground);
+    }
+    if(((hour ==  4 || hour == 16) && minute <= 22) ||
+            ((hour ==  3 || hour == 15) && minute >= 23))
+    {
+        lightVier(cForeground);
+    }
+    if(((hour ==  5 || hour == 17) && minute <= 22) ||
+            ((hour ==  4 || hour == 16) && minute >= 23))
+    {
+        lightFuenf2(cForeground);
+    }
+    if(((hour ==  6 || hour == 18) && minute <= 22) ||
+            ((hour ==  5 || hour == 17) && minute >= 23))
+    {
+        lightSechs(cForeground);
+    }
+    if(((hour ==  7 || hour == 19) && minute <= 22) ||
+            ((hour ==  6 || hour == 18) && minute >= 23))
+    {
+        lightSieben(cForeground);
+    }
+    if(((hour ==  8 || hour == 20) && minute <= 22) ||
+            ((hour ==  7 || hour == 19) && minute >= 23))
+    {
+        lightAcht(cForeground);
+    }
+    if(((hour ==  9 || hour == 21) && minute <= 22) ||
+            ((hour ==  8 || hour == 20) && minute >= 23))
+    {
+        lightNeun(cForeground);
+    }
+    if(((hour ==  10 || hour == 22) && minute <= 22) ||
+            ((hour ==  9 || hour == 21) && minute >= 23))
+    {
+        lightZehn2(cForeground);
+    }
+    if(((hour ==  11 || hour == 23) && minute <= 22) ||
+            ((hour ==  10 || hour == 22) && minute >= 23))
+    {
+        lightElf(cForeground);
+    }
+    if(((hour ==  12 || hour == 0) && minute <= 22) ||
+            ((hour ==  11 || hour == 23) && minute >= 23))
+    {
+        lightZwoelf(cForeground);
+    }
+    if(minute >= 58 || minute <= 2)
+    {
+        lightUhr(cForeground);
+    }
+    if((hour ==  5  && minute >= 23) ||
+            (hour >= 6 && hour <= 10) ||
+            (hour ==  11  && minute <= 22))
+    {
+        lightVor2(cForeground);
+        lightMittag(cForeground);
+    }
+    if((hour ==  12  && minute >= 23) ||
+            (hour >= 13 && hour <= 18) ||
+            (hour ==  19  && minute <= 22))
+    {
+        lightNach2(cForeground);
+        lightMittag(cForeground);
+    }
+    if((hour ==  19  && minute >= 23) ||
+            (hour >= 20 || hour <= 5) ||
+            (hour ==  5  && minute <= 22))
+    {
+        lightNachts(cForeground);
+    }
+    if((hour ==  11  && minute >= 23) ||
+            (hour ==  12  && minute <= 22))
+    {
+        lightMittag(cForeground);
+    }
+}
+
+void lightEs(uint32_t color)
+{
+    strip.setPixelColor(132, color);
+    strip.setPixelColor(133, color);
+}
+
+void lightWar(uint32_t color)
+{
+    strip.setPixelColor(135, color);
+    strip.setPixelColor(136, color);
+    strip.setPixelColor(137, color);
+}
+
+void lightIst(uint32_t color)
+{
+    strip.setPixelColor(138, color);
+    strip.setPixelColor(139, color);
+    strip.setPixelColor(140, color);
+}
+
+void lightGleich(uint32_t color)
+{
+    strip.setPixelColor(131, color);
+    strip.setPixelColor(130, color);
+    strip.setPixelColor(129, color);
+    strip.setPixelColor(128, color);
+    strip.setPixelColor(127, color);
+    strip.setPixelColor(126, color);
+}
+
+void lightGenau(uint32_t color)
+{
+    strip.setPixelColor(124, color);
+    strip.setPixelColor(123, color);
+    strip.setPixelColor(122, color);
+    strip.setPixelColor(121, color);
+    strip.setPixelColor(120, color);
+}
+
+void lightGerade(uint32_t color)
+{
+    strip.setPixelColor(108, color);
+    strip.setPixelColor(109, color);
+    strip.setPixelColor(110, color);
+    strip.setPixelColor(111, color);
+    strip.setPixelColor(112, color);
+    strip.setPixelColor(113, color);
+}
+
+void lightFuenf1(uint32_t color)
+{
+    strip.setPixelColor(115, color);
+    strip.setPixelColor(116, color);
+    strip.setPixelColor(117, color);
+    strip.setPixelColor(118, color);
+}
+
+void lightViertel(uint32_t color)
+{
+    strip.setPixelColor(103, color);
+    strip.setPixelColor(102, color);
+    strip.setPixelColor(101, color);
+    strip.setPixelColor(100, color);
+    strip.setPixelColor(99, color);
+    strip.setPixelColor(98, color);
+    strip.setPixelColor(97, color);
+}
+
+void lightZehn1(uint32_t color)
+{
+    strip.setPixelColor(84, color);
+    strip.setPixelColor(85, color);
+    strip.setPixelColor(86, color);
+    strip.setPixelColor(87, color);
+}
+
+void lightZwanzig(uint32_t color)
+{
+    strip.setPixelColor(88, color);
+    strip.setPixelColor(89, color);
+    strip.setPixelColor(90, color);
+    strip.setPixelColor(91, color);
+    strip.setPixelColor(92, color);
+    strip.setPixelColor(93, color);
+    strip.setPixelColor(94, color);
+}
+
+void lightNach1(uint32_t color)
+{
+    strip.setPixelColor(83, color);
+    strip.setPixelColor(82, color);
+    strip.setPixelColor(81, color);
+    strip.setPixelColor(80, color);
+}
+
+void lightVor1(uint32_t color)
+{
+    strip.setPixelColor(79, color);
+    strip.setPixelColor(78, color);
+    strip.setPixelColor(77, color);
+}
+
+void lightHalb(uint32_t color)
+{
+    strip.setPixelColor(75, color);
+    strip.setPixelColor(74, color);
+    strip.setPixelColor(73, color);
+    strip.setPixelColor(72, color);
+}
+
+void lightEins(uint32_t color)
+{
+    strip.setPixelColor(62, color);
+    strip.setPixelColor(63, color);
+    strip.setPixelColor(64, color);
+    strip.setPixelColor(65, color);
+}
+
+void lightZwei(uint32_t color)
+{
+    strip.setPixelColor(40, color);
+    strip.setPixelColor(41, color);
+    strip.setPixelColor(42, color);
+    strip.setPixelColor(43, color);
+}
+
+void lightDrei(uint32_t color)
+{
+    strip.setPixelColor(60, color);
+    strip.setPixelColor(61, color);
+    strip.setPixelColor(62, color);
+    strip.setPixelColor(63, color);
+}
+
+void lightVier(uint32_t color)
+{
+    strip.setPixelColor(36, color);
+    strip.setPixelColor(37, color);
+    strip.setPixelColor(38, color);
+    strip.setPixelColor(39, color);
+}
+
+void lightFuenf2(uint32_t color)
+{
+    strip.setPixelColor(57, color);
+    strip.setPixelColor(56, color);
+    strip.setPixelColor(55, color);
+    strip.setPixelColor(54, color);
+}
+
+void lightSechs(uint32_t color)
+{
+    strip.setPixelColor(29, color);
+    strip.setPixelColor(28, color);
+    strip.setPixelColor(27, color);
+    strip.setPixelColor(26, color);
+    strip.setPixelColor(25, color);
+}
+
+void lightSieben(uint32_t color)
+{
+    strip.setPixelColor(65, color);
+    strip.setPixelColor(66, color);
+    strip.setPixelColor(67, color);
+    strip.setPixelColor(68, color);
+    strip.setPixelColor(69, color);
+    strip.setPixelColor(70, color);
+}
+
+void lightAcht(uint32_t color)
+{
+    strip.setPixelColor(44, color);
+    strip.setPixelColor(45, color);
+    strip.setPixelColor(46, color);
+    strip.setPixelColor(47, color);
+}
+
+void lightNeun(uint32_t color)
+{
+    strip.setPixelColor(34, color);
+    strip.setPixelColor(33, color);
+    strip.setPixelColor(32, color);
+    strip.setPixelColor(31, color);
+}
+
+void lightZehn2(uint32_t color)
+{
+    strip.setPixelColor(12, color);
+    strip.setPixelColor(13, color);
+    strip.setPixelColor(14, color);
+    strip.setPixelColor(15, color);
+}
+
+void lightElf(uint32_t color)
+{
+    strip.setPixelColor(59, color);
+    strip.setPixelColor(58, color);
+    strip.setPixelColor(57, color);
+}
+
+void lightZwoelf(uint32_t color)
+{
+    strip.setPixelColor(52, color);
+    strip.setPixelColor(51, color);
+    strip.setPixelColor(50, color);
+    strip.setPixelColor(49, color);
+    strip.setPixelColor(48, color);
+}
+
+void lightUhr(uint32_t color)
+{
+    strip.setPixelColor(17, color);
+    strip.setPixelColor(18, color);
+    strip.setPixelColor(19, color);
+}
+
+void lightVor2(uint32_t color)
+{
+    strip.setPixelColor(21, color);
+    strip.setPixelColor(22, color);
+    strip.setPixelColor(23, color);
+}
+
+void lightNach2(uint32_t color)
+{
+    strip.setPixelColor(11, color);
+    strip.setPixelColor(10, color);
+    strip.setPixelColor(9, color);
+    strip.setPixelColor(8, color);
+}
+
+void lightNachts(uint32_t color)
+{
+    strip.setPixelColor(11, color);
+    strip.setPixelColor(10, color);
+    strip.setPixelColor(9, color);
+    strip.setPixelColor(8, color);
+    strip.setPixelColor(7, color);
+    strip.setPixelColor(6, color);
+}
+
+void lightMittag(uint32_t color)
+{
+    strip.setPixelColor(5, color);
+    strip.setPixelColor(4, color);
+    strip.setPixelColor(3, color);
+    strip.setPixelColor(2, color);
+    strip.setPixelColor(1, color);
+    strip.setPixelColor(0, color);
+}


Removed debug messages.

Removed debug messages.

--- arduino/surfcube/surfcube.ino
+++ arduino/surfcube/surfcube.ino
@@ -65,8 +65,10 @@

   EEPROM.get(EEPROM_STEPPER_ADDR, stepperCurrentPosition);
   stepperTargetPosition = stepperCurrentPosition;
+  /*
   Serial.print("read stepperCurrentPosition from EEPROM: ");
   Serial.println(stepperCurrentPosition);
+  */

   pinMode(RED_PIN, OUTPUT);
   pinMode(YELLOW_PIN, OUTPUT);
@@ -111,15 +113,22 @@
   String command;
   int val;
   if (Serial.available() > 0) {
+    /*
     Serial.println("Data received");
+    */
     command = Serial.readStringUntil('\n');
     while(Serial.available() == 0) {}
     val = Serial.parseInt();
+    // Remove new line character after reading the integer.
+    Serial.readStringUntil('\n');
+
+    /*
     Serial.print("command = [");
     Serial.print(command);
     Serial.print("]; val = [");
     Serial.print(val);
     Serial.println("]");
+    */
     if (command == "forward") {
       stepperTargetPosition += val;
       stepperTargetPosition = clamp(stepperTargetPosition, 0, STEPPER_MAX_POSITION);
@@ -159,11 +168,6 @@
     } else {
       Serial.println("Command not understood!");
     }
-
-    // Remove any data in the buffer.
-    while(Serial.available()) {
-      Serial.read();
-    }
   }
   serialNextCheck = now + 1;
 }


Update LIDARLite_Wire_Library_GetDistance_ContinuousRead.ino

--- Arduino/LIDARLite_Wire_Library_GetDistance_ContinuousRead/LIDARLite_Wire_Library_GetDistance_ContinuousRead.ino
+++ Arduino/LIDARLite_Wire_Library_GetDistance_ContinuousRead/LIDARLite_Wire_Library_GetDistance_ContinuousRead.ino
@@ -19,44 +19,32 @@

 void setup()
 {
-  delay(2000);
   Wire.begin(); // join i2c bus
   Serial.begin(9600); // start serial communication at 9600bps
-  Serial.println("<start>");
 }

 void loop()
 {
-//  Serial.println("> loop - 01");
   Wire.beginTransmission((int)LIDARLite_ADDRESS); // transmit to LIDAR-Lite
   Wire.write((int)RegisterMeasure); // sets register pointer to  (0x00)
   Wire.write((int)MeasureValue); // sets register pointer to  (0x00)
   Wire.endTransmission(); // stop transmitting
-//  Serial.println("> loop - 02");

   delay(20); // Wait 20ms for transmit

-//  Serial.println("> loop - 03");
   Wire.beginTransmission((int)LIDARLite_ADDRESS); // transmit to LIDAR-Lite
   Wire.write((int)RegisterHighLowB); // sets register pointer to (0x8f)
   Wire.endTransmission(); // stop transmitting
-//  Serial.println("> loop - 04");

   delay(20); // Wait 20ms for transmit

-//  Serial.println("> loop - 05");
   Wire.requestFrom((int)LIDARLite_ADDRESS, 2); // request 2 bytes from LIDAR-Lite
-//  Serial.println("> loop - 06");

   if(2 <= Wire.available()) // if two bytes were received
   {
-//    Serial.println("> loop - 07");
     reading = Wire.read(); // receive high byte (overwrites previous reading)
     reading = reading << 8; // shift high byte to be high 8 bits
     reading |= Wire.read(); // receive low byte as lower 8 bits
     Serial.println(reading); // print the reading
-//    Serial.println("> loop - 08");
   }
-//  Serial.println("> loop - 09");
 }
-


Edit stuff

Edit stuff

--- StopMotorWithPetting/StopMotorWithPetting_ino/StopMotorWithPetting_ino.ino
+++ StopMotorWithPetting/StopMotorWithPetting_ino/StopMotorWithPetting_ino.ino
@@ -52,12 +52,13 @@

       if (numPets == 3) {
         digitalWrite(motorPin, LOW);
+        digitalWrite(servoPin, LOW);
       } else if (numPets < 3) {
         if (first < 0 && sensorValue > 0 && sensorValue < 200) {
           first = sensorValue;
           Serial.println("low: ");
           Serial.println(first);
-        } else if (first > 0 && sensorValue > first && sensorValue > 700){
+        } else if (first > 0 && sensorValue > 700){
           numPets++;
           Serial.println("**************Stroke number: ");
           Serial.println(numPets);


PIR inactivity code corrected

PIR inactivity code corrected

--- ESP8266-code/Log-PIR-Switch.ino
+++ ESP8266-code/Log-PIR-Switch.ino
@@ -113,7 +113,6 @@
   Serial.println("/");

 }
-
 void loop() {
     unsigned long now = millis();
     if (switch_changed) {
@@ -131,14 +130,12 @@
       Serial.print(now/1000);
       Serial.print(" PIR ");
       Serial.println(pir_on);
-      if (pir_on ) {
-          if (! pir_movement) {
+      pir_millis = now;
+      if (pir_on && ! pir_movement) {
               pir_movement = true;
               Serial.println(" movement");
               rtlog("movement",pir_movement);
           }
-      else pir_millis = now;
-      }
       pir_changed = false;
     }
     if ( ! pir_on && pir_movement && now - pir_millis > inactive_interval) {


Fix #define variable arguements issues

Fix #define variable arguements issues

--- Event_Printer/Event_Printer.ino
+++ Event_Printer/Event_Printer.ino
@@ -13,11 +13,11 @@

 /* Debug Macros */
 #if DEBUG
-#define DEBUG_PRINT(x)    Serial.print(x)
-#define DEBUG_PRINT_LN(x) Serial.println(x)
-#elif
-#define DEBUG_PRINT(x)
-#define DEBUG_PRINT_LN(x)
+#define DEBUG_PRINT(x,...)    Serial.print(x,__VA_ARGS__)
+#define DEBUG_PRINT_LN(x,...) Serial.println(x,__VA_ARGS__)
+#else
+#define DEBUG_PRINT(x,...)
+#define DEBUG_PRINT_LN(x,...)
 #endif // DEBUG

 MCP_CAN CAN(9);


timed loop w/ spin outside

timed loop w/ spin outside

--- scr_arduino/scr_arduino.ino
+++ scr_arduino/scr_arduino.ino
@@ -31,6 +31,12 @@
 #define PMD_TX 14
 #define PMD_RX 15
 #define PMD_RESET 8
+
+// Loop Publish Rate
+#define PUB_RATE 33
+
+// Last millis() publish time
+unsigned long last_pub_time = 0;

 // Ros Initialization stuff
 ros::NodeHandle_<ArduinoHardware, 3, 3, 128, 128>  nh;
@@ -192,40 +198,41 @@

 void loop()
 {
-
-  if(mode == 0){
-    lw_cmd_spd = 0;
-    rw_cmd_spd = 0;
-  }
-  // Get Freshest Values
-  updateEncoderReading();
-
-  // Compute New Control Values
-  L_DCMotorPID.Compute();
-  R_DCMotorPID.Compute();
-
-  // Update motor command
-  lm_cmd += L_PIDout;
-  rm_cmd += R_PIDout;
-
- if(mode == 0){
-    lm_cmd = 0;
-    rm_cmd = 0;
-  }
-  // Populate messages
-  l_wheel_msg.data = L_WheelVelocity;
-  r_wheel_msg.data = R_WheelVelocity;
-
-  // Publish Data
-  left_wheel_pub.publish( &l_wheel_msg );
-  right_wheel_pub.publish( &r_wheel_msg );
-
+  if (millis() - last_pub_time > PUB_RATE)
+  {
+    last_pub_time = millis();
+
+    if(mode == 0){
+      lw_cmd_spd = 0;
+      rw_cmd_spd = 0;
+    }
+    // Get Freshest Values
+    updateEncoderReading();
+
+    // Compute New Control Values
+    L_DCMotorPID.Compute();
+    R_DCMotorPID.Compute();
+
+    // Update motor command
+    lm_cmd += L_PIDout;
+    rm_cmd += R_PIDout;
+
+   if(mode == 0){
+      lm_cmd = 0;
+      rm_cmd = 0;
+    }
+    // Populate messages
+    l_wheel_msg.data = L_WheelVelocity;
+    r_wheel_msg.data = R_WheelVelocity;
+
+    // Publish Data
+    left_wheel_pub.publish( &l_wheel_msg );
+    right_wheel_pub.publish( &r_wheel_msg );
+
+    // Write Speeds to motor driver
+    pmd.setSpeeds(lm_cmd, rm_cmd);
+  }
+
   // Handle Callbacks
   nh.spinOnce();
-
-  // Write Speeds to motor driver
-  pmd.setSpeeds(lm_cmd, rm_cmd);
-
-  delay(30);
-}
-
+}


Fixed typo

Fixed typo

--- module/module.ino
+++ module/module.ino
@@ -280,7 +280,7 @@
 	}
   //Serial.print(signals[0]); Serial.print(signals[1]); Serial.print(signals[2]); Serial.print(" ");
 	Serial.print(numValid); Serial.print(numInvalid);
-	//Serial.print(" ");
+	Serial.print(" ");
   	//delay(1);

 	if (numValid == sampleSize) {


test update

test update

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -1,6 +1,6 @@
 /* bugs
 *  001 : initialise_number_select cause reset when called minno ~ maxno loop moret han 3 times
-*  002 : o_tempCinside is not a moving point
+*  002 : tempCprevious is a 5 min moving point
 */

 #include <avr/eeprom.h>
@@ -66,6 +66,8 @@
 // Timer
 Timer t;
 long temp_Mills;
+int tvIsOnEvent;
+int tvIsOffEvent;

 // eeprom status
 int o_pwrSrc;
@@ -81,6 +83,12 @@
 int setUpStatus;
 int wrkModeStatus;

+// tv power status
+int tvPowerStatus;
+
+// Timer status
+int timerStatus = 0 ;
+
 // tv IR code
 unsigned long tv_input = 0x20DFD02F;
 unsigned long tv_right = 0x20DF609F;
@@ -195,17 +203,16 @@
   // pin mode
   pinMode(SETUP_IN_PIN, INPUT);
   pinMode(WRK_MODE_IN_PIN, INPUT);
-  /*
-  pinMode(DN_IN_PIN, INPUT_PULLUP);
-  pinMode(UP_IN_PIN, INPUT_PULLUP);
-  */
-  pinMode(PIR_IN_PIN, INPUT);
+  // SETUP_IN_PIN and WRK_MODE_IN_PIN is analog pin, to pull-up
+  digitalWrite(SETUP_IN_PIN, HIGH);
+  digitalWrite(WRK_MODE_IN_PIN, HIGH);
+
+  pinMode(PIR_IN_PIN, INPUT_PULLUP);

   // buzzer
   pinMode(BZ_OU_PIN, OUTPUT);
   digitalWrite(BZ_OU_PIN, HIGH);
-  digitalWrite(SETUP_IN_PIN, HIGH);
-  digitalWrite(WRK_MODE_IN_PIN, HIGH);
+

   delay(300);

@@ -259,19 +266,125 @@
       lcd.write(3);
     }

-    lcd.setCursor(4, 1);
-    lcd.write(4);
-  }
-
+      // if powered by TV
+      if ( o_pwrSrc == 1 ) {
+
+        // input change
+        o_offMode = 0;
+        tvPowerStatus = 1;
+        timerStatus = 1;
+
+        tvOnTimer();
+
+        lcd.setCursor(4, 1);
+        lcd.write(4);
+
+        lcd.setCursor(6, 1);
+        lcd.write(5);
+
+      } else {
+        timerStatus = 0 ;
+      }
+  }

   // event Timer
-  int updateTempCEvent      = t.every(2000, doUpdateTempC);
-  int updateTempCArrayEvent = t.every(4000, doUpdateTempCArray);
+  int TempCEvent      = t.every(2000, doUpdateTempC);
+  int TempCArrayEvent = t.every(4000, doUpdateTempCArray);
   /*
   int updateTempCArrayEvent = t.every(300000, doUpdateTempCArray);
   */
+
   // PIR
   attachInterrupt(0, PIRCHECKING, CHANGE);
+
+}
+
+
+void loop()
+{
+  // receiving ir and change status
+  // remote on / off, tv remote on / off
+  decode_results results;
+
+  t.update();
+
+  // PIR
+  if ( pirOnOff != o_pirOnOff) {
+    Serial.println("PIR rising called");
+    if ( pirOnOff == 1 ) {
+      doTvControlbyPir("off");
+    } else {
+      doTvControlbyPir("on");
+    }
+    o_pirOnOff = pirOnOff;
+  }
+
+  // IR receive
+  if (irrecv.decode(&results)) {
+    changemodebyir(&results);
+    irrecv.enableIRIn();
+  }
+
+  if (r != o_r) {
+    changelcdicon();
+    alarm_set();
+    o_r = r;
+  }
+}
+
+oid changelcdicon()
+{
+
+  if ( o_wrkMode == 1 && o_startMode == 1 ) {
+    lcd.setCursor(0, 1);
+    lcd.write(2);
+
+    if ( o_beepMode == 1 ) {
+      lcd.setCursor(2, 1);
+      lcd.write(3);
+    }
+
+    if ( timerStatus == 1 ) {
+      lcd.setCursor(4, 1);
+      lcd.write(4);
+    } else {
+      lcd.setCursor(4, 1);
+      lcd.print(" ");
+    }
+
+  } else {
+    lcd.setCursor(0, 1);
+    lcd.print("     ");
+  }
+
+  if ( tvPowerStatus == 1 ) {
+    lcd.setCursor(6, 1);
+    lcd.write(5);
+  } else {
+    lcd.setCursor(6, 1);
+    lcd.print(" ");
+  }
+}
+
+void changemodebyir (decode_results *results)
+{
+  if ( results->bits > 0 && results->bits == 32 ) {
+    switch (results->value) {
+      case 0xFF02FD: // remote on
+        o_wrkMode = ! o_wrkMode;
+        o_startMode = 1;
+        r = !r;
+        break;
+      case 0xFF9867: // remote off
+        timerStatus = ! timerStatus;
+        r = !r;
+        break;
+      case 0x20DF10EF: // tv remore on/off
+        tvPowerStatus = ! tvPowerStatus;
+        r = !r;
+        break;
+    }
+  }
 }

 void PIRCHECKING()
@@ -280,25 +393,156 @@
 }

-
-
-
-
-void loop()
-{
-
-  t.update();
-
-}
-
-
-
+void tvOnTimer()
+{
+    t.stop(tvIsOffEvent);
+    tvIsOnEvent = t.every(3000000, doTvOnOffbyTimer("off"));
+}
+
+void tvOffTimer()
+{
+    t.stop(tvIsOnEvent);
+    tvIsOffEvent = t.every(600000, doTvOnOffbyTimer("on"));
+}
+
+void doTvOnOffbyTimer(String onoff)
+{
+  switch (onoff) {
+    case on:
+      irSendTv("on");
+      tvOnTimer();
+      lcd.setCursor(15, 0);
+      lcd.print(" ");
+      break;
+    case off:
+      irSendTv("off");
+      tvOffTimer();
+      lcd.setCursor(15, 0);
+      lcd.write(6);
+      break;
+  }
+}
+
+void doTvControlbyPir(String onoff)
+{
+  switch (onoff) {
+    case on:
+      irSendTv("on");
+      break;
+    case off:
+      irSendTv("off");
+      break;
+  }
+}
+
+void irSendTv(String onoff)
+{
+  if ( wrkMode == 1 && startMode == 1 )
+  {
+    if ( offMode == 1 )
+    {
+        switch (onoff) {
+          case on:
+            if ( tvPowerStatus == 0 )
+            {
+                  irsend.sendNEC(tv_onoff, 32);
+                  tvPowerStatus = 1;
+                  temp_Mills = millis();
+                  delay(300);
+                  irrecv.enableIRIn();
+            }
+            break;
+          case off:
+            if ( tvPowerStatus == 1 )
+            {
+                  irsend.sendNEC(tv_onoff, 32);
+                  tvPowerStatus = 0;
+                  temp_Mills = millis();
+                  delay(300);
+                  irrecv.enableIRIn();
+            }
+            break;
+          default:
+            return;
+            break;
+        }
+    } else {
+        switch (onoff) {
+          case on:
+            if ( tvPowerStatus == 0 )
+            {
+                  irsend.sendNEC(tv_input, 32);
+                  delay(3000);
+                  for ( int i = 0 ; i < o_channelGap ; i++ ) {
+                    irsend.sendNEC(tv_left, 32);
+                    delay(300);
+                  }
+                  irsend.sendNEC(tv_enter, 32);
+                  tvPowerStatus = 1;
+                  delay(300);
+                  irrecv.enableIRIn();
+            }
+            break;
+          case off:
+            if ( tvPowerStatus == 1 )
+            {
+                  irsend.sendNEC(tv_input, 32);
+                  delay(3000);
+                  for ( int i = 0 ; i < o_channelGap ; i++ ) {
+                    irsend.sendNEC(tv_right, 32);
+                    delay(300);
+                  }
+                  irsend.sendNEC(tv_enter, 32);
+                  tvPowerStatus = 0;
+                  delay(300);
+                  irrecv.enableIRIn();
+            }
+            break;
+          default:
+            return;
+            break;
+        }
+
+    }
+  } else {
+
+    return;
+
+  }
+
+}
+
+// TimeTime
+void displaytimeleft() {
+
+  if ( tvPowerStatus == 1) {
+    float timeleft = o_tvOnTime - ((millis() - temp_Mills) / 1000 / 60) ;
+  } else {
+    float timeleft = o_tvOffTime - ((millis() - temp_Mills) / 1000 / 60) ;
+  }
+
+  String str_a = String(int(timeleft));
+  int length_a = str_a.length();
+
+  lcd.setCursor(10, 1);
+  for ( int i = 0; i < ( 3 - length_a ) ; i++ ) {
+    lcd.print(" ");
+  }
+  lcd.print(str_a);
+
+}
+
+// update every 2 sec
 void doUpdateTempC()
 {
   tempCinside = getdalastemp();
   displayTemperature(tempCinside);
-}
-
+  if ( timerStatus == 1) {
+    displaytimeleft();
+  }
+}
+
+// update every 5 mins
 void doUpdateTempCArray()
 {
   for ( int i = 0 ; i < 11 ; i++ ) {
@@ -340,7 +584,6 @@
   }
 }

-
 float getdalastemp()
 {
   sensors.requestTemperatures();
@@ -348,7 +591,6 @@

   return tempC;
 }
-

 void alarm_set()
 {


added voltage metering

added voltage metering

--- hacks/rf_temp_sensor/rf_temp_sensor_sensor/rf_temp_sensor_sensor.ino
+++ hacks/rf_temp_sensor/rf_temp_sensor_sensor/rf_temp_sensor_sensor.ino
@@ -25,6 +25,7 @@
 String messageString = "";
 int messageId = 0;
 float tempC = -127.00; //-127.00 is the error temp
+float vIn = 0.00;

 void setup() {
   // initialize the LED pin as an output:
@@ -50,8 +51,13 @@
   Serial.println("Getting temperatures...");
   sensors.requestTemperatures();
   tempC = sensors.getTempC(firstThermometer);
+
+  // Get and print battery voltage
+  Serial.println("Getting voltage...");
+  // 9v = 3.85, 6v = 2.55, 11.9v = 5.00 => k = 2.35,
+  vIn = 2.35 * (analogRead(1) * (5.0/1023.0));

-  // Make temperature message, e.g. "I:1 T:22.50 \n"
+  // Make message, e.g. "I:1 T:22.50 \n"
   messageString = "I:";
   messageString = messageString + String(messageId, DEC);
   messageString = messageString + " T:";
@@ -61,6 +67,8 @@
   } else {
     messageString = messageString + String(tempC, 2);
   }
+  messageString = messageString + " V:";
+  messageString = messageString + String(vIn, 2);
   messageString = messageString + "\n";

   // Prepare and send message


More samples on DS18B20

More samples on DS18B20

--- cmdMULTIsens/src/sketch.ino
+++ cmdMULTIsens/src/sketch.ino
@@ -16,7 +16,7 @@
 #define Dht22Pin 4
 #define DhtType DHT22
 // number of samples to be averaged (not used!)
-// #define Dht22Samples 16
+// #define Dht22Samples 1

 // measurement pin of TMP36 is connected to analog pin 1
 #define VbatPin A0
@@ -29,7 +29,7 @@
 #define Tmp36Samples 16

 #define DS18Pin 10
-#define DS18Samples 3
+#define DS18Samples 16

 // Initialise DHT sensor: measurement pin, sensortype
 DHT dht(Dht22Pin, DhtType);


housekeeping

housekeeping

--- arduino/arduino.ino
+++ arduino/arduino.ino
@@ -1,22 +0,0 @@
-/*
-  Control for the Arduino Uno BarBot.
-
-  Created by Aaron Roth on 5/6/2012.
-*/
-
-const int rightValve = 8;
-const int leftValve = 11;
-
-void setup() {
- pinMode(8, OUTPUT);
- pinMode(11, OUTPUT);
-}
-
-void loop() {
-  digitalWrite(rightValve, HIGH);
-  digitalWrite(leftValve, HIGH);
-  delay(1000);
-  digitalWrite(rightValve, LOW);
-  digitalWrite(leftValve, LOW);
-  delay(1000);
-}


added temperature reading periodic

added temperature reading periodic

--- arduino/src/src.ino
+++ arduino/src/src.ino
@@ -1,5 +1,8 @@
 #define maxlen 50
-
+#include "DHT.h"
+#define DHTPIN 2
+#define DHTTYPE DHT22
+DHT dht(DHTPIN, DHTTYPE);
 int pingPin[3] = {3, 5, 7}; //{T,R,L}
 int max_timeout[3] = {6000, 3250, 3250}; //{T,R,L}
 int timeout;
@@ -10,7 +13,7 @@
 short idx = 0;
 short sleep_left = 0;
 int i = 0;
-
+int temp_count = 0;
 int statusLed = 11;
 int errorLed = 12;

@@ -36,10 +39,12 @@
 void setup()
 {
   Serial.begin(9600);
+  dht.begin();
 }

 void loop()
 {
+  temp_count++;
   Pin = pingPin[inc];
   timeout = max_timeout[inc];
   getDuration();
@@ -56,8 +61,20 @@
     Serial.print(",");
     Serial.print(data[1]);
     Serial.print(",");
-    Serial.println(data[2]);
+    Serial.print(data[2]);
+    if(temp_count == 18000) {
+	temp_count = 0;
+    	float f = dht.readTemperature(true);
+	Serial.print(",");
+    	if(isnan(f))
+	    Serial.println("Error in DHT");
+    	else
+            Serial.println(f);
+    }
+    else
+	Serial.println("");
+
   }
   inc = inc % 3;

-}
+}


v8.4 Display date and day on main window

--- WeatherDisplay.ino
+++ WeatherDisplay.ino
@@ -159,7 +159,7 @@
   client.stop(); //stop client

 #ifdef DEBUG
-  Serial.println(result);
+  Serial.println(result); // Print out the JSON data
 #endif
   result.replace('[', ' ');
   result.replace(']', ' ');
@@ -270,13 +270,10 @@
                   temperature,
                   timeS,
                   idString.toInt(),
-#ifdef DISPLAYDATE // Display the date
                   dateS,
-#else              // Display the day of week
                   dayI,
                   monthI,
                   yearI,
-#endif
                   description);
   }
 } // void getWeatherData()
@@ -399,25 +396,16 @@
 }

 // Displays the main weather
-#ifdef DISPLAYDATE // Dislpays the date
 void printMainData(String humidityString,
                    String temperature,
                    String time,
                    int weatherID,
                    String dateS,
-                   String description)
-{
-#else // Dislpays the day of week
-void printMainData(String humidityString,
-                   String temperature,
-                   String time,
-                   int weatherID,
                    int dayI,
                    int monthI,
                    int yearI,
                    String description)
 {
-#endif
   byte maxLeghtOfParam;

   tft.setTextColor(YELLOW);
@@ -448,16 +436,13 @@
   tft.print("% RH");
   tft.setTextColor(YELLOW);
   tft.setTextSize(1);
-#ifdef DISPLAYDATE // Dislpays the date
   maxLeghtOfParam = std::min((int)dateS.length(), 22); // Limit characters
-  tft.setCursor((11 - (maxLeghtOfParam / 2)) * 4, 150); // Center text
-  tft.print(dateS);
-#else // Dislpays the day of week
   String theDayOfWeek = getDayOfWeek(dayOfWeek(yearI, monthI, dayI));
-  maxLeghtOfParam = std::min((int)theDayOfWeek.length(), 22); // Limit characters
+  maxLeghtOfParam = maxLeghtOfParam + std::min((int)theDayOfWeek.length() + 1, 22); // Limit characters
   tft.setCursor((11 - (maxLeghtOfParam / 2)) * 4, 150); // Center text
   tft.print(theDayOfWeek);
-#endif
+  tft.print(" ");
+  tft.print(dateS);
 }

 void printWeatherIcon(int id)


minor changes

minor changes

--- WifiWeatherGuy.ino
+++ WifiWeatherGuy.ino
@@ -12,10 +12,10 @@
 #include "display.h"
 #include "dbg.h"

-#define CS D6
-#define DC D8
-#define TFT_LED D2
-#define SWITCH D3
+#define CS	D6
+#define DC	D8
+#define TFT_LED	D2
+#define SWITCH	D3
 #define HAVE_PWM

 bool debug;
@@ -24,8 +24,8 @@
 ESP8266WebServer server(80);
 ESP8266HTTPUpdateServer httpUpdater;

-uint32_t last_fetch_conditions = 0, last_fetch_forecasts = 0;
-uint32_t display_on = 0;
+uint32_t last_fetch_conditions, last_fetch_forecasts;
+uint32_t display_on;
 uint8_t fade;
 bool connected;

@@ -61,7 +61,7 @@
 	retry_interval = 1000 * (int)o[F("retry_interval")];
 }

-static volatile bool swtch = false;
+static volatile bool swtch;

 void setup() {
 	Serial.begin(115200);
@@ -198,7 +198,7 @@
 	if (!current_observation.success())
 		return false;
 	time_t epoch = (time_t)atoi(current_observation[F("observation_epoch")] | "0");
-	if (epoch == c.epoch || epoch == 0)
+	if (epoch <= c.epoch)
 		return false;

 	c.epoch = epoch;


set WiFi hostname correctly

set WiFi hostname correctly

--- WifiWeatherGuy.ino
+++ WifiWeatherGuy.ino
@@ -112,6 +112,7 @@
   tft.println(cfg.dim);

   WiFi.mode(WIFI_STA);
+  WiFi.hostname(cfg.hostname);
   WiFi.begin(cfg.ssid, cfg.password);
   while (WiFi.status() != WL_CONNECTED) {
     delay(500);
@@ -126,8 +127,10 @@
   tft.println();
   tft.println(WiFi.localIP());

-  if (mdns.begin(cfg.hostname, WiFi.localIP()))
+  if (mdns.begin(cfg.hostname, WiFi.localIP())) {
     out.println("MDNS started");
+    mdns.addService("http", "tcp", 80);
+  }

   ArduinoOTA.setHostname(cfg.hostname);
   ArduinoOTA.onStart([]() {
@@ -161,7 +164,6 @@
   server.on("/config", HTTP_POST, []() {
     if (server.hasArg("plain")) {
       String body = server.arg("plain");
-      Serial.print(body);
       File f = SPIFFS.open("/config.json", "w");
       f.print(body);
       f.close();
@@ -433,6 +435,7 @@

   ArduinoOTA.handle();
   server.handleClient();
+  mdns.update();

   uint32_t now = millis();
   bool swtch = !digitalRead(SWITCH);


commit and push test by severin

commit and push test by severin

--- embeded/src/Sortic150.ino
+++ embeded/src/Sortic150.ino
@@ -12,7 +12,7 @@
 #include "PlacerSeverin.h"
 #include "DetectorSeverin.h"

-//Sensor:
+//Sensors:
 int DistanceSensorPin = A1;

 //Motors:


Remove Arduino file

Remove Arduino file

--- Li_Charger.ino
+++ Li_Charger.ino
@@ -1,9 +0,0 @@
-void setup() {
-  // put your setup code here, to run once:
-
-}
-
-void loop() {
-  // put your main code here, to run repeatedly:
-
-}


Added a sketch to set time.

Added a sketch to set time.

--- Sensors/Documentation/RTC/SETTIME/SETTIME.ino
+++ Sensors/Documentation/RTC/SETTIME/SETTIME.ino
@@ -16,11 +16,11 @@
 void setDateTime(){

   byte second =      00; //0-59
-  byte minute =      45; //0-59
-  byte hour =        14; //0-23
-  byte weekDay =     6; //1-7
-  byte monthDay =    27; //1-31
-  byte month =       6; //1-12
+  byte minute =      11; //0-59
+  byte hour =        9; //0-23
+  byte weekDay =     3; //1-7
+  byte monthDay =    8; //1-31
+  byte month =       7; //1-12
   byte year  =       15; //0-99

   Wire.beginTransmission(DS1307_ADDRESS);


Bug fixes

Bug fixes

Fixed a bug where one could save empty settings and corrupt data in a way that crashes the cpu core.
Simple fix was to prevent storage of empty password, api key and channel in new settings page.

--- esp32LightServerRGB.ino
+++ esp32LightServerRGB.ino
@@ -543,7 +543,6 @@
   if (!server.authenticate(www_username, string2char(resetpass))) {
     Serial.println("Setup request no/bad password");
     return server.requestAuthentication();
-
   }
   int ouireset = 0;
   String testteu = server.arg("RESET");
@@ -554,6 +553,15 @@
   if (testteu == "OUI") {
     if (passme == resetpass) {
       ouireset = 1;
+      if (noupass == "") {
+        ouireset = 3;
+      }
+      if (lakey == "") {
+        ouireset = 3;
+      }
+      if (lechan == "") {
+        ouireset = 3;
+      }
     } else {
       ouireset = 2;
     }
@@ -582,9 +590,13 @@
     contenu += "<form action=\"/setup\" method=\"post\">\n"
                "
Changes les réglages ici !
"
                "<input type=\"hidden\" name=\"RESET\" value=\"OUI\">
\n"
-               "Vieux Password :
\n<input type=\"password\" name=\"PASSME\" value=\"password\">
\n"
-               "
!!! MAUVAIS PASSWORD !!!

\n"
-               "Nouveau Password :
\n<input type=\"password\" name=\"LAPASSE\" value=\"\">
\n"
+               "Vieux Password :
\n<input type=\"password\" name=\"PASSME\" value=\"password\">
\n";
+    if (ouireset != 3) {
+      contenu += "
!!! MAUVAIS PASSWORD !!!

\n";
+    } else {
+      contenu += "
!!! LES CHAMPS NE PEUVENT PAS ÊTRE VIDE !!!

\n";
+    }
+    contenu += "Nouveau Password :
\n<input type=\"password\" name=\"LAPASSE\" value=\"\">
\n"
                "ThingSpeak API Key :
\n<input type=\"text\" name=\"APIKEY\" value=\"";
     contenu += thingkey;
     contenu += "\">
\n"
@@ -849,6 +861,8 @@
   ledcSetup(1, 12000, 8); // 12 kHz PWM, 8-bit resolution
   ledcSetup(2, 12000, 8);
   ledcSetup(3, 12000, 8);
+  //      preferences.putString("resetpass", "admin");
+
   derncoul = preferences.getString("derncoul", "#000000");
   r = preferences.getUInt("r", 0);
   g = preferences.getUInt("g", 0);


Changes driving enables arround

Changes driving enables arround

--- donkey-car/arduino-shield-v1/servo_controller/servo_controller.ino
+++ donkey-car/arduino-shield-v1/servo_controller/servo_controller.ino
@@ -180,11 +180,11 @@
             if((rc_throttle_servo_pulse_length < RC_THROTTLE_DEAD_ZONE_MIN)
             || (rc_throttle_servo_pulse_length > RC_THROTTLE_DEAD_ZONE_MAX))
             {
-                throttle_servo.writeMicroseconds(max(rc_throttle_servo_pulse_length, 1500)); // backwards is brake
+                throttle_servo.writeMicroseconds(serial_throttle_servo_pulse_length);
             }
             else
             {
-                throttle_servo.writeMicroseconds(serial_throttle_servo_pulse_length);
+                throttle_servo.writeMicroseconds(1500);
             }

             if((rc_steering_servo_pulse_length < RC_STEERING_DEAD_ZONE_MIN)
@@ -199,7 +199,7 @@
         }
         else
         {
-            throttle_servo.writeMicroseconds(max(rc_throttle_servo_pulse_length, 1500)); // backwards is brake
+            throttle_servo.writeMicroseconds(rc_throttle_servo_pulse_length);
             steering_servo.writeMicroseconds(rc_steering_servo_pulse_length);
         }
     }


Updated directions in more advanced example.

--- examples/MoreAdvancedPulseForMobile/MoreAdvancedPulseForMobile.ino
+++ examples/MoreAdvancedPulseForMobile/MoreAdvancedPulseForMobile.ino
@@ -7,8 +7,9 @@
  *   1. Add this device to your Simblee Cloud account
  *   2. Create a pool with a unique ESN on your SimbleeCloud account.
  *   3. Use the Pool ESN as the destESN in this sketch.
- *   4. Place the contents of the web directory on an appropriate server.
- *   5. Update "PulseDemoPage.html" with the Pool ESN
+ *   4. Update "web/PulseDemoPage.html" with the Pool ESN
+ *   5. Optional: Place the contents of the web directory on an appropriate server.
+ *   6. Open a browser to PulseDemoPage.html (either on a server or local)
  */
 #include <SimbleeForMobile.h>
 #include <BarGraph.h>


Fixed debounce issue on sound on/off renamed bool to be more intuitive.

--- arduboy-game/arduboy-game.ino
+++ arduboy-game/arduboy-game.ino
@@ -25,7 +25,7 @@
      shouldPlayTone2,
      shouldPlayTone3;

-bool musicOnOff = true;
+bool musicOn = true;

 // Bullets array - We may need a playerBullets and enemyBullets at some point and a MAX global int for each
 Bullet playerBullets[MAX_PLAYER_BULLETS];
@@ -193,7 +193,7 @@

 void settingsScreen() {

-  long lastDebounceTime = 0;  // the last time the button was pressed
+  long lastDebounceTime = millis();  // the last time the button was pressed
   bool exit_settings_menu = false;
   byte selectedItem;

@@ -228,7 +228,7 @@
             break;

           case SETTINGS_SOUND:
-            musicOnOff = !musicOnOff;
+            musicOn = !musicOn;
             printMusicOnOff();
             break;

@@ -298,7 +298,7 @@
 }

 void printMusicOnOff() {
-  if(musicOnOff) {
+  if(musicOn) {
     printText("SOUND  ON ", 20, 25, 1);
     arduboy.drawRect(17, 22, 35, 13, 1);
   } else {


started reading pins rather than setting them every cycle

--- brew_controller.ino
+++ brew_controller.ino
@@ -62,7 +62,7 @@
 const int tempInterval = 500; //Time in milliseconds to check temps
 long previousMillis = 0;
 long tempPrevMillis = 0;
-boolean BKon = false;
+//boolean BKon = false;

 #define Neutral 0
 #define Press 1
@@ -100,7 +100,7 @@
     case 2:
       tft.fillCircle(125, 8, 5, RED);
       digitalWrite(BKSSR, HIGH);
-      BKon = true;
+      //BKon = true;
       break;
   }
 }
@@ -121,7 +121,7 @@
     case 2:
       tft.fillCircle(125, 8, 5, BLACK);
       digitalWrite(BKSSR, LOW);
-      BKon = false;
+      //BKon = false;
       break;
   }
 }
@@ -580,7 +580,10 @@
       //firing the HLT only
       if ((!paused) && (currHLT < setHLT) && (currHLT != 0))
       {
-        elementOn(0);
+        if (digitalRead(HLTSSR) == LOW)
+        {
+          elementOn(0);
+        }
       }
       else
       {
@@ -592,22 +595,37 @@
       if ((!paused) && (currRIMS < setRIMS) && (currRIMS != 0))
       {
         //ensure HLT off
-        elementOff(0);
+        if (digitalRead(HLTSSR) == HIGH)
+        {
+          elementOff(0);
+        }
         //now turn on RIMS
-        elementOn(1);
+        if (digitalRead(RIMSSSR) == LOW)
+        {
+          elementOn(1);
+        }
       }
       else
       {
         //turn off RIMS
-        elementOff(1);
+        if (digitalRead(RIMSSSR) == HIGH)
+        {
+          elementOff(1);
+        }
         //fire HLT?
         if ((!paused) && (currHLT < setHLT))
         {
-          elementOn(0);
+          if (digitalRead(HLTSSR) == LOW)
+          {
+            elementOn(0);
+          }
         }
         else
         {
-          elementOff(0);
+          if (digitalRead(HLTSSR) == HIGH)
+          {
+            elementOff(0);
+          }
         }
       }
       break;
@@ -619,9 +637,10 @@

       if (!paused)
       {
-        if (BKon)
-        {
-          if (currentMillis - previousMillis > (long)onDuration)
+        //if (BKon)
+        if (digitalRead(BKSSR))
+        {
+          if ((currentMillis - previousMillis > (long)onDuration) && (setBK < 100))
           {
             previousMillis = currentMillis;
             elementOff(2);
@@ -641,8 +660,6 @@
   }

-  //turn off elements regardless of mode
-
   delay(100);
 }


updated arduino  script

updated arduino  script

--- arduino/player.ino
+++ arduino/player.ino
@@ -12,8 +12,8 @@
   switch(score)
   {
     case 1:
-      result[0] = 1;
-      result[1] = 2;
+      result[0] = 10;
+      result[1] = 13;

     default:
       result[0] = score;


Update AnalogReadSendBytes.ino

Update AnalogReadSendBytes.ino

--- Arduino/SerialCommunication/AnalogReadSendBytes/AnalogReadSendBytes.ino
+++ Arduino/SerialCommunication/AnalogReadSendBytes/AnalogReadSendBytes.ino
@@ -16,8 +16,7 @@
     ; // wait for serial port to connect. Needed for native USB port only
   }

-  pinMode(2, INPUT);   // digital sensor is on digital pin 2
-  establishContact();  // send a byte to establish contact until receiver responds
+  pinMode(2, INPUT);   // digital sensor is on digital pin 2  establishContact();  // send a byte to establish contact until receiver responds
 }

 void loop() {


Updated to work with the current RF24 library

Tested on January 2020.

--- bare_receiver/bare_receiver.ino
+++ bare_receiver/bare_receiver.ino
@@ -2,12 +2,7 @@
 #include "nRF24L01.h"
 #include "RF24.h"

-class RF24Test: public RF24
-{
-public: RF24Test(int a, int b): RF24(a,b) {}
-};
-
-RF24Test radio(9,10);
+RF24 radio(9, 10);

 // Radio pipe addresses for the 2 nodes to communicate.
 const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
@@ -15,59 +10,57 @@
 void setup()
 {
   Serial.begin(57600);
-
+
   radio.begin();
-
+
   radio.openWritingPipe(pipes[1]);
-  radio.openReadingPipe(1,pipes[0]);
-
+  radio.openReadingPipe(1, pipes[0]);
+
   radio.startListening();
   Serial.println("Listening...");
 }

 void loop()
 {
-    // if there is data ready
-    if ( radio.available() )
-     {
-      byte transmission[7];
-      bool done = false;
-      while (!done)
-      {
-        // Fetch the payload, and see if this was the last one.
-        done = radio.read( &transmission, 7 );
+  // if there is data ready
+  if ( radio.available() )
+  {
+    byte transmission[7];

-        // Spew it
-        Serial.print(transmission[0]);
-        Serial.print(" ");
-        Serial.print(transmission[1]);
-        Serial.print(" ");
-        Serial.print(transmission[2]);
-        Serial.print(" ");
-        Serial.print(transmission[3]);
-        Serial.print(" ");
-        Serial.print(transmission[4]);
-        Serial.print(" ");
-        Serial.print(transmission[5]);
-        Serial.print(" ");
-        Serial.print(transmission[6]);
-        Serial.print("   ");
+    while (radio.available()) {
+      radio.read( &transmission, sizeof(transmission));
+    }

-	 // Delay just a little bit to let the other unit
-	 // make the transition to receiver
-	 delay(20);
-      }
+    // Spew it
+    Serial.print(transmission[0]);
+    Serial.print(" ");
+    Serial.print(transmission[1]);
+    Serial.print(" ");
+    Serial.print(transmission[2]);
+    Serial.print(" ");
+    Serial.print(transmission[3]);
+    Serial.print(" ");
+    Serial.print(transmission[4]);
+    Serial.print(" ");
+    Serial.print(transmission[5]);
+    Serial.print(" ");
+    Serial.print(transmission[6]);
+    Serial.print("   ");

-      // First, stop listening so we can talk
-      radio.stopListening();
+    // Delay just a little bit to let the other unit
+    // make the transition to receiver
+    delay(20);

-      // Send the final one back.
-      byte response = B0;
-      radio.write( &response, sizeof(response) );
-      Serial.println("Sent response.\n\r");
+    // First, stop listening so we can talk
+    radio.stopListening();

-      // Now, resume listening so we catch the next packets.
-      radio.startListening();
+    // Send the final one back.
+    byte response = B0;
+    radio.write( &response, sizeof(response) );
+    Serial.println("Sent response.\n\r");

-    }
+    // Now, resume listening so we catch the next packets.
+    radio.startListening();
+
+  }
 }


Pesky little pointer

Pesky little pointer

--- master/master.ino
+++ master/master.ino
@@ -31,18 +31,18 @@
 }

 void loop(void)
-{
+{
   int address;
   char cmd[10];
   char c;
-
+
   while ( Serial.available() ) {
     c = Serial.read();
     if ( c != '\r' ) {
       input += c;
     } else {
       input.toCharArray(cmd,10);
-      byte okparse = sscanf(cmd, "%d %d", &address, state);
+      byte okparse = sscanf(cmd, "%d %d", &address, &state);
       printf("%d", state);

       if (okparse == 2 ) {


these are good too

these are good too

--- amazing_cycle/amazing_cycle.ino
+++ amazing_cycle/amazing_cycle.ino
@@ -42,7 +42,7 @@
   LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);          // Use this for WS2812B
   //  LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS);  // Use this for WS2801 or APA102
   FastLED.setBrightness(max_bright);
-  set_max_power_in_volts_and_milliamps(5, 4000);                // FastLED 2.1 Power management set at 5V, 500mA
+  set_max_power_in_volts_and_milliamps(5.5, 7000);                // FastLED 2.1 Power management set at 5V, 500mA
 }

 bool allWhite = false;


Refactored to handle two GY-521 MPU6050 Breakout Boards.  Work In Progress

--- ardu-predator/ardu-predator.ino
+++ ardu-predator/ardu-predator.ino
@@ -2,7 +2,13 @@
  * ardu-predator.ino
  *
  * @author Mike Muscato
- * @date   2017-01-11
+ * @date   2017-07-04
+ *
+ * Refactored to handle two GY-521 MPU6050 Breakout Boards.
+ * One fixed to the body, the other dynamic on the head.
+ * By calculating the difference between tilt and yaw angles...
+ * we can keep the shoulder cannon pointing along our relative...
+ * line of vision, regardless of our absolute body position.
  *
  * =============  Attribution ==========================
  * Based on MPU6050_Latest_code.ino
@@ -23,16 +29,6 @@

 // Standard included arduino servo library
 #include "Servo.h"
-
-// Initialize gyro instance
-// TODO:  Update this to initialize two gyros with +VDC/Ground arguments
-MPU6050 mpuStatic(0x68);
-MPU6050 mpuDynam(0x69);
-
-// Initialize servo instances
-Servo yawServo;
-Servo pitchServo;
-

 // Comment to turn off Serial printing
 #define DEBUG
@@ -49,8 +45,14 @@
 	#define DPRINTLN(...)      //blank line
 #endif

-
-// TODO:  Find out if it's really necessary to turn on this LED...probably not.
+// Initialize gyro instances for both MPUs
+MPU6050 mpus[2] = {MPU6050(0x68), MPU6050(0x69)};
+
+// Initialize servo instances
+Servo yawServo;
+Servo pitchServo;
+
+//LED will give us status of the loop, if it turns off something failed.
 const int LED_PIN = 13;

 // Prevent the servos from rotating beyond mechanical limits
@@ -60,17 +62,20 @@
 const int maxYaw = 135;
 const int minYaw = 45;

-
 // You must supply your gyro offsets here,
 // Use MPU6050_calibration.ino found at:
 //     https://forum.arduino.cc/index.php?PHPSESSID=h4c6487i42hbb7uh6rjk0eadp1&topic=446713.msg3073854#msg3073854
 //
 // Calibration code also copied in my repo:  arduino/MPU6050/
 //
-// Gyro 0 (head) calibrated at:   {-3074,  -2036,  1236,    63,    -16,     78}
+// Gyro 0 calibrated at:  {-3074,  -2036,  1236,    63,    -16,     78}
+// Gyro 1 calibrated at:  {-1143,  -1197,   989,   147,    -78,    -10}
+//
 //                           XA      YA      ZA     XG      YG      ZG
-int mpuStaticOffsets[6] = {-3074,  -2036,  1236,    63,    -16,     78};
-int mpuDynamOffsets[6]  = {-1143,  -1197,   989,   147,    -78,    -10};
+int mpuOffsets[2][6] =  {
+                          {-3074,  -2036,  1236,    63,    -16,     78},
+                          {-1143,  -1197,   989,   147,    -78,    -10}
+                        };

 // var to store the servo position when testing
 int pos = 0;
@@ -81,11 +86,6 @@
 // Will be used for timing events.
 unsigned long currentMillis = 0;    // stores the value of millis() in each iteration of loop()
 unsigned long prevMillis = 0;    // stores the value of millis() in each iteration of loop()
-
-// Will be used for switching readings so that we don't overrun the buffer
-int whichMPU = 0;
-
-

@@ -104,20 +104,18 @@

-
-
-
 // ================================================================
 // ===               INTERRUPT DETECTION ROUTINE                ===
 // ================================================================
-volatile bool mpuInterrupt0 = false;     // indicates whether MPU interrupt pin has gone high
-volatile bool mpuInterrupt1 = false;     // indicates whether MPU interrupt pin has gone high
-
+// indicates whether MPU interrupt pin has gone high
+volatile bool mpuInterrupt[2] = {false, false};
+
+//Intentional duplication. Interrupt routine cannot pass args.
 void dmpDataReady0() {
-    mpuInterrupt0 = true;
+    mpuInterrupt[0] = true;
 }
 void dmpDataReady1() {
-    mpuInterrupt1 = true;
+    mpuInterrupt[1] = true;
 }

@@ -125,241 +123,175 @@
 // ================================================================
 // ===                      MPU DMP SETUP                       ===
 // ================================================================
-int FifoAlive0 = 0; // tests if the interrupt is triggering
-int FifoAlive1 = 0; // tests if the interrupt is triggering
-//int IsAlive = -20;     // counts interrupt start at -20 to get 20+ good values before assuming connected
-// MPU control/status vars
-uint8_t mpuIntStatus0;   // holds actual interrupt status byte from MPU
-uint8_t devStatus0;      // return status after each device operation (0 = success, !0 = error)
-uint16_t packetSize0;    // expected DMP packet size (default is 42 bytes)
-uint16_t fifoCount0;     // count of all bytes currently in FIFO
-uint8_t fifoBuffer0[64]; // FIFO storage buffer
-
-uint8_t mpuIntStatus1;   // holds actual interrupt status byte from MPU
-uint8_t devStatus1;      // return status after each device operation (0 = success, !0 = error)
-uint16_t packetSize1;    // expected DMP packet size (default is 42 bytes)
-uint16_t fifoCount1;     // count of all bytes currently in FIFO
-uint8_t fifoBuffer1[64]; // FIFO storage buffer
-
-// orientation/motion vars
-Quaternion q0;           // [w, x, y, z]         quaternion container
-Quaternion q1;           // [w, x, y, z]         quaternion container
-//VectorInt16 aa;         // [x, y, z]            accel sensor measurements
-//VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
-//VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
-VectorFloat gravity0;    // [x, y, z]            gravity vector
-VectorFloat gravity1;    // [x, y, z]            gravity vector
-//float euler[3];         // [psi, theta, phi]    Euler angle container
-float ypr0[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
-float ypr1[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
-//byte StartUP = 200; // lets get 200 readings from the MPU before we start trusting them (Bot is not trying to balance at this point it is just starting up.)
-
-
-
-/**
- * MPU6050Connect
- * =============================================================
- *
- * @Edited by Mike Muscato to enable dual MPU configuration
- * @date   2017-07-02
- *
- */
-void MPU6050Connect(int connectMPU) {
-  static int MPUInitCntr = 0;
-
-  Serial.print(F("Initializing MPU ")); Serial.println(connectMPU);
-
-  if (connectMPU == 0) {
+uint8_t devStatus; // return status after each initialization operation (0 = success, !0 = error)
+
+//Containers for each MPU's communication
+int FifoAlive[2] = {0, 0}; // tests if the interrupt is triggering
+uint16_t packetSize[2];    // expected DMP packet size (default is 42 bytes)
+uint16_t fifoCount[2];     // count of all bytes currently in FIFO
+uint8_t fifoBuffer[2][64]; // FIFO storage buffer
+
+// orientation/motion vars
+// (overwritten during each read/calculate cycle so they do not need to be duplicated for each MPU)
+Quaternion q;           // [w, x, y, z]         quaternion container
+VectorFloat gravity;    // [x, y, z]            gravity vector
+float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
+
+
+
+/**
+ * MPU6050 Connection / Initialization routine
+ * =============================================================
+ *
+ * @author Modified by Mike Muscato to enable dual MPU configuration
+ * @date   2017-07-04
+ *
+ */
+void MPU6050Connect() {
+
+  for (int i = 0; i < 2; i++) {
+    Serial.print(F("Initializing MPU ")); Serial.println(i);
+
+    static int MPUInitCntr = 0;  //Counter for looping and eventual initialization failure.
+
     // initialize device
-    mpuStatic.initialize();
+    mpus[i].initialize();
     // load and configure the DMP
-    devStatus0 = mpuStatic.dmpInitialize();
-  }
-  else {
-    // initialize device
-    mpuDynam.initialize();
-    // load and configure the DMP
-    devStatus1 = mpuDynam.dmpInitialize();
-  }
-
-  if (devStatus0 != 0) {
-    // ERROR!
-    // 1 = initial memory load failed
-    // 2 = DMP configuration updates failed
-    // (if it's going to break, usually the code will be 1)
-
-    char * StatStr[5] { "No Error", "initial memory load failed", "DMP configuration updates failed", "3", "4"};
-
-    MPUInitCntr++;
-
-    Serial.print(F("MPU connection Try #"));
-    Serial.println(MPUInitCntr);
-    Serial.print(F("DMP Initialization failed (code "));
-    Serial.print(StatStr[devStatus0]);
-    Serial.println(F(")"));
-
-    if (MPUInitCntr >= 10) return; //only try 10 times
-    delay(1000);
-    MPU6050Connect(connectMPU); // Lets try again
-    return;
-  }
-
-  if (connectMPU == 0) {
-    mpuStatic.setXAccelOffset(mpuStaticOffsets[0]);
-    mpuStatic.setYAccelOffset(mpuStaticOffsets[1]);
-    mpuStatic.setZAccelOffset(mpuStaticOffsets[2]);
-    mpuStatic.setXGyroOffset(mpuStaticOffsets[3]);
-    mpuStatic.setYGyroOffset(mpuStaticOffsets[4]);
-    mpuStatic.setZGyroOffset(mpuStaticOffsets[5]);
-
-    Serial.println(F("Enabling DMP on Static MPU..."));
-    mpuStatic.setDMPEnabled(true);
+    devStatus = mpus[i].dmpInitialize();
+
+    if (devStatus != 0) {
+
+      // ERROR Checking!
+      // 1 = initial memory load failed
+      // 2 = DMP configuration updates failed
+      // (if it's going to break, usually the code will be 1)
+
+      char *StatStr[5] { "No Error", "initial memory load failed", "DMP configuration updates failed", "3", "4"};
+
+      MPUInitCntr++;
+
+      Serial.print(F("MPU")); Serial.print(i); Serial.print(F(" connection Try #")); Serial.println(MPUInitCntr);
+      Serial.print(F("DMP Initialization failed (code ")); Serial.print(StatStr[devStatus]); Serial.println(F(")"));
+
+      if (MPUInitCntr >= 10) return; //only try 10 times
+      delay(1000);
+      MPU6050Connect(); // Lets try again
+      return;
+    }
+
+    //Set offset values for each of our MPUs from our array.
+    mpus[i].setXAccelOffset(mpuOffsets[i][0]);
+    mpus[i].setYAccelOffset(mpuOffsets[i][1]);
+    mpus[i].setZAccelOffset(mpuOffsets[i][2]);
+    mpus[i].setXGyroOffset(mpuOffsets[i][3]);
+    mpus[i].setYGyroOffset(mpuOffsets[i][4]);
+    mpus[i].setZGyroOffset(mpuOffsets[i][5]);
+
+    Serial.print(F("Enabling DMP on MPU")); Serial.println(i);
+    mpus[i].setDMPEnabled(true);

     // enable Arduino interrupt detection
-    Serial.println(F("Enabling interrupt detection on Static MPU (Arduino external interrupt pin 2 on the Uno)..."));
-    Serial.print(F("mpuStatic.getInterruptDrive=  ")); Serial.println(mpuStatic.getInterruptDrive());
-    attachInterrupt(0, dmpDataReady0, RISING); //pin 2 on the Uno
-    mpuIntStatus0 = mpuStatic.getIntStatus();
-    // get expected DMP packet size for later comparison
-    packetSize0 = mpuStatic.dmpGetFIFOPacketSize();
+    int intPin = i + 2;
+    Serial.print(F("Enabling interrupt detection on MPU")); Serial.print(i); Serial.print(F("(Arduino external interrupt pin ")); Serial.print(intPin); Serial.println(F(" on the Uno)..."));
+    Serial.print(F("mpu")); Serial.print(i); Serial.print(F(".getInterruptDrive=  ")); Serial.println(mpus[i].getInterruptDrive());  //Current interrupt drive mode (0=push-pull, 1=open-drain)
+
+    //Intentional duplication. Interrupt routine cannot pass args.
+    if (i == 0) {
+      attachInterrupt(i, dmpDataReady0, RISING);
+    }
+    else {
+      attachInterrupt(i, dmpDataReady1, RISING);
+    }
+
+    packetSize[i] = mpus[i].dmpGetFIFOPacketSize();  // get expected DMP packet size for later comparison
     delay(1000); // Let it Stabalize
-    mpuStatic.resetFIFO(); // Clear fifo buffer
-    mpuStatic.getIntStatus();
-    mpuInterrupt0 = false; // wait for next interrupt
-  }
-  else {
-    mpuDynam.setXAccelOffset(mpuDynamOffsets[0]);
-    mpuDynam.setYAccelOffset(mpuDynamOffsets[1]);
-    mpuDynam.setZAccelOffset(mpuDynamOffsets[2]);
-    mpuDynam.setXGyroOffset(mpuDynamOffsets[3]);
-    mpuDynam.setYGyroOffset(mpuDynamOffsets[4]);
-    mpuDynam.setZGyroOffset(mpuDynamOffsets[5]);
-
-    Serial.println(F("Enabling DMP on Dyanmic MPU..."));
-    mpuDynam.setDMPEnabled(true);
-
-    // enable Arduino interrupt detection
-    Serial.println(F("Enabling interrupt detection on Dynamic MPU (Arduino external interrupt pin 3 on the Uno)..."));
-    Serial.print(F("mpuDynam.getInterruptDrive=  ")); Serial.println((mpuDynam.getInterruptDrive()));
-    attachInterrupt(1, dmpDataReady1, RISING); //pin 3 on the Uno
-    mpuIntStatus1 = mpuDynam.getIntStatus();
-    // get expected DMP packet size for later comparison
-    packetSize1 = mpuDynam.dmpGetFIFOPacketSize();
-    delay(1000); // Let it Stabalize
-    mpuDynam.resetFIFO(); // Clear fifo buffer
-    mpuDynam.getIntStatus();
-    mpuInterrupt1 = false; // wait for next interrupt
-  }
-
-}
-
-
-
-// ================================================================
-// ===                    MPU DMP Get Data                      ===
-// ================================================================
-void GetDMP(int dmpMPU) { // Best version I have made so far
-  //Serial.println("dmpMPU");
-  // Serial.println(F("FIFO interrupt at:"));
-  // Serial.println(micros());
-
-  if (dmpMPU == 0) {
-    static unsigned long LastGoodPacketTime;
-    mpuInterrupt0 = false;
-    FifoAlive0 = 1;
-    fifoCount0 = mpuStatic.getFIFOCount();
-    if ((!fifoCount0) || (fifoCount0 % packetSize0)) { // we have failed Reset and wait till next time!
-      digitalWrite(LED_PIN, LOW); // lets turn off the blinking light so we can see we are failing.
-        mpuStatic.resetFIFO();// clear the buffer and start over
+    mpus[i].resetFIFO(); // Clear fifo buffer
+    mpuInterrupt[i] = false; // wait for next interrupt
+
+  }
+
+}
+
+
+
+/**
+ * GetDMP Reads the data from our MPUs and stores it in each mpus instance.
+ * =============================================================
+ *
+ * @author Modified by Mike Muscato to enable dual MPU configuration
+ * @date   2017-07-04
+ *
+ */
+void GetDMP() {
+
+  for (int i = 0; i < 2; i++) {
+    mpuInterrupt[i] = false;
+    FifoAlive[i] = 1;
+    fifoCount[i] = mpus[i].getFIFOCount();
+
+    if ((!fifoCount[i]) || (fifoCount[i] % packetSize[i])) { // we have failed Reset and wait till next time!
+      digitalWrite(LED_PIN, LOW); // lets turn off the blinking LED so we can see we are failing.
+        mpus[i].resetFIFO();// clear the buffer and start over
     }
     else {
-      while (fifoCount0  >= packetSize0) { // Get the packets until we have the latest!
-          mpuStatic.getFIFOBytes(fifoBuffer0, packetSize0); // lets do the magic and get the data
-          fifoCount0 -= packetSize0;
+      while (fifoCount[i]  >= packetSize[i]) { // Get the packets until we have the latest!
+          mpus[i].getFIFOBytes(fifoBuffer[i], packetSize[i]); // lets do the magic and get the data
+          fifoCount[i] -= packetSize[i];
       }
-      LastGoodPacketTime = millis();
-      MPUMath(dmpMPU); // <<<<<<<<<<<<<<<<<<<<<<<<<<<< On success MPUMath() <<<<<<<<<<<<<<<<<<<
-      digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Blink the Light
     }
-  }
-  else {
-    static unsigned long LastGoodPacketTime;
-    mpuInterrupt1 = false;
-    FifoAlive1 = 1;
-    fifoCount1 = mpuDynam.getFIFOCount();
-    if ((!fifoCount1) || (fifoCount1 % packetSize1)) { // we have failed Reset and wait till next time!
-      digitalWrite(LED_PIN, LOW); // lets turn off the blinking light so we can see we are failing.
-        mpuDynam.resetFIFO();// clear the buffer and start over
-    }
-    else {
-      while (fifoCount1  >= packetSize1) { // Get the packets until we have the latest!
-          mpuDynam.getFIFOBytes(fifoBuffer1, packetSize1); // lets do the magic and get the data
-          fifoCount1 -= packetSize1;
-      }
-      LastGoodPacketTime = millis();
-      MPUMath(dmpMPU); // <<<<<<<<<<<<<<<<<<<<<<<<<<<< On success MPUMath() <<<<<<<<<<<<<<<<<<<
-      digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Blink the Light
-    }
-  }
-}
-
-
-// ================================================================
-// ===                        MPU Math                          ===
-// ================================================================
-void MPUMath(int mathMPU) {
-  //Serial.println("mathMPU");
-  if (mathMPU == 0) {
-    mpuStatic.dmpGetQuaternion(&q0, fifoBuffer0);
-    mpuStatic.dmpGetGravity(&gravity0, &q0);
-    mpuStatic.dmpGetYawPitchRoll(ypr0, &q0, &gravity0);
-
-    // Add 90-degrees to center servos when sensor is level (e.g. 0 degrees)
+  }
+
+  MPUMath(); // Successful!  Do the math and show angles from both MPUs
+  digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Blink the LED on each cycle
+
+}
+
+
+
+/**
+ * MPUMath Calculates angles of MPUs from raw sensor data
+ * =============================================================
+ *
+ * @author Modified by Mike Muscato to enable dual MPU configuration
+ * @date   2017-07-04
+ *
+ */
+void MPUMath() {
+  for (int i = 0; i < 2; i++) {
+    // Get the raw data from the sensor
+    mpus[i].dmpGetQuaternion(&q, fifoBuffer[i]);
+    mpus[i].dmpGetGravity(&gravity, &q);
+    mpus[i].dmpGetYawPitchRoll(ypr, &q, &gravity);
+
+    // Calculate readable angles
+    // Adds 90-degrees to center servos when sensor is level (e.g. 0 degrees)
     // TODO: Move the +90 gyro/servo leveling magic number to another method,
     // ...it doesn't belong here and will cause readability problems later.
-    Yaw = (ypr0[0] * 180.0 / M_PI) + 90;
-    Pitch = (ypr0[1] *  180.0 / M_PI) + 90;
-    Roll = (ypr0[2] *  180.0 / M_PI) + 90;
-  }
-  else {
-    mpuDynam.dmpGetQuaternion(&q1, fifoBuffer1);
-    mpuDynam.dmpGetGravity(&gravity1, &q1);
-    mpuDynam.dmpGetYawPitchRoll(ypr1, &q1, &gravity1);
-
-    // Add 90-degrees to center servos when sensor is level (e.g. 0 degrees)
-    // TODO: Move the +90 gyro/servo leveling magic number to another method,
-    // ...it doesn't belong here and will cause readability problems later.
-    Yaw = (ypr1[0] * 180.0 / M_PI) + 90;
-    Pitch = (ypr1[1] *  180.0 / M_PI) + 90;
-    Roll = (ypr1[2] *  180.0 / M_PI) + 90;
-  }
-
-
-  Serial.print(F("\tValues for MPU :"));Serial.print(mathMPU);
-  Serial.print(F("\tYaw:"));Serial.print(Yaw);
-  Serial.print(F("\tPitch:"));Serial.print(Pitch);
-  Serial.print(F("\tRoll:"));Serial.println(Roll);
-
-  // Serial.print the current actual values of the gyro position.
-//  DPRINTSTIMER(100) {
-//    DPRINTSFN(15, "\tValues for MPU :", mathMPU, 6, 1);
-//    DPRINTSFN(15, "\tYaw:", Yaw, 6, 1);
-//    DPRINTSFN(15, "\tPitch:", Pitch, 6, 1);
-//    DPRINTSFN(15, "\tRoll:", Roll, 6, 1);
-//    DPRINTLN();
-//  }
-
-
-/*
-  // Timer - don't try and move the servos too frequently, they need time to get to the current position.
-  // TODO: Remove delay magic number and move to global var for tuning mechanical
-  if (currentMillis >= prevMillis + 15) {
-    moveServos(round(Yaw), round(Pitch));
-  }
-*/
-
-}
-
+    Yaw = (ypr[0] * 180.0 / M_PI) + 90;
+    Pitch = (ypr[1] *  180.0 / M_PI) + 90;
+    Roll = (ypr[2] *  180.0 / M_PI) + 90;
+
+    //TODO: Add YPR values to temp var for each MPU, so that we can diff them.
+
+    // Serial.print the current angle values of the gyro position.
+    // DPRINTSTIMER(x) argument is the number of milliseconds between print events
+    // Smaller numbers give more reliable switching between MPU 0 an 1 but seem to cause crashing (Buffer overrun?)
+    //    DPRINTSTIMER(1) {
+    //      DPRINTSFN(15, "\tValues for MPU :", i, 6, 1);
+    //      DPRINTSFN(15, "\tYaw:", Yaw, 6, 1);
+    //      DPRINTSFN(15, "\tPitch:", Pitch, 6, 1);
+    //      DPRINTSFN(15, "\tRoll:", Roll, 6, 1);
+    //      DPRINTLN();
+    //    }
+
+  }
+
+    // Timer - don't try and move the servos too frequently, they need time to get to the current position.
+    // TODO: Remove delay magic number and move to global var for tuning mechanical response
+    if (currentMillis >= prevMillis + 15) {
+      moveServos(round(Yaw), round(Pitch)); // TODO:  Change these values to the new diff'd values.
+    }
+}

 /**
  * Move the servos to the current gyro postion
@@ -383,6 +315,7 @@
   int invertedYaw = map(servoYaw, 0, 179, 179, 0);

   // Prevent the servos from panning farther than my head can rotate.
+  // May not be necessary after adding 2nd gyro and using relative angles.
   if (invertedYaw > maxYaw) {
     invertedYaw = maxYaw;
   }
@@ -391,6 +324,7 @@
   }

   // Prevent the servos from tilting farther than my head can nod.
+  // May not be necessary after adding 2nd gyro and using relative angles.
   if (servoPitch > maxPitch) {
     servoPitch = maxPitch;
   }
@@ -399,16 +333,16 @@
   }

   // Print out the current yaw and pitch angle values being sent to the servos.
-  DPRINTSTIMER(100) {
-    DPRINTSFN(15, "\tServo - Yaw:", servoYaw, 6, 1);
-    DPRINTSFN(15, "\tServo - invertYaw:", invertedYaw, 6, 1);
-    DPRINTSFN(15, "\tPitch:", servoPitch, 6, 1);
-    DPRINTLN();
-  }
+  //  DPRINTSTIMER(100) {
+  //    DPRINTSFN(15, "\tServo - Yaw:", servoYaw, 6, 1);
+  //    DPRINTSFN(15, "\tServo - invertYaw:", invertedYaw, 6, 1);
+  //    DPRINTSFN(15, "\tPitch:", servoPitch, 6, 1);
+  //    DPRINTLN();
+  //  }

   // Move the servos to the current yaw/pitch values
-  //yawServo.write(invertedYaw);
-  //pitchServo.write(servoPitch);
+  yawServo.write(invertedYaw);
+  pitchServo.write(servoPitch);

   // Reset the timer for comparison on the next loop
   prevMillis = currentMillis;
@@ -427,15 +361,14 @@
  * @return {void}
  */
 void setup() {
-  Serial.begin(115200);
+  Serial.begin(38400);
   while (!Serial);  // Wait for the connection to be established?

   // Run MPU initializations
   Serial.println(F("i2cSetup"));
   i2cSetup();
-  Serial.println(F("MPU6050Connect"));
-  MPU6050Connect(0);
-  MPU6050Connect(1);
+  Serial.println(F("MPU6050 Connection Routine"));
+  MPU6050Connect();
   Serial.println(F("Setup complete"));

   pinMode(LED_PIN, OUTPUT);
@@ -444,7 +377,7 @@
   yawServo.attach(9);
   pitchServo.attach(10);

-  // Center the servos' start position
+  // Center the servo start positions
   yawServo.write(90);
   pitchServo.write(90);
 }
@@ -463,16 +396,9 @@
 void loop() {
   currentMillis = millis();   // Capture the latest value of millis()

-
-    if (mpuInterrupt0) { // Wait for MPU interrupt or extra packet(s) available
-      GetDMP(0);
-    }
-
-    if (mpuInterrupt1) { // Wait for MPU interrupt or extra packet(s) available
-      GetDMP(1);
-    }
-
-
+  if (mpuInterrupt[0] && mpuInterrupt[1]) { // Wait for MPU interrupt or extra packet(s) available on both MPUs
+    GetDMP();
+  }

   // Uncomment for setting and adjusting the hardware start position.
   // (e.g. Setting rotation and leveling the pan/tilt servo arms at initial 90-degree position)


Fixing a bug caused by changing the RTC Lib.

The bug was silly, I didn't change the previously used array of datetime to use the new library's object.

--- Ned.ino
+++ Ned.ino
@@ -1,7 +1,10 @@
 /*
 This code below was written by Muntadhar Haydar (@mrmhk97).
 As of March 18, 2017.
-Last Modification was on March 19, 2017.
+March 19, 2017:
+-Changing RTC Library.
+March 20, 2017:
+-Fixing a bug caused by changing the RTC Lib.

 TODO::
 Implement Auto/Manual Control modes for development, debugging and presenting.
@@ -19,7 +22,7 @@
 #define LONGITUDE 32.011302

 //Comment the next definition unless debugging or developing.
-//#define DEBUG
+#define DEBUG

 unsigned long timer; //TODO:: Add something!
 int datetime[6]; //An array to store the Datetime.
@@ -66,6 +69,10 @@
 void CalculateSunTimes()
 {
     Time time = rtc.time();
+    #ifdef DEBUG
+    sprintf(buffer, "Datetime: %02d/%02d/%d %02d:%02d:%02d\n", time.date, time.mon, time.yr, time.hr, time.min, time.sec); //Print the times for debugging.
+    Serial.print(buffer);
+    #endif
     int t; //An integer used to see if there is a result from Sunrise Lib.
     byte Times[4] = { 0, 0, 0, 0 }; //0: Sunrise hour, 1: minute, 2: Sunset hour, 3: minute.
     t = mySunrise.Rise(time.mon, time.date); //Attempt to calculate sunrise time.
@@ -83,14 +90,16 @@
     }
     else { /*Either Pole*/ }

-    int currentMinutes = datetime[4] + (datetime[3] * 60); //converting it into minutes makes easier to compare.
-    isItDayTime = currentMinutes > (Times[0] * 60) + Times[1] && currentMinutes < (Times[2] * 60) + Times[3];
+    int currentClock = time.min + (time.hr * 100); //converting it into minutes makes easier to compare.
+    isItDayTime = currentClock > (Times[0] * 100) + Times[1] && currentClock < (Times[2] * 100) + Times[3];
     /*
     i.e.
-    if current minutes, aka time as of now, is greater than Sunrise time and lesser than Sunset time then it's Day time, and night if it is not.
+    if currentClock, aka time as of now, is greater than Sunrise time AND lesser than Sunset time then it's Day time, and night if it is not.
     */
     WriteOutput(!isItDayTime);
     #ifdef DEBUG
+    sprintf(buffer, "Datetime minutes: %d, Sunrise minutes: %d, Sunset minutes %d\n", currentClock, (Times[0] * 100) + Times[1], (Times[2] * 100) + Times[3]); //Print the times for debugging.
+    Serial.print(buffer);
     sprintf(buffer, "As of %02d/%02d, approximately, sun rises at %02d:%02d and sets at %02d:%02d\n", time.date, time.mon, Times[0], Times[1], Times[2], Times[3]); //Print the times for debugging.
     Serial.print(buffer);
     #endif
@@ -107,5 +116,4 @@
     digitalWrite(i, level);
     i += i == 9 ? 4 : 1;
   }
-}
-
+}


fixed compile errors

fixed compile errors

--- human-readable_testbed/human-readable_testbed.ino
+++ human-readable_testbed/human-readable_testbed.ino
@@ -1,13 +1,27 @@
-void func*[] tests;
+typedef int (*testFunction)();
+
+const int numberOfTests = 1;
+
+testFunction tests[numberOfTests];
+
+int smokeTest() {
+  return 0;
+}

 void setup () {
-  // init pins
-
-  // register tests
-
+  return;
 }

-void smokeTest() {
-
+void registerTests() {
+  tests[0] = &smokeTest;
 }

+int main() {
+  static int testResults[numberOfTests];
+  setup();
+  registerTests();
+  for (int i = sizeof(tests); i > 0; i--) {
+    testResults[i] = tests[i]();
+  }
+  return testResults[0];
+}


Update Example_1.ino

Update Example_1.ino

--- firmware/examples/Example_1.ino
+++ firmware/examples/Example_1.ino
@@ -1,7 +1,7 @@
 // This #include statement was automatically added by the Particle IDE.
 #include "ncd_gateway/ncd_gateway.h"

-int testRelay(String arg)
+int testRelay(String arg);
 //S3B module;

 byte receiveBuffer[256];


FIx ESP32 compilation

FIx ESP32 compilation

--- wled00/wled00.ino
+++ wled00/wled00.ino
@@ -90,7 +90,7 @@
  #endif

 //version code in format yymmddb (b = daily build)
-#define VERSION 2001262
+#define VERSION 2001281

 char versionString[] = "0.9.0-b2";

@@ -535,7 +535,9 @@
     if (!offMode) strip.service();
   }
   yield();
+  #ifdef ESP8266
   MDNS.update();
+  #endif
   if (millis() - lastMqttReconnectAttempt > 30000) initMqtt();

   //DEBUG serial logging


Now throws failure at start for wrong pixelcount

--- BiblioPixelSerialReceiver.ino
+++ BiblioPixelSerialReceiver.ino
@@ -65,6 +65,13 @@
     };
 }

+typedef struct __attribute__((__packed__))
+{
+	uint8_t type;
+	uint16_t pixelCount;
+	uint8_t spiSpeed;
+} config_t;
+
 uint16_t numLEDs = NUM_LEDS;
 uint8_t bytesPerPixel = 3;

@@ -170,9 +177,30 @@
         }
         else if (cmd == CMDTYPE::SETUP_DATA)
         {
-            for(int i=0; i<size; i++) Serial.read();
-            // Just succeed. Config is hardcoded at compile time
-            Serial.write(RETURN_CODES::SUCCESS);
+            // for(int i=0; i<size; i++) Serial.read();
+
+            uint8_t result = RETURN_CODES::SUCCESS;
+            config_t temp;
+
+            if (size != sizeof(config_t))
+            {
+                result = RETURN_CODES::ERROR_SIZE;
+            }
+            else
+            {
+                size_t read = Serial.readBytes((char*)&temp, sizeof(config_t));
+                if (read != size)
+                {
+                    result = RETURN_CODES::ERROR_SIZE;
+                }
+                else
+                {
+                    if(temp.pixelCount / bytesPerPixel != NUM_LEDS)
+                        result = RETURN_CODES::ERROR_PIXEL_COUNT;
+                }
+            }
+
+            Serial.write(result);
         }
         else if (cmd == CMDTYPE::BRIGHTNESS)
         {


Added first try to adjust these motors

Added first try to adjust these motors

--- tests/baseTest/baseTest.ino
+++ tests/baseTest/baseTest.ino
@@ -83,10 +83,10 @@
 void ajustaMotor(){
   if(motoresAtivados){
     if(contaDireita > contaEsquerda){
-
+      pwmEsquerda += kpEsquerda * (contaDireita - contaEsquerda);
     }
-    else if(contaEsq){
-
+    else if(contaEsquerda > contaDireita){
+      pwmDireita += kpDireita * (contaEsquerda - contaDireita);
     }

     ACELERA_DIREITA(pwmDireita);


Fix MAC address according to rules

Fix MAC address according to rules

--- net_th_meter/net_th_meter.ino
+++ net_th_meter/net_th_meter.ino
@@ -63,7 +63,7 @@
 float dsT[ONE_WIRE_CNT] = { EMPTY_VAL, EMPTY_VAL, EMPTY_VAL };

 // Ethernet
-const byte mac[] = { 0xAB, 0xB6, 0xAA, 0x43, 0xA5, 0x9D };
+const byte mac[] = { 0x0B, 0xB6, 0xAA, 0x43, 0xA5, 0x9D };
 IPAddress ip(192, 168, 1, 8);
 EthernetServer server = EthernetServer(TCP_PORT);
 EthernetClient client;


Added warning when user tries to compile FSKModem example

--- examples/FSKModem/FSKModem.ino
+++ examples/FSKModem/FSKModem.ino
@@ -70,7 +70,7 @@
     while (true);
   }

-  #error "This sketch is just an API guide! Read the note at line 6."
+  #warning "This sketch is just an API guide! Read the note at line 6."
 }

 void loop() {


Try to fix the throttle position

Try to fix the throttle position

--- Event_Printer/Event_Printer.ino
+++ Event_Printer/Event_Printer.ino
@@ -105,12 +105,14 @@
         {
           case MSG_ID_BMSK_Control_Module:
           {
-            new_value = K25_THROTTLE_PERCENTAGE(data[1]);
-            if ( new_value != motorcycle_state.throttle_position )
+              /*
+            float new_throttle = K25_THROTTLE_PERCENTAGE(data[1]);
+            if ( new_throttle != motorcycle_state.throttle_position )
             {
                 status_changed = true;
-                motorcycle_state.throttle_position = (K25_Throttle_Position_t)new_value;
+                motorcycle_state.throttle_position = (K25_Throttle_Position_t)new_throttle;
             }
+            */

             new_value = LO_NIBBLE(data[4]);
             if ( new_value != motorcycle_state.clutch )


Begin adding non-Teensy USB MIDI support

Add header and declaration changes to use the Leonardo / Pro Micro
MIDI library, including USB support.

Those libraries don't seem to have flush support... #ifdef out for
now.

--- MidiController.ino
+++ MidiController.ino
@@ -1,4 +1,15 @@
 #include <MIDI.h>
+#ifndef CORE_TEENSY // Leonardo/Pro Micro USB MIDI library
+#include <midi_UsbTransport.h>
+
+static const unsigned sUsbTransportBufferSize = 16;
+typedef midi::UsbTransport<sUsbTransportBufferSize> UsbTransport;
+
+UsbTransport sUsbTransport;
+
+MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, usbMIDI); // USB
+MIDI_CREATE_DEFAULT_INSTANCE(); // Serial
+#endif // CORE_TEENSY

 #include <Bounce2.h>

@@ -357,9 +368,10 @@
     PinState[pinNum] = NewState[pinNum];
   }

-  // Send any queued USB MIDI data
+#ifdef CORE_TEENSY  // Send any queued USB MIDI data
   usbMIDI.send_now();
   USE_SERIAL_PORT.flush(); // Serial port underlying MIDI library
+#endif

   delay(1); // Don't send too quickly.  FIXME do something more?
 }


Multiplayer fix

Multiplayer fix

--- RC_Transmitter.ino
+++ RC_Transmitter.ino
@@ -8,7 +8,7 @@
 // -Value changes are stored in EEPROM, individually per vehicle
 // NRF24L01+PA+LNA SMA radio modules with power amplifier are supported from board version 1.1

-const float codeVersion = 1.21; // Software revision
+const float codeVersion = 1.22; // Software revision
 const float boardVersion = 1.0; // Board revision (MUST MATCH WITH YOUR BOARD REVISION!!)

 //
@@ -181,7 +181,7 @@
   else radio.setPALevel(RF24_PA_MAX); // Independent NRF24L01 3.3 PSU, so "FULL" transmission level allowed

   radio.setDataRate(RF24_250KBPS);
-  radio.setAutoAck(true);                  // Ensure autoACK is enabled
+  radio.setAutoAck(pipeOut[vehicleNumber - 1], true); // Ensure autoACK is enabled
   radio.enableAckPayload();
   radio.enableDynamicPayloads();
   radio.setRetries(5, 5);                  // 5x250us delay (blocking!!), max. 5 retries
@@ -500,8 +500,8 @@
     }
   }

-  // if the transmission was not confirmed (from the receiver) after > 200ms...
-  if (millis() - previousSuccessfulTransmission > 200) {
+  // if the transmission was not confirmed (from the receiver) after > 1s...
+  if (millis() - previousSuccessfulTransmission > 1000) {
     greenLED.on();
     transmissionState = false;
     memset(&payload, 0, sizeof(payload)); // clear the payload array, if transmission error


update light two

update light two

Former-commit-id: afd99ec9a730cedcadc9c7ee5a40384f135573d1

--- LED-control/LED_control/firmware/LightBrick_Jeremy/LightBrick_Jeremy.ino
+++ LED-control/LED_control/firmware/LightBrick_Jeremy/LightBrick_Jeremy.ino
@@ -9,11 +9,11 @@
 #define WIRELESS_MODE_INFRA	1
 #define WIRELESS_MODE_ADHOC	2

-#define light_number 7
+#define light_number 8

 // Wireless configuration parameters ----------------------------------------
-unsigned char local_ip[] = {192,254,42,209}; // IP address of WiShield
-unsigned char gateway_ip[] = {192,254,42,208};	// router or gateway IP address
+unsigned char local_ip[] = {192,168,0,4}; // IP address of WiShield
+unsigned char gateway_ip[] = {192,168,0,1};	// router or gateway IP address
 unsigned char subnet_mask[] = {255,255,255,0};	// subnet mask for the local network
 char ssid[] = "moodL";		// max 32 bytes


Populated all the pin's attributes into the JSON string for every pin.

--- ServerSketch/ServerSketch.ino
+++ ServerSketch/ServerSketch.ino
@@ -581,7 +581,7 @@
   system("/home/root/startAP");

   // Init Galileo HW
-
+
   // Enable all digital pins as outputs
   for(int i=0; i<14; i++)
   {
@@ -611,6 +611,9 @@
     g_abD[i] = false;
   for(i=0; i<TOTAL_NUM_Px; i++)
     g_aiP[i] = 0;
+
+  // JSON protocol code
+  initBoardState();

   Serial.println("Starting WebSocket");
   initWebsocket();
@@ -724,15 +727,44 @@
   poStatus = aJson.createItem("OK");

   // Create PINS
-  //aJson.addItemToObject(poItem, "analog", poPin13);
-  //aJson.addItemToObject(poPins,"13",poPins);
-
-  int iaPinConnects[10];
-
-
+  int iaPinConnects[TOTAL_NUM_OF_PINS];
   char caPinNumBuffer[10];
-  for(int i=0; i<TOTAL_NUM_OF_PINS ;i++)
-  {
+//  for(int i=0; i<TOTAL_NUM_OF_PINS ;i++)
+  for(int i=0; i<1 ;i++)
+  {
+    aJson.addItemToObject(apoPin[i],"label", aJson.createItem( g_aPins[i].label ) );
+
+    // Populate the pin's type
+    if( g_aPins[i].is_analog )
+    {
+      aJson.addItemToObject(apoPin[i],"is_analog", aJson.createTrue() );
+    }
+    else
+    {
+        aJson.addItemToObject(apoPin[i],"is_analog", aJson.createFalse() );
+    }
+
+    // Populate the pin's direction
+    if( g_aPins[i].is_input )
+    {
+      aJson.addItemToObject(apoPin[i],"is_input", aJson.createTrue() );
+    }
+    else
+    {
+        aJson.addItemToObject(apoPin[i],"is_input", aJson.createFalse() );
+    }
+
+    // Populate pin's value
+    aJson.addItemToObject(apoPin[i],"value", aJson.createItem( g_aPins[i].value ) );
+
+    // TO DO - Add pin connections array
+    aJson.addItemToObject(apoPin[i],"connections", aJson.createIntArray(iaPinConnects,0) );
+
+    // Push to JSON structure
+    sprintf(caPinNumBuffer,"%d",i);
+    aJson.addItemToObject(poPins,caPinNumBuffer,apoPin[i]);
+
+    /*
     aJson.addItemToObject(apoPin[i],"label", aJson.createItem("None") );
     aJson.addItemToObject(apoPin[i],"is_analog", aJson.createFalse() );
     aJson.addItemToObject(apoPin[i],"is_input", aJson.createFalse() );
@@ -740,14 +772,21 @@
     aJson.addItemToObject(apoPin[i],"connections", aJson.createIntArray(iaPinConnects,0) );
     sprintf(caPinNumBuffer,"%d",i);
     aJson.addItemToObject(poPins,caPinNumBuffer,apoPin[i]);
-  }
-
-
-//  poItem = aJson.createItem("Value13");
-//  aJson.addItemToObject(poPins,"13",poItem);
-
-
-// poPins =   aJson.createItem("20"); // THIS WORKS
+    */
+  }
+
+/*
+typedef struct Pin {
+  char label[PIN_LABEL_SIZE];
+  boolean is_analog;
+  boolean is_input;
+  float value;
+  boolean connections[TOTAL_NUM_OF_PINS];
+} Pin;
+
+Pin g_aPins[TOTAL_NUM_OF_PINS];
+*/
+

   // Create CONNECTIONS
   int iaConnections[10];


Update comments

Update comments

Has more detailed information on how the data printing function works

--- EPROM_Dumper/EPROM_Dumper.ino
+++ EPROM_Dumper/EPROM_Dumper.ino
@@ -40,20 +40,20 @@
 void print_data(bool full_data)
 {

-  if(full_data)
+  if(full_data) //If data option is 1 (TRUE)
   {
-    Serial.print(PINL, HEX);
-    Serial.print(" ");
-    Serial.print(PORTC, BIN);
-    Serial.print(" ");
-    Serial.print(PORTA, BIN);
+    Serial.print(PINL, HEX);    //Print data received from L register pins
+    Serial.print(" ");          //Print a space
+    Serial.print(PORTC, BIN);   //Print Upper Address
+    Serial.print(" ");          //Print a space
+    Serial.print(PORTA, BIN);   //Print Lower Address
     Serial.print("\n");

   }
-  else
+  else                          //If data option is 0 (FALSE)
   {
-    Serial.print(PINF, HEX);
-    Serial.print(" ");
+    Serial.print(PINF, HEX);    //Print data received from L register pins
+    Serial.print(" ");          //Print space
   }
 }


Update comments to mention Trinket

Update comments to mention Trinket

--- dee-oh-tee.ino
+++ dee-oh-tee.ino
@@ -1,6 +1,9 @@
 /**
- * A simple library for drawing fun shapes with a laser that's attached to a pan/tilt
+ * A simple sketch for drawing fun shapes with a laser that's attached to a pan/tilt
  * servo. (Cat not included.)
+ *
+ * This sketch is designed for the Trinket microcontroller, which is Arduino-compatible
+ * and made by Adafruit. It should be easily portable to any Arduino platform.
  *
  * This type of servo works on angles, but I find it easier to think in Cartesian
  * coordinates. Most of the functions in this library take x- and y-coordinates. The


initialise_pwr_src_select

--- _09_ir_tx_rx/_09_ir_tx_rx.ino
+++ _09_ir_tx_rx/_09_ir_tx_rx.ino
@@ -45,7 +45,6 @@

 // IR
 #define maxLen 800
-
 volatile  unsigned int irBuffer[maxLen]; //stores timings - volatile because changed by ISR
 volatile unsigned int x = 0; //Pointer thru irBuffer - volatile because changed by ISR

@@ -226,20 +225,48 @@
   */
 }

+
+boolean initialise_pwr_src_select()
+{
+  irrecv.resume();
+  while(irrecv.decode(&results) != 1 ) { }
+
+  switch (results.value) {
+    case 0xFF02FD:
+        return True;
+        break;
+    case 0xFF9867:
+        return False;
+        break;
+    default:
+        initialise_pwr_src_select();
+        break;
+  }
+}
+
 void run_initialise_setup() {

   decode_results results;

   lcd.clear();
   lcd.setCursor(0, 0);
-  lcd.print("setup :");
+  lcd.print("Setup :");
   lcd.setCursor(0, 1);
-  lcd.print("press any button");
-
+  lcd.print("Press any button");
+
+  irrecv.resume();
   while(irrecv.decode(&results) != 1 ) { }

-  lcd.setCursor(0, 0);
-  lcd.print('s');
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print('Select pwr src :');
+  lcd.setCursor(0, 1);
+  lcd.print("ON: TV OFF: USB");
+
+  boolean pwrSrc = initialise_pwr_src_select();
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print(pwrSrc);

 /*


remore scale.tare() in loop

remore scale.tare() in loop

--- _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
+++ _03-hx711-scale/_03-hx711-scale-v3-adaptor/_03-hx711-scale-pro-mini/_03-hx711-scale-pro-mini.ino
@@ -9,7 +9,6 @@
 const int nemoisonPin = 9;
 volatile int measured = 0;
 volatile int tosend   = 0;
-int nofchecked = 0;
 long startMills;

 void setup()
@@ -38,7 +37,15 @@
 void loop()
 {
   measured = int( scale.get_units(10) * 1000 );
-  if ( measured < 0 ) { measured = 0; }
+
+  if ( DEBUG_OUT ) {
+    Serial.print((millis() - startMills) * 0.001, 2);
+    Serial.print(" : ");
+    Serial.println(measured);
+  }
+
+  if (( measured < 0 ) || ( measured > 7000 )){ measured = 0; }
+
   tosend = measured;

   if ( measured > 500 )
@@ -46,18 +53,9 @@
     digitalWrite(nemoisonPin, HIGH);
   } else {
     digitalWrite(nemoisonPin, LOW);
-    if ( nofchecked > 600 ) {
-      nofchecked = 0;
-      scale.tare();
     }
   }

-  if ( DEBUG_OUT ) {
-    Serial.print((millis() - startMills) * 0.001, 2);
-    Serial.print(" : ");
-    Serial.println(measured);
-  }
-  nofchecked++;
   delay(200);
 }


Update quarterturn_withinterrupt.ino

Update quarterturn_withinterrupt.ino

--- encoder/quarterturn_withinterrupt.ino
+++ encoder/quarterturn_withinterrupt.ino
@@ -49,9 +49,7 @@
      - Falling-edge detection (5->0V): CS12 = CS11 = 1, CS10 = 0; or
      - Rising-edge detection (0->5V): CS12 = CS11 = CS10 = 1

-     When TCNT1 reaches a value of 125 (=1/4 turn on the motor for a 500 count encoder) an if-statement causes the LED on the Arduino to flash and we reset TCNT1 to 0.
-
-     Note that this implementation avoids using an interrupt service routine (ISR) -> see equivalent example for interrupt version
+     When TCNT1 reaches a value of 125 (=1/4 turn on the motor for a 500 count encoder) the interrupt service routine (ISR) is called and TCNT1 is reset to zero
 */

 void setup() {


Forgot to save Sketch. I'm committing this just to make sure we don't loose anything.

--- ServerSketch/ServerSketch.ino
+++ ServerSketch/ServerSketch.ino
@@ -123,7 +123,7 @@
     Serial.print("Value: ");
     Serial.println(String(iValue));
     g_aiP[iPin] = iValue; // Toggle state
-    analogWrite(iPin, g_abD[iPin]); // Set state
+    analogWrite(iPin, g_aiP[iPin]); // Set state
   }
   else
   {
@@ -480,8 +480,15 @@
   for(int i=0; i<14; i++)
   {
     pinMode(i, OUTPUT);
-    digitalWrite(i, LOW);
-  }
+  }
+
+  // Init pins
+  digitalWrite(0, LOW);digitalWrite(1, LOW);digitalWrite(2, LOW);
+  digitalWrite(4, LOW);digitalWrite(7, LOW);digitalWrite(8, LOW);
+  digitalWrite(12, LOW);digitalWrite(13, LOW);
+
+  analogWrite(3, 0);analogWrite(5, 0);analogWrite(6, 0);
+  analogWrite(9, 0);analogWrite(10, 0);analogWrite(11, 0);

   // Init pin state variables
   int i=0;


Update SW01_Temperature_Measurement.ino

Update SW01_Temperature_Measurement.ino

--- examples/SW01_Temperature_Measurement/SW01_Temperature_Measurement.ino
+++ examples/SW01_Temperature_Measurement/SW01_Temperature_Measurement.ino
@@ -13,11 +13,8 @@

 	The sensor communicates over the I2C Bus.

-	------------------------TIPS--------------------------
-	Comment out this line ----->Wire.pins(2, 14); for support
-	on other devices
-
 *************************************************************/
+
 #include <xCore.h>
 #include <xSW01.h>

@@ -30,7 +27,10 @@
 	Serial.begin(115200);

 	// Set the I2C Pins for CW01
-	Wire.pins(2, 14);
+	#ifdef ESP8266
+	  Wire.pins(2, 14);
+	  Wire.setClockStretchLimit(15000);
+	#endif

 	// Start the I2C Comunication
 	Wire.begin();
@@ -52,8 +52,8 @@
 	float tempF;
 	tempC = tempF = 0;

-  // Read and calculate data from SW01 sensor
-  SW01.poll();
+	// Read and calculate data from SW01 sensor
+	SW01.poll();

 	// Request SW01 to get the temperature measurement and store in
 	// the temperature variable
@@ -68,6 +68,6 @@
 	Serial.print(tempF);
 	Serial.println(" F");

-  // Small delay between sensor reads
+  	// Small delay between sensor reads
 	delay(DELAY_TIME);
 }