Optional tempo encoder on step sequencer

--- examples/OONTZ_Step_Seq/OONTZ_Step_Seq.ino
+++ examples/OONTZ_Step_Seq/OONTZ_Step_Seq.ino
@@ -29,6 +29,10 @@

 #define WIDTH     ((sizeof(T) / sizeof(T[0])) * 2)
 #define N_BUTTONS ((sizeof(T) / sizeof(T[0])) * 16)
+
+// Encoder on pins 4,5 sets tempo.  Optional, not present in
+// standard OONTZ, but won't affect things if unconnected.
+enc e(4, 5);

 uint8_t       grid[WIDTH];                 // Sequencer state
 uint8_t       heart        = 0,            // Heartbeat LED counter
@@ -64,6 +68,8 @@
   oontz.clear();
   oontz.writeDisplay();
   memset(grid, 0, sizeof(grid));
+  e.setBounds(60 * 4, 480 * 4 + 3); // Set tempo limits
+  e.setValue(bpm * 4);              // *4's for encoder detents
 }

 // Turn on (or off) one column of the display
@@ -79,6 +85,8 @@
   uint8_t       mask;
   boolean       refresh = false;
   unsigned long t       = millis();
+
+  enc::poll(); // Read encoder(s)

   if((t - prevReadTime) >= 20L) { // 20ms = min Trellis poll time
     if(oontz.readSwitches()) {    // Button state change?
@@ -125,6 +133,8 @@
     }
     prevBeatTime = t;
     refresh      = true;
+    bpm          = e.getValue() / 4; // Div for encoder detents
+    beatInterval = 60000L / bpm;
   }

   if(refresh) oontz.writeDisplay();


Update comment

Update comment

--- examples/esp8266/esp8266.ino
+++ examples/esp8266/esp8266.ino
@@ -84,15 +84,22 @@
 void handleCommand(LosantCommand *command) {
   Serial.print("Command received: ");
   Serial.println(command->name);
-
   // Optional command payload. May not be present on all commands.
   JsonObject payload = *command->payload;
-
   // Perform action specific to the command received.
   if(strcmp(command->name, "toggle") == 0) {
     toggle();
+<<<<<<< Updated upstream
     // Access values from payload
     // change the key to the specific field in the payload
+=======
+    /**
+    * In Losant, including a payload along with your
+    * command is optional. This is an example of how
+    * to parse a JSON payload from Losant and print
+    * the value of a key called "temperature".
+    */
+>>>>>>> Stashed changes
     // int temperature = payload["temperature"];
     // Serial.println(temperature);
   }
@@ -197,4 +204,4 @@
   }

   delay(100);
-}
+}


Left click is now a single method with a delay

--- arduino/clicker/clicker.ino
+++ arduino/clicker/clicker.ino
@@ -7,8 +7,8 @@
 //Clicking vars
 boolean leftClicking = false;
 int leftClickStart = 0;
-int leftClickDown = 10;
-int leftClickUp = 0;
+int leftClickDown = 3;
+int leftClickUp = 15;

 boolean rightClicking = false;
 int rightClickStart = 0;
@@ -29,14 +29,22 @@
   byte opCode = Serial.read();
   switch (opCode) {
     case 1: //Left click
-      beginLeftClick();
+      performLeftClick();
       break;
   }
  }

  if (leftClicking) {
    continueLeftClick();
+ } else {
+   leftClick.write(leftClickUp);
  }
+}
+
+void performLeftClick() {
+  leftClick.write(leftClickDown);
+  delay(80);
+  leftClick.write(leftClickUp);
 }

 void beginLeftClick() {
@@ -47,7 +55,7 @@

 void continueLeftClick() {
  leftClickStart++;
- if (leftClickStart > 100) {
+ if (leftClickStart > 2500) {
   leftClickStart = 0;
   leftClicking = false;
   leftClick.write(leftClickUp);


undo ajson test additions.

undo ajson test additions.

--- firmware/PCB_V02/PCB_V02.ino
+++ firmware/PCB_V02/PCB_V02.ino
@@ -1,6 +1,4 @@
-#include <aJSON.h>
-
- /*
+/*
 -------------------------------------------------
 | Zachary Nelson
 | znelson1@ford.com
@@ -68,8 +66,6 @@
 int motorPulse = 1;
 volatile int motorState = LOW;
 boolean motorCommand = false;
-
-aJsonStream serial_stream(&Serial);

 void setup() {
   //set pins to output so you can control the shift register
@@ -175,16 +171,6 @@
     inputString = "";
     stringComplete = false;
   }
-
-  if (serial_stream.available()) {
-    serial_stream.skip();
-  }
-
-  if (serial_stream.available()) {
-    aJsonObject *msg = aJson.parse(&serial_stream);
-
-    aJson.deleteItem(msg);
-  }
 }

 void sendDigit(int i){


Add how to send a state/air-con to IRsendDemo.ino (#594)

- Add example of how to send a typical `state[]`-type protocol.
- Remove precompiler options to make it simpler to read.

--- examples/IRsendDemo/IRsendDemo.ino
+++ examples/IRsendDemo/IRsendDemo.ino
@@ -1,6 +1,6 @@
 /* IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend.
  *
- * Version 1.0 April, 2017
+ * Version 1.1 January, 2019
  * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009,
  * Copyright 2009 Ken Shirriff, http://arcfn.com
  *
@@ -46,6 +46,10 @@
                         650, 550, 650, 550, 600, 550, 650, 550, 650, 550,
                         650, 1650, 600, 550, 650, 1650, 650, 1650, 650, 1650,
                         650, 1650, 650, 1650, 650, 1650, 600};
+// Example Samsung A/C state captured from IRrecvDumpV2.ino
+uint8_t samsungState[kSamsungAcStateLength] = {
+    0x02, 0x92, 0x0F, 0x00, 0x00, 0x00, 0xF0,
+    0x01, 0xE2, 0xFE, 0x71, 0x40, 0x11, 0xF0};

 void setup() {
   irsend.begin();
@@ -53,19 +57,16 @@
 }

 void loop() {
-#if SEND_NEC
   Serial.println("NEC");
-  irsend.sendNEC(0x00FFE01FUL, 32);
-#endif  // SEND_NEC
+  irsend.sendNEC(0x00FFE01FUL);
   delay(2000);
-#if SEND_SONY
   Serial.println("Sony");
-  irsend.sendSony(0xa90, 12, 2);
-#endif  // SEND_SONY
+  irsend.sendSony(0xa90, 12, 2);  // 12 bits & 2 repeats
   delay(2000);
-#if SEND_RAW
   Serial.println("a rawData capture from IRrecvDumpV2");
   irsend.sendRaw(rawData, 67, 38);  // Send a raw data capture at 38kHz.
-#endif  // SEND_RAW
+  delay(2000);
+  Serial.println("a Samsung A/C state from IRrecvDumpV2");
+  irsend.sendSamsungAC(samsungState);
   delay(2000);
 }


Fix several bugs with garage sensor

Fix several bugs with garage sensor

* Use an actual function for debug now
* Fix temperature always returned as an int instead of float
* Init thermometer in setup

--- home_02_garage/home_02_garage.ino
+++ home_02_garage/home_02_garage.ino
@@ -9,8 +9,17 @@
 // This reads a magnetic door sensor. At least with this style
 // the sensor is normally open and the circuit closes when the
 // two sensors are next to each other.
+//
+// Connect one wire to digital and other to ground
+//
+// TEMP421 code thanks to http://ka1kjz.com (my bookmark no longer points to the source
+// posting though, should still be on there somewhere
+// TEMP421 pinout (pins are counted if sensor is on right):
+// D - pin3
+// G - pin1
+// + - pin2
+// A - pin4

-// Connect one wire to digital and other to ground

 #include <JeeLib.h>

@@ -18,7 +27,7 @@

 // user settings
-//#define DEBUG        // Comment out to disable
+#define DEBUG false         // Set false to turn off all debugging
 const int JEELINK_ID = 1;   // Jeelink is id 1 (or 0 to broadcast)
 const int NETGROUP = 100;   // Netgroup everyone is on
 const int NODE_ID = 2;      // id of THIS node
@@ -33,28 +42,10 @@
 int batt_loop_count = 99;      // Make high so we get data first time
 int has_lowbat = false;        // Start out assuming it's fine

-// Basic macro for debugging
-// Ideally change this to a function once I figure out how to accept anything
-#ifdef DEBUG
-  #define DEBUG_PRINT(x) Serial.println(x)
-#else
-  #define DEBUG_PRINT(x)
-#endif
-
-
-// TEMP421 code thanks to http://ka1kjz.com (my bookmark no longer points to the source
-// posting though, should still be on there somewhere
-// TEMP421 pinout (pins are counted if sensor is on right):
-// D - pin3
-// G - pin1
-// + - pin2
-// A - pin4
-
 // Secong parameter that's commented out is the rate of communication
 // Can be KHZMAX (default), KHZ400, or KHZ100
 PortI2C temp_port1 (1 /*, PortI2C::KHZ400 */);
 DeviceI2C temp_dev1 (temp_port1, 0x2A);  // I2C Address of 0x2A
-

 // Currently just have sensor connected to port 4
 //int DIO1 = 1 + DIO_OFFSET;
@@ -63,8 +54,25 @@
 const int DIO4 = 4 + DIO_OFFSET;

+// Print the line to serial if debug is enabled. The delay is important
+void debug_print(String x) {
+  if (DEBUG) {
+    Serial.println(x);
+    delay(100);
+  }
+}
+
+
+// Convenience function that will take in a float and return a string
+String float2str(float val, int length) {
+  char strval[length];
+  dtostrf(val, 0, 2, strval);
+  return strval;
+}
+
+
 // Returns the temperature of tempdev where tempdev is a DeviceI2C object
-int get_temperature(DeviceI2C tempdev) {
+float get_temperature(DeviceI2C tempdev) {
   int temp_lo = 0;
   int temp_high = 0;
   float tempc = 0;
@@ -89,14 +97,18 @@

 void setup() {
-#ifdef DEBUG
-  Serial.begin(57600);
-#endif
-  DEBUG_PRINT("Initializing");
+  if (DEBUG){
+    Serial.begin(57600);
+  }
+  debug_print("Initializing");

   rf12_initialize(NODE_ID, RF12_915MHZ, NETGROUP);

-  pinMode(DIO4, INPUT_PULLUP);
+  // Do this so the initialize the thermometer (which starts at 0.00)
+  float _unused = get_temperature(temp_dev1);
+  delay(200);
+
+  pinMode(DIO4, INPUT_PULLUP);
 }

@@ -118,17 +130,17 @@
     batt_loop_count++;
   }

-#ifdef DEBUG
-  if (door_status_4 == DOOR_OPEN) {
-    DEBUG_PRINT("Door open");
+  tempc = get_temperature(temp_dev1);
+
+  if (DEBUG) {
+    if (door_status_4 == DOOR_OPEN) {
+      debug_print("Door open");
+    }
+    else {
+      debug_print("Door closed");
+    }
+    debug_print(float2str(tempc, 7));
   }
-  else {
-    DEBUG_PRINT("Door closed");
-  }
-#endif
-
-  tempc = get_temperature(temp_dev1);
-  DEBUG_PRINT(tempc);

   payload[0] = has_lowbat;
   payload[1] = int(tempc * 100);


slight refactor, get pressure units right

--- ScoutWeatherStation/scout_weather_station.ino
+++ ScoutWeatherStation/scout_weather_station.ino
@@ -49,6 +49,7 @@
 // set parameters for devices, such as i2c addresses
 // pins, etc
 //
+#define BME280_TEMP_OFFSET 0
 #define SLEEP_SECONDS 8
 #define OLED_RESET 0
 #define BME_ADDRESS 0x76
@@ -148,7 +149,7 @@
 // hpascals_to_inhg convert from pascals to inHg
 //
 float hpascals_to_inhg(float hpascals) {
-  return (hpascals * 100 * 0.00029529983071445);
+  return (hpascals * 0.00029529983071445);
 }

 ////////////////////////////////////////////////////
@@ -164,6 +165,16 @@
     Serial.println("Could not find a valid BME280 sensor, check wiring!");
     while (1);
   }
+
+//https://github.com/letscontrolit/ESPEasy/issues/164
+  sensor.setSampling(Adafruit_BME280::MODE_FORCED,
+                    Adafruit_BME280::SAMPLING_X1, // temperature
+                    Adafruit_BME280::SAMPLING_X1, // pressure
+                    Adafruit_BME280::SAMPLING_X1, // humidity
+                    Adafruit_BME280::FILTER_OFF   );
+
+
+
 #endif

 #if SENSOR == USING_BMP
@@ -219,6 +230,8 @@
   Serial.print(celsius_to_fahrenheit(temperature), 2);
   Serial.println("F");
   Serial.print("Pressure: ");
+  Serial.print(pressure);
+  Serial.println("hPa");
   Serial.print(hpascals_to_inhg(pressure));
   Serial.println("inHg");

@@ -265,7 +278,7 @@
   display.setCursor(18, 48);
   display.print("Pres: ");
   display.print(hpascals_to_inhg(pressure));
-  display.println("mmHg");
+  display.println("inHg");

 #endif // BME

@@ -273,7 +286,7 @@
   display.setCursor(18, 48);
   display.print("Pres: ");
   display.print(hpascals_to_inhg(pressure));
-  display.println("mmHg");
+  display.println("inHg");

 #endif // BMP

@@ -436,12 +449,15 @@
     humidity = sensor.readHumidity();
     temperature = sensor.readTemperature();
     // don't have pressure
-    pressure = 101325; // 1 atm, 30mmHg
+    pressure = 101325; // 1 atm, 30inHg

 #endif
 #if SENSOR == USING_BME
+    //https://www.esp8266.com/viewtopic.php?f=13&t=8030&sid=5b736d896eb9758f6ae56ce5aefbaceb&start=28
+
+    sensor.takeForcedMeasurement();
     humidity = sensor.readHumidity();
-    temperature = sensor.readTemperature();
+    temperature = sensor.readTemperature() - BME280_TEMP_OFFSET;
     pressure = sensor.readPressure();
 #endif


Ultrasonic Sensor function

Ultrasonic Sensor function

I have made the arduino send the info for the ultrasonic sensors and I
have also added the functionability of control the motors speed in
during the command line of the raspberry pi.

--- Testing_Arduino101_2/Testing_Arduino101_2.ino
+++ Testing_Arduino101_2/Testing_Arduino101_2.ino
@@ -76,11 +76,13 @@

 //------------------PINs---------------------
-#define TRIGGER_PIN1 0
-#define ECHO_PIN1 1
-
-#define TRIGGER_PIN2 2
-#define ECHO_PIN2 4
+#define TRIGGER_PIN1 A5
+#define ECHO_PIN1 2
+
+//DO NOT USE PIN 1, IT CAUSES CONSTANT ZEROS
+//DO NOT USE PIN 2 as an ECHO, IT WILL ALSO CAUSE CONSTANT ZEROS
+#define TRIGGER_PIN2 4
+#define ECHO_PIN2 A4

 #define MAX_DISTANCE 200

@@ -92,7 +94,9 @@
 #define AMOTOR 3

 #define AMOTOR_BRAKE 9
-#define BMOTOR_BRAKE 8
+#define BMOTOR_BRAKE 8
+
+#define ULTRA_FREQUENCY 10

 //------------------SENSORSs------------------
@@ -104,7 +108,7 @@

 //------------------VARIABLESs----------------
 char input;
-int servoH = 0;
+int servoH_top = 0, servoH_bottom = 0;
 long last_time = 0;
 int control = 0;
 int stop_button = 10;
@@ -126,6 +130,7 @@
     digitalWrite(BMOTOR_BRAKE, HIGH);

 }
+/*
 void move_forward(){

     digitalWrite(DIR_A, HIGH);
@@ -137,6 +142,7 @@
     digitalWrite(AMOTOR, HIGH);
     digitalWrite(BMOTOR, HIGH);
 }
+*/
 void variable_forward(){
     while(Serial.available () > 2);//wait for the motor speed info
     motor_speed[0] = Serial.parseInt();//motor A speed
@@ -158,6 +164,7 @@
     analogWrite(AMOTOR, motor_speed[0]);
     analogWrite(BMOTOR, motor_speed[1]);
 }
+/*
 void move_reverse(){
     digitalWrite(DIR_A, LOW);
     digitalWrite(DIR_B, LOW);
@@ -169,10 +176,30 @@

     digitalWrite(AMOTOR, HIGH);
     digitalWrite(BMOTOR, HIGH);
-
-}
-
-
+}
+*/
+void variable_reverse(){
+    while(Serial.available () > 2);//wait for the motor speed info
+    motor_speed[0] = Serial.parseInt();//motor A speed
+    motor_speed[1] = Serial.parseInt();//motor B speed
+
+    if(motor_speed[0] > 255){
+      motor_speed[0] = 255;
+    }
+    if(motor_speed[1] > 255){
+      motor_speed[1] = 255;
+    }
+
+    digitalWrite(DIR_A, LOW);
+    digitalWrite(DIR_B, LOW);
+
+    digitalWrite(AMOTOR_BRAKE, LOW);
+    digitalWrite(BMOTOR_BRAKE, LOW);
+
+    analogWrite(AMOTOR, motor_speed[0]);
+    analogWrite(BMOTOR, motor_speed[1]);
+}
+/*
 void move_in(){
     digitalWrite(DIR_A, HIGH);
     digitalWrite(DIR_B, LOW);
@@ -184,7 +211,29 @@
     digitalWrite(AMOTOR, HIGH);
     digitalWrite(BMOTOR, HIGH);
 }
-
+*/
+void variable_in(){
+    while(Serial.available () > 2);//wait for the motor speed info
+    motor_speed[0] = Serial.parseInt();//motor A speed
+    motor_speed[1] = Serial.parseInt();//motor B speed
+
+    if(motor_speed[0] > 255){
+      motor_speed[0] = 255;
+    }
+    if(motor_speed[1] > 255){
+      motor_speed[1] = 255;
+    }
+
+    digitalWrite(DIR_A, HIGH);
+    digitalWrite(DIR_B, LOW);
+
+    digitalWrite(AMOTOR_BRAKE, LOW);
+    digitalWrite(BMOTOR_BRAKE, LOW);
+
+    analogWrite(AMOTOR, motor_speed[0]);
+    analogWrite(BMOTOR, motor_speed[1]);
+}
+/*
 void move_out(){
     digitalWrite(DIR_A, LOW);
     digitalWrite(DIR_B, HIGH);
@@ -196,7 +245,28 @@
     digitalWrite(AMOTOR, HIGH);
     digitalWrite(BMOTOR, HIGH);
 }
-
+*/
+void variable_out(){
+    while(Serial.available () > 2);//wait for the motor speed info
+    motor_speed[0] = Serial.parseInt();//motor A speed
+    motor_speed[1] = Serial.parseInt();//motor B speed
+
+    if(motor_speed[0] > 255){
+      motor_speed[0] = 255;
+    }
+    if(motor_speed[1] > 255){
+      motor_speed[1] = 255;
+    }
+
+    digitalWrite(DIR_A, LOW);
+    digitalWrite(DIR_B, HIGH);
+
+    digitalWrite(AMOTOR_BRAKE, LOW);
+    digitalWrite(BMOTOR_BRAKE, LOW);
+
+    analogWrite(AMOTOR, motor_speed[0]);
+    analogWrite(BMOTOR, motor_speed[1]);
+}
 void stop_motor(){
     digitalWrite(DIR_A, LOW);
     digitalWrite(DIR_B, LOW);
@@ -211,11 +281,17 @@

 void us_sensor(){
-  delay(50);
-
-  ultrasonic1 = sonar1.ping_cm();
-  ultrasonic2 = sonar2.ping_cm();
-
+  int i = 0, total1 = 0, total2 = 0,ave_us1 = 0, ave_us2 = 0;
+  for(i = 0; i < ULTRA_FREQUENCY; i++){
+    total1 += sonar1.ping_cm();
+    total2 += sonar2.ping_cm();
+  }
+  ave_us1 = total1 / ULTRA_FREQUENCY;
+  ave_us2 = total2 / ULTRA_FREQUENCY;
+
+  ultrasonic1 = ave_us1;
+  ultrasonic2 = ave_us2;
+  /*
   if(ultrasonic1 < 20){
         Serial.print("1");
   }
@@ -230,28 +306,41 @@
         Serial.print("0");

   Serial.print("\n");
-  delay(50);
-
-}
+  */
+  Serial.print(ultrasonic1);
+  Serial.print('-');
+  Serial.print(ultrasonic2);
+  Serial.print("&");
+}
+
 void servo_info(){
-  Serial.println(myservo.read());
+  Serial.print(myservo.read());
+  Serial.print("--");
+  Serial.print(servoH_top);
+  Serial.print('-');
+  Serial.print(servoH_bottom);
+  Serial.print('&');
 }
 void servo_bottom(){
-  myservo.write(0);
+  myservo.write(servoH_bottom);
 }
 void servo_top(){
-  myservo.write(servoH);
-}
+  myservo.write(servoH_top);
+}
+void servo_change(){
+    while(Serial.available () > 2);//wait for the motor speed info
+    servoH_top = Serial.parseInt();//motor A speed
+    servoH_bottom = Serial.parseInt();//motor B speed
+}
+

 //------------------CODEs---------------------
 void setup() {
         Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
-
+        //Serial.println("Welcome to the Arduino Command HQ");
         myservo.attach(5);

-        enableInterrupt(stop_button, stop_motor_ALL , CHANGE);
-
-
+        enableInterrupt(stop_button, stop_motor_ALL , CHANGE);

         pinMode(AMOTOR, OUTPUT);
         pinMode(BMOTOR, OUTPUT);
@@ -259,20 +348,27 @@
         pinMode(BMOTOR_BRAKE, OUTPUT);
         pinMode(DIR_A, OUTPUT);
         pinMode(DIR_B, OUTPUT);
+

         pinMode(TRIGGER_PIN1, OUTPUT);
         pinMode(ECHO_PIN1, INPUT);
         pinMode(TRIGGER_PIN2, OUTPUT);
         pinMode(ECHO_PIN2, INPUT);
-
+
+        /*
         Serial.println(AMOTOR);
         Serial.println(BMOTOR);
         Serial.println(AMOTOR_BRAKE);
         Serial.println(BMOTOR_BRAKE);
-}
-
-void loop() {
+        */
+        delay(100);
+
+}
+
+void loop() {
+
   command();
+  //us_sensor();
 }

@@ -281,7 +377,8 @@
       if (Serial.available() > 0) {
           // read the incoming byte:
           input = Serial.read(); //single character
-
+          //Serial.print("Receieved: ");
+          //Serial.print(input);

           switch(input){
@@ -289,75 +386,84 @@
             case 'w':
               if(command_status == 1){
                 //move_forward();
+                //Serial.print("Hello1");
                 variable_forward();
               }
               break;

             case 'r':
               if(command_status == 1){
-                move_reverse();
+                //move_reverse();
+                //Serial.print("Hello2");
+                variable_reverse();
               }
               break;

             case 'o':
               if(command_status == 1){
-                move_out();
+                //move_out();
+                //Serial.print("Hello3");
+                variable_out();
               }
               break;

             case 'i':
               if(command_status == 1){
-                move_in();
+                //move_in();
+                //Serial.print("Hello4");
+                variable_in();
               }
               break;

             case 'x':
               if(command_status == 1){
+                //Serial.print("Hello5");
                 stop_motor();
               }
               break;

             case 'u':
               if(command_status == 1){
-                noInterrupts();
+                //Serial.println("Hello6");
+                //noInterrupts();
                 us_sensor();
-                interrupts();
+                //us_sensor();
+                //interrupts();
               }
               break;

             case 'n':
               if(command_status == 1){
                 servo_info();
+                //Serial.print("Hello7");
               }
               break;

             case 't':
               if(command_status == 1){
                 servo_top();
+                //Serial.print("Hello8");
               }
               break;

             case 'b':
               if(command_status == 1){
+                //Serial.print("Hello12");
                 servo_bottom();
               }
               break;

-            case 'p':
-              if(command_status == 1){
-                servoH++;
-              }
-              break;
-
-            case 'e':
-              if(command_status == 1){
-                servoH--;
-              }
-              break;
+            case 'c':
+              if(command_status == 1){
+                servo_change();
+                //Serial.print("Hello9");
+              }
             case '9':
               command_status = 1;
+              //Serial.print("Hello10");
               break;
             default:
+              //Serial.print("Hello11");
             break;
           }
       }


Fixed Cap

Fixed Cap

--- Testing_Arduino101_2/Testing_Arduino101_2.ino
+++ Testing_Arduino101_2/Testing_Arduino101_2.ino
@@ -375,16 +375,11 @@
         //Serial.println("Welcome to the Arduino Command HQ");
         myservo.attach(5);
         myservo.write(servoH_top);
-
-        //pinMode(IRA, INPUT_PULLUP);
-        //pinMode(IRB, INPUT_PULLUP);
-
-        encoder_A.init(MOTOR_393_SPEED_ROTATIONS,MOTOR_393_TIME_DELTA);
-        encoder_B.init(MOTOR_393_SPEED_ROTATIONS,MOTOR_393_TIME_DELTA);
+
+        //encoder_A.init(MOTOR_393_SPEED_ROTATIONS,MOTOR_393_TIME_DELTA);
+        //encoder_B.init(MOTOR_393_SPEED_ROTATIONS,MOTOR_393_TIME_DELTA);

         enableInterrupt(stop_button, stop_motor_ALL , CHANGE);
-        //enableInterrupt(IRA,encoderA,CHANGE);
-        //enableInterrupt(IRB,encoderB,CHANGE);

         pinMode(AMOTOR, OUTPUT);
         pinMode(BMOTOR, OUTPUT);
@@ -406,16 +401,11 @@
         Serial.println(BMOTOR_BRAKE);
         */
         delay(100);
-
-}
-
-void loop() {
-  /*Serial.print(irA_value);
-  Serial.print(" ");
-  Serial.println(irB_value);
-  analogWrite(AMOTOR, 80);
-  analogWrite(BMOTOR, 80);
-  */
+        //Serial.println("End of Setup");
+}
+
+void loop() {
+  //Serial.println("Loop");
   command();
   //us_sensor();
 }
@@ -426,31 +416,29 @@
           // read the incoming byte:
           input = Serial.read(); //single character
           //Serial.print("Receieved: ");
-          //Serial.print(input);
+          //Serial.println(input);

           switch(input){
-
             case 'w':
               if(command_status == 1){
                 //move_forward();
-                //Serial.print("Hello1");
                 variable_forward();
+                //Serial.print("Forward");
               }
               break;

             case 'r':
               if(command_status == 1){
                 //move_reverse();
-                //Serial.print("Hello2");
                 variable_reverse();
+                //Serial.print("Backward");
               }
               break;

             case 'o':
               if(command_status == 1){
                 //move_out();
-                //Serial.print("Hello3");
                 variable_out();
               }
               break;
@@ -458,21 +446,18 @@
             case 'i':
               if(command_status == 1){
                 //move_in();
-                //Serial.print("Hello4");
                 variable_in();
               }
               break;

             case 'x':
               if(command_status == 1){
-                //Serial.print("Hello5");
                 stop_motor();
               }
               break;

             case 'u':
               if(command_status == 1){
-                //Serial.println("Hello6");
                 //noInterrupts();
                 us_sensor();
                 //us_sensor();
@@ -483,34 +468,29 @@
             case 'n':
               if(command_status == 1){
                 servo_info();
-                //Serial.print("Hello7");
               }
               break;

             case 't':
               if(command_status == 1){
                 servo_top();
-                //Serial.print("Hello8");
               }
               break;

             case 'b':
               if(command_status == 1){
-                //Serial.print("Hello12");
                 servo_bottom();
               }
               break;

             case 'c':
               if(command_status == 1){
-                servo_change();
-                //Serial.print("Hello9");
+                servo_change();
               }
               break;

             case 'R':
               command_status = 1;
-              //Serial.print("Hello10");
               break;

             case 'k':
@@ -526,14 +506,18 @@
                 //Serial.print("report");
               }
               break;
+
             case 'C':
+              //Serial.print("Received: C");
               if(command_status == 1){
                 get_cap_value();
-              }
-              break;
+                //Serial.print("Cap");
+              }
+              break;
+

             default:
-              //Serial.print("Hello11");
+             // Serial.println("NULL");
             break;
           }
       }


Some tweaks were done to the ISR's

Some tweaks were done to the ISR's

--- laborations/encoder/encoder_ard/encoder_ard.ino
+++ laborations/encoder/encoder_ard/encoder_ard.ino
@@ -31,7 +31,7 @@
   {
     pulses = pulses - 0.5;
   }
-
+
   Serial.println(pulses);
   // Remember to attach interrupt with a new ISR
   attachInterrupt(11, encoderFallA, FALLING);
@@ -49,7 +49,7 @@
   {
     pulses = pulses - 0.5;
   }
-
+
   Serial.println(pulses);
   attachInterrupt(11, encoderRiseA, RISING);
 }
@@ -61,12 +61,12 @@
   if (encoderSignalA == 1)
   {
     pulses = pulses + 0.5;
-  }
+  }
   if (encoderSignalA == 0)
   {
     pulses = pulses - 0.5;
   }
-
+
   Serial.println(pulses);
   attachInterrupt(12, encoderFallB, FALLING);
 }
@@ -79,12 +79,12 @@
   if (encoderSignalA == 0)
   {
     pulses = pulses + 0.5;
-  }
+  }
   if (encoderSignalA == 1)
   {
     pulses = pulses - 0.5;
   }
-
+
   Serial.println(pulses);
   attachInterrupt(12, encoderRiseB, RISING);
 }


turned onTime into a variable

turned onTime into a variable

makes it easier to change the amount of time it is on for

--- led_sequence_combined/led_sequence_combined.ino
+++ led_sequence_combined/led_sequence_combined.ino
@@ -17,6 +17,8 @@
 const int upPin = 4;
 const int pingPin = 3;
 const int downPin = 5;
+// how long the on operiod should be
+const int onTime = 300;

@@ -111,13 +113,13 @@
   //****************************************************

   // if the counter > 0 the startup sequence has been initiated
-  if ((counter > 0) && (counter < 100)) {
+  if ((counter > 0) && (counter < onTime)) {
     on();
   }

   // if counter > 99 it is time to shut down
-  if (counter > 99) {
+  if (counter > (onTime-1)) {
     turnoff();
   }

@@ -185,9 +187,9 @@
   // 0 is the lowest counter number, 100 is the highest number
   // 255 is where the output number should start (because it is on when counter = 0
   // 0 is where the output ends when the counter  hits 100
-  redVal = map(counter, 0, 100, 255, 0);
+  redVal = map(counter, 0, onTime, 255, 0);
   // turns up the green as the red fades out
-  greenVal = map(counter, 0, 100, 0, 255);
+  greenVal = map(counter, 0, onTime, 0, 255);
   //sets the color
   strip.setPixelColor(0, redVal, greenVal, 0); //pixel number, r,g,b
   //pushes change to neopixels


Arduino refactor

Arduino refactor

--- Arduino/KAKUSender/KAKUSender.ino
+++ Arduino/KAKUSender/KAKUSender.ino
@@ -9,7 +9,7 @@
 // Used for the KAKU remote functionality
 const long transmitterAddress = 12877286;
 const int transmitterPin = 7;
-const int transmitterPeriod = 254;
+const int transmitterPeriod = 260;

 // Used for smart lights
 const byte ldrPin = A0;
@@ -26,7 +26,7 @@

 byte timeArrayPosition = 0;

-// KAKU transmitter
+// KAKU Transmitter
 NewRemoteTransmitter transmitter(transmitterAddress, transmitterPin, transmitterPeriod);

 // Ethernet details
@@ -66,22 +66,22 @@
   int lightNumber;

   // Light 1
-  if (strstr(data, "1")) {
+  if (strstr(data, "0")) {
     lightNumber = 0;
   }

   // Light 2
-  if (strstr(data, "2")) {
+  if (strstr(data, "1")) {
     lightNumber = 1;
   }

   // Light 3
-  if (strstr(data, "3")) {
+  if (strstr(data, "2")) {
     lightNumber = 2;
   }

   // Light 4
-  if (strstr(data, "4")) {
+  if (strstr(data, "3")) {
     lightNumber = 3;
   }


improved servo values

improved servo values

--- turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
+++ turtleCode/arduino/final/LCD12864_test/LCD12864_test.ino
@@ -41,9 +41,9 @@
 #define SS_PIN		      10
 #define servopin        6

-#define mouth_open_pos    100
-#define mouth_closed_pos  30
-#define mouth_wait_pos    77
+#define mouth_open_pos    142
+#define mouth_closed_pos  77
+#define mouth_wait_pos    115

 MFRC522 mfrc522(SS_PIN, RST_PIN);	// Create MFRC522 instance
 MFRC522::MIFARE_Key key;


[doc] update HTTPSRequest.ino (#3925)

[doc] update HTTPSRequest.ino (#3925)

add limitations of https connections

--- libraries/ESP8266WiFi/examples/HTTPSRequest/HTTPSRequest.ino
+++ libraries/ESP8266WiFi/examples/HTTPSRequest/HTTPSRequest.ino
@@ -6,6 +6,11 @@
  *  We fetch and display the status of
  *  esp8266/Arduino project continuous integration
  *  build.
+ *
+ *  Limitations:
+ *    only RSA certificates
+ *    no support of Perfect Forward Secrecy (PFS)
+ *    TLSv1.2 is supported since SDK 2.4.0-rc1
  *
  *  Created by Ivan Grokhotkov, 2015.
  *  This example is in public domain.


update fuer SX-XBee Interface, protokoll rev. 1.1

--- examples/SxXBee2/SxXBee2.ino
+++ examples/SxXBee2/SxXBee2.ino
@@ -1,31 +1,30 @@
 /*
  * SxXBee2.ino
  *
+ *  Changed on: 12.10.2015   new protocol rev1.1
+ *  Changed on: 04.09.2015   broadcast of power state
  *  Created on: 28.08.2015
- *  Changed on: 30.08.2015
- *  Changed on: 04.09.2015   broadcast of power state
- *  Changed on: 26.09.2015   new wording: SX22b class
+ *
+ *
  *  Author and Copyright: Michael Blank
  *
  *  reads date from xbee and sends them to SX Bus
  *
  *  !!! SX lib does not work with SoftwareSerial Lib !!!
  *
- *  benötigte Hardware:
- *     SX-Basisplatine von R.Thamm
+ *  Hardware: SX-Basisplatine von R.Thamm
  *     + Xbee an RX/TX des Arduino Pro Mini
- *  siehe http://opensx.net/funkregler/basisstation-xbee-platine
  */

 #include <SX22b.h>   // this is the Selectrix library
-#include <SX22Command.h>   // this is the Selectrix Command library
+#include <SXCommand.h>   // this is the Selectrix Command library
 #include <XBee.h> // XBee library by Andrew Rapp

 #define LED  13   // LED indicator at pin 13

 SX22b sx;                // selectrix library
-SX22Command sxcmd;      // holds command data
+SXCommand sxcmd;      // holds command data

 static int ledState = LOW;
 static byte oldSx[MAX_CHANNEL_NUMBER];
@@ -35,7 +34,7 @@

 static uint8_t track, oldTrack;

-uint8_t payload[12] ;   // 12 byte string for sending data to coordinator
+uint8_t payload[12] ;   // 12 byte string for sending data to xbees

 // Create an XBee object
 XBee xbee = XBee();
@@ -45,7 +44,7 @@
 ZBRxResponse rx = ZBRxResponse();
 ModemStatusResponse msr = ModemStatusResponse();

-// Address of receiving XBee
+// Address of receiving XBee (always: Broadcast!)
 XBeeAddress64 broadcast64;
 ZBTxRequest zbTx;
 ZBTxStatusResponse txStatus;
@@ -71,7 +70,7 @@
 */
 void setup() {

-    Serial.begin(9600);      // for comm with xbee
+    Serial.begin(9600);      // for comm with xbee - TODO increase to 57600
     pinMode(LED,OUTPUT);     // indicator for rec. packet
     xbee.setSerial(Serial);
     broadcast64 = XBeeAddress64(0, 0x0000FFFF);  //broadcast address
@@ -87,24 +86,55 @@
     delay(100); // give some time to initalize
 }

-/** transmit power state as broadcast to all XBees
- *  "P 1" = track power (gleisbit) is on
- *  "P 0" = track power is off
+/** transmit loco data as "adr data" broadcast
+    to all xbees
 */
-void send_power_state(uint8_t on) {
+void sendData(uint8_t ch, uint8_t d) {
   for (int i=0; i <12; i++) {
     payload[i]=0;
   }
-      payload[0]='P';
-      payload[1]= ' ';
-      if (on == 1) {
-         payload[2] = '1';
-      } else {
-         payload[2] = '0';
-      }
-      payload[3]=0;  // string end  */
-
-      xbee.send(zbTx);
+   payload[0]='F';  // for "feedback"
+  // address (channel) to string
+   uint8_t p3 = ch / 100;
+   uint8_t p2 = (ch - 100*p3) / 10;
+   uint8_t p1 = (ch - 100*p3 - 10*p2);
+   uint8_t end = 3;
+
+   if (p3 == 0) {
+      payload[1]= (uint8_t)p2 + '0';
+      payload[2]= (uint8_t)p1 + '0';
+      payload[3]= ' ';
+      end = 3;
+   } else {
+      payload[1]= (uint8_t)p3 + '0';
+      payload[2]= (uint8_t)p2 + '0';
+      payload[3]= (uint8_t)p1 + '0';
+      payload[4]= ' ';
+      end = 4;
+   }
+
+   // convert data to string
+   p3 = d / 100;
+   p2 = (d - 100*p3) / 10;
+   p1 = (d - 100*p3 - 10*p2);
+   if (p3 == 0) {
+      payload[end+1]= (uint8_t)p2 + '0';
+      payload[end+2]= (uint8_t)p1 + '0';
+      payload[end+3]= '\n';
+   } else {
+      payload[end+1]= (uint8_t)p3 + '0';
+      payload[end+2]= (uint8_t)p2 + '0';
+      payload[end+3]= (uint8_t)p1 + '0';
+      payload[end+4]= '\n';   // index max. 8 (of 11)
+   }
+
+#if defined(_DEBUG) || defined(_DEBUG_AVR)
+   sendPayloadToSerial();
+#endif   // defined(_DEBUG) || defined(_DEBUG_AVR)
+
+#ifndef _DEBUG_AVR
+   xbee.send(zbTx);
+#endif
 }

 /** receive loop for:
@@ -125,20 +155,38 @@
             char c = rx.getData(i);
             s += c;
          }
-
-         // interpret SX command from XBee
-         int n= s.indexOf(' '); // command split by space
-         // example:  "44 31" = set loco #44 to speed 31,
-         //                forward, Light=off, F=off
-         //       (standard selectrix data format, 8 bit)
-         if (n != -1) {
-            String ch = s.substring(0,n);
+         if ((s[0] == 'R') || (s[0] == 'r')) {
+            // read command, 1 int attribute
+            // "R44" =read data of channel 44
+            String ch = s.substring(1);
             int i_ch = ch.toInt();
-            String s2 = s.substring(n+1,s.length());
-            int i_value = s2.toInt();
-            do {
- 		delay(10);
-            } while (sx.set(i_ch,i_value));  // send to SX bus
+            if ( ((i_ch >=1) && (i_ch <=99))
+                || (i_ch == 127)) {
+               uint8_t d = sx.get(i_ch);
+               sendData((uint8_t)i_ch, d);
+            }
+         } else if ((s[0] == 'S') || (s[0] == 's')) {
+            // "SET" command
+            // interpret SX command from XBee
+            int n= s.indexOf(' '); // command split by space
+            // example:  "S44 31" = set loco #44 to speed 31,
+            //                forward, Light=off, F=off
+            //       (standard selectrix data format, 8 bit)
+            // 127=trackpower also handled like a standard SX channel
+            if (n != -1) {
+               String ch = s.substring(1,n); // remove leading 's', until space
+               int i_ch = ch.toInt();
+               String s2 = s.substring(n+1,s.length());
+               int i_value = s2.toInt();
+               if ((i_value >= 0 ) && (i_value <= 255)) {  //data valid
+                  uint8_t dsx = sx.get(i_ch);  // read current data on bus for this loco
+                  if (dsx != (uint8_t)i_value) { // sent only if data have changed
+                     do {
+                        delay(10);
+                     } while (sx.set(i_ch,i_value));  // send to SX bus
+                  }
+               }
+            }

          }
          digitalWrite(LED,LOW);  // indicate stop of send to SX Bus
@@ -153,7 +201,11 @@
     if ((track != oldTrack) || ( (millis() - lastPowerSent) > 10000 ) ){
       oldTrack = track;
       lastPowerSent = millis();
-      send_power_state(track);
+      if (track == 0) {
+         sendData(127,0);
+      } else {
+         sendData(127,1);
+      }
     }

 }


feature, fix: fixed stuff, added stuff

feature, fix: fixed stuff, added stuff

--- exampleFile/exampleFile.ino
+++ exampleFile/exampleFile.ino
@@ -1,28 +1,38 @@
+String inputWord = "";
+boolean wordComplete = false;
+int i = 0;
+
 void setup() {
     Serial.begin(9600);
-    pinMode(13, OUTPUT);
+    inputWord.reserve(200);
 }

 void loop() {
-    Serial.print("test");
-    Serial.println("LINE");
-    delay(500);
+    Serial.println(i++);
+    delay(100);
 }
+

 void serialEvent() {
     while (Serial.available()) {
+        int test;
+        char inChar = (char)Serial.read();

-        char ch = (char)Serial.read();
-
-        Serial.print(ch);
-        Serial.println(ch);
-
-        if (ch == '\n') {
-            Serial.print("Line detected");
-        } else if (ch == '1') {
-            digitalWrite(13, HIGH);
-        } else if (ch == '0') {
-            digitalWrite(13, LOW);
+        if (inChar == ' ' || inChar == '.') {
+            wordComplete = true;
+        } else {
+            inputWord += inChar;
         }
     }
+    if (wordComplete) {
+        if (inputWord.equalsIgnoreCase("ON")) {
+            digitalWrite(13, HIGH);
+        } else if (inputWord.equalsIgnoreCase("OFF")) {
+            digitalWrite(13, LOW);
+        } else if (inputWord.equalsIgnoreCase("PRINT")) {
+            Serial.println(inputWord);
+        }
+        inputWord = "";
+        wordComplete = false;
+    }
 }


Default Dutch repeater frequencies for your convenience

--- src/Arduino/_23cm-trx/EEPROM.ino
+++ src/Arduino/_23cm-trx/EEPROM.ino
@@ -22,7 +22,7 @@
  *
  */

-const unsigned int magicnumber = 31241;
+const unsigned int magicnumber = 31342;
 unsigned int eeprompointer = 0;

 // Read global settings
@@ -51,7 +51,7 @@
   if (memory < 0 || memory > VFO_MEMORY_LOCATION) { return; }

   eeprompointer = 100 + memory * 10;
-  if (!checkMagicNumber()) { defaultsMemory(); return; } // 2 bytes
+  if (!checkMagicNumber()) { defaultsMemory(memory); return; } // 2 bytes

   rxFreqHz               = EEPROMReadLong();             // 4 bytes
   subAudioIndex          = EEPROMReadInt();              // 2 bytes
@@ -63,10 +63,49 @@
   Serial.println(eeprompointer);
 }

-void defaultsMemory() {
-  rxFreqHz = 1298375000;   // Defaults to PI2NOS
-  subAudioIndex      = -1; // -1 is no audio. See subaudio.ino.
-  repeaterShiftIndex = 0;  // Min 0, max 4, see PLL.ino
+void defaultsMemory(int memory) {
+  switch (memory) {
+    case 0: rxFreqHz  = 1298375000;  // PI6NOS
+            subAudioIndex     = -1;  // -1 is no audio. See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    case 1: rxFreqHz  = 1298200000;  // PI6HGL
+            subAudioIndex      = 8;  // 88.5 Hz, See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    case 2: rxFreqHz  = 1298625000;  // PI6RTD
+            subAudioIndex      = 8;  // 88.5 Hz, See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    case 3: rxFreqHz  = 1298575000;  // PI6ASN
+            subAudioIndex     = -1;  // -1 is no audio. See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    case 4: rxFreqHz  = 1298500000;  // PI6AMF
+            subAudioIndex      = 8;  // 88.5 Hz, See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    case 5: rxFreqHz  = 1298400000;  // PI6EHN
+            subAudioIndex     = -1;  // -1 is no audio. See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    case 6: rxFreqHz  = 1298425000;  // PI6NOG
+            subAudioIndex      = 6;  // 82.5 Hz, See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    case 7: rxFreqHz  = 1242530000;  // PI6SHB
+            subAudioIndex      = 2;  // 71.9 Hz, See subaudio.ino.
+            repeaterShiftIndex = 4;  // +28 MHz, see PLL.ino
+            break;
+    case 8: rxFreqHz  = 1298700000;  // PI6HVN
+            subAudioIndex     = -1;  // -1 is no audio. See subaudio.ino.
+            repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+            break;
+    default: rxFreqHz  = 1298000000;  // Simplex
+             subAudioIndex     = -1;  // -1 is no audio. See subaudio.ino.
+             repeaterShiftIndex = 0;  // -28 MHz, see PLL.ino
+             break;
+  }
 }

 // Writes memory settings to EEPROM


adapt - upd 4

adapt - upd 4

--- firmware/examples/heart.ino
+++ firmware/examples/heart.ino
@@ -1,4 +1,11 @@
-#include "ledmatrix-max7219-max7221.h"
+/*
+  Example
+
+  Scrolling text and simple vector drawing
+*/
+
+// subdirectory is required for Spark WEB IDE
+#include "ledmatrix-max7219-max7221/ledmatrix-max7219-max7221.h"

 LEDMatrix *led;


consolidate main loops into individual functions.

--- firmware/PCB_V02/PCB_V02.ino
+++ firmware/PCB_V02/PCB_V02.ino
@@ -89,14 +89,12 @@
   pinMode(clockPin, OUTPUT);
   pinMode(dataPin, OUTPUT);
   pinMode(motorPin, OUTPUT);
-
   pinMode(redLED, OUTPUT);
   pinMode(blueLED, OUTPUT);
   pinMode(greenLED, OUTPUT);
   pinMode(digitLED, OUTPUT);

   digitalWrite(digitLED, LOW);
-
   analogWrite(blueLED, 100);
   analogWrite(redLED, 100);
   analogWrite(greenLED, 100);
@@ -105,7 +103,12 @@
 }

 void loop() {
-
+  controlMotor();
+  getData();
+  isUsbConnected();
+}
+
+void controlMotor() {
   // Is the motor on? If so, has it been on for more time than motorOn?
   // Is the motorCommand still ON or has it been turned off by other logic?
   // If all true, then turn off the motor and record the time.
@@ -141,7 +144,9 @@
     digitalWrite(motorPin, motorState);
     motorPulse = motorCount;
   }
-
+}
+
+void getData() {
   if (serialStream.available()) {
     serialStream.skip();
   }
@@ -152,17 +157,7 @@
     processMessage(msg);
     aJson.deleteItem(msg);
   }
-
-  // Until USB has been connected, display a spinning wheel on
-  // the 7 segment display.
-  if (!usbConnected) {
-    for (int c = 0; c < 6; c++) {
-      sendDigit(circle[c]);
-      delay(50);
-    }
-  }
-}
-
+}
 /*
  Three cases so far:
  {"name": "shift", "value": 1}     value is an integer. either 1 or 0.
@@ -227,4 +222,15 @@
   shiftOut(dataPin, clockPin, LSBFIRST, i);
   //take the latch pin high so the LEDs will light up:
   digitalWrite(latchPin, HIGH);
+}
+
+void isUsbConnected() {
+  // Until USB has been connected, display a spinning wheel on
+  // the 7 segment display.
+  if (!usbConnected) {
+    for (int c = 0; c < 6; c++) {
+      sendDigit(circle[c]);
+      delay(50);
+    }
+  }
 }


Clarifying comments to aid users in understanding stepper motors and use of DCU segment

--- VernierStepper/VernierStepper.ino
+++ VernierStepper/VernierStepper.ino
@@ -3,11 +3,26 @@
 Controls a stepper motor (unipolar or bipolar) connected to a Vernier Digital
 Control Unit (DCU) connected to BTD 2 connector.

+Stepper motors are unique in that they allow for very exact positioning of the
+drive shaft. Additional guidance related to stepper motors can be found in the
+user manual for the DCU http://www.vernier.com/files/manuals/dcu-btd.pdf
+
 This sketch causes the stepper motor to rotate 100 steps and then the rotation
 pauses for one second and the rotation is repeated in the opposite direction.
 See www.vernier.com/arduino for more information.

-*/int Duration=30; //step time in ms
+The sketch makes use of a segment of code for the DCU.
+
+There are at least two points of note for this sketch. First the DCU must have
+an external power source in order drive the motor. Second, if you try to cycle the
+stepper motor too quickly (by having a small int Duration) the motor may not be
+able to complete its cycle before being forced to start again. In both cases you will
+observe the shaft on the motor vibrating, but not rotating.
+
+*/
+
+int Duration=50; /*step time in ms. If this value is too low for your motor
+it will cause the motor to shake without moving.*/
 int Direction =0;//direction 0 =CW, 1 = CCW
 //the lines below are so that you can quickly change this code if you want to
 //use the DCU in the BTD1 connector for some reason.
@@ -32,33 +47,40 @@
 {
 DCU(0);//Turn off all lines
 delay (1000);
-Step(100,0);//rotate clockwise
+Step(100,0);//rotate clockwise 100 steps
 delay (1000);
-Step(100,1);// rotate counter clockwise
+Step(100,1);// rotate counter clockwise 100 steps
 } ;// end of loop

 void Step(int Steps, int direction)
 {
   int x;
-  int StepValue;if (direction ==0)
-    {
-      DCUStep[0]=5;//,9,10,6}; //on this order for CW
+  int StepValue;
+  if (direction ==0)
+    {
+      /*
+      The following sequences are for a "normal" stepper motor.
+      5,9,10,6 steps the motor CW
+      Reverse the order for CCW
+      */
+      DCUStep[0]=5; //CW
       DCUStep[1]=9;
       DCUStep[2]=10;
       DCUStep[3]=6;
     }
     else
      {
-       DCUStep[0]=6;//,9,10,6}; //on this order for CW
+       DCUStep[0]=6; //CCW
        DCUStep[1]=10;
        DCUStep[2]=9;
        DCUStep[3]=5;
     }
   for (x=0; x<=Steps; x++) // set up step pattern
     {
-      output = x%4;
+      output = x%4;// % = modulo: returns the remainder of x divided by the value (4) in the case
+      //as "x" increments "output" will progress from 0, 1, 2, 3 repeating
       StepValue = DCUStep[output];
-      DCU(StepValue);
+      DCU(StepValue); // This points to the case for the DCU. See void DCU below.
       Serial.print(output);
       Serial.print("  ");
       Serial.println(StepValue);
@@ -66,7 +88,7 @@
     } ;//end of for
 };// end of Step

-void DCU (int output)
+void DCU (int output)// This segment of code is copied from a DCU sketch as a complete module
 {
   switch (output)
   {


update led devices in adalight sketch (#262)

this is suitable for latest tag. see here: https://github.com/FastLED/FastLED/blob/v3.1.3/FastLED.h

--- assets/firmware/arduino/adalight/adalight.ino
+++ assets/firmware/arduino/adalight/adalight.ino
@@ -22,25 +22,40 @@

 void setup() {
   // Uncomment/edit one of the following lines for your leds arrangement.
-  // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
-  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
-  // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<NEOPIXEL    , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<BTM1829     , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<TM1812      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<TM1809      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<TM1804      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<TM1803      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<UCS1903     , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<UCS1903B    , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<UCS1904     , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<UCS2903     , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<WS2812      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<WS2852      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  FastLED.addLeds<WS2812B     , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<SK6812      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<SK6822      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<APA106      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<PL9823      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<WS2811      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<WS2813      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<APA104      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<WS2811_40   , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<GW6205      , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<GW6205_40   , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<LPD1886     , DATA_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<LPD1886_8BIT, DATA_PIN, RGB>(leds, NUM_LEDS);

-  // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
-
-  // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<WS2801 , DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<WS2803 , DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
   // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
-  // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<P9813  , DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<APA102 , DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<SK9822 , DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
+  // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

   // initial RGB flash
   LEDS.showColor(CRGB(255, 0, 0));


2 Ebenen selbstfahren hinzugefügt

2 Ebenen selbstfahren hinzugefügt

--- RF_ATtiny85_Lastenaufzug/RF_ATtiny85_Lastenaufzug.ino
+++ RF_ATtiny85_Lastenaufzug/RF_ATtiny85_Lastenaufzug.ino
@@ -29,8 +29,8 @@
  * GND = GND
  * PB1 = Transistor (PNP)
  * PB2 = DATA (433Mhz Empfänger)
- * PB3 = Relais 1
- * PB4 = Relais 2
+ * PB3 = Relais 1 (AB)
+ * PB4 = Relais 2 (AUF)
  *
  * Info:
  * Falls ein anderer Arduino Controller verwendet wird, muss man die Pins anpassen.
@@ -82,12 +82,19 @@
 boolean S1State=false;
 boolean S2State=false;
 boolean ROState=false;
+// wir haben auch keinen Sensor für das erkennen in welchem Stockwerk es ist, somit werden wir auch da mit
+// Boolean Felder Raten.
+boolean floor_og=false;
+boolean floor_eg=false;
+
 char mode[4]; // ein Reservierter Speicher fuer Modus ON / OFF
 unsigned long relaistime = 60000L; // Schalte die Relais Versorgungsspannung nach 1min. ab.
 // Wie lange das Relais den Status ON hat bis es wieder abgeschalten wird. Somit kann es
 // einen bestimmten Weg zuruecklegen.
-// unser Lastenaufzug schaft 6m pro Minute somit habe ich es auf 1m selbstfahren beschraenkt
-unsigned long worktime = 5000L;
+// unser Lastenaufzug schaft 6m pro Minute somit habe ich es auf 2m selbstfahren beschraenkt
+unsigned long worktime = 6000L;
+// vom 1.OG runter in das EG braucht es ca. 14 Sekunden.
+unsigned long worktimeto_eg = 14000L;

 unsigned long task2 = 0;

@@ -129,17 +136,21 @@

 void SecRelais1(char mode){
   /*
-   * Relais 1 with state check
+   * Relais 1 with state check (DOWN)
    */
   if (mode == "ON") {
     if (S1State == false && S2State == false) {
       S1State=true;
+      //liftdown=true;
+      //liftup=false;
       digitalWrite(S1, LOW);
-    } else if (S1State == false && S2State == false) {
+    } else if (S1State == false && S2State == true) {
       digitalWrite(S2, HIGH);
       S2State=false;
+      //liftup=false;
       delay(80);
       S1State=true;
+      //liftdown=true;
       digitalWrite(S1, LOW);
     } else if (S1State == true && S2State == false) {
       // do nothing
@@ -153,7 +164,7 @@

 void SecRelais2(char mode){
   /*
-   * Relais 2 with state check
+   * Relais 2 with state check (UP)
    */
   if (mode == "ON") {
     if (S2State == false && S1State == false) {
@@ -183,37 +194,75 @@
   //Serial.print("Code = ");
   //Serial.println(receivedCode);

-  if (receivedCode == 531272){
+  if (receivedCode == 531272) {
     task2 = millis();
     //Serial.println("Switch Relais 1 ON");
-    SWRelais("ON");
-    SecRelais1("ON");
-
-  } else if (receivedCode == 531380){
+    if (floor_og == true && floor_eg == true) {
+      // do nothing
+    } else {
+      SWRelais("ON");
+      SecRelais1("ON");
+    }
+
+  } else if (receivedCode == 531380) {
     //Serial.println("Switch Relais 2 ON");
     task2 = millis();
     SWRelais("ON");
     SecRelais2("ON");

-  } else if ( receivedCode == 531276 || receivedCode == 531436 || receivedCode == 531384){
+  } else if ( receivedCode == 531276 || receivedCode == 531436 || receivedCode == 531384) {
     //Serial.println("Switch Relais 1 and 2 OFF");
     SecRelais2("OFF");
     SecRelais1("OFF");
   }
-
-}
+}
+

 void loop() {
   unsigned long currmillis = millis();
-
-  if ((unsigned long)(currmillis - task2) >= worktime) {
-    if ( S1State == true || S2State == true ) {
-      //Serial.println("Switch Relais after worktime OFF");
-      SecRelais1("OFF");
-      SecRelais2("OFF");
-    }
-  }
-
+
+  // weg von der Winde zum 1.OG
+  if (floor_eg == false && floor_og == false && S2State == true) {
+    if ((unsigned long)(currmillis - task2) >= worktime) {
+      if ( S1State == true || S2State == true ) {
+        //Serial.println("Switch Relais after worktime OFF");
+        SecRelais1("OFF");
+        SecRelais2("OFF");
+        floor_og=true;
+      }
+    }
+    // weg vom 1.OG nach EG
+  } else if (floor_eg == false && floor_og == true && S2State == true) {
+    if ((unsigned long)(currmillis - task2) >= worktimeto_eg) {
+      if ( S1State == true || S2State == true ) {
+        //Serial.println("Switch Relais after worktime OFF");
+        SecRelais1("OFF");
+        SecRelais2("OFF");
+        floor_eg=true;
+      }
+    }
+    // zueruck auf das 1.OG
+  } else if (floor_eg == true && floor_og == true && S1State == true) {
+    if ((unsigned long)(currmillis - task2) >= worktimeto_eg) {
+      if ( S1State == true || S2State == true ) {
+        //Serial.println("Switch Relais after worktime OFF");
+        SecRelais1("OFF");
+        SecRelais2("OFF");
+        floor_eg=false;
+      }
+    }
+    // zurueck auf start
+  } else if (floor_eg == false && floor_og == true && S1State == true) {
+    if ((unsigned long)(currmillis - task2) >= worktime) {
+      if ( S1State == true || S2State == true ) {
+        //Serial.println("Switch Relais after worktime OFF");
+        SecRelais1("OFF");
+        SecRelais2("OFF");
+        floor_og=false;
+      }
+    }
+  }
+
   // schalte das Relais nach eingestellter Zeit aus
   if ((unsigned long)(currmillis - task2) >= relaistime) {
     if (ROState == true) {


Fixed header display issue

Fixed header display issue

--- src/aquarium_wise_controller.ino
+++ src/aquarium_wise_controller.ino
@@ -362,13 +362,15 @@
     case 12:
     case 13:
     case 14:
-    case 15:
+      utext.print(110, 12, "1");
+      break;
     case 5:
     case 6:
     case 7:
     case 8:
     case 9:
     case 10:
+    case 15:
     case 16:
         utext.print(160, 12, "a");
         utext.print(60, 12, "1");


Added debug statements for determining direction of articulation

--- src/SabertoothDriverROS/SabertoothDriverROS.ino
+++ src/SabertoothDriverROS/SabertoothDriverROS.ino
@@ -231,7 +231,10 @@
 int getArticulationDirection(int from, int to) {

   int delta = from-to;
-  if (delta > -DELTA_RANGE && delta < DELTA_RANGE) {
+  if (delta >= -DELTA_RANGE && delta <= DELTA_RANGE) {
+    char msg[] = "Determined direction: NONE...";
+    debugMsg.data = msg;
+    pubDebug.publish(&debugMsg);
     return ARTICULATION_DIRECTION_NONE;
   }

@@ -242,7 +245,7 @@
   // whole frame of reference clockwise

   //Shift "to" and "from" so that "to" is the angle that we need to turn and "from" is 0
-  if(from > 0 && from <= 180){
+  if(from >= 0 && from <= 180){

     // shift "to" by however much "from" shifted (counter clockwise)
     to -= from;
@@ -250,7 +253,6 @@
       to += 360;
     }

-
     // shift "from" to 0 degrees
     from = 0;
   }
@@ -273,6 +275,9 @@
   int clockwiseDistance = 360 - to;

   if(counterClockwiseDistance > clockwiseDistance){
+    char msg[] = "Determined direction: CLOCKWISE!";
+    debugMsg.data = msg;
+    pubDebug.publish(&debugMsg);
     return ARTICULATION_DIRECTION_CLOCKWISE;
   }
   else{


added button clear

added button clear

--- Arduino/TurquoiseBicuspid.ino
+++ Arduino/TurquoiseBicuspid.ino
@@ -6,6 +6,8 @@
 String BUFFER = "";
 char DELIMETER = ':';
 int LED = 11;
+int BUT = 2;
+int BUTT_STATE = 0;
 int TIME_START = 0;
 int REDPIN = 6;
 int GREPIN = 3;
@@ -24,6 +26,7 @@

 void setup()
 {
+   pinMode(BUT, INPUT);
    pinMode(LED, OUTPUT);
    pinMode(REDPIN, OUTPUT);
    pinMode(GREPIN, OUTPUT);
@@ -43,6 +46,15 @@

 void loop()
 {
+  BUTT_STATE = digitalRead(BUT);
+  if(BUTT_STATE == HIGH) {
+    Serial.println("Clear");
+    REPEATING = false;
+    //digitalWrite(LED, HIGH);
+  }
+  else {
+    //digitalWrite(LED, LOW);
+  }
   // read from bluetooth
   if(btSerial.available()) {
     while(btSerial.available()) {


More Bug Fixes

More Bug Fixes

--- ps2_controller/ps2_controller.ino
+++ ps2_controller/ps2_controller.ino
@@ -471,6 +471,8 @@
           serial_rx_buffer_controller[6] = 0x7F;
           serial_rx_buffer_controller[7] = 0x00;
           serial_rx_buffer_controller[8] = 0x00;
+          serial_rx_buffer_controller[9] = 0x00;
+          serial_rx_buffer_controller[10] = 0x00;

           for (serial_rx_buffer_counter = 0; serial_rx_buffer_counter < sizeof(serial_rx_buffer_controller); serial_rx_buffer_counter++) {
             Serial.write(serial_rx_buffer_controller[serial_rx_buffer_counter]); //  This line writes the serial data back to the computer as a way to check if the Arduino isn't interpreting wrong values


No need to re-initialize differently than the first initialization. This fixes the bug where exiting and restarting the CanCat software caused CAN frames to no longer be received. Bug caused by the set_baudrate function in the can_due drivers not re-enabling the CAN bus.

--- sketches/M2_CAN_haz_bus/M2_CAN_haz_bus.ino
+++ sketches/M2_CAN_haz_bus/M2_CAN_haz_bus.ino
@@ -456,52 +456,26 @@
                 break;

             case CMD_CAN_BAUD:
-                if(initialized == 0) // First init
+                //Initialize based on mode
+                if(mode == CMD_CAN_MODE_SNIFF_CAN0)
                 {
-                    //Initialize based on mode
-                    if(mode == CMD_CAN_MODE_SNIFF_CAN0)
-                    {
-                        device = &Can0;
-                        results = Init_Sniff(serial_buffer[3]);
-                    }
-                    else if (mode == CMD_CAN_MODE_SNIFF_CAN1)
-                    {
-                        device = &Can1;
-                        results = Init_Sniff(serial_buffer[3]);
-                    }
-                    else if (mode == CMD_CAN_MODE_CITM)
-                    {
-                        results = Init_CITM(serial_buffer[3]);
-                    }
-                    else
-                    {
-                        logHexStr(mode, "Invalid mode", 12);
-                        results = 0;
-                        initialized = 0;
-                    }
+                    device = &Can0;
+                    results = Init_Sniff(serial_buffer[3]);
+                }
+                else if (mode == CMD_CAN_MODE_SNIFF_CAN1)
+                {
+                    device = &Can1;
+                    results = Init_Sniff(serial_buffer[3]);
                 }
-                else // Just changing the baud rate
+                else if (mode == CMD_CAN_MODE_CITM)
                 {
-                    if (mode == CMD_CAN_MODE_SNIFF_CAN0)
-                    {
-                        Can0.set_baudrate(baud_rates_table[serial_buffer[3]]);
-                        results = 1; //TODO: Error checking
-                    }
-                    else if(mode == CMD_CAN_MODE_SNIFF_CAN1)
-                    {
-                        Can1.set_baudrate(baud_rates_table[serial_buffer[3]]);
-                        results = 1; //TODO: Error checking
-                    }
-                    else if (mode == CMD_CAN_MODE_CITM)
-                    {
-                        Can0.set_baudrate(baud_rates_table[serial_buffer[3]]);
-                        Can1.set_baudrate(baud_rates_table[serial_buffer[3]]);
-                        results = 1; //TODO: Error checking
-                    }
-                    else
-                    {
-                        results = 0;
-                    }
+                    results = Init_CITM(serial_buffer[3]);
+                }
+                else
+                {
+                    logHexStr(mode, "Invalid mode", 12);
+                    results = 0;
+                    initialized = 0;
                 }
                 send(&results, CMD_CAN_BAUD_RESULT, 1);
                 break;


trying to fix empty %s'

trying to fix empty %s'

--- sketches/monitor_nodown/monitor_nodown.ino
+++ sketches/monitor_nodown/monitor_nodown.ino
@@ -20,7 +20,7 @@
 /* --- Constants --- */
 const unsigned int BAUD = 9600;
 const unsigned int CHARS = 8;
-const unsigned int BUFFER = 128;
+const unsigned int BUFFER = 256;
 const unsigned int DIGITS = 4;
 const unsigned int PRECISION = 2;
 const unsigned int WAIT = 2000;
@@ -77,7 +77,7 @@
   dtostrf(get_pressure(), DIGITS, PRECISION, PASCALS);
   dtostrf(get_volts(), DIGITS, PRECISION, VOLTS);
   dtostrf(get_amps(), DIGITS, PRECISION, AMPS);
-  sprintf(JSON, "{'cycles':%d,'int_t':%s,'ext_t':%s,'int_h':%s,'ext_h':%s,'volts':%s,'amps':%s, 'bars':%s}", CYCLES, INT_TEMPERATURE, EXT_TEMPERATURE, INT_HUMIDITY, EXT_HUMIDITY, VOLTS, AMPS, PASCALS);
+  sprintf(JSON, "{'cycles':%d,'int_t':%s,'ext_t':%s,'int_h':%s,'ext_h':%s,'volts':%s,'amps':%s,'bars':%s}", CYCLES, INT_TEMPERATURE, EXT_TEMPERATURE, INT_HUMIDITY, EXT_HUMIDITY, VOLTS, AMPS, PASCALS);
   Serial.println(JSON);
   delay(WAIT);
   CYCLES++;


Fix pinout because backwards

Fix pinout because backwards

--- arduino/LidarServo/LidarServo.ino
+++ arduino/LidarServo/LidarServo.ino
@@ -1,76 +1,76 @@
-#include <I2C.h>
-#include <Servo.h>
-#define    LIDARLite_ADDRESS   0x62          // Default I2C Address of LIDAR-Lite.
-#define    RegisterMeasure     0x00          // Register to write to initiate ranging.
-#define    MeasureValue        0x04          // Value to initiate ranging.
-#define    RegisterHighLowB    0x8f          // Register to get both High and Low bytes in 1 call.
-
-// HOW TO WIRE
-// Specific to the cable I soldered to my personal servo and Lidar
-
-// SOLID   ORANGE     GND
-// STRIPED ORANGE     5V
-
-// SOLID   BLUE       Pin 13 - Servo Signal
-
-// SOLID   GREEN      Pin 1 - Lidar SCL
-// STRIPED GREEN      Pin 0 - Lidar SDA
-
-Servo myservo;
-int pos = 0;
-int range = 0;
-
-int STARTANGLE = 45;
-int ENDANGLE = 135;
-
-void setup() {
-  Serial.begin(9600); //Opens serial connection at 9600bps.
-  I2c.begin(); // Opens & joins the irc bus as master
-  delay(100); // Waits to make sure everything is powered up before sending or receiving data
-  I2c.timeOut(50); // Sets a timeout to ensure no locking up of sketch if I2C communication fails
-
-  myservo.attach(13);
-}
-
-int getLidarRange(){
-  // Write 0x04 to register 0x00
-  uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses
-  while (nackack != 0) { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
-    nackack = I2c.write(LIDARLite_ADDRESS, RegisterMeasure, MeasureValue); // Write 0x04 to 0x00
-    delay(1); // Wait 1 ms to prevent overpolling
-  }
-
-  byte distanceArray[2]; // array to store distance bytes from read function
-
-  // Read 2byte distance from register 0x8f
-  nackack = 100; // Setup variable to hold ACK/NACK resopnses
-  while (nackack != 0) { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
-    nackack = I2c.read(LIDARLite_ADDRESS, RegisterHighLowB, 2, distanceArray); // Read 2 Bytes from LIDAR-Lite Address and store in array
-    delay(1); // Wait 1 ms to prevent overpolling
-  }
-  int distance = (distanceArray[0] << 8) + distanceArray[1];  // Shift high byte [0] 8 to the left and add low byte [1] to create 16-bit int
-  return distance;
-}
-
-void spinAndScan(int pos){
-  // move servo to position
-  myservo.write(pos);
-
-  //scan and print distance
-  range = getLidarRange();
-  Serial.print("range: ");
-  Serial.print(range);
-  Serial.print(" pos: ");
-  Serial.println(pos - 90);
-}
-
-
-void loop() {
-  for(pos = STARTANGLE; pos < ENDANGLE; pos += 1){
-    spinAndScan(pos);
-  }
-  for(pos = ENDANGLE; pos>=STARTANGLE; pos-=1){
-    spinAndScan(pos);
-  }
-}
+#include <I2C.h>
+#include <Servo.h>
+#define    LIDARLite_ADDRESS   0x62          // Default I2C Address of LIDAR-Lite.
+#define    RegisterMeasure     0x00          // Register to write to initiate ranging.
+#define    MeasureValue        0x04          // Value to initiate ranging.
+#define    RegisterHighLowB    0x8f          // Register to get both High and Low bytes in 1 call.

+// HOW TO WIRE
+// Specific to the cable I soldered to my personal servo and Lidar
+
+// SOLID   ORANGE     GND
+// STRIPED ORANGE     5V
+
+// SOLID   BLUE       Pin 13 - Servo Signal
+
+// SOLID   GREEN      Pin 16 - Lidar SCL
+// STRIPED GREEN      Pin 17 - Lidar SDA
+
+Servo myservo;
+int pos = 0;
+int range = 0;
+
+int STARTANGLE = 45;
+int ENDANGLE = 135;
+
+void setup() {
+  Serial.begin(9600); //Opens serial connection at 9600bps.
+  I2c.begin(); // Opens & joins the irc bus as master
+  delay(100); // Waits to make sure everything is powered up before sending or receiving data
+  I2c.timeOut(50); // Sets a timeout to ensure no locking up of sketch if I2C communication fails
+
+  myservo.attach(13);
+}
+
+int getLidarRange(){
+  // Write 0x04 to register 0x00
+  uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses
+  while (nackack != 0) { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
+    nackack = I2c.write(LIDARLite_ADDRESS, RegisterMeasure, MeasureValue); // Write 0x04 to 0x00
+    delay(1); // Wait 1 ms to prevent overpolling
+  }
+
+  byte distanceArray[2]; // array to store distance bytes from read function
+
+  // Read 2byte distance from register 0x8f
+  nackack = 100; // Setup variable to hold ACK/NACK resopnses
+  while (nackack != 0) { // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
+    nackack = I2c.read(LIDARLite_ADDRESS, RegisterHighLowB, 2, distanceArray); // Read 2 Bytes from LIDAR-Lite Address and store in array
+    delay(1); // Wait 1 ms to prevent overpolling
+  }
+  int distance = (distanceArray[0] << 8) + distanceArray[1];  // Shift high byte [0] 8 to the left and add low byte [1] to create 16-bit int
+  return distance;
+}
+
+void spinAndScan(int pos){
+  // move servo to position
+  myservo.write(pos);
+
+  //scan and print distance
+  range = getLidarRange();
+  Serial.print("range: ");
+  Serial.print(range);
+  Serial.print(" pos: ");
+  Serial.println(pos - 90);
+}
+
+
+void loop() {
+  for(pos = STARTANGLE; pos < ENDANGLE; pos += 1){
+    spinAndScan(pos);
+  }
+  for(pos = ENDANGLE; pos>=STARTANGLE; pos-=1){
+    spinAndScan(pos);
+  }
+}
+


send sensible pixel data

send sensible pixel data

--- arduino/led_matrix/led_matrix.ino
+++ arduino/led_matrix/led_matrix.ino
@@ -9,7 +9,8 @@

 CRGB leds[NUM_LEDS];
-int r, g, b, x, y;
+int r, g, b;
+int x, y, xx;

 void setup() {
   FastLED.addLeds<WS2812B, PIN>(leds, NUM_LEDS);//.setCorrection(TypicalLEDStrip);
@@ -25,7 +26,12 @@
       b = Serial.read();
       g = Serial.read();
       r = Serial.read();
-      leds[x + y * WIDTH] = CRGB(r, g, b);
+      if (y % 2 == 0) {
+        xx = x;
+      } else {
+        xx = WIDTH - x - 1;
+      }
+      leds[x + yy * WIDTH] = CRGB(r, g, b);
     }
     Serial.print('X');
   }


script arduino led

script arduino led

--- bp_led.ino
+++ bp_led.ino
@@ -1,22 +1,25 @@

 // constants won't change. They're used here to
 // set pin numbers:
-const int buttonPin = 3;     // the number of the pushbutton pin
-const int ledPin =  2;      // the number of the LED pin
+const int buttonPin = 3;        // the number of the pushbutton pin
+const int ledPin =  2;          // the number of the LED pin
+const String CONST_ID = "01";   // the main Id
+const String CONST_TYPE = "01"; // the id of press button

 // variables will change:
-int buttonState = 0;         // variable for reading the pushbutton status
+int buttonState = 0;            // variable for reading the pushbutton status
 int ledState = 0;
 int currenteState = 0;

+
 void setup() {
+  Serial.begin(9600);
   // initialize the LED pin as an output:
   pinMode(ledPin, OUTPUT);
   // initialize the pushbutton pin as an input:
   pinMode(buttonPin, INPUT);
-  Serial.print("By SB & LB");
 }

@@ -43,11 +46,11 @@
 // turn LED on:
 void turnOn(){
    digitalWrite(ledPin, HIGH);
-   Serial.println("LED ON");
+   Serial.println(CONST_ID+":"+CONST_TYPE+":1");
 }

 // turn LED Off:
 void turnOff(){
   digitalWrite(ledPin, LOW);
-  Serial.println("LED OFF");
+  Serial.println(CONST_ID+":"+CONST_TYPE+":2");
 }


Formatting HVAC

Formatting HVAC

--- Arduino_HVAC_Controller/HVAC_Controller.ino
+++ Arduino_HVAC_Controller/HVAC_Controller.ino
@@ -37,8 +37,10 @@
 // -------------Library Interaction--------------
 // Data wire is plugged into busPin on the Arduino
 #define ONE_WIRE_BUS busPin
+
 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
 OneWire oneWire(ONE_WIRE_BUS);
+
 // Pass our oneWire reference to Dallas Temperature.
 DallasTemperature sensors(&oneWire);
 //void wdt_reset(void);
@@ -89,7 +91,7 @@
     //Serial.print(" reports: ");
     //Serial.println(sensors.getTempF(addrs[x]));
     temp = sensors.getTempF(addrs[x]);
-    if(temp > currentTemp){
+    if(temp > currentTemp){     // WHY DO I HAVE THIS AS > ??? ------------------------
       currentTemp = temp;
     }
   }


BC127Terminal: add conversion of carriage return to newline

--- examples/07-Bluetooth/BC127Terminal/BC127Terminal.ino
+++ examples/07-Bluetooth/BC127Terminal/BC127Terminal.ino
@@ -1,12 +1,13 @@
 /*
-*	BC127Terminal
+*  BC127Terminal
 *
-*	Created: Ira Ray Jenkins, Creare, December 2020
-*	Purpose: Demonstrates a serial terminal with the BC127 module.
+* Created: Ira Ray Jenkins, Creare, December 2020
+* Purpose: Demonstrates a serial terminal with the BC127 module.
 *
 */

-#include <Arduino.h>
+//The BC127 ends its lines with a carriage return, not a newline.  The Arduino Serial Monitor doesn't like this.
+#define TRANSLATE_CR_FOR_ARDUINO_SERIALMONITOR true   //set to true to convert in-coming carriage returns into newlines

 usb_serial_class *USB_Serial;
 HardwareSerial *BT_Serial;
@@ -23,17 +24,30 @@
 {
     while (BT_Serial->available())
     {
-        USB_Serial->write(BT_Serial->read());
+      char c = BT_Serial->read();
+      if (TRANSLATE_CR_FOR_ARDUINO_SERIALMONITOR) {
+          if (c == '\r') c = '\n'; //replace carriage return with newline to make pretty in Arduino Serial Monitor
+      }
+      USB_Serial->write(c);
     }
 }

 void setup()
 {
-    //  myTympan.beginBothSerial();
-    Serial.begin(9600);
+    Serial.begin(115200);
     Serial1.begin(9600);
+    delay(1000);
+
     USB_Serial = &Serial;
     BT_Serial = &Serial1;
+
+    Serial.println("Type commands to send to the BC127");
+    Serial.println("Try HELP, or try STATUS, or try ADVERTISING ON...");
+    Serial.println("Be sure to use carriage return, not newline...");
+    Serial.println();
+    Serial.println("Sending VERSION command...");
+    Serial.println();
+    BT_Serial->print("VERSION");BT_Serial->print('\r'); //terminate all commands with carriage return
 }

 void loop()


my stuff

my stuff

--- Teensy-Reactor-Controller.ino
+++ Teensy-Reactor-Controller.ino
@@ -31,7 +31,7 @@
 // Create a Flag to tell the main loop when the StartPin interrupt has been triggered.
 boolean StartPinFlag = false;

-// Create a Flag to tell if autopurge is on.
+// Create a Flag to tell if AutoPurge is on.
 boolean AutoPurgeFlag = false;

 // Sets the trigger edge for the StartPin signal. 0 is falling, 1 is rising. I am making it


Changed from NO2 and CO to no2 and co.

Changed from NO2 and CO to no2 and co.

--- things/examples/arduino/EggShield/EggShield.ino
+++ things/examples/arduino/EggShield/EggShield.ino
@@ -25,10 +25,10 @@
 char packetBuffer[768];

 PROGMEM prog_char *loopPacket1 = "{\"path\":\"/api/v1/thing/reporting\",\"requestID\":\"";
-PROGMEM prog_char *loopPacket2 = "\",\"things\":{\"/device/climate/arduino/sensor\":{\"prototype\":{\"device\":{\"name\":\"Arduino with EggShield\",\"maker\":\"Arduino\"},\"name\":true,\"status\":[\"present\",\"absent\",\"recent\"],\"properties\":{\"NO2\":\"ppb\",\"CO\":\"ppb\",\"temperature\":\"celsius\",\"humidity\":\"percentage\"}},\"instances\":[{\"name\":\"Air Quality\",\"status\":\"present\",\"unit\":{\"serial\":\"";
+PROGMEM prog_char *loopPacket2 = "\",\"things\":{\"/device/climate/arduino/sensor\":{\"prototype\":{\"device\":{\"name\":\"Arduino with EggShield\",\"maker\":\"Arduino\"},\"name\":true,\"status\":[\"present\",\"absent\",\"recent\"],\"properties\":{\"no2\":\"ppb\",\"co\":\"ppb\",\"temperature\":\"celsius\",\"humidity\":\"percentage\"}},\"instances\":[{\"name\":\"Air Quality\",\"status\":\"present\",\"unit\":{\"serial\":\"";
 PROGMEM prog_char *loopPacket3 = "\",\"udn\":\"195a42b0-ef6b-11e2-99d0-";
-PROGMEM prog_char *loopPacket4 = "-egg-shield\"},\"info\":{\"NO2\":\"";
-PROGMEM prog_char *loopPacket5 = "\",\"CO\":\"";
+PROGMEM prog_char *loopPacket4 = "-egg-shield\"},\"info\":{\"no2\":\"";
+PROGMEM prog_char *loopPacket5 = "\",\"co\":\"";
 PROGMEM prog_char *loopPacket6 = "\",\"temperature\":\"";
 PROGMEM prog_char *loopPacket7 = "\",\"humidity\":\"";
 PROGMEM prog_char *loopPacket8 = "\"},\"uptime\":\"";


Examples: removing commented-out include of Audio.h

--- examples/01-Basic/TrebleBoost/TrebleBoost.ino
+++ examples/01-Basic/TrebleBoost/TrebleBoost.ino
@@ -11,7 +11,6 @@
 */

 //here are the libraries that we need
-//include <Audio.h>           //include the Teensy Audio Library
 #include <Tympan_Library.h>  //include the Tympan Library

 //set the sample rate and block size


horloge_cycles_ultradiens

--- files/horloge_cycles_ultradiens/horloge_cycles_ultradiens.ino
+++ files/horloge_cycles_ultradiens/horloge_cycles_ultradiens.ino
@@ -276,14 +276,21 @@

   // Préparation de l’affichage du pourcentage du cycle
   display.setTextSize( 2 );
-  if( cycleAtt < 0.005 )
-    { display.setCursor( 53, 21 ); display.print( cycleAtt, 0 ); }
-  else if( cycleAtt < 9.995 )
-    { display.setCursor( 34, 21 ); display.print( cycleAtt, 2 ); }
-  else if( cycleAtt < 99.95 )
-    { display.setCursor( 34, 21 ); display.print( cycleAtt, 1 ); }
-  else
-    { display.setCursor( 42, 21 ); display.print( cycleAtt, 0 ); }
+  #if false // Affichage avec 3 chiffres significatifs pour le déverminage
+    if( cycleAtt < 0.005 )
+      { display.setCursor( 53, 21 ); display.print( cycleAtt, 0 ); }
+    else if( cycleAtt < 9.995 )
+      { display.setCursor( 34, 21 ); display.print( cycleAtt, 2 ); }
+    else if( cycleAtt < 99.95 )
+      { display.setCursor( 34, 21 ); display.print( cycleAtt, 1 ); }
+    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 ); }
+    display.print( cycleAtt, 0 );
+  #endif
   display.print( char( 37 ) ); // signe %

   // Préparation de l’affichage de la courbe du cycle


Update 01_Particle.ino

Update 01_Particle.ino

--- firmware/examples/01_Particle/01_Particle.ino
+++ firmware/examples/01_Particle/01_Particle.ino
@@ -11,6 +11,9 @@
  *
  * Blynk library is licensed under MIT license
  * This example code is in public domain.
+ *
+ * WARNING: It is recommended to use SparkCorePolledTimer library
+ *          to make periodic actions (similar to SimpleTimer on Arduino).
  *
  **************************************************************/
 //#define BLYNK_DEBUG // Uncomment this to see debug prints


added notes  for later

added notes  for later

--- ZstabalizationTest1/ZstabalizationTest1.ino
+++ ZstabalizationTest1/ZstabalizationTest1.ino
@@ -58,12 +58,16 @@
           // Move ROV DOWN
           // Insert MOTOR CODE here
           // michael note: use map to max it from max to zero. you'll remember
+          // move from up to down (closer to depth saved, closer to zero
+          // map(x, max sensor, depthSavedState, 255, 0)
       }
     // if ROV is below saved state
       if(sensor.depth() < depthSavedState){
           // Move ROV UP
           // Insert MOTOR CODE here
           // michael note: use map to max it from max to zero. you'll remember
+          // move from up to down (closer to depth saved, closer to zero
+          // map(x, max sensor, depthSavedState, 0, 255)
       }

     }


All codes added

All codes added

Not all use both “steps” and “directions” vars, might wanna check
what’s necessary. Please check I’m using proper term for pins.

--- arduinoFIles/finalSprintCode/finalSprintCode.ino
+++ arduinoFIles/finalSprintCode/finalSprintCode.ino
@@ -91,16 +91,30 @@
  }

  if (serialInput == "RPC"){
-   directions = 1;
+   step = 5;
    spinPlatform();
 }

- if (serialInput = "FSU"){
-   directions = 0;
+ if (serialInput == "RPN"){
+   step = -5;
    spinPlatform();
  }

-
+ if (serialInput == "CLS"){
+   calibrateLinear();
+ }
+
+ if (serialInput == "CPS"){
+   calibrateStepper();
+ }
+
+ if (serialInput == "GB?"){
+   drawingButton();
+ }
+
+ if (serialInput == "OS?"){
+   callibrateLinear();
+ }

  }

@@ -194,6 +208,8 @@
 }

 }
+
+void calibrateLinear(int steps, int directions){
   int limitSwitchOne() {
   int reading = digitalRead(masterOnOff);
   int callibrateOne = digitalRead(limitOne);
@@ -215,10 +231,51 @@
 }}
 }

+void drawingButton(int steps, int directions){
+  int exportButton() {
+  int greenReading = digitalRead(greenButton);
+  int orangeReading = digitalRead(masterOnOff);
+
+ if (orangeReading == LOW) {
+  //Serial.println("System ON");
+  if (greenReading == LOW) { // START ROTATING
+     linearMotor->step(0, FORWARD, MICROSTEP);
+      Serial.println("Set Go");
+    }
+
+  if (greenReading == HIGH) {
+    Serial.println("Paused");}
+}}
+
+}
+
+void calibrateStepper(int steps, int directions){
+  int limitSwitchOne() {
+  int reading = digitalRead(masterOnOff);
+  int callibrateOne = digitalRead(limitOne);
+  int callibrateTwo = digitalRead(limitTwo);
+
+ if (reading == LOW) {
+  //Serial.println("System ON");
+  if (callibrateOne == LOW) { // START ROTATING
+      //digitalWrite(platformStep, HIGH);
+      Serial.println("Pressed");
+    }
+     if (callibrateTwo == LOW) {
+      digitalWrite(platformStep, LOW);
+      Serial.println("Released"); }}
+
+
+  if (reading == HIGH) {
+    Serial.println("System OFF");}
+}}
+}
+
 void spinPlatform(int steps, int directions){ //this spins the cake platform given # of steps
   int stepCounter = steps;
+  //int turn = directions;
   while (stepCounter>0){
-    Serial.print("turn a step");
+    Serial.print("turn a step cw");
     digitalWrite(platformStep, HIGH);
     delay(200);
     digitalWrite(platformStep,LOW);
@@ -226,6 +283,11 @@
     delay(200);

   while (stepCounter<0){
-    Serial.print(
-
-}}
+    Serial.print("turn a step ccw");
+    digitalWrite(platformStep, LOW);
+    delay(200);
+    digitalWrite(platformStep, HIGH);
+    stepCounter -= 1;
+    delay(200); }
+
+}}


Sketch now returns proper temperatures

Sketch now returns proper temperatures

--- sous_vide_arduino/sous_vide_arduino.ino
+++ sous_vide_arduino/sous_vide_arduino.ino
@@ -18,13 +18,7 @@
 void setup()
 {
     Serial.begin(57600);
-
     sensors.begin();
-    if (!sensors.getAddress(thermometer, 0)) {
-        Serial.println("Unable to find address for Device 0");
-    }
-
-    sensors.setResolution(thermometer, 9);
 }

 float temperature()
@@ -36,7 +30,7 @@
 {
     // Sleep if there are no incoming commands
     if (!Serial.available()) {
-        Bean.sleep(20000);
+        Bean.sleep(4294967294);
     }

     Bean.setLed(0, 0, 255);
@@ -50,7 +44,7 @@

         // Return 0x00, current temp, target temp, enabled, 0xFF
         Serial.write(0x00);
-        Serial.write((int)temperature());
+        Serial.write((int) sensors.getTempFByIndex(0));
         Serial.write(targetTempF);
         Serial.write(enabled ? 0x01 : 0x00);
         Serial.write(0xFF);


commit

commit

--- watermeter/mqtt.ino
+++ watermeter/mqtt.ino
@@ -17,7 +17,7 @@
   // handle message arrived

   time_t timeFromServer;
-  time_t waterFromServer;
+  unsigned long waterFromServer;
   unsigned int pos;

   String s = "";


[lmr] Try to stabilize the ADC when returning from sleep and don't sleep while waiting for RFM to send

--- arduino/lmremote/lmremote.ino
+++ arduino/lmremote/lmremote.ino
@@ -146,7 +146,7 @@

     // HDR=0 means to broadcast, no ACK requested
     rf12_sendStart(0, outbuf, len);
-    rf12_sendWait(2);
+    rf12_sendWait(0);
   }  /* while txCount */

   rf12_sleep(RF12_SLEEP);
@@ -175,7 +175,7 @@
     digitalWrite(_pinProbeSupplyBase + pin, HIGH);
   }
   // takes about 15uS to stabilize and the enabling process takes 6us per pin at 16MHz
-  delayMicroseconds(10);
+  delayMicroseconds(10);
 }

 void checkTemps(void)
@@ -187,13 +187,14 @@
   {
     if (PIN_DISABLED(pin))
       continue;
-
+
     unsigned int newRead = analogRead(pin);
+
     //Serial.println(newRead, DEC);
     if (newRead != _previousReads[pin])
       modified = true;
     _previousReads[pin] = newRead;
-
+
     digitalWrite(_pinProbeSupplyBase + pin, LOW);
   }

@@ -223,7 +224,7 @@
 {
   //Serial.begin(115200);

-  // Turn off the units we never use (this only affects non-sleep power
+  // Turn off the units we never use (this only affects non-sleep power)
   PRR = bit(PRUSART0) | bit(PRTWI) | bit(PRTIM1) | bit(PRTIM2);
   // Disable digital input buffers on the analog in ports
   DIDR0 = bit(ADC5D) | bit(ADC4D) | bit(ADC3D) | bit(ADC2D) | bit(ADC1D) | bit(ADC0D);
@@ -242,9 +243,28 @@
   transmitTemps(2);
 }

+void stabilizeAdc(void)
+{
+  if (_pinBattery != 0xff)
+  {
+    unsigned int last;
+    unsigned int curr = analogRead(_pinBattery);
+    unsigned int cnt = 0;
+    // Reads the adc a bunch of times until the value settles
+    // Usually you hear "discard the first few ADC readings after sleep"
+    // but this seems a bit more scientific
+    do {
+      ++cnt;
+      last = curr;
+      curr = analogRead(_pinBattery);
+    } while ((cnt < 10) && (abs(last - curr) > 2));
+  }
+}
+
 void loop(void)
 {
   sleepSeconds(_sleepInterval);
+  stabilizeAdc();
   checkTemps();
 }


Debug comment

Debug comment

--- examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
+++ examples/UbidotsSaveMultiValues/UbidotsSaveMultiValues.ino
@@ -34,7 +34,7 @@

 void setup() {
   Serial.begin(115200);
-  client.setDebug(true);
+  client.setDebug(true); // Set true to make available debug messages
 }

 void loop() {


Updated version

Updated version

--- Pan_Tilt_laser/Pan_Tilt_laser.ino
+++ Pan_Tilt_laser/Pan_Tilt_laser.ino
@@ -15,7 +15,8 @@
     v1.1.0 - Added Markov-based speed control
     v1.2.0 - Added Markov-based pause length/frequency
     v1.2.1 - Added Heartbeat during pause
-    v1.2.2 - Added laser shake to enhance cat enjoyment
+    v1.3.0 - Added laser shake to enhance cat enjoyment
+    v1.3.1 - Changed probability polling frequency to once a second
 */
 /**************************************************************************/

@@ -90,7 +91,7 @@

   panTilt.updateAngles();
-
+
   if(markovShakeState == 2){
     shake();
   }


added some functions to fully close/extend the actuator

--- Arduino/robotdesk/robotdesk.ino
+++ Arduino/robotdesk/robotdesk.ino
@@ -11,6 +11,8 @@

 const int RELAY_1_A = 0;
 const int RELAY_1_B = 1;
+const int FULLEXTEND_TIME = 30000;
+const int IN_PER_SEC = 0.6;

 // the setup routine runs once when you press reset:
@@ -27,8 +29,11 @@
 // the loop routine runs over and over again forever:
 void loop() {

-  hello_actuator();

+
+  //hello_actuator();
+  reset_to_closed();
+  //fully_extend();

 }

@@ -54,6 +59,18 @@

   //lets wait before starting again...
   delay(5000);
+}
+
+void reset_to_closed(){
+
+ retractActuator(0);
+ delay(100000);
+
+}
+
+void fully_extend() {
+  extendActuator(0);
+  delay(100000);
 }

 void listen_on_serial(){


Se modifica luces ritmicas con loops para el encendido y apagado de los pines

--- luces_ritmicas/luces_ritmicas.ino
+++ luces_ritmicas/luces_ritmicas.ino
@@ -1,42 +1,34 @@
 /*Luces ritmicas
-*Copyright: codigoelectronica.com
-* Author: Oscar Fernandez
+* Copyright: codigoelectronica.com
+* Author: Oscar Fernandez Alzate @oscar_fedezal
 * License: MIT
 */

+//Creamos un array donde colocamos los números de los pines
+//que van a crear el efecto rítmico
+int inputsPints[] = {2,3,4,5,6,7,8};
+
+
 void setup() {
-  pinMode(2, OUTPUT);
-  pinMode(3, OUTPUT);
-  pinMode(4, OUTPUT);
-  pinMode(5, OUTPUT);
-  pinMode(6, OUTPUT);
-  pinMode(7, OUTPUT);

+  //En un for recorremos el array completo
+  for(int index = 0; index < 7; index ++){
+    //Colocamos como salida los pines declarados en el array
+    pinMode(inputsPints[index], OUTPUT);
+  }
 }

 void loop() {
-  digitalWrite(2, HIGH);
-  delay(1000);
-  digitalWrite(3, HIGH);
-  delay(1000);
-  digitalWrite(4, HIGH);
-  delay(1000);
-  digitalWrite(5, HIGH);
-  delay(1000);
-  digitalWrite(6, HIGH);
-  delay(1000);
-  digitalWrite(7, HIGH);
-  delay(1000);
-  digitalWrite(2, LOW);
-  delay(1000);
-  digitalWrite(3, LOW);
-  delay(1000);
-  digitalWrite(4, LOW);
-  delay(1000);
-  digitalWrite(5, LOW);
-  delay(1000);
-  digitalWrite(6, LOW);
-  delay(1000);
-  digitalWrite(7, LOW);
-  delay(1000);
+
+  for(int index = 0; index < 7; index ++){
+    //En el mismo for, colocamos como estado alto al pin
+    digitalWrite(inputsPints[index], HIGH);
+    delay(500);
+  }
+
+  for(int index = 0; index < 7; index ++){
+    //En el mismo for, colocamos como estado bajo al pin
+    digitalWrite(inputsPints[index], LOW);
+    delay(200);
+  }
 }


wip, broken

wip, broken

--- embedded-particle/sense-motion.ino
+++ embedded-particle/sense-motion.ino
@@ -18,14 +18,13 @@
 const int kSwitchGnd = D6;
 const int kSwitchSense = D7;

-const int debounceDelay = 5;
-const int doubleClickDelay = 500;
+const int debounceDelay = 50;
+const int buttonLongPressDelay = 5000;

 int lastButtonStateChangeTime = 0;
-int lastButtonReleaseTime = 0;
-int buttonPresses = 0;
-// hold on to button presses until cleared by cloud function
-int buttonPressesForCloud = 0;
+int lastButtonPressTime = 0;
+// hold on to button state until cleared by cloud function
+int buttonStateForCloud = 0;
 bool lastButtonReading = false;
 bool buttonState = false;

@@ -79,43 +78,46 @@
 void buttonLoop() {
   int buttonReading = getButtonState();

-  // reset timer
+  // reset timer if button has changed state
   if (buttonReading != lastButtonReading) {
     lastButtonStateChangeTime = millis();
   }
   lastButtonReading = buttonReading;
-

   if ((millis() - lastButtonStateChangeTime) > debounceDelay) {
     // It's been debounceDelay and no button state changes
     if (buttonReading != buttonState) {
       // real (not bouncy) change to button state
       buttonState = buttonReading;
-      if (!buttonReading) {
-        // button is off, so increase number of button presses by 1
-        // and set time of last button press
-        buttonPresses = buttonPresses + 1;
-        lastButtonReleaseTime = millis();
-      }
+      if (buttonReading) {
+        // button was pressed
+        lastButtonPressTime = millis();
+      } else {
+        // button was released
+        if ((millis() - lastButtonPressTime) < buttonLongPressDelay) {
+          // short button press and release
+          // set LED to show short button press
+          RGB.color(0, 0, 255);
+          keepLEDColor = 20; // keep color for 20 cycles
+          buttonStateForCloud = 1;
+        } else {
+          // button release after long press
+          RGB.color(255, 0, 140);
+          keepLEDColor = 20;
+        }
+      }
     }
-  }

-  if ((millis() - lastButtonReleaseTime) > doubleClickDelay) {
-    // time to wait for a second click is up
-    if (buttonPresses > 0) {
-      if (buttonPresses == 1) {
-        // set LED to show single button press
-        RGB.color(0, 0, 255);
-        keepLEDColor = 20; // keep color for 20 cycles
+    if (buttonState) {
+      // button is being pressed
+      RGB.color(0, 0, 255);
+      keepLEDColor = 1;
+      if (millis() - lastButtonPressTime > buttonLongPressDelay) {
+        // button held
+        // set LED to show long button press
+        RGB.color(255, 0, 140);
+        buttonStateForCloud = 2;
       }
-
-      if (buttonPresses == 2) {
-        // set LED to show double button press
-        RGB.color(255, 0, 140);
-        keepLEDColor = 20;
-      }
-      buttonPressesForCloud = buttonPresses;
-      buttonPresses = 0;
     }
   }
 }
@@ -175,14 +177,14 @@
 }

 int getButton(String unused) {
-  int r = buttonPressesForCloud;
-  buttonPressesForCloud = 0;
+  int r = buttonStateForCloud;
+  buttonStateForCloud = 0;
   return r;
 }

 void loop() {
     delay(50);
     updateDisplay();
-    updateMotionState();
+    // updateMotionState();
     buttonLoop();
 }


Greatly reduce file sizes by processing in the switch statement. Right now it doens't need to be any more complicated

--- Event_Printer/Event_Printer.ino
+++ Event_Printer/Event_Printer.ino
@@ -50,52 +50,52 @@
     if( motorcycle_state.heated_grips == K25_Heated_Grips_State_off ) Serial.print("OFF");
     else if( motorcycle_state.heated_grips == K25_Heated_Grips_State_low ) Serial.print("LOW");
     else if( motorcycle_state.heated_grips == K25_Heated_Grips_State_high ) Serial.print("HIGH");
-    else Serial.print("Unknown");
+    else Serial.print("Unknown");
     Serial.println();

     Serial.print("Turn Signals: ");
     if( motorcycle_state.turn_signals == K25_Turn_Signals_State_off ) Serial.print("OFF");
     else if( motorcycle_state.turn_signals == K25_Turn_Signals_State_left ) Serial.print("LEFT");
     else if( motorcycle_state.turn_signals == K25_Turn_Signals_State_right ) Serial.print("RIGHT");
-    else if( motorcycle_state.turn_signals == K25_Turn_Signals_State_both ) Serial.print("HAZARDS");
-    else Serial.print("Unknown");
+    else if( motorcycle_state.turn_signals == K25_Turn_Signals_State_both ) Serial.print("HAZARDS");
+    else Serial.print("Unknown");
     Serial.println();

     Serial.print("High Beam: ");
     if( motorcycle_state.high_beam == K25_High_Beam_State_off ) Serial.print("OFF");
-    else if( motorcycle_state.high_beam == K25_High_Beam_State_on ) Serial.print("ON");
-    else Serial.print("Unknown");
+    else if( motorcycle_state.high_beam == K25_High_Beam_State_on ) Serial.print("ON");
+    else Serial.print("Unknown");
     Serial.println();

     Serial.print("Info Button: ");
     if( motorcycle_state.info_button == K25_Info_Button_State_short_press ) Serial.print("SHORT");
-    else if( motorcycle_state.info_button == K25_Info_Button_State_long_press ) Serial.print("LONG");
-    else Serial.print("Unknown");
+    else if( motorcycle_state.info_button == K25_Info_Button_State_long_press ) Serial.print("LONG");
+    else Serial.print("Unknown");
     Serial.println();

     Serial.print("Clutch: ");
     if( motorcycle_state.clutch == K25_Clutch_Lever_State_out ) Serial.print("OUT");
-    else if( motorcycle_state.clutch == K25_Clutch_Lever_State_in ) Serial.print("IN");
-    else Serial.print("Unknown");
+    else if( motorcycle_state.clutch == K25_Clutch_Lever_State_in ) Serial.print("IN");
+    else Serial.print("Unknown");
     Serial.println();

     Serial.print("Brakes: ");
     if( motorcycle_state.brake_levers == K25_Brake_Lever_State_none ) Serial.print("NONE");
-    else if( motorcycle_state.brake_levers == K25_Brake_Lever_State_front ) Serial.print("FRONT");
-    else if( motorcycle_state.brake_levers == K25_Brake_Lever_State_rear ) Serial.print("REAR");
-    else Serial.print("Unknown");
+    else if( motorcycle_state.brake_levers == K25_Brake_Lever_State_front ) Serial.print("FRONT");
+    else if( motorcycle_state.brake_levers == K25_Brake_Lever_State_rear ) Serial.print("REAR");
+    else Serial.print("Unknown");
     Serial.println();

     Serial.print("ABS: ");
     if( motorcycle_state.abs_system == K25_ABS_State_off ) Serial.print("OFF");
-    else if( motorcycle_state.abs_system == K25_ABS_State_on ) Serial.print("ON");
-    else Serial.print("Unknown");
+    else if( motorcycle_state.abs_system == K25_ABS_State_on ) Serial.print("ON");
+    else Serial.print("Unknown");
     Serial.println();

     Serial.print("ALS: ");
     if( motorcycle_state.als == K25_ALS_State_dark ) Serial.print("DARK");
-    else if( motorcycle_state.als == K25_ALS_State_light ) Serial.print("LIGHT");
-    else Serial.print("Unknown");
+    else if( motorcycle_state.als == K25_ALS_State_light ) Serial.print("LIGHT");
+    else Serial.print("Unknown");
     Serial.println();
 }

@@ -138,7 +138,8 @@
         {
           case MSG_ID_BMSK_Control_Module:
           {
-            handle_MSG_ID_BMSK_Control_Module(data, length);
+            motorcycle_state.throttle_position = (K25_Throttle_Position_t)K25_THROTTLE_PERCENTAGE(data[1]);
+            motorcycle_state.clutch = (K25_Clutch_Lever_State)LO_NIBBLE(data[4]);
           } break;

           case MSG_ID_BMSK_Control_Module_2:
@@ -148,17 +149,20 @@

           case MSG_ID_ZFE_Control_Module:
           {
-            handle_MSG_ID_ZFE_Control_Module(data, length);
+            motorcycle_state.high_beam = (K25_High_Beam_State)LO_NIBBLE(data[6]);
+            motorcycle_state.turn_signals = (K25_Turn_Signals_State)data[7];
           } break;

           case MSG_ID_ZFE_Control_Module_2:
           {
-            handle_MSG_ID_ZFE_Control_Module_2(data, length);
+              motorcycle_state.heated_grips = (K25_Heated_Grips_State)HI_NIBBLE(data[7]);
+              motorcycle_state.info_button = (K25_Info_Button_State)HI_NIBBLE(data[5]);
           } break;

           case MSG_ID_ABS_Control_Module:
           {
-            handle_MSG_ID_ABS_Control_Module(data, length);
+            motorcycle_state.brake_levers = (K25_Brake_Lever_State)LO_NIBBLE(data[6]);
+            motorcycle_state.abs_system = (K25_ABS_State)HI_NIBBLE(data[1]);
           } break;

           case MSG_ID_ABS_Control_Module_2:
@@ -168,70 +172,13 @@

           case MSG_ID_Instrument_Cluster:
           {
-            handle_MSG_ID_Instrument_Cluster(data, length);
+
           } break;

           case MSG_ID_Instrument_Cluster_2:
           {
-            handle_MSG_ID_Instrument_Cluster_2(data, length);
+            motorcycle_state.als = (K25_ALS_State)LO_NIBBLE(data[1]);
           } break;
         }
      }
 }
-
-void handle_MSG_ID_Instrument_Cluster(byte *data, byte length)
-{
-    DEBUG_PRINT("Instrument Cluster: ");
-}
-
-void handle_MSG_ID_Instrument_Cluster_2(byte *data, byte length)
-{
-    // AMBIENT LIGHT SENSOR
-    byte value = LO_NIBBLE(data[1]);
-    motorcycle_state.als = (K25_ALS_State)value;
-}
-
-void handle_MSG_ID_ABS_Control_Module(byte *data, byte length)
-{
-    // BRAKE LEVERS
-    byte value = LO_NIBBLE(data[6]);
-    motorcycle_state.brake_levers = (K25_Brake_Lever_State)value;
-
-    // ABS Status
-    value = HI_NIBBLE(data[1]);
-    motorcycle_state.abs_system = (K25_ABS_State)value;
-}
-
-void handle_MSG_ID_BMSK_Control_Module(byte *data, byte length)
-{
-    // THROTTLE POSITION
-    float fvalue = data[1];
-    motorcycle_state.throttle_position = (K25_Throttle_Position_t)K25_THROTTLE_PERCENTAGE(fvalue);
-
-    // CLUTCH LEVER
-    byte value = LO_NIBBLE(data[4]);
-    motorcycle_state.clutch = (K25_Clutch_Lever_State)value;
-}
-
-void handle_MSG_ID_ZFE_Control_Module(byte *data, byte length)
-{
-    // HIGH BEAM
-    byte value = LO_NIBBLE(data[6]);
-    motorcycle_state.high_beam = (K25_High_Beam_State)value;
-
-    // TURN SIGNAL
-    value = data[7];
-    motorcycle_state.turn_signals = (K25_Turn_Signals_State)value;
-}
-
-void handle_MSG_ID_ZFE_Control_Module_2(byte *data, byte length)
-{
-    // HEATED GRIPS
-    byte value = HI_NIBBLE(data[7]);
-    motorcycle_state.heated_grips = (K25_Heated_Grips_State)value;
-
-    // INFO BUTTON
-    value = HI_NIBBLE(data[5]);
-    motorcycle_state.info_button = (K25_Info_Button_State)value;
-}
-


Arduino communicates via CmdMessenger 3.5

--- arduino/brew_kettle/brew_kettle.ino
+++ arduino/brew_kettle/brew_kettle.ino
@@ -32,13 +32,9 @@
 boolean heaterIsOn = LOW;
 boolean pumpIsOn = LOW;

-// Mustnt conflict / collide with our message payload data.
-char field_separator = ',';
-char command_separator = ';';
-
-// Attach a new CmdMessenger object to the default Serial port
-CmdMessenger cmdMessenger = CmdMessenger(Serial, field_separator, \
-					 command_separator);
+
+// Attach CmdMessenger
+CmdMessenger cmdMessenger = CmdMessenger(Serial);

 // Commands we send from the Arduino to be received on the PC
 enum
@@ -47,13 +43,20 @@
   kError,
   kFullStatus,
   kTemperature,
+  kPumpStatus,
+  kHeaterStatus,
+  kPIDStatus,
+  kPID,
+  kHeater,
   kPump,
-  kHeater,
-  kPIDStatus,
   kSetpoint,
   kPValue,
   kIValue,
 };
+
+void OnArduinoReady() {
+  cmdMessenger.sendCmd(kAcknowledge, "Arduino ready");
+}

 void measureTemperature() {
   int index = analogRead(A0) - adcSubstract;
@@ -192,6 +195,9 @@
   temperaturePID.SetSampleTime(windowSize);

   Serial.begin(115200);
+
+  cmdMessenger.printLfCr();
+  cmdMessenger.sendCmd(kAcknowledge, "Arduino ready");
 }

 void loop () {


fixed signatures of Arduino sketch functions

--- examples/start_stop/start_stop.ino
+++ examples/start_stop/start_stop.ino
@@ -16,7 +16,7 @@
 /**
  * Start the pump, pause for a second, and stop the pump.
  */
-int setup()
+void setup()
 {

     // Initialise the LED to use for communication.
@@ -46,7 +46,7 @@
 /**
  * Do nothing here.
  */
-int loop()
+void loop()
 {
     delay(10);
 }


removed payload debugging

removed payload debugging

--- tracked-racer-esp/tracked-racer-esp.ino
+++ tracked-racer-esp/tracked-racer-esp.ino
@@ -96,7 +96,6 @@
   // define specific ws listener handler
   webSocketsServerListener.onTextMessage([](uint8_t num, WStype_t type, uint8_t *payload, size_t length) {

-    VERBOSE_F("PAYLOAD %s", payload);
     // try to parse payload as json
     DynamicJsonDocument docRequest;
     DeserializationError err = deserializeJson(docRequest, payload);