add first pass of audio sampling code

add first pass of audio sampling code

Currently, the script reads the average voltage over a window of 100 x 20ms = 2 seconds
and prints the average voltage level over serial. This is a raw, hardware-dependent
number that should be processed later, or prior to sending.

error: pathspec 'src/audio_sampler/src/audio_sampler/audio_sampler.ino' did not match any file(s) known to git

--- src/audio_sampler/src/audio_sampler/audio_sampler.ino
+++ src/audio_sampler/src/audio_sampler/audio_sampler.ino
@@ -0,0 +1,134 @@
+/*
+ * Silence Thresholder
+ * For Chatty Coasters
+ */
+
+/* DECLARATIONS */
+
+/* Discretize audio input to one sample every SAMPLE_WINDOW mS:
+ * e.g. 50mS = 20Hz sample rate. */
+const int sampleWindow = 50;
+
+/* After TIME_THRESH sampleWindows below VOL_THRESH, trigger event
+ * 20Hz * 5S wait time = 100 */
+int timeThresh = 100;
+int timeThreshCount;
+
+/* Record the average voltage over a window to be reported. */
+float runningAverage = 0;
+int windowSize = 100;
+int currWindow = 0;
+
+/* Thresholds for discretizing voltage to low, med, high.
+ * WARNING: need to adjust based on audio input's hardware. */
+const float lowThresh = 0.5f;
+const float medThresh = 1.2f;
+const float highThresh = 2.1f;
+
+/* Function pointer to a function to activate after silence threshold
+ * is achieved. */
+void (*threshFunc)(float *) = NULL;
+
+/* Function to run in setup to intially train the thresholder on how
+ * chatty the converstaion is. Chattiness is a factor from 0.1 to
+ * 1.0 representing quiet to loud. */
+void trainPhrase(); // TODO
+float chattiness; // TODO
+
+/* Do not speak again for COOLDOWN milliseconds after speaking. */
+int cooldown;
+const int cooldownTime = 5000;
+
+/* Threshold function declarations */
+void blinkLed(float *);
+void printThresh(float *);
+void sendAudio(float *);
+
+unsigned int sample;
+
+/* Pin declarations */
+int led = 13;
+
+/* MAIN CODE */
+
+void setup() {
+    pinMode(led, OUTPUT);
+    Serial.begin(9600);
+    timeThreshCount = 0;
+    // threshFunc = &printThresh;
+    // threshFunc = &blinkLed;
+    threshFunc = &sendAudio;
+
+	// trainPhrase();
+}
+
+
+void loop() {
+  unsigned long startMillis= millis();  // Start of sample window
+	double volts = audioSample(startMillis);
+  Serial.print("Volts: ");
+	Serial.println(volts);
+  Serial.print("Window: ");
+  Serial.println(currWindow);
+
+  if (++currWindow > windowSize)
+  {
+    runningAverage /= currWindow;
+    threshFunc(&runningAverage);
+    runningAverage = 0;
+    currWindow = 0;
+  }
+  else
+  {
+    runningAverage += volts;
+  }
+
+}
+
+double audioSample(unsigned long startMillis) {
+    unsigned int peakToPeak = 0;   // peak-to-peak level
+    unsigned int signalMax = 0;
+    unsigned int signalMin = 1024;
+
+    // collect data for 50 mS
+    while (millis() - startMillis < sampleWindow)
+    {
+        sample = analogRead(0);
+        if (sample < 1024)  // toss out spurious readings
+        {
+            if (sample > signalMax)
+            {
+                signalMax = sample;  // save just the max levels
+            }
+            else if (sample < signalMin)
+            {
+                signalMin = sample;  // save just the min levels
+            }
+        }
+    }
+    peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
+	return (peakToPeak * 3.3) /1024; // convert to volts
+}
+
+void trainPhrase() {
+	// machine learning jazz maybe
+}
+
+void blinkLed(float *unused) {
+    /* Intentionally block thread, do not listen during blocking */
+    digitalWrite(led, HIGH);
+    delay(2000);
+    digitalWrite(led, LOW);
+}
+
+void printThresh(float *unused) {
+    Serial.println("*********REACHED A THRESHOLD!**********");
+}
+
+void sendAudio(float *average) {
+  //TODO: send average over serial, marshalling to be decided
+  Serial.print("*********Boutta send some audio: ");
+  Serial.print(*average);
+  Serial.println("*********");
+}
+


basic pressure sensor sketch

basic pressure sensor sketch

error: pathspec 'ardesp/presure_sensor/presure_sensor.ino' did not match any file(s) known to git

--- ardesp/presure_sensor/presure_sensor.ino
+++ ardesp/presure_sensor/presure_sensor.ino
@@ -0,0 +1,17 @@
+void setup() {
+  // put your setup code here, to run once:
+  Serial.begin(115200);
+//  pinMode(A0,INPUT);
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+int analogValue = analogRead(A0);
+float pressure = (analogValue - 25)* .19; // conversion/"calibration" because sensor 4.5v=1.2MPa
+Serial.print("Value: ");
+Serial.print(analogValue);
+Serial.print("    Pressure: ");
+Serial.print(pressure);
+Serial.println(" PSI");
+delay(400);
+}


Added GCN Controller V5 which will support...

...repeating blocks of a macro, instead of repeating the entire macro.

error: pathspec 'gcn_controller_v5/gcn_controller_v5.ino' did not match any file(s) known to git

--- gcn_controller_v5/gcn_controller_v5.ino
+++ gcn_controller_v5/gcn_controller_v5.ino
@@ -0,0 +1,922 @@
+// This project uses 4 8-bit shift register, such as 74HC595 or HCF4094, in cascading format
+/*
+  GCN Controller for Arduino UNO by WhatAboutGaming
+  For use in the Twitch.TV stream TwitchTriesToPlay.
+  https://www.twitch.tv/twitchtriestoplay
+  https://github.com/WhatAboutGaming/Twitch-Plays-Stuff
+
+  Reference:
+  http://www.int03.co.uk/crema/hardware/gamecube/gc-control.html
+  http://www.seas.upenn.edu/~gland/gamecube.html
+  https://nintenduino.wordpress.com/documentation/controller-reference/
+  https://nintenduino.files.wordpress.com/2013/12/untitled.png
+  https://nintenduino.files.wordpress.com/2013/12/protocolv1-0.png
+  https://github.com/NicoHood/Nintendo
+  https://github.com/dekuNukem/gc3ds
+*/
+
+/*
+  PINOUTS
+
+
+  Protoboard Side|SR Bit      |Variable Name |GCN Controller Side
+  13 LEFT        |22 and 23   |axisY         |Analog Axis Y // Done
+  14 LEFT        |20 and 21   |axisX         |Analog Axis X // Done
+  15 LEFT        |18 and 19   |axisCx        |Axis C X // Done
+  16 LEFT        |16 and 17   |axisCy        |Axis C Y // Done
+  6  LEFT        |7           |buttonDDown   |D-Down // Done
+  5  LEFT        |6           |buttonDLeft   |D-Left // Done
+  8  LEFT        |8           |axisLTrigger  |L Analog Trigger // Done
+  7  LEFT        |10          |buttonLTrigger|L Digital Trigger // Done
+  10 LEFT        |0           |buttonTurbo   |Turbo (Bootleg Controller Button) // Done
+  11 LEFT        |24          |buttonMode    |Mode (Bootleg Controller Button) // Done
+  12 LEFT        |3           |buttonStart   |Start // Done
+  4  RIGHT       |9           |axisRTrigger  |R Analog Trigger // Done
+  3  LEFT        |4           |buttonDUp     |D-Up // Done
+  4  LEFT        |5           |buttonDRight  |D-Right // Done
+  5  RIGHT       |15          |buttonB       |B // Done
+  3  RIGHT       |11          |buttonRTrigger|R Digital Trigger // Done
+  6  RIGHT       |12          |buttonY       |Y // Done
+  8  RIGHT       |13          |buttonX       |X // Done
+  7  RIGHT       |14          |buttonA       |A // Done
+  10 RIGHT       |2           |buttonZ       |Z // Done
+  9  RIGHT       |1           |buttonMacro   |Macro (Bootleg Controller Button) // Done
+  9  LEFT        |A0 (Not SR) |motorInput    |Motor
+  11 RIGHT       |A1 (Not SR) |turboLed      |Turbo LED (Bootleg Controller Function)
+  12 RIGHT       |A2 (Not SR) |macroLed      |Macro LED (Bootleg Controller Function)
+*/
+
+#define latchPin 2 // HCF4094/74HC595 Latch/Strobe Input
+#define dataPin 3 // HCF4094/74HC595 Data Input
+#define clockPin 4 // HCF4094/74HC595 Clock Input
+
+/*
+  #define buttonLTrigger 0 // Left 7 // Bit
+  #define buttonRTrigger 1 // Right 3 // Bit
+  #define buttonZ 2 // Right 10 // Bit
+  #define buttonStart 3 // Left 12 // Bit
+
+  #define buttonY 4 // Right 6 // Bit
+  #define buttonX 5 // Right 8 // Bit
+  #define buttonB 6 // Right 5 // Bit
+  #define buttonA 7 // Right 7 // Bit
+
+  #define axisLTrigger 8 // Left 8 // Bit
+  #define axisRTrigger 9 // Right 4 // Bit
+  #define buttonMacro 10 // Right 9 // Bit
+  #define buttonTurbo 11 // Left 10 // Bit
+
+  #define buttonDUp 12 // Left 3 // Bit
+  #define buttonDDown 13 // Left 6 // Bit
+  #define buttonDRight 14 // Left 4 // Bit
+  #define buttonDLeft 15 // Left 5 // Bit
+
+  #define axisXHalf 16 // Left 14
+  #define axisXFull 17 // Left 14 // Both are part of the same byte
+
+  #define axisYHalf 18 // Left 13
+  #define axisYFull 19 // Left 13 // Both are part of the same byte
+
+  #define axisCxHalf 20 // left 15
+  #define axisCxFull 21 // left 15 // Both are part of the same byte
+
+  #define axisCyHalf 22 // Left 16
+  #define axisCyFull 23 // Left 16 // Both are part of the same byte
+
+  #define buttonMode 24 // Left 11 // Bit
+*/
+#define buttonTurbo 0 // Left 10 // Bit
+#define buttonMacro 1 // Right 9 // Bit
+#define buttonZ 2 // Right 10 // Bit
+#define buttonStart 3 // Left 12 // Bit
+
+#define buttonDUp 4 // Left 3 // Bit
+#define buttonDRight 5 // Left 4 // Bit
+#define buttonDLeft 6 // Left 5 // Bit
+#define buttonDDown 7 // Left 6 // Bit
+
+#define axisLTrigger 8 // Left 8 // Bit
+#define axisRTrigger 9 // Right 4 // Bit
+#define buttonLTrigger 10 // Left 7 // Bit
+#define buttonRTrigger 11 // Right 3 // Bit
+
+#define buttonY 12 // Right 6 // Bit
+#define buttonX 13 // Right 8 // Bit
+#define buttonA 14 // Right 7 // Bit
+#define buttonB 15 // Right 5 // Bit
+
+#define axisCxHalf 18 // Left 14
+#define axisCxFull 19 // Left 14 // Both are part of the same byte
+
+#define axisCyHalf 16 // Left 13
+#define axisCyFull 17 // Left 13 // Both are part of the same byte
+
+#define axisXHalf 20 // left 15
+#define axisXFull 21 // left 15 // Both are part of the same byte
+
+#define axisYHalf 22 // Left 16
+#define axisYFull 23 // Left 16 // Both are part of the same byte
+
+#define buttonMode 24 // Left 11 // Bit
+/*
+  serial_rx_buffer[0] = 0x01; //  Preamble
+  serial_rx_buffer[1] = 0x00; //  Digital L Trigger, Digital R Trigger, Z, Start, Y, X, B, A
+  serial_rx_buffer[2] = 0x00; //  Analog L Trigger, Analog R Trigger, Macro (Bootleg), Turbo (Bootleg), DUp, DDown, DRight, DLeft
+  serial_rx_buffer[3] = 0x7F; //  Analog X Axis
+  serial_rx_buffer[4] = 0x7F; //  Analog Y Axis
+  serial_rx_buffer[5] = 0x7F; //  C X Axis
+  serial_rx_buffer[6] = 0x7F; //  C Y Axis
+  serial_rx_buffer[7] = 0x00; //  Mode (Bootleg), Buffer Array Element 7  //  All other bits in this Buffer Array Element are unused
+  serial_rx_buffer[8] = 0x00; //  Unused
+  serial_rx_buffer[9] = 0x00; //  Delay Byte 2
+  serial_rx_buffer[10] = 0x00; // Delay Byte 1
+  serial_rx_buffer[11] = 0x01; // Postamble
+*/
+/////////////////////////////////
+
+const uint8_t startingMacroIndex = 0x04;
+const uint8_t endingMacroIndex = 0x64;
+const uint8_t macroBufferSize = endingMacroIndex - startingMacroIndex;
+const uint8_t startingMacroMetadataIndex = endingMacroIndex + 1;
+const uint8_t endingMacroMetadataIndex = startingMacroMetadataIndex + macroBufferSize;
+const uint8_t macroMetadataSize = endingMacroMetadataIndex - startingMacroMetadataIndex; // Using define on these variables for some reason was making it return wrong values
+//const uint8_t macroMetadataSize = macroBufferSize;
+
+uint8_t macroIndex = 0;
+uint8_t currentMacroIndexRunning = 0;
+uint8_t macroInputsToRun = 0;
+uint8_t loopMacro = 0; //0 = Don't loop, 1 = loop
+uint8_t timesToLoop = 0; //0 = Loop indefinitely, >0 = loop n times
+uint8_t loopCounter = 0;
+//uint8_t macroHasInnerLoops = 0; //This variable is used to tell if the macro has inner loops (eg: a+b,[wait b]255) // 0 = There are NO inner loops !0 = There is at least one inner loop
+uint8_t howManyInnerLoopsMacroHas = 0; //This variable is used to tell if the macro has inner loops (eg: a+b,[wait b]255) and how many there are // 0 = There are NO inner loops !0 = There are n inner loops, where N is this variable
+uint8_t macroMetadataIndex = 0;
+uint8_t currentMacroMetadataIndexRunning = 0;
+
+#define motorInput A0 // Left 9
+#define turboLed A1 // Right 11
+#define macroLed A2 // Right 12
+
+// Left 9 = Motor Input = A0
+// Right 11 = Turbo LED = A1
+// Right 12 = Macro LED = A2
+
+bool defaultStatus[] =        {HIGH,        HIGH,        HIGH,    HIGH,        HIGH,      HIGH,         HIGH,        HIGH,        LOW,          LOW,          HIGH,           HIGH,           HIGH,    HIGH,    HIGH,    HIGH,    HIGH,       LOW,        HIGH,       LOW,        HIGH,      LOW,       HIGH,      LOW,       HIGH,       HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH};
+bool inputStatus[] =          {HIGH,        HIGH,        HIGH,    HIGH,        HIGH,      HIGH,         HIGH,        HIGH,        LOW,          LOW,          HIGH,           HIGH,           HIGH,    HIGH,    HIGH,    HIGH,    HIGH,       LOW,        HIGH,       LOW,        HIGH,      LOW,       HIGH,      LOW,       HIGH,       HIGH, HIGH, HIGH, HIGH, HIGH, HIGH, HIGH};
+//uint8_t commandArray[] = {buttonLTrigger, buttonRTrigger, buttonZ, buttonStart, buttonY, buttonX, buttonB, buttonA, axisLTrigger, axisRTrigger, buttonMacro, buttonTurbo, buttonDUp, buttonDDown, buttonDRight, buttonDLeft, axisXHalf, axisXFull, axisYHalf, axisYFull, axisCxHalf, axisCxFull, axisCyHalf, axisCyHalf, buttonMode, 25, 26, 27, 28, 29, 30, 31};
+uint8_t commandArray[] = {buttonTurbo, buttonMacro, buttonZ, buttonStart, buttonDUp, buttonDRight, buttonDLeft, buttonDDown, axisLTrigger, axisRTrigger, buttonLTrigger, buttonRTrigger, buttonY, buttonX, buttonA, buttonB, axisCyHalf, axisCyFull, axisCxHalf, axisCxFull, axisXHalf, axisXFull, axisYHalf, axisYHalf, buttonMode, 25, 26, 27, 28, 29, 30, 31};
+uint8_t motorArray[] = {motorInput, turboLed, macroLed}; // Motor, Turbo LED, Macro LED
+
+bool isInputting = false;
+bool isInputtingDelayed = false;
+
+bool didInputChange = false;
+
+uint32_t inputDelay = 0;
+uint32_t previousInputDelay = 0;
+//uint32_t currentMillis = 0;
+
+uint32_t baudRate = 500000;
+
+uint8_t serial_rx_buffer[12];
+uint8_t current_macro_input[12];
+uint8_t old_macro_input[12];
+uint8_t macro_buffer[macroBufferSize][12];
+uint8_t macro_loop_metadata[macroMetadataSize][12]; // Contains informations such as how many times to repeat a portion of a macro, and where to start and end
+uint32_t controller = 0;
+
+void setup()
+{
+  Serial.begin(baudRate);
+
+  pinMode(motorInput, INPUT);
+  pinMode(turboLed, INPUT);
+  pinMode(macroLed, INPUT);
+
+  pinMode(latchPin, OUTPUT);
+  pinMode(dataPin, OUTPUT);
+  pinMode(clockPin, OUTPUT);
+
+  digitalWrite(latchPin, LOW);
+  for (int8_t i = 31; i >= 0; i--)
+  {
+    digitalWrite(clockPin, LOW);
+    digitalWrite(dataPin, defaultStatus[i]);
+    digitalWrite(clockPin, HIGH);
+  }
+  digitalWrite(latchPin, HIGH);
+
+  // Press the buttons X, Y and Start for 2 seconds to reset the controller,
+  // this is a built in controller feature to make it easier to reset analog sticks and
+  // triggers without having to unplug the controller, thanks Nintendo, this feature is very useful!
+  inputStatus[buttonX] = LOW;
+  inputStatus[buttonY] = LOW;
+  inputStatus[buttonStart] = LOW;
+
+  digitalWrite(latchPin, LOW);
+  for (int8_t i = 31; i >= 0; i--)
+  {
+    digitalWrite(clockPin, LOW);
+    digitalWrite(dataPin, inputStatus[i]);
+    digitalWrite(clockPin, HIGH);
+  }
+  digitalWrite(latchPin, HIGH);
+
+  delay(2000);
+
+  // Now we release the buttons X, Y and Start after 2 seconds have passed
+  inputStatus[buttonX] = HIGH;
+  inputStatus[buttonY] = HIGH;
+  inputStatus[buttonStart] = HIGH;
+
+  digitalWrite(latchPin, LOW);
+  for (int8_t i = 31; i >= 0; i--)
+  {
+    digitalWrite(clockPin, LOW);
+    digitalWrite(dataPin, inputStatus[i]);
+    digitalWrite(clockPin, HIGH);
+  }
+  digitalWrite(latchPin, HIGH);
+
+  //  Reset everything
+  serial_rx_buffer[0] = 0x00;
+  serial_rx_buffer[1] = 0x00;
+  serial_rx_buffer[2] = 0x00;
+  serial_rx_buffer[3] = 0x7F;
+  serial_rx_buffer[4] = 0x7F;
+  serial_rx_buffer[5] = 0x7F;
+  serial_rx_buffer[6] = 0x7F;
+  serial_rx_buffer[7] = 0x00;
+  serial_rx_buffer[8] = 0x00;
+  serial_rx_buffer[9] = 0x00;
+  serial_rx_buffer[10] = 0x00;
+  serial_rx_buffer[11] = 0x00;
+
+  current_macro_input[0] = 0x00;
+  current_macro_input[1] = 0x00;
+  current_macro_input[2] = 0x00;
+  current_macro_input[3] = 0x7F;
+  current_macro_input[4] = 0x7F;
+  current_macro_input[5] = 0x7F;
+  current_macro_input[6] = 0x7F;
+  current_macro_input[7] = 0x00;
+  current_macro_input[8] = 0x00;
+  current_macro_input[9] = 0x00;
+  current_macro_input[10] = 0x00;
+  current_macro_input[11] = 0x00;
+
+  old_macro_input[0] = 0x00;
+  old_macro_input[1] = 0x00;
+  old_macro_input[2] = 0x00;
+  old_macro_input[3] = 0x7F;
+  old_macro_input[4] = 0x7F;
+  old_macro_input[5] = 0x7F;
+  old_macro_input[6] = 0x7F;
+  old_macro_input[7] = 0x00;
+  old_macro_input[8] = 0x00;
+  old_macro_input[9] = 0x00;
+  old_macro_input[10] = 0x00;
+  old_macro_input[11] = 0x00;
+
+  Serial.println(startingMacroIndex);
+  Serial.println(endingMacroIndex);
+  Serial.println(macroBufferSize);
+  Serial.println(startingMacroMetadataIndex);
+  Serial.println(endingMacroMetadataIndex);
+  Serial.println(macroMetadataSize);
+
+}
+
+void loop()
+{
+  //currentMillis = millis();
+  if (Serial.available() > 0)
+  {
+    controller = Serial.readBytes(serial_rx_buffer, sizeof(serial_rx_buffer)) && 0xFF;
+
+    //  Set Start Byte (Preamble Byte) and End Byte (Postamble Byte)
+    //  1 == 0x01
+    if ((serial_rx_buffer[0] == 0x01) && (serial_rx_buffer[11] == 0x01))
+    {
+      for (uint8_t currentInputIndex = 0; currentInputIndex < sizeof(serial_rx_buffer); currentInputIndex++) {
+        current_macro_input[currentInputIndex] = serial_rx_buffer[currentInputIndex];
+      }
+      // Make the button presses actually work
+      macroIndex = 0;
+      currentMacroIndexRunning = 0;
+      macroInputsToRun = 0;
+      loopMacro = 0;
+      timesToLoop = 0;
+      loopCounter = 0;
+      howManyInnerLoopsMacroHas = 0;
+      isInputting = true;
+      isInputtingDelayed = false;
+      previousInputDelay = millis();
+    }
+    if ((serial_rx_buffer[0] >= startingMacroIndex) && (serial_rx_buffer[11] >= startingMacroIndex))
+    {
+      if ((serial_rx_buffer[0] < endingMacroIndex) && (serial_rx_buffer[11] < endingMacroIndex))
+      {
+        if (serial_rx_buffer[0] == serial_rx_buffer[11]) {
+          // Stop the current loop when we receive a new macro
+          macroIndex = 0;
+          currentMacroIndexRunning = 0;
+          macroInputsToRun = 0;
+          loopMacro = 0;
+          timesToLoop = 0;
+          loopCounter = 0;
+          howManyInnerLoopsMacroHas = 0;
+          //isInputting = false;
+          isInputtingDelayed = false;
+          macroIndex = serial_rx_buffer[0] - startingMacroIndex;
+          for (uint8_t macroInputIndex = 0; macroInputIndex < sizeof(serial_rx_buffer); macroInputIndex++) {
+            macro_buffer[macroIndex][macroInputIndex] = serial_rx_buffer[macroInputIndex];
+            //Serial.println(macro_buffer[macroIndex][macroInputIndex]);
+          }
+        }
+      }
+    }
+    if ((serial_rx_buffer[0] == endingMacroIndex) && (serial_rx_buffer[11] == endingMacroIndex))
+    {
+      // Stop the current loop when we receive a new macro setter (The thing that tells how a macro should be executed, if it should loop, how many inputs it has to iterate through)
+      macroIndex = 0;
+      currentMacroIndexRunning = 0;
+      macroInputsToRun = 0;
+      loopMacro = 0;
+      timesToLoop = 0;
+      loopCounter = 0;
+      howManyInnerLoopsMacroHas = 0;
+      isInputtingDelayed = false;
+      isInputting = false;
+      macroInputsToRun = serial_rx_buffer[1];
+      loopMacro = serial_rx_buffer[2];
+      currentMacroIndexRunning = serial_rx_buffer[3];
+      timesToLoop = serial_rx_buffer[4]; // Times to repeat, if == 0, it'll not repeat, if != 0, it'll repeat n times, so in this case, gramatically speaking, timesToLoop and times to repeat are different things (does this make sense?), so the max amount of times it can loop is 256, the amount of times it can repeat is 255, the first iteration is not a repetition (Repeat input? Repeated input?) (Again, does this makes sense?)
+      loopCounter = serial_rx_buffer[5];
+      howManyInnerLoopsMacroHas = serial_rx_buffer[6]; // Different than 0 if there are, 0 if there aren't
+      //isInputting = true;
+      //previousInputDelay = millis();
+    }
+    if ((serial_rx_buffer[0] >= startingMacroMetadataIndex) && (serial_rx_buffer[11] >= startingMacroMetadataIndex)) {
+      if ((serial_rx_buffer[0] < endingMacroMetadataIndex) && (serial_rx_buffer[11] < endingMacroMetadataIndex)) {
+        if (serial_rx_buffer[0] == serial_rx_buffer[11]) {
+          //Serial.print("Received loop metadata 1 info at index ");
+          //Serial.println(serial_rx_buffer[0]);
+          // Stop the current loop when we receive a new macro
+          macroIndex = 0;
+          currentMacroIndexRunning = 0;
+          macroInputsToRun = 0;
+          loopMacro = 0;
+          timesToLoop = 0;
+          loopCounter = 0;
+          howManyInnerLoopsMacroHas = 0;
+          //isInputting = false;
+          isInputtingDelayed = false;
+          macroMetadataIndex = serial_rx_buffer[0] - startingMacroMetadataIndex;
+          /*
+            macro_loop_metadata[macroMetadataIndex][0] = 0; // Preamble
+            macro_loop_metadata[macroMetadataIndex][1] = 0; // Inputs to execute (number of inputs that should be executed in this inner loop) (Use same logic as [5] here instead?)
+            macro_loop_metadata[macroMetadataIndex][2] = 0; // Current input index
+            macro_loop_metadata[macroMetadataIndex][3] = 0; // Times to loop (number of times this inner loop should be executed, before going to the next inner loop, if any)
+            macro_loop_metadata[macroMetadataIndex][4] = 0; // Loop counter (number of times this inner loop was executed)
+            macro_loop_metadata[macroMetadataIndex][5] = 0; // Where is the next inner loop's first input (index 0 input for the next inner loop, aka the index for the input in the macro_buffer array) (Continue normally if value is 0, or do nothing if there are no more inputs to be executed)
+            macro_loop_metadata[macroMetadataIndex][6] = 0; // Where to start (index of the starting input) (Inclusive)
+            macro_loop_metadata[macroMetadataIndex][7] = 0; // Where to end (index of the ending input) (Inclusive)
+            macro_loop_metadata[macroMetadataIndex][8] = 0; // How many inner loops that should be executed after this (if <=0, don't execute inner loops any inner loops after this, and move on as normal, if there are normal inputs to be exeucuted, execute those, if there's nothing else to do, go back to the beginning of the larger loop, if > 0, execute n inner loops after this)
+            macro_loop_metadata[macroMetadataIndex][9] = 0; // Unused?
+            macro_loop_metadata[macroMetadataIndex][10] = 0; // Unused?
+            macro_loop_metadata[macroMetadataIndex][11] = 0; // Postamble
+          */
+          for (uint8_t macroInputMetadataIndex = 0; macroInputMetadataIndex < sizeof(serial_rx_buffer); macroInputMetadataIndex++) {
+            macro_loop_metadata[macroMetadataIndex][macroInputMetadataIndex] = serial_rx_buffer[macroInputMetadataIndex];
+            //Serial.print("macroMetadataIndex = ");
+            //Serial.println(macroMetadataIndex);
+            //Serial.print("macroInputMetadataIndex = ");
+            //Serial.println(macroInputMetadataIndex);
+            Serial.println(macro_loop_metadata[macroMetadataIndex][macroInputMetadataIndex]);
+          }
+          //Serial.println("");
+        }
+      }
+    }
+    if ((serial_rx_buffer[0] == endingMacroMetadataIndex) && (serial_rx_buffer[11] == endingMacroMetadataIndex)) {
+      //Serial.print("Received loop metadata 2 info at index ");
+      //Serial.println(serial_rx_buffer[0]);
+    }
+  }
+  runMacro();
+  pressButtons();
+} // Close Loop Function
+
+void runMacro()
+{
+  if (isInputting == false) {
+    if (macroInputsToRun != 0) {
+      if (macroInputsToRun > currentMacroIndexRunning)
+      {
+        if (loopCounter <= timesToLoop) {
+          for (uint8_t currentInputIndex = 0; currentInputIndex < sizeof(serial_rx_buffer); currentInputIndex++) {
+            current_macro_input[currentInputIndex] = macro_buffer[currentMacroIndexRunning][currentInputIndex];
+            //Serial.println(current_macro_input[currentInputIndex]);
+            //Serial.print("currentMacroIndexRunning = ");
+            //Serial.println(currentMacroIndexRunning);
+          }
+          //Serial.print("currentMacroIndexRunning = ");
+          //Serial.println(currentMacroIndexRunning);
+          if (howManyInnerLoopsMacroHas <= 0) {
+            //Serial.println("\r\nTEST A");
+            /*
+              currentMacroMetadataIndexRunning = currentMacroIndexRunning + startingMacroMetadataIndex;
+              Serial.print("currentMacroMetadataIndexRunning = ");
+              Serial.println(currentMacroMetadataIndexRunning);
+            */
+            //
+            /*
+              Serial.println("");
+              Serial.print("howManyInnerLoopsMacroHas = ");
+              Serial.println(howManyInnerLoopsMacroHas);
+              Serial.print(" , currentMacroIndexRunning = ");
+              Serial.println(currentMacroIndexRunning);
+              Serial.println("");
+            */
+          }
+          if (howManyInnerLoopsMacroHas > 0) {
+            //Serial.println("\r\nTEST B");
+            //
+            currentMacroMetadataIndexRunning = currentMacroIndexRunning + startingMacroMetadataIndex;
+            if (macro_loop_metadata[currentMacroIndexRunning][2] == currentMacroMetadataIndexRunning) {
+              Serial.println("YEAH 2");
+            }
+            if (macro_loop_metadata[currentMacroIndexRunning][2] == currentMacroIndexRunning) {
+              //Serial.print("currentMacroMetadataIndexRunning = ");
+              //Serial.println(currentMacroMetadataIndexRunning);
+              Serial.println("YEAH");
+            }
+            Serial.print("startingMacroMetadataIndex = ");
+            Serial.println(startingMacroMetadataIndex);
+            Serial.print("currentMacroIndexRunning = ");
+            Serial.println(currentMacroIndexRunning);
+            Serial.print("macro_loop_metadata[currentMacroIndexRunning][2] = ");
+            Serial.println(macro_loop_metadata[currentMacroIndexRunning][2]); // Returning wrong values??????????
+            Serial.print("currentMacroMetadataIndexRunning = ");
+            Serial.println(currentMacroMetadataIndexRunning);
+            /*
+              Serial.println("");
+              Serial.print("howManyInnerLoopsMacroHas = ");
+              Serial.println(howManyInnerLoopsMacroHas);
+              Serial.print(" , currentMacroIndexRunning = ");
+              Serial.println(currentMacroIndexRunning);
+              Serial.println("");
+            */
+          }
+          // Make the button presses actually work
+          isInputting = true;
+          previousInputDelay = millis();
+        }
+      }
+      if (currentMacroIndexRunning < macroInputsToRun) {
+        currentMacroIndexRunning++;
+      }
+      if (loopMacro != 0) {
+        if (currentMacroIndexRunning >= macroInputsToRun) {
+          currentMacroIndexRunning = 0;
+          /*
+            if (timesToLoop <= 0) {
+            //
+            }
+          */
+          if (timesToLoop > 0 && loopCounter <= timesToLoop) {
+            // Sending this block for redundancy sake, will comment this block if something goes wrong (it shouldn't)
+            Serial.write(endingMacroIndex);
+            Serial.write(macroInputsToRun);
+            Serial.write(loopMacro);
+            Serial.write(currentMacroIndexRunning);
+            Serial.write(timesToLoop);
+            Serial.write(loopCounter);
+            Serial.write(howManyInnerLoopsMacroHas);
+            Serial.write(0x00);
+            Serial.write(0x00);
+            Serial.write(0x00);
+            Serial.write(0x00);
+            Serial.write(endingMacroIndex);
+            loopCounter++;
+            Serial.write(endingMacroIndex);
+            Serial.write(macroInputsToRun);
+            Serial.write(loopMacro);
+            Serial.write(currentMacroIndexRunning);
+            Serial.write(timesToLoop);
+            Serial.write(loopCounter);
+            Serial.write(howManyInnerLoopsMacroHas);
+            Serial.write(0x00);
+            Serial.write(0x00);
+            Serial.write(0x00);
+            Serial.write(0x00);
+            Serial.write(endingMacroIndex);
+          }
+        }
+      }
+    }
+  }
+}
+
+void pressButtons()
+{
+  if (isInputtingDelayed == false)
+  {
+    //  Define input delay (If Buffer Array Element 9 and 10 !=0)
+    inputDelay = (uint32_t)current_macro_input[9] << 8 | (uint32_t)current_macro_input[10];
+  }
+  if (isInputting == true)
+  {
+    didInputChange = false;
+    // Send the controller data back so it can be used to display controller information on the overlay
+    for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
+      if (current_macro_input[currentByteIndex] != old_macro_input[currentByteIndex]) {
+        didInputChange = true;
+      }
+      old_macro_input[currentByteIndex] = current_macro_input[currentByteIndex];
+    }
+    if (didInputChange == true) {
+      if (macroInputsToRun != 0) {
+        // This block is used to tell the backend where in the macro chain the current macro input is
+        Serial.write(endingMacroIndex);
+        Serial.write(macroInputsToRun);
+        Serial.write(loopMacro);
+        Serial.write(currentMacroIndexRunning);
+        Serial.write(timesToLoop);
+        Serial.write(loopCounter);
+        Serial.write(howManyInnerLoopsMacroHas);
+        Serial.write(0x00);
+        Serial.write(0x00);
+        Serial.write(0x00);
+        Serial.write(0x00);
+        Serial.write(endingMacroIndex);
+      }
+      for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
+        // Send only data back if it has changed, I don't know how to do this without having two loops
+        Serial.write(current_macro_input[currentByteIndex]);
+        //Serial.println(current_macro_input[currentByteIndex]);
+        //Serial.println("TEST");
+      }
+      /*
+        if (current_macro_input[2] == macro_loop_metadata[currentMacroIndexRunning][2]) {
+        //
+        //Serial.println("TEST");
+        }
+      */
+    }
+    Serial.flush();
+    //  Press Button
+
+    //  First 8 buttons, Buffer Array Element 1
+    //  Digital L Trigger, Digital R Trigger, Z, Start, Y, X, B, A
+    inputStatus[buttonLTrigger] = !(current_macro_input[1] & B00000001);
+    inputStatus[buttonRTrigger] = !(current_macro_input[1] & B00000010);
+    inputStatus[buttonZ] = !(current_macro_input[1] & B00000100);
+    inputStatus[buttonStart] = !(current_macro_input[1] & B00001000);
+    inputStatus[buttonY] = !(current_macro_input[1] & B00010000);
+    inputStatus[buttonX] = !(current_macro_input[1] & B00100000);
+    inputStatus[buttonB] = !(current_macro_input[1] & B01000000);
+    inputStatus[buttonA] = !(current_macro_input[1] & B10000000);
+
+    //  Second 8 buttons, Buffer Array Element 2
+    //  Analog L Trigger, Analog R Trigger, Macro (Bootleg), Turbo (Bootleg), DUp, DDown, DRight, DLeft
+    //  Analog R and L Triggers have to be inverted (invert the logic level)
+    inputStatus[axisLTrigger] = (current_macro_input[2] & B00000001);
+    inputStatus[axisRTrigger] = (current_macro_input[2] & B00000010);
+    inputStatus[buttonMacro] = !(current_macro_input[2] & B00000100);
+    inputStatus[buttonTurbo] = !(current_macro_input[2] & B00001000);
+    inputStatus[buttonDUp] = !(current_macro_input[2] & B00010000);
+    inputStatus[buttonDDown] = !(current_macro_input[2] & B00100000);
+    inputStatus[buttonDRight] = !(current_macro_input[2] & B01000000);
+    inputStatus[buttonDLeft] = !(current_macro_input[2] & B10000000);
+
+    //  4 Axis, Buffer Array Elements 3, 4, 5, 6
+    //  X, Y, CX, CY
+
+    //X STICK
+    if (current_macro_input[3] > 127)
+    {
+      // Push X Stick to Right
+      inputStatus[axisXHalf] = HIGH;
+      inputStatus[axisXFull] = HIGH;
+    }
+
+    if (current_macro_input[3] < 127)
+    {
+      // Push X Stick to Left
+      inputStatus[axisXHalf] = LOW;
+      inputStatus[axisXFull] = LOW;
+    }
+
+    if (current_macro_input[3] == 127)
+    {
+      // Keep X Stick Centered
+      inputStatus[axisXHalf] = HIGH;
+      inputStatus[axisXFull] = LOW;
+    }
+
+    //Y STICK
+    if (current_macro_input[4] > 127)
+    {
+      // Push Y Stick to Up
+      inputStatus[axisYHalf] = LOW;
+      inputStatus[axisYFull] = LOW;
+    }
+
+    if (current_macro_input[4] < 127)
+    {
+      // Push Y Stick to Down
+      inputStatus[axisYHalf] = HIGH;
+      inputStatus[axisYFull] = HIGH;
+    }
+
+    if (current_macro_input[4] == 127)
+    {
+      // Keep Y Stick Centered
+      inputStatus[axisYHalf] = HIGH;
+      inputStatus[axisYFull] = LOW;
+    }
+
+    //CX STICK
+    if (current_macro_input[5] > 127)
+    {
+      // Push CX Stick to Right
+      inputStatus[axisCxHalf] = HIGH;
+      inputStatus[axisCxFull] = HIGH;
+    }
+
+    if (current_macro_input[5] < 127)
+    {
+      // Push CX Stick to Left
+      inputStatus[axisCxHalf] = LOW;
+      inputStatus[axisCxFull] = LOW;
+    }
+
+    if (current_macro_input[5] == 127)
+    {
+      // Keep CX Stick Centered
+      inputStatus[axisCxHalf] = HIGH;
+      inputStatus[axisCxFull] = LOW;
+    }
+
+    //CY STICK
+    if (current_macro_input[6] > 127)
+    {
+      // Push CY Stick to Down
+      inputStatus[axisCyHalf] = LOW;
+      inputStatus[axisCyFull] = LOW;
+    }
+
+    if (current_macro_input[6] < 127)
+    {
+      // Push CY Stick to Up
+      inputStatus[axisCyHalf] = HIGH;
+      inputStatus[axisCyFull] = HIGH;
+    }
+
+    if (current_macro_input[6] == 127)
+    {
+      // Keep CY Stick Centered
+      inputStatus[axisCyHalf] = HIGH;
+      inputStatus[axisCyFull] = LOW;
+    }
+
+    //  Mode (Bootleg), Buffer Array Element 7
+    //  All other bits in this Buffer Array Element are unused
+    inputStatus[buttonMode] = !(current_macro_input[7] & B00000001);
+
+    digitalWrite(latchPin, LOW);
+    for (int8_t i = 31; i >= 0; i--)
+    {
+      digitalWrite(clockPin, LOW);
+      digitalWrite(dataPin, inputStatus[i]);
+      digitalWrite(clockPin, HIGH);
+    }
+    digitalWrite(latchPin, HIGH);
+
+    //  Buffer Array Element 8 is unused in this code, but is existing in case changes are needed
+
+    //  Buffer Array Elements 9 and 10 are used to tell the Arduino how long commands are executed, on a delay ranging from 1-65535ms
+    if (inputDelay != 0)
+    {
+      isInputtingDelayed = true;
+      //  The block below executes Soft Delay for holding the buttons down
+      if (isInputtingDelayed == true)
+      {
+        if (millis() - previousInputDelay >= inputDelay)
+        {
+          //  Now we need to stop the Soft Delay
+
+          //  Reset everything
+          serial_rx_buffer[0] = 0x00;
+          serial_rx_buffer[1] = 0x00;
+          serial_rx_buffer[2] = 0x00;
+          serial_rx_buffer[3] = 0x7F;
+          serial_rx_buffer[4] = 0x7F;
+          serial_rx_buffer[5] = 0x7F;
+          serial_rx_buffer[6] = 0x7F;
+          serial_rx_buffer[7] = 0x00;
+          serial_rx_buffer[8] = 0x00;
+          serial_rx_buffer[9] = 0x00;
+          serial_rx_buffer[10] = 0x00;
+          serial_rx_buffer[11] = 0x00;
+
+          current_macro_input[0] = 0x00;
+          current_macro_input[1] = 0x00;
+          current_macro_input[2] = 0x00;
+          current_macro_input[3] = 0x7F;
+          current_macro_input[4] = 0x7F;
+          current_macro_input[5] = 0x7F;
+          current_macro_input[6] = 0x7F;
+          current_macro_input[7] = 0x00;
+          current_macro_input[8] = 0x00;
+          current_macro_input[9] = 0x00;
+          current_macro_input[10] = 0x00;
+          current_macro_input[11] = 0x00;
+
+          didInputChange = false;
+
+          // Send the controller data back so it can be used to display controller information on the overlay
+          for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
+            if (current_macro_input[currentByteIndex] != old_macro_input[currentByteIndex]) {
+              didInputChange = true;
+            }
+            old_macro_input[currentByteIndex] = current_macro_input[currentByteIndex];
+          }
+          if (didInputChange == true) {
+            if (macroInputsToRun != 0) {
+              // This block is used to tell the backend where in the macro chain the current macro input is
+              Serial.write(endingMacroIndex);
+              Serial.write(macroInputsToRun);
+              Serial.write(loopMacro);
+              Serial.write(currentMacroIndexRunning);
+              Serial.write(timesToLoop);
+              Serial.write(loopCounter);
+              Serial.write(howManyInnerLoopsMacroHas);
+              Serial.write(0x00);
+              Serial.write(0x00);
+              Serial.write(0x00);
+              Serial.write(0x00);
+              Serial.write(endingMacroIndex);
+            }
+            for (uint8_t currentByteIndex = 0; currentByteIndex < sizeof(current_macro_input); currentByteIndex++) {
+              // Send only data back if it has changed, I don't know how to do this without having two loops
+              Serial.write(current_macro_input[currentByteIndex]);
+              //Serial.println(current_macro_input[currentByteIndex]);
+            }
+          }
+          Serial.flush();
+          //  First 8 buttons, Buffer Array Element 1
+          //  Digital L Trigger, Digital R Trigger, Z, Start, Y, X, B, A
+          inputStatus[buttonLTrigger] = !(current_macro_input[1] & B00000001);
+          inputStatus[buttonRTrigger] = !(current_macro_input[1] & B00000010);
+          inputStatus[buttonZ] = !(current_macro_input[1] & B00000100);
+          inputStatus[buttonStart] = !(current_macro_input[1] & B00001000);
+          inputStatus[buttonY] = !(current_macro_input[1] & B00010000);
+          inputStatus[buttonX] = !(current_macro_input[1] & B00100000);
+          inputStatus[buttonB] = !(current_macro_input[1] & B01000000);
+          inputStatus[buttonA] = !(current_macro_input[1] & B10000000);
+
+          //  Second 8 buttons, Buffer Array Element 2
+          //  Analog L Trigger, Analog R Trigger, Macro (Bootleg), Turbo (Bootleg), DUp, DDown, DRight, DLeft
+          //  Analog R and L Triggers have to be inverted (invert the logic level)
+          inputStatus[axisLTrigger] = (current_macro_input[2] & B00000001);
+          inputStatus[axisRTrigger] = (current_macro_input[2] & B00000010);
+          inputStatus[buttonMacro] = !(current_macro_input[2] & B00000100);
+          inputStatus[buttonTurbo] = !(current_macro_input[2] & B00001000);
+          inputStatus[buttonDUp] = !(current_macro_input[2] & B00010000);
+          inputStatus[buttonDDown] = !(current_macro_input[2] & B00100000);
+          inputStatus[buttonDRight] = !(current_macro_input[2] & B01000000);
+          inputStatus[buttonDLeft] = !(current_macro_input[2] & B10000000);
+
+          //  4 Axis, Buffer Array Elements 3, 4, 5, 6
+          //  X, Y, CX, CY
+
+          //X STICK
+          if (current_macro_input[3] > 127)
+          {
+            // Push X Stick to Right
+            inputStatus[axisXHalf] = HIGH;
+            inputStatus[axisXFull] = HIGH;
+          }
+
+          if (current_macro_input[3] < 127)
+          {
+            // Push X Stick to Left
+            inputStatus[axisXHalf] = LOW;
+            inputStatus[axisXFull] = LOW;
+          }
+
+          if (current_macro_input[3] == 127)
+          {
+            // Keep X Stick Centered
+            inputStatus[axisXHalf] = HIGH;
+            inputStatus[axisXFull] = LOW;
+          }
+
+          //Y STICK
+          if (current_macro_input[4] > 127)
+          {
+            // Push Y Stick to Up
+            inputStatus[axisYHalf] = LOW;
+            inputStatus[axisYFull] = LOW;
+          }
+
+          if (current_macro_input[4] < 127)
+          {
+            // Push Y Stick to Down
+            inputStatus[axisYHalf] = HIGH;
+            inputStatus[axisYFull] = HIGH;
+          }
+
+          if (current_macro_input[4] == 127)
+          {
+            // Keep Y Stick Centered
+            inputStatus[axisYHalf] = HIGH;
+            inputStatus[axisYFull] = LOW;
+          }
+
+          //CX STICK
+          if (current_macro_input[5] > 127)
+          {
+            // Push CX Stick to Right
+            inputStatus[axisCxHalf] = HIGH;
+            inputStatus[axisCxFull] = HIGH;
+          }
+
+          if (current_macro_input[5] < 127)
+          {
+            // Push CX Stick to Left
+            inputStatus[axisCxHalf] = LOW;
+            inputStatus[axisCxFull] = LOW;
+          }
+
+          if (current_macro_input[5] == 127)
+          {
+            // Keep CX Stick Centered
+            inputStatus[axisCxHalf] = HIGH;
+            inputStatus[axisCxFull] = LOW;
+          }
+
+          //CY STICK
+          if (current_macro_input[6] > 127)
+          {
+            // Push CY Stick to Down
+            inputStatus[axisCyHalf] = LOW;
+            inputStatus[axisCyFull] = LOW;
+          }
+
+          if (current_macro_input[6] < 127)
+          {
+            // Push CY Stick to Up
+            inputStatus[axisCyHalf] = HIGH;
+            inputStatus[axisCyFull] = HIGH;
+          }
+
+          if (current_macro_input[6] == 127)
+          {
+            // Keep CY Stick Centered
+            inputStatus[axisCyHalf] = HIGH;
+            inputStatus[axisCyFull] = LOW;
+          }
+
+          //  Mode (Bootleg), Buffer Array Element 7
+          //  All other bits in this Buffer Array Element are unused
+          inputStatus[buttonMode] = !(current_macro_input[7] & B00000001);
+          // Sometimes buttons are considered as released by the console between inputs, the pieces of code below will hopefully make it so buttons are only released at the end of the final iteration of a loopable macro, or released at the final input of a non-loopable macro, or released at the end of a basic input
+          if (loopMacro == 0) {
+            if (currentMacroIndexRunning == macroInputsToRun) {
+              digitalWrite(latchPin, LOW);
+              for (int8_t i = 31; i >= 0; i--)
+              {
+                digitalWrite(clockPin, LOW);
+                digitalWrite(dataPin, inputStatus[i]);
+                digitalWrite(clockPin, HIGH);
+              }
+              digitalWrite(latchPin, HIGH);
+            }
+          }
+          if (loopMacro != 0) {
+            if (loopCounter > timesToLoop) {
+              digitalWrite(latchPin, LOW);
+              for (int8_t i = 31; i >= 0; i--)
+              {
+                digitalWrite(clockPin, LOW);
+                digitalWrite(dataPin, inputStatus[i]);
+                digitalWrite(clockPin, HIGH);
+              }
+              digitalWrite(latchPin, HIGH);
+            }
+          }
+
+          //  Buffer Array Element 8 is unused in this code, but is existing in case changes are needed
+          isInputtingDelayed = false;
+          isInputting = false;
+          previousInputDelay += inputDelay;
+          inputDelay = 0;
+        }
+      }
+    }
+  }
+}


Update SlaveModule.ino

Update SlaveModule.ino

error: pathspec 'Arduino' did not match any file(s) known to git
error: pathspec 'code/SlaveModule/SlaveModule.ino' did not match any file(s) known to git


Working PWM Test Code

Working PWM Test Code

PWM test code works for multiple chains with multiple smart cable parasites.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/dkadish/nuit_blanche_ocean.git/'


Added ROS Arduino code using rosserial_arduino

error: pathspec 'ROS/crawler_ros_node/crawler_ros_node.ino' did not match any file(s) known to git

--- ROS/crawler_ros_node/crawler_ros_node.ino
+++ ROS/crawler_ros_node/crawler_ros_node.ino
@@ -0,0 +1,108 @@
+#include <ros.h>
+#include <ros/time.h>
+#include <geometry_msgs/Twist.h>
+#include <sensor_msgs/Range.h>
+#include <Servo.h>
+#include <Wire.h>
+
+#define LIDARLITE_ADDR 0x62
+#define LIDARLITE_CMD_CTRL_ADDR 0x00
+#define LIDARLITE_TRIG_VAL 0x04
+#define LIDARLITE_RANGE_ADDR 0x8f
+
+Servo wheel_speed_servo, wheel_direction_servo;
+const int lidar_pwr_en[] = {
+  12, 13};    // PWR_EN pins to put lidars to sleep
+ros::NodeHandle nh;
+
+sensor_msgs::Range range_msg;
+ros::Publisher pub_range("range_data", &range_msg);
+char frame_id[] = "/lidar_0";
+int enabled_lidar = 0;
+int lidar_state = 0;    // {0:Triggered, 1:Requested data, 2:Receiving data}
+
+void vel_cmd_cb(const geometry_msgs::Twist &cmd_msg) {
+  wheel_speed_servo.write(90 - 90 * cmd_msg.linear.x);
+  wheel_direction_servo.write(90 + 90 * cmd_msg.angular.z);
+}
+ros::Subscriber<geometry_msgs::Twist> sub_vel("cmd_vel", vel_cmd_cb);
+
+void setup() {
+  Wire.begin();
+  nh.initNode();
+  nh.advertise(pub_range);
+  nh.subscribe(sub_vel);
+
+  range_msg.radiation_type = 2;
+  range_msg.field_of_view = 0.001;
+  range_msg.max_range = 40;
+  range_msg.min_range = 0.1;
+
+  wheel_speed_servo.attach(8);
+  wheel_direction_servo.attach(9);
+  calibrate_servo(wheel_direction_servo, 0, 180);
+
+  enable_and_trigger(0);
+}
+
+void loop() {
+  switch (lidar_state) {
+  case 0:
+    Wire.beginTransmission(LIDARLITE_ADDR);
+    Wire.write(LIDARLITE_RANGE_ADDR);
+    if (Wire.endTransmission() == 0) lidar_state = 1;
+    break;
+  case 1:
+    if (Wire.requestFrom(LIDARLITE_ADDR, 2) > 0) lidar_state = 2;
+    break;
+  case 2:
+    if (Wire.available() >= 2) {
+      uint16_t range_data = Wire.read() << 8;
+      range_data += Wire.read();
+      if(range_data < 40000){
+        range_msg.range = (float)range_data;
+        range_msg.header.stamp = nh.now();
+        frame_id[7] = enabled_lidar + '0';
+        range_msg.header.frame_id = frame_id;
+        pub_range.publish(&range_msg);
+      }
+      if (enabled_lidar == 0)  enable_and_trigger(1);
+      else enable_and_trigger(0);
+      lidar_state = 0;
+    }
+  }
+  nh.spinOnce();
+  delay(1);
+}
+
+void enable_and_trigger(int lidar_id) {
+  // Put all lidars to sleep
+  for (int i = 0; i < sizeof(lidar_pwr_en) / sizeof(*lidar_pwr_en); i++)
+    digitalWrite(lidar_pwr_en[i], LOW);
+
+  // Wake up the specified lidar and mark it's state as triggered
+  digitalWrite(lidar_pwr_en[lidar_id], HIGH);
+  enabled_lidar = lidar_id;
+
+  // Trigger the signal acquisition
+  while (1) {
+    Wire.beginTransmission(LIDARLITE_ADDR);
+    Wire.write(LIDARLITE_CMD_CTRL_ADDR);
+    Wire.write(LIDARLITE_TRIG_VAL);
+    if (Wire.endTransmission() == 0) break;
+    delay(1);
+  }
+}
+
+void calibrate_servo(Servo & servo, int minVal, int maxVal) {
+  const int calibration_delay = 1000;
+  const int calibration_angles[] = {
+    maxVal, minVal, (minVal + maxVal) / 2, (minVal + maxVal) / 2      };
+  for (int i = 0; i < sizeof(calibration_angles) / sizeof(*calibration_angles); i++) {
+    servo.write(calibration_angles[i]);
+    delay(calibration_delay);
+  }
+}
+
+
+


Create particle_photon_to_ir.ino

Create particle_photon_to_ir.ino

error: pathspec 'Infrared/particle_photon_to_ir.ino' did not match any file(s) known to git


Preliminary 3DOF Implementation

Preliminary 3DOF Implementation

error: pathspec 'Robotic' did not match any file(s) known to git
error: pathspec 'Arm/Titan16_3DOF/Titan16_3DOF.ino' did not match any file(s) known to git


something

something

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/ivegotasthma/washmashine.git/'


Introducing the Claw project

Introducing the Claw project

error: pathspec 'Claw/Claw_controller/Claw_controller.ino' did not match any file(s) known to git

--- Claw/Claw_controller/Claw_controller.ino
+++ Claw/Claw_controller/Claw_controller.ino
@@ -0,0 +1,28 @@
+int buttonState = 1 //
+int servoPosition
+
+//this is nothing yet, working on it. ;)
+/*
+Een grijper die open of dicht gaat naar aanleiding van de waarde die middels een draaiknop wordt gegeven (en middels MAP functie omgevormd tot een bruikbare waarde)
+Als een object gegrepen is,
+dan luidt er een buzzer.
+En
+Het ledje gaat knipperen
+Als hoe kleiner de hoek is van de grijper, hoe feller het ledje gaat branden
+
+Op de LCD wordt weergeven:
+de hoek van de motor(dus de grijper) = Vraagt de waarde op van de huidige grijperwaarde
+Hoe vaak een object is gepakt = Telt
+En geeft weer indien een object wordt vastgehouden.*/
+
+void setup() {
+  // put your setup code here, to run once:
+
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+
+analogRead (buttonState)
+servoposition = map(buttonState, 0, 1023, 0, 180) //" map(value, fromLow, fromHigh, toLow, toHigh)
+}


add Arduino's nrf module

add Arduino's nrf module

error: pathspec 'Arduino/sendRF/sendRF.ino' did not match any file(s) known to git

--- Arduino/sendRF/sendRF.ino
+++ Arduino/sendRF/sendRF.ino
@@ -0,0 +1,24 @@
+#include <SPI.h>
+#include <RF24.h>
+
+// ce, csn pins
+RF24 radio(9,10);
+
+void setup() {
+  // put your setup code here, to run once:
+  radio.begin();
+  radio.setPALevel(RF24_PA_MAX);
+  radio.setChannel(0x76);
+  radio.openWritingPipe(0xF0F0F0F0E1LL);
+  radio.enableDynamicPayloads();
+  radio.powerUp();
+
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  const char text[] = "Hello World!";
+  radio.write(&text, sizeof(text));
+  delay(1000);
+
+}


Create Potmeter_ABP.ino

Create Potmeter_ABP.ino

error: pathspec 'The' did not match any file(s) known to git
error: pathspec 'Things' did not match any file(s) known to git
error: pathspec 'Network/potmeter-workshop/Potmeter_ABP/Potmeter_ABP.ino' did not match any file(s) known to git


add rfid module

add rfid module

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/werar/iothome.git/'


Adding a simple signal probe; sample a pulse sequence for analysis. DHT example.

error: pathspec 'examples/Sandbox/CosaProbe/CosaProbe.ino' did not match any file(s) known to git

--- examples/Sandbox/CosaProbe/CosaProbe.ino
+++ examples/Sandbox/CosaProbe/CosaProbe.ino
@@ -0,0 +1,148 @@
+/**
+ * @file CosaProbe.ino
+ * @version 1.0
+ *
+ * @section License
+ * Copyright (C) 2013, Mikael Patel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA  02111-1307  USA
+ *
+ * @section Description
+ * Probe to sample pulse sequence for analysis.
+ *
+ * This file is part of the Arduino Che Cosa project.
+ */
+
+#include "Cosa/Types.h"
+#include "Cosa/ExternalInterrupt.hh"
+#include "Cosa/RTC.hh"
+#include "Cosa/Power.hh"
+#include "Cosa/Watchdog.hh"
+#include "Cosa/IOStream/Driver/UART.hh"
+#include "Cosa/Trace.hh"
+
+/**
+ * Probe to collect samples using an external interrupt pin.
+ * Interrupt handler captures and records the pulse with until
+ * max number of samples or illegal pulse. Sample request/await
+ * starts interrupt handler and stops on max time.
+ */
+class Probe : public ExternalInterrupt {
+private:
+  static const uint8_t SAMPLE_MAX = 128;
+
+  volatile uint16_t m_sample[SAMPLE_MAX];
+  volatile uint8_t m_sampling;
+  volatile uint32_t m_start;
+  volatile uint8_t m_ix;
+
+  const uint16_t LOW_THRESHOLD;
+  const uint16_t HIGH_THRESHOLD;
+
+  virtual void on_interrupt(uint16_t arg = 0);
+
+public:
+  Probe(Board::ExternalInterruptPin pin, uint16_t low, uint16_t high) :
+    ExternalInterrupt(pin, ExternalInterrupt::ON_CHANGE_MODE),
+    m_sampling(false),
+    m_start(0L),
+    m_ix(0),
+    LOW_THRESHOLD(low),
+    HIGH_THRESHOLD(high)
+  {
+  }
+
+  void sample_request();
+  void sample_await(uint32_t ms);
+
+  friend IOStream& operator<<(IOStream& outs, Probe& probe);
+};
+
+IOStream& operator<<(IOStream& outs, Probe& probe)
+{
+  outs << probe.m_ix << ':';
+  for (uint8_t i = 0; i < probe.m_ix; i++)
+    outs << ' ' << probe.m_sample[i];
+  return (outs);
+}
+
+void
+Probe::on_interrupt(uint16_t arg)
+{
+  if (m_start == 0L) {
+    m_start = RTC::micros();
+    m_ix = 0;
+    return;
+  }
+  uint32_t stop = RTC::micros();
+  uint16_t us = (stop - m_start);
+  m_start = stop;
+  m_sample[m_ix++] = us;
+  if (us < LOW_THRESHOLD || us > HIGH_THRESHOLD) goto exception;
+  if (m_ix != SAMPLE_MAX) return;
+
+ exception:
+  m_sampling = false;
+  disable();
+}
+
+void
+Probe::sample_request()
+{
+  m_sampling = true;
+  m_start = 0L;
+  enable();
+}
+
+void
+Probe::sample_await(uint32_t ms)
+{
+  uint32_t start = RTC::millis();
+  while (m_sampling && RTC::since(start) < ms) Power::sleep(SLEEP_MODE_IDLE);
+  disable();
+}
+
+Probe probe(Board::EXT0, 20, 100);
+
+void setup()
+{
+  uart.begin(9600);
+  trace.begin(&uart, PSTR("CosaProbe: started"));
+  Watchdog::begin();
+  RTC::begin();
+}
+
+void loop()
+{
+  SLEEP(2);
+
+  // Make a request (DHT)
+  probe.set_mode(IOPin::OUTPUT_MODE);
+  probe.set();
+  probe.clear();
+  Watchdog::delay(32);
+  probe.set();
+  probe.set_mode(IOPin::INPUT_MODE);
+  DELAY(40);
+
+  // Wait for the response
+  probe.sample_request();
+  probe.sample_await(1000);
+
+  // Print samples
+  trace << probe << endl;
+}
+


Started code for outputexpander.

Started code for outputexpander.

error: pathspec 'Mpe/Plugs/OutputExpander/OutputExpander.ino' did not match any file(s) known to git

--- Mpe/Plugs/OutputExpander/OutputExpander.ino
+++ Mpe/Plugs/OutputExpander/OutputExpander.ino
@@ -0,0 +1,31 @@
+//Pin connected to ST_CP of 74HC595
+int latchPin = 8;
+//Pin connected to SH_CP of 74HC595
+int clockPin = 12;
+////Pin connected to DS of 74HC595
+int dataPin = 11;
+
+void setup() {
+  //set pins to output so you can control the shift register
+  pinMode(latchPin, OUTPUT);
+  pinMode(clockPin, OUTPUT);
+  pinMode(dataPin, OUTPUT);
+}
+
+void loop() {
+  // count from 0 to 255 and display the number
+  // on the LEDs
+  for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
+    // take the latchPin low so
+    // the LEDs don't change while you're sending in bits:
+    digitalWrite(latchPin, LOW);
+    // shift out the bits:
+    shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
+
+    //take the latch pin high so the LEDs will light up:
+    digitalWrite(latchPin, HIGH);
+    // pause before next value:
+    delay(500);
+  }
+}
+


Create controller.ino

Create controller.ino

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/robreeves/robotany.git/'


all sparked up

all sparked up

error: pathspec 'sparkcode/spark-rc-car-example.ino' did not match any file(s) known to git

--- sparkcode/spark-rc-car-example.ino
+++ sparkcode/spark-rc-car-example.ino
@@ -0,0 +1,119 @@
+// int pwmb = A5;
+// int dirb = A3;
+// int brakeb = D5;
+// int senb = A1;
+
+//                     chn a       chn b
+// Direction          D12/A4      D13/A3
+// PWM                  D3/D0     D11/A5
+// Brake              D9/D6     D8/D5
+// Current Sensing      A0/A0     A1/A1
+
+// pinMode(pwmb, OUTPUT);
+// pinMode(dirb, OUTPUT);
+// pinMode(brakeb, OUTPUT);
+// pinMode(senb, INPUT);
+
+
+
+/* A Spark function to parse the commands */
+int rcCarControl(String command);
+
+/* Globals -------------------------------------------------------------------*/
+int leftMotorEnable   = A5;
+int rightMotorEnable  = D0;
+int leftMotorDir    = A3;
+int rightMotorDir   = A4;
+
+
+/* This function is called once at start up ----------------------------------*/
+void setup()
+{
+  //Register Spark function
+  Spark.function("rccar", rcCarControl);
+
+  pinMode(leftMotorDir, OUTPUT);
+  pinMode(leftMotorEnable, OUTPUT);
+  pinMode(rightMotorDir, OUTPUT);
+  pinMode(rightMotorEnable, OUTPUT);
+
+  pinMode(D7,OUTPUT);
+}
+
+/* This function loops forever --------------------------------------------*/
+void loop()
+{
+  // Nothing to do here
+}
+
+/*******************************************************************************
+ * Function Name  : rcCarControl
+ * Description    : Parses the incoming API commands and sets the motor control
+                    pins accordingly
+ * Input          : RC Car commands
+                    e.g.: rc,FORWARD
+                          rc,BACK
+ * Output         : Motor signals
+ * Return         : 1 on success and -1 on fail
+ *******************************************************************************/
+int rcCarControl(String command)
+{
+  if(command.substring(3,7) == "STOP")
+  {
+    digitalWrite(leftMotorEnable,LOW);
+    digitalWrite(rightMotorEnable,LOW);
+
+    digitalWrite(leftMotorDir,LOW);
+    digitalWrite(rightMotorDir,LOW);
+
+    return 1;
+  }
+
+  if(command.substring(3,7) == "BACK")
+  {
+    digitalWrite(leftMotorDir,LOW);
+    digitalWrite(rightMotorDir,LOW);
+
+    digitalWrite(leftMotorEnable,HIGH);
+    digitalWrite(rightMotorEnable,HIGH);
+
+    return 1;
+  }
+
+  if(command.substring(3,10) == "FORWARD")
+  {
+    digitalWrite(leftMotorDir,HIGH);
+    digitalWrite(rightMotorDir,HIGH);
+
+    digitalWrite(leftMotorEnable,HIGH);
+    digitalWrite(rightMotorEnable,HIGH);
+
+    return 1;
+  }
+
+  if(command.substring(3,8) == "RIGHT")
+  {
+    digitalWrite(leftMotorDir,HIGH);
+    digitalWrite(rightMotorDir,LOW);
+
+    digitalWrite(leftMotorEnable,HIGH);
+    digitalWrite(rightMotorEnable,HIGH);
+
+    return 1;
+  }
+
+  if(command.substring(3,7) == "LEFT")
+  {
+    digitalWrite(leftMotorDir,LOW);
+    digitalWrite(rightMotorDir,HIGH);
+
+    digitalWrite(leftMotorEnable,HIGH);
+    digitalWrite(rightMotorEnable,HIGH);
+
+    return 1;
+  }
+
+  // If none of the commands were executed, return false
+  return -1;
+}
+


Channel 1 rotating in 1 direction, slowly.

error: pathspec 'MotorLab/MotorLab.ino' did not match any file(s) known to git

--- MotorLab/MotorLab.ino
+++ MotorLab/MotorLab.ino
@@ -0,0 +1,116 @@
+// MotorLab WIP
+
+#define NUM_MOTOR_CHANNELS 4
+#define NUM_MOTOR_SIGNALS  4
+
+uint8_t motor[NUM_MOTOR_CHANNELS][NUM_MOTOR_SIGNALS];
+
+
+
+// Debug declarations
+    int ledPin = 13;  // select the pin for the LED
+
+
+// Joystick declaration
+    int JoyX = A0;    // select the input pin for the potentiometer
+    int JoyY = A1;
+
+    int JoyXVal = 0;  // variable to store the value coming from the sensor
+    int JoyYVal = 0;
+
+
+uint8_t iGlobalStep = 0;
+void setup()
+{
+    pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT:
+    Serial.begin(9600);
+
+    motor[0][0] = A4;
+    motor[0][1] = A5;
+    motor[0][2] = 23;
+    motor[0][3] = 20;
+
+    for (int i=0; i< NUM_MOTOR_SIGNALS; i++) {pinMode(motor[0][i], OUTPUT);}
+
+    digitalWrite(ledPin, HIGH);     // turn the ledPin on
+    iGlobalStep = 0;
+}
+
+int debugJoyXY(int iX, int iY)
+{
+    Serial.print("JoyX: [");
+    Serial.print(JoyXVal);
+    Serial.print("], JoyY: [");
+    Serial.print(JoyYVal);
+    Serial.print("\n");
+
+    return 0;
+}
+
+void loop()
+{
+    switch(iGlobalStep)
+    {
+        case 0:
+            digitalWrite(motor[0][0], 0);
+            digitalWrite(motor[0][1], 0);
+            digitalWrite(motor[0][2], 0);
+            digitalWrite(motor[0][3], 1);
+            break;
+        case 1:
+            digitalWrite(motor[0][0], 0);
+            digitalWrite(motor[0][1], 0);
+            digitalWrite(motor[0][2], 1);
+            digitalWrite(motor[0][3], 1);
+            break;
+        case 2:
+            digitalWrite(motor[0][0], 0);
+            digitalWrite(motor[0][1], 0);
+            digitalWrite(motor[0][2], 1);
+            digitalWrite(motor[0][3], 0);
+            break;
+        case 3:
+            digitalWrite(motor[0][0], 0);
+            digitalWrite(motor[0][1], 1);
+            digitalWrite(motor[0][2], 1);
+            digitalWrite(motor[0][3], 0);
+            break;
+        case 4:
+            digitalWrite(motor[0][0], 0);
+            digitalWrite(motor[0][1], 1);
+            digitalWrite(motor[0][2], 0);
+            digitalWrite(motor[0][3], 0);
+            break;
+        case 5:
+            digitalWrite(motor[0][0], 1);
+            digitalWrite(motor[0][1], 1);
+            digitalWrite(motor[0][2], 0);
+            digitalWrite(motor[0][3], 0);
+            break;
+        case 6:
+            digitalWrite(motor[0][0], 1);
+            digitalWrite(motor[0][1], 0);
+            digitalWrite(motor[0][2], 0);
+            digitalWrite(motor[0][3], 0);
+            break;
+        case 7:
+            digitalWrite(motor[0][0], 1);
+            digitalWrite(motor[0][1], 0);
+            digitalWrite(motor[0][2], 0);
+            digitalWrite(motor[0][3], 1);
+            break;
+
+        default:
+            digitalWrite(motor[0][0], 0);
+            digitalWrite(motor[0][1], 0);
+            digitalWrite(motor[0][2], 0);
+            digitalWrite(motor[0][3], 0);
+            break;
+
+    }
+
+    delay(1);
+
+    if (++iGlobalStep >=8){ iGlobalStep = 0; }
+
+}


Added Ultrasonic.ino sketch

Added Ultrasonic.ino sketch

error: pathspec 'Source/Ultrasonic.ino' did not match any file(s) known to git

--- Source/Ultrasonic.ino
+++ Source/Ultrasonic.ino
@@ -0,0 +1,54 @@
+#include "Arduino.h"
+
+class Ultrasonic
+{
+public:
+
+    Ultrasonic(int trig, int echo)
+    {
+      pinMode(trig, OUTPUT);
+      pinMode(echo, INPUT);
+      Trig = trig;
+      Echo = echo;
+    }
+
+    long Timing()
+    {
+      digitalWrite(Trig, LOW);
+      delayMicroseconds(2);
+      digitalWrite(Trig, HIGH);
+      delayMicroseconds(10);
+      digitalWrite(Trig, LOW);
+      long duration = pulseIn(Echo, HIGH);
+      return duration;
+    }
+
+    long Ranging()
+    {
+      long duration = Timing();
+      long distacne = duration / 29 / 2;
+      return distacne;
+    }
+
+private:
+
+    int Trig;
+    int Echo;
+};
+
+Ultrasonic ultrasonic(9, 8);
+
+void setup()
+{
+  Serial.begin(9600);
+}
+
+void loop()
+{
+  int dist = ultrasonic.Ranging();
+  if(dist > 2 && dist < 400){
+    Serial.print(dist);
+    Serial.print(" ");
+    delay(100);
+  }
+}


Create template_home.ino

Create template_home.ino

Version for first Watterott SenseBox Home Kit

error: pathspec 'files/template_home/template_home.ino' did not match any file(s) known to git

--- files/template_home/template_home.ino
+++ files/template_home/template_home.ino
@@ -0,0 +1,200 @@
+/*
+SenseBox Home - Citizen Sensingplatform
+Version: 2.1
+Date: 2015-09-09
+Homepage: http://www.sensebox.de
+Author: Jan Wirwahn, Institute for Geoinformatics, University of Muenster
+Note: Sketch for SenseBox Home Kit
+Email: support@sensebox.de
+*/
+
+#include <Wire.h>
+#include "HDC100X.h"
+#include "BMP280.h"
+#include <Makerblog_TSL45315.h>
+#include <SPI.h>
+#include <Ethernet.h>
+
+//SenseBox ID
+
+//Sensor IDs
+
+//Configure ethernet connection
+IPAddress myIp(192, 168, 0, 42);
+byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+char server[] = "www.opensensemap.org";
+EthernetClient client;
+
+//Load sensors
+Makerblog_TSL45315 TSL = Makerblog_TSL45315(TSL45315_TIME_M4);
+HDC100X HDC(0x43);
+BMP280 BMP;
+
+//measurement variables
+float temperature = 0;
+float humidity = 0;
+double tempBaro, pressure;
+uint32_t lux;
+uint16_t uv;
+int messTyp;
+#define UV_ADDR 0x38
+#define IT_1   0x1
+
+unsigned long oldTime = 0;
+const unsigned long postingInterval = 10000;
+
+void setup() {
+  // Open serial communications and wait for port to open:
+  Serial.begin(9600);
+  // start the Ethernet connection:
+  Serial.println("SenseBox Home software version 2.1");
+  Serial.println();
+  Serial.print("Starting ethernet connection...");
+  if (Ethernet.begin(mac) == 0) {
+    Serial.println("Failed to configure Ethernet using DHCP");
+    Ethernet.begin(mac, myIp);
+  }else Serial.println("done!");
+  delay(1000);
+  //Initialize sensors
+  Serial.print("Initializing sensors...");
+  Wire.begin();
+  Wire.beginTransmission(UV_ADDR);
+  Wire.write((IT_1<<2) | 0x02);
+  Wire.endTransmission();
+  delay(500);
+  HDC.begin(HDC100X_TEMP_HUMI,HDC100X_14BIT,HDC100X_14BIT,DISABLE);
+  TSL.begin();
+  BMP.begin();
+  BMP.setOversampling(4);
+  Serial.println("done!");
+  Serial.println("Starting loop.");
+  temperature = HDC.getTemp();
+  Serial.println(temperature,2);
+}
+
+void loop()
+{
+  // if there are incoming bytes available
+  // from the server, read them and print them:
+  if (client.available()) {
+    char c = client.read();
+    Serial.print(c);
+    //Serial.write(c);
+  }
+
+  if (millis() - oldTime > postingInterval) {
+    oldTime = millis();
+    //-----Pressure-----//
+    Serial.println("Posting pressure");
+    messTyp = 2;
+    char result = BMP.startMeasurment();
+    if(result!=0){
+      delay(result);
+      result = BMP.getTemperatureAndPressure(tempBaro,pressure);
+      postObservation(pressure, PRESSURESENSOR_ID, SENSEBOX_ID);
+      //Serial.print("Temp_baro = ");Serial.println(tempBaro,2);
+      //Serial.print("Pressure  = ");Serial.println(pressure,2);
+    }
+    delay(2000);
+    //-----Humidity-----//
+    Serial.println("Posting humidity");
+    messTyp = 2;
+    humidity = HDC.getHumi();
+    //Serial.print("Humidity = "); Serial.println(humidity);
+    postObservation(humidity, HUMISENSOR_ID, SENSEBOX_ID);
+    delay(2000);
+    //-----Temperature-----//
+    Serial.println("Posting temperature");
+    messTyp = 2;
+    temperature = HDC.getTemp();
+    //Serial.println(temperature,2);
+    //Serial.print("Temperature = ");Serial.println(temperature);
+    postObservation(temperature, TEMPSENSOR_ID, SENSEBOX_ID);
+    delay(2000);
+    //-----Lux-----//
+    Serial.println("Posting illuminance");
+    messTyp = 1;
+    lux = TSL.readLux();
+    //Serial.print("Illumi = "); Serial.println(lux);
+    postObservation(lux, LUXSENSOR_ID, SENSEBOX_ID);
+    delay(2000);
+    //UV intensity
+    messTyp = 1;
+    uv = getUV();
+    postObservation(uv, UVSENSOR_ID, SENSEBOX_ID);
+  }
+}
+
+void postObservation(float measurement, String sensorId, String boxId){
+  char obs[10];
+  if (messTyp == 1) dtostrf(measurement, 5, 0, obs);
+  else if (messTyp == 2) dtostrf(measurement, 5, 2, obs);
+  Serial.println(obs);
+  //json must look like: {"value":"12.5"}
+  //post observation to: http://opensensemap.org:8000/boxes/boxId/sensorId
+  Serial.println("connecting...");
+  String value = "{\"value\":";
+  value += obs;
+  value += "}";
+  if (client.connect(server, 8000))
+  {
+    Serial.println("connected");
+    // Make a HTTP Post request:
+    client.print("POST /boxes/");
+    client.print(boxId);
+    client.print("/");
+    client.print(sensorId);
+    client.println(" HTTP/1.1");
+    // Send the required header parameters
+    client.println("Host:opensensemap.org");
+    client.println("Content-Type: application/json");
+    client.println("Connection: close");
+    client.print("Content-Length: ");
+    client.println(value.length());
+    client.println();
+    // Send the data
+    client.print(value);
+    client.println();
+  }
+  waitForResponse();
+}
+
+void waitForResponse()
+{
+  // if there are incoming bytes available
+  // from the server, read them and print them:
+  boolean repeat = true;
+  do{
+    if (client.available())
+    {
+      char c = client.read();
+      Serial.print(c);
+    }
+    // if the servers disconnected, stop the client:
+    if (!client.connected())
+    {
+      Serial.println();
+      Serial.println("disconnecting.");
+      client.stop();
+      repeat = false;
+    }
+  }
+  while (repeat);
+}
+
+uint16_t getUV(){
+  byte msb=0, lsb=0;
+  uint16_t uvValue;
+
+  Wire.requestFrom(UV_ADDR+1, 1); //MSB
+  delay(1);
+  if(Wire.available()) msb = Wire.read();
+
+  Wire.requestFrom(UV_ADDR+0, 1); //LSB
+  delay(1);
+  if(Wire.available()) lsb = Wire.read();
+
+  uvValue = (msb<<8) | lsb;
+
+  return uvValue*5;
+}


Long Long Long is way to phylosophical for Arduino

/bin/sh: 1: Syntax error: Unterminated quoted string


Create quarterturn_nointerrupt.ino

Create quarterturn_nointerrupt.ino

error: pathspec 'encoder/quarterturn_nointerrupt.ino' did not match any file(s) known to git

--- encoder/quarterturn_nointerrupt.ino
+++ encoder/quarterturn_nointerrupt.ino
@@ -0,0 +1,121 @@
+/*
+
+  Encoder 1/4 Turn Demo (Robot Chemistry 4.IS8)
+
+  James H. Bannock and John C. de Mello
+
+  Department of Chemistry,
+  Imperial College London
+
+  Version 1.02
+
+  Created: Feb 2015
+  Updated: Nov 2016
+
+  Revisions: Increased commnenting and improved setup
+
+  ---
+
+  Requirements:
+
+  Optical quadrature encoder with resolution of 500 counts per revolution attached to Arduino Pin 5.
+
+  ---
+
+  Timer Notes:
+
+     Each timer has two 8-bit registers TCCRxA and TCCRxB which store the configurable setup. (TCCRnX = Timer/Counter Control Register X for Timer n)).
+
+     (All the following terms (such as TCCR1A etc.) are inbuilt macros (like the #define operation) and represent a number - either a register value or a counter value).
+
+     Arduinos support multiple timers/counters with varying resolutions.
+
+     The Uno has three timers (Timer0, Timer1 and Timer2).
+
+     Timer1 is a 16 bit timer (i.e. can support a counter value between 0 and 65535 (2^16-1)).
+
+     (Timer0 and Timer2 are 8-bit timers and therefore only support a max. counter value of 255).
+
+     TCNT1 (Timer/Counter Register for Timer1) stores the current value of the counter.
+
+     Here we use a simple implementation of the counter where TCNT1 stores the number of signals received from a quadrature optical encoder.
+
+     To achieve this we set the timer/counter to a configuration where the timer/counter source is an external pin (the encoder), which is fixed on Pin5 for Timer1 on the Uno.
+
+     Note that because we are using the hardware timer we do not need to write: pinMode(5, INPUT_PULLUP);
+
+     The necessary configuration bits we need to setup the counter are in the TCCR1B register.
+
+     We must set the Clock Select (CS) bits to either:
+
+     - Falling-edge detection (5->0V): CS12 = CS11 = 1, CS10 = 0; or
+     - Rising-edge detection (0->5V): CS12 = CS11 = CS10 = 1
+
+     When TCNT1 reaches a value of 125 (=1/4 turn on the motor for a 500 count encoder) an if-statement causes the LED on the Arduino to flash and we reset TCNT1 to 0.
+
+     Note that this implementation avoids using an interrupt service routine (ISR) -> see equivalent example for interrupt version
+*/
+
+void setup() {
+
+  //Serial.begin(9600);
+
+  pinMode(13, OUTPUT); // activate the LED pin
+
+  // switch off interrupts to avoid conflict while changing settings
+  noInterrupts();
+
+  // reset timer/counter registers A and B.
+  TCCR1A = 0;
+  TCCR1B = 0;
+
+  // set the counter to external Timer1 source Pin5 and configure for rising-edge detection.
+  TCCR1B |= (1 << CS12); // set CS12 HIGH - bit 2 (4) - equally you could write TCCR1B |= 4;
+  TCCR1B |= (1 << CS11); // set CS11 HIGH - bit 1 (2)
+  TCCR1B |= (1 << CS10); // set CS10 HIGH - bit 0 (1)
+
+  //Serial.print("TCCR1B (in decimal): ");
+  //Serial.println(TCCR1B);
+  //Serial.print("TCCR1B (in binary): ");
+  //Serial.println(TCCR1B, BIN);
+
+  //TCCR1B &= ~(1 << CS12);
+
+  //Serial.print("TCCR1B: ");
+  //Serial.println(TCCR1B);
+
+  /*
+     Nptes:
+
+     X |= Y is shorthand for X = X OR Y (in binary this is effectively an addition operation).
+
+     e.g. suppose X = 2 (B00000010) and Y = 4 (B00000100) then X |= Y would set X = B00000110 => 6
+
+     Y |= (1 << X) is shorthand for setting bit X in byte Y to a value of 1, and equates to a decimal addition of 2^X.
+
+     e.g. take line 73, CS12 = 2 so if Y = 0 intially then the operation has the effect of setting bit 2 to 1, which equates to a decimal value of 4 (2^2)
+
+     Note that if you want to set bit X in byte Y to zero then the OR statement may not work if bit X is set at 1.
+
+     (If you want to set bit X to zero then you can use: Y &= ~(1 << X), where & is an AND operation and ~ is a NOT operation, see commented limes 82-85)
+
+     If you uncomment the Serial commands on lines 61 and 77-80 and upload to an Arduino you will see that TCCR1B = 7.
+
+     This is because we sets bits 0 (value 2^0 = 1), 1 (value 2^1 = 2) and 2 (value 2^2 = 4) to 1, which sums to 7.
+  */
+
+  // switch on interrupts again
+  interrupts();
+}
+
+void loop() {
+
+  if (TCNT1 > 125) { // if counter has counted greater than 125 pulses
+    digitalWrite(13, HIGH); // LED on
+    delay(100); // wait a bit
+    digitalWrite(13, LOW); // LED off
+    TCNT1 = 0; // reset counter
+  }
+
+  delay(10); // wait a bit
+}


Code To Control the Arduino

Code To Control the Arduino

error: pathspec 'Testing_Arduino101/Testing_Arduino101.ino' did not match any file(s) known to git

--- Testing_Arduino101/Testing_Arduino101.ino
+++ Testing_Arduino101/Testing_Arduino101.ino
@@ -0,0 +1,98 @@
+#include <NewPing.h>
+
+#define TRIGGER_PIN1 2
+#define ECHO_PIN1 4
+
+#define TRIGGER_PIN2 5
+#define ECHO_PIN2 6
+
+#define TRIGGER_PIN3 7
+#define ECHO_PIN3 8
+
+#define TRIGGER_PIN4 10
+#define ECHO_PIN4 13
+
+#define MAX_DISTANCE 200
+
+#define LED 13
+#define LMOTOR 9
+#define RMOTOR 3
+
+NewPing sonar1(TRIGGER_PIN1, ECHO_PIN1, MAX_DISTANCE);
+NewPing sonar2(TRIGGER_PIN2, ECHO_PIN2, MAX_DISTANCE);
+NewPing sonar3(TRIGGER_PIN3, ECHO_PIN3, MAX_DISTANCE);
+NewPing sonar4(TRIGGER_PIN4, ECHO_PIN4, MAX_DISTANCE);
+
+char input;
+int conInput;
+
+
+void setup() {
+        Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
+        pinMode(LED, OUTPUT);
+}
+
+void loop() {
+
+        // send data only when you receive data:
+        if (Serial.available() > 0) {
+                // read the incoming byte:
+                input = Serial.read(); //single character
+
+                Serial.print("I received as a char: ");
+                Serial.println(input);
+
+                switch(input){
+                  case '0':
+                  led_off();
+                  break;
+                  case '1':
+                  led_on();
+                  break;
+                  case 'f':
+                  move_foward();
+                  break;
+                  case 's':
+                  stop_motor();
+                  break;
+                  case 'u':
+                  us_sensor();
+                  default:
+                  break;
+                }
+        }
+}
+void led_on(){
+  digitalWrite(LED, HIGH);
+
+}
+void led_off(){
+  digitalWrite(LED, LOW);
+}
+void move_foward(){
+  digitalWrite(LMOTOR, HIGH);
+  digitalWrite(RMOTOR, HIGH);
+}
+void stop_motor(){
+  digitalWrite(LMOTOR, LOW);
+  digitalWrite(RMOTOR, LOW);
+}
+void us_sensor(){
+  delay(50);
+
+  Serial.print("Sensor 1: ");
+  Serial.print(sonar1.ping_cm());
+
+  Serial.print("Sensor 2: ");
+  Serial.print(sonar2.ping_cm());
+
+  Serial.print("Sensor 3: ");
+  Serial.print(sonar3.ping_cm());
+
+  Serial.print("Sensor 4: ");
+  Serial.print(sonar4.ping_cm());
+
+  delay(50);
+
+}
+


oscillator+scope example

oscillator+scope example

error: pathspec 'examples/OscillatorScope_example/OscillatorScope_example.ino' did not match any file(s) known to git


added Sonoff S20 EU plug

added Sonoff S20 EU plug

error: pathspec 'sonoff-homie-s20/sonoff-homie-s20.ino' did not match any file(s) known to git

--- sonoff-homie-s20/sonoff-homie-s20.ino
+++ sonoff-homie-s20/sonoff-homie-s20.ino
@@ -0,0 +1,73 @@
+#include <Homie.h>
+
+#define PIN_LED     13      // PIN 12 / HSPI_MOSI; UART0_CTS MTCK
+#define PIN_RELAY   12      // PIN 10 / HSPI_MISO MTDI
+#define PIN_BUTTON  0
+
+#define BRAND "sonoff-s20"
+#define FW_NAME "sonoff-s20"
+#define FW_VERSION "1.0.0"
+
+unsigned long buttonDownTime = 0;
+byte lastButtonState = 1;
+byte buttonPressHandled = 0;
+
+HomieNode relayNode("switch", "switch");
+
+bool relayHandler(const HomieRange& range, const String& value) {
+  if (value != "true" && value != "false") return false;
+
+  bool on = (value == "true");
+  digitalWrite(PIN_RELAY, on ? HIGH : LOW);
+  relayNode.setProperty("on").send(value);
+  Homie.getLogger() << "switch is " << (on ? "on" : "off") << endl;
+
+  return true;
+}
+
+void toggleRelay() {
+  bool on = digitalRead(PIN_RELAY) == HIGH;
+  digitalWrite(PIN_RELAY, on ? LOW : HIGH);
+  relayNode.setProperty("on").send(on ? "false" : "true");
+  Homie.getLogger() << "Switch is " << (on ? "off" : "on") << endl;
+}
+
+void loopHandler() {
+  byte buttonState = digitalRead(PIN_BUTTON);
+  if ( buttonState != lastButtonState ) {
+    if (buttonState == LOW) {
+      buttonDownTime = millis();
+      buttonPressHandled = 0;
+    }
+    else {
+      unsigned long dt = millis() - buttonDownTime;
+      if ( dt >= 90 && dt <= 900 && buttonPressHandled == 0 ) {
+        toggleRelay();
+        buttonPressHandled = 1;
+      }
+    }
+    lastButtonState = buttonState;
+  }
+}
+
+void setup() {
+  Serial.begin(115200);
+  Serial << endl << endl;
+
+  pinMode(PIN_RELAY, OUTPUT);
+  pinMode(PIN_BUTTON, INPUT_PULLUP);
+  digitalWrite(PIN_RELAY, LOW);
+
+  Homie_setFirmware(FW_NAME, FW_VERSION);
+  Homie_setBrand(BRAND);
+  relayNode.advertise("on").settable(relayHandler);
+
+  Homie.setLedPin(PIN_LED, LOW);
+  Homie.setResetTrigger(PIN_BUTTON, LOW, 5000);
+  Homie.setLoopFunction(loopHandler);
+  Homie.setup();
+}
+
+void loop() {
+  Homie.loop();
+}


Arduinofilu lisätty

Arduinofilu lisätty

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/teemune/TestiRepomies.git/'


Create RS485_slave_stepperMotor.ino

Create RS485_slave_stepperMotor.ino

error: pathspec 'cc/RS485_slave_stepperMotor.ino' did not match any file(s) known to git

--- cc/RS485_slave_stepperMotor.ino
+++ cc/RS485_slave_stepperMotor.ino
@@ -0,0 +1,98 @@
+#include <SimpleModbusSlave.h>
+#include <AccelStepper.h>
+#include <Wire.h>
+#include "rgb_lcd.h"
+
+
+#define baud 38400
+#define timeout 1000
+#define polling 1000 // the scan rate
+#define retry_count 10
+
+
+int Distance = 0;
+
+rgb_lcd lcd;
+
+const int colorR = 255;
+const int colorG = 0;
+const int colorB = 0;
+
+#define TxEnablePin 2
+#define  LED 10
+
+enum
+{
+  // just add or remove registers and your good to go...
+  // The first register starts at address 0
+  ADC_VAL,
+  PWM_VAL,
+  HOLDING_REGS_SIZE // leave this one
+  // total number of registers for function 3 and 16 share the same register array
+  // i.e. the same address space
+};
+
+unsigned int holdingRegs[HOLDING_REGS_SIZE]; // function 3 and 16 register array
+
+ AccelStepper stepper3(2, 8, 9);
+void setup()
+{Serial.begin(38400);
+
+
+
+  modbus_configure(&Serial, 38400, SERIAL_8N2, 1, 2, HOLDING_REGS_SIZE, holdingRegs);
+
+  // modbus_update_comms(baud, byteFormat, id) is not needed but allows for easy update of the
+  // port variables and slave id dynamically in any function.
+  modbus_update_comms(9600, SERIAL_8N2, 1);
+
+
+ lcd.begin(16, 2);
+
+    lcd.setRGB(colorR, colorG, colorB);
+
+    // Print a message to the LCD.
+   lcd.print("XYZ");
+
+     stepper3.setMaxSpeed(5600.0);
+    stepper3.setAcceleration(8000.0);
+}
+
+void loop()
+{
+
+
+
+  modbus_update();
+
+  //holdingRegs[ADC_VAL] = analogRead(A0); // update data to be read by the master to adjust the PWM
+
+ //analogWrite(LED, holdingRegs[1]);
+
+
+  //lcd.setCursor(5, 1);
+    //lcd.print(holdingRegs[1]);
+
+int value = holdingRegs[0];
+
+if (value > 120)
+
+ {int value1 = -abs(value/10);
+     lcd.setCursor(5, 0);
+    lcd.print(value1);
+
+stepper3.moveTo(value1*12);
+    stepper3.run();
+
+
+ }
+   else {
+
+    lcd.setCursor(5, 0);
+    lcd.print(holdingRegs[0]);
+
+stepper3.moveTo(holdingRegs[0]*25);
+    stepper3.run();
+   }
+
+}


Doubled

Doubled

error: pathspec 'arduino' did not match any file(s) known to git
error: pathspec 'code/MeasureTemp/MeasureTemp.ino' did not match any file(s) known to git


do we understand it better if the SPI logging is better?

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/trinamic/T-Bone.git/'


Changed name of pixel board

Changed name of pixel board

error: pathspec 'Sketches/LED' did not match any file(s) known to git
error: pathspec 'Board/led_board/led_board.ino' did not match any file(s) known to git


First Revision

First Revision

error: pathspec 'SpinCode/SpinCode.ino' did not match any file(s) known to git

--- SpinCode/SpinCode.ino
+++ SpinCode/SpinCode.ino
@@ -0,0 +1,88 @@
+#include <Wire.h>
+#include <Adafruit_L3GD20.h>
+
+// Masking Defs
+#define BIT_MASK 8191 // 13 bits, all ones
+#define EIGHT_BIT_MAX 255 // 8 bits, all ones, the maximum value the LED would take (255), used for flipping ranges
+#define ABS_MASK 32767 // 15 bits, all ones, && with 16 bit signed integer to take off sign bit
+#define QUARTER ABS_MASK >> 2 // 15 bits all ones divided by 4
+#define HALF ABS_MASK >> 1 // 15 bits all ones divided by 2
+#define THREE_QUARTER QUARTER + HALF // summed together to produce 3/4
+#define SHIFT_NUM 6 // right shifting the masked accelerometer data by this number will change the range to 0 -> 127
+
+#define r 10
+#define g 12
+#define b 9
+
+Adafruit_L3GD20 gyro;
+
+long sum;
+int accel_in = 0;
+int masked_in;
+
+void setup()
+{
+  pinMode(r,OUTPUT);
+  pinMode(g,OUTPUT);
+  pinMode(b,OUTPUT);
+
+  if (!gyro.begin(gyro.L3DS20_RANGE_2000DPS))
+  {
+    while (1);
+  }
+
+  //analogWrite(r,1);
+  //analogWrite(g,1);
+}
+
+void loop()
+{
+  sum = 0;
+  for(int i = 0; i < 8; i++)
+  { gyro.read();
+    sum = sum + abs(gyro.data.z);
+    delay(1);
+  }
+  sum = sum >> 3;
+  accel_in = (int)sum;
+
+  // assuming accel_in = signed 16 bit input
+  // r -> pwm value for red from 0 -> 255
+  // g -> pwm value for green 0 -> 255
+  // b -> pwm value for blue 0 -> 255
+
+//  accel_in = accel_in + 1;
+
+
+//  for(int i = 0; i < 127; i++)
+//  { analogWrite(g,127-i);
+//    analogWrite(r,i);
+//      delay(10);
+//  }
+
+accel_in = accel_in & ABS_MASK; // take absolute value of accelerometer data
+masked_in = accel_in & BIT_MASK; // 13 bit mask of accelerometer data
+
+if(accel_in < QUARTER){ // first quarter of accelerometer range
+analogWrite(r,0);
+analogWrite(g,masked_in >> SHIFT_NUM); // green ranges 0 -> 127
+analogWrite(b,EIGHT_BIT_MAX - ( masked_in >> SHIFT_NUM)); // blue ranges 255 -> 128
+}
+else if(accel_in < HALF){ // second quarter of accelerometer range
+analogWrite(r,0);
+analogWrite(g,(EIGHT_BIT_MAX >> 1) + (masked_in >> SHIFT_NUM)); // green ranges 128 -> 255
+analogWrite(b,(EIGHT_BIT_MAX >> 1) - (masked_in >> SHIFT_NUM)); // blue ranges 127 -> 0
+}
+else if(accel_in < THREE_QUARTER){// third quarter of accelerometer range
+analogWrite(r,masked_in >> SHIFT_NUM); // red ranges 0 -> 127
+analogWrite(g,EIGHT_BIT_MAX - ( masked_in >> SHIFT_NUM)); // green ranges 255 -> 128
+analogWrite(b,0);
+}
+else{ // final quarter of accelerometer range
+analogWrite(r,(EIGHT_BIT_MAX >> 1) + (masked_in >> SHIFT_NUM)); // red ranges 128 -> 255
+analogWrite(g,(EIGHT_BIT_MAX >> 1) - (masked_in >> SHIFT_NUM)); // green ranges 127 -> 0
+analogWrite(b,0);
+}
+
+}
+


Updated NTP example

Updated NTP example

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/PaoloP74/WiFiESP.git/'


Added documentation to the serialTestSketch arduino sketch.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/jondolan/igvc-software.git/'


Neurosky Mindwave Meter

Neurosky Mindwave Meter

This is incomplete. needs to have the 2nd servo configured in the code.

error: pathspec 'MindWave_DualServo_Monitor_v3/MindWave_DualServo_Monitor_v3.ino' did not match any file(s) known to git

--- MindWave_DualServo_Monitor_v3/MindWave_DualServo_Monitor_v3.ino
+++ MindWave_DualServo_Monitor_v3/MindWave_DualServo_Monitor_v3.ino
@@ -0,0 +1,202 @@
+////////////////////////////////////////////////////////////////////////
+// Arduino Bluetooth Interface with Mindwave
+//
+// Some of this is example code provided by NeuroSky, Inc. and is provided
+// license free.
+
+// This Code has been modified to control a Servo with it's signal wire attached to pin 13 and serial out info on which case it is using.
+// Urban Reininger - urban@ross.org - 2014-02-07
+////////////////////////////////////////////////////////////////////////
+
+#include <Servo.h>
+
+Servo servo1;  // create servo object to control a servo
+Servo servo2;  // create servo object to control a servo
+
+int pos = 0;    // variable to store the servo position
+int servo1Degrees = 0;
+int servo2Degrees = 0;
+
+#define BAUDRATE 57600
+#define DEBUGOUTPUT 0
+
+#define powercontrol 10
+
+// checksum variables
+byte generatedChecksum = 0;
+byte checksum = 0;
+int payloadLength = 0;
+byte payloadData[64] = {
+  0};
+byte poorQuality = 0;
+byte attention = 0;
+byte meditation = 0;
+
+// system variables
+long lastReceivedPacket = 0;
+boolean bigPacket = false;
+
+// Microprocessor Setup  ------------------------------------------
+
+void setup() {
+
+  servo1.attach(13);  // attaches the servo on pin 13 to the servo object
+
+  Serial.begin(BAUDRATE);           // USB
+}
+
+// Read data from Serial UART    ------------------------------------------
+byte ReadOneByte() {
+  int ByteRead;
+
+  while(!Serial.available());
+  ByteRead = Serial.read();
+
+#if DEBUGOUTPUT
+  Serial.print((char)ByteRead);   // echo the same byte out the USB serial (for debug purposes)
+#endif
+
+  return ByteRead;
+}
+
+//MAIN LOOP//
+void loop() {
+
+
+  // Look for sync bytes
+  if(ReadOneByte() == 170) {
+    if(ReadOneByte() == 170) {
+
+      payloadLength = ReadOneByte();
+      if(payloadLength > 169)                      //Payload length can not be greater than 169
+          return;
+
+      generatedChecksum = 0;
+      for(int i = 0; i < payloadLength; i++) {
+        payloadData[i] = ReadOneByte();            //Read payload into memory
+        generatedChecksum += payloadData[i];
+      }
+
+      checksum = ReadOneByte();                      //Read checksum byte from stream
+      generatedChecksum = 255 - generatedChecksum;   //Take one's compliment of generated checksum
+
+        if(checksum == generatedChecksum) {
+
+        poorQuality = 200;
+        attention = 0;
+        meditation = 0;
+
+        for(int i = 0; i < payloadLength; i++) {    // Parse the payload
+          switch (payloadData[i]) {
+          case 2:
+            i++;
+            poorQuality = payloadData[i];
+            bigPacket = true;
+            break;
+          case 4:
+            i++;
+            attention = payloadData[i];
+            break;
+          case 5:
+            i++;
+            meditation = payloadData[i];
+            break;
+          case 0x80:
+            i = i + 3;
+            break;
+          case 0x83:
+            i = i + 25;
+            break;
+          default:
+            break;
+          } // switch
+        } // for loop
+
+#if !DEBUGOUTPUT
+
+        // *** Add your code here ***
+
+        if(bigPacket) {
+          if(poorQuality == 0)
+          Serial.print("Conencted! ");
+
+          Serial.print("Noise: ");
+          Serial.print(poorQuality, DEC);
+          Serial.print(" Attention: ");
+          Serial.print(attention , DEC);
+          Serial.print(" Meditation: "); // added
+          Serial.print(meditation, DEC); //added
+
+          Serial.print(" Time since last packet: ");
+          Serial.print(millis() - lastReceivedPacket, DEC);
+          lastReceivedPacket = millis();
+          Serial.print("\n");
+
+
+// How the Servo's angle increases or decreases -------------------------------------
+
+if(poorQuality == 0){
+
+          if (meditation > servo1Degrees){  //tesing meditation
+
+            servo1Degrees=(servo1Degrees+3);
+            servo1.write(servo1Degrees);
+            Serial.print("Meditation Up - Servo Degrees: ");
+            Serial.print(servo1Degrees);
+            Serial.print("\n");
+
+            }
+          if(meditation <= servo1Degrees){  //tesing meditation
+            servo1Degrees=(servo1Degrees-3);
+            servo1.write(servo1Degrees);
+            Serial.print("Meditation Down - Servo Degrees: ");
+            Serial.print(servo1Degrees);
+            Serial.print("\n");
+
+          } // end meditation testing
+
+
+           if (attention > servo2Degrees){  //tesing attention
+
+            servo2Degrees=(servo2Degrees+3);
+            servo2.write(servo2Degrees);
+            Serial.print("Attention Up - Servo Degrees: ");
+            Serial.print(servo2Degrees);
+            Serial.print("\n");
+
+            }
+
+          if(attention <= servo2Degrees){  //tesing attention
+            servo2Degrees=(servo2Degrees-3);
+            servo2.write(servo2Degrees);
+            Serial.print("Attention Down - Servo Degrees: ");
+            Serial.print(servo2Degrees);
+            Serial.print("\n");
+
+          } // end attention testing
+
+
+} else {
+
+       servo1Degrees=0;
+       servo2Degrees=0;
+       servo1.write(servo1Degrees);
+       servo2.write(servo2Degrees);
+
+       Serial.print("Poor connection, Servos set to 0 Degrees!!!");
+       Serial.print("\n");
+        } // end else
+
+        }
+#endif
+        bigPacket = false;
+      }
+      else {
+        // Checksum Error
+      }  // end if else for checksum
+    } // end if read 0xAA byte
+  } // end if read 0xAA byte
+}
+
+
+


Tutorial 3

Tutorial 3

Tutorial med knapper tilføjet

error: pathspec 'tutorial' did not match any file(s) known to git
error: pathspec 'files/_3_buttons/_3_buttons.ino' did not match any file(s) known to git


add the finally working attempt at a pwm fan controller

error: pathspec 'arduino/bridgehead_pwm/bridgehead_pwm.ino' did not match any file(s) known to git

--- arduino/bridgehead_pwm/bridgehead_pwm.ino
+++ arduino/bridgehead_pwm/bridgehead_pwm.ino
@@ -0,0 +1,169 @@
+/*
+                Fast PWM Test
+
+Demostrates the generation of high speed PWM
+using timers 1 and 4
+There are two pieces of code:
+
+One for pins 9, 10 and 11 using TIMER 1
+with frequencies up to 62kHz
+
+Other for pins 5 and 6 using TIMER 4
+with frequencies up to 187kHz
+
+*/
+
+/**********************************************************
+   Fast PWM on pins 9,10,11 (TIMER 1)
+
+   Do not use analogWrite to pins 9, 10 or 11 if using
+   this functions as they use the same timer.
+
+   Those functions will probably conflict with the
+   servo library.
+
+   Uses 5 PWM frequencies between 61Hz and 62.5kHz
+
+**********************************************************/
+
+// Frequency modes for TIMER1
+#define PWM62k   1   // 62500 Hz
+#define PWM8k    2   //  7812 Hz
+#define PWM1k    3   //   976 Hz
+#define PWM244   4   //   244 Hz
+#define PWM61    5   //    61 Hz
+
+// Direct PWM change variables
+// OCR = output compare register
+#define PWM9   OCR1A
+#define PWM10  OCR1B
+#define PWM11  OCR1C
+
+// Configure the PWM clock
+// The argument is one of the 5 previously defined modes
+void pwm91011configure(int mode) {
+  // Configure DDRB
+  // DDRB is the Port B Data Direction Register.
+  DDRB |= 1 << 5;  // Set port B pin 5 (Arduino 9) to output mode
+  DDRB |= 1 << 6;  // Set port B pin 6 (Arduino 10) to output mode
+  DDRB |= 1 << 7;  // Set port B pin 7 (Arduino 11) to output mode
+
+  // Configure TCCR1A
+  //  00 : Channel A disabled D9
+  //  00 : Channel B disabled D10
+  //  00 : Channel C disabled D11
+  //  01 : Fast PWM 8 bit
+  // TCCR1A is the Timer/Counter1 Control Register A.
+  TCCR1A = 1;      // Set prescaler to 1, to increment at 16 MHz
+  TCCR1A |= 0x80;  // Activate channel 5
+  TCCR1A |= 0x20;  // Activate channel 6
+  TCCR1A |= 0x08;  // Activate channel 7
+
+  // Configure TCCR1B
+  // TCCR1B is the Timer/Counter 1 Control Register B.
+  // Clock mode and Fast PWM 8 bit
+  TCCR1B = mode | 0x08;
+
+  // Configure TCCR1C
+  // TCCR1C is the Timer/Counter 1 Control Register C.
+  TCCR1C = 0;      // Stop timer/counter channel c
+}
+
+/**********************************************************
+   Fast PWM on pins 5, 6 (High Speed TIMER 4)
+
+   Do not use analogWrite to pins 5 or 6 if using
+   this functions as they use the same timer.
+
+   Those functions will conflict with the
+   MSTIMER2 library.
+
+   Uses 7 PWM frequencies between 2930Hz and 187.5kHz
+
+   Timer 4 uses a PLL as input so that its clock frequency
+   can be up to 96MHz on standard Arduino Leonardo.
+   We limit imput frequency to 48MHz to generate 187.5kHz PWM
+   If needed, we can double that up to 375kHz
+
+**********************************************************/
+
+// Frequency modes for TIMER4
+#define PWM187k 1   // 187500 Hz
+#define PWM94k  2   //  93750 Hz
+#define PWM47k  3   //  46875 Hz
+#define PWM23k  4   //  23437 Hz
+#define PWM12k  5   //  11719 Hz
+#define PWM6k   6   //   5859 Hz
+#define PWM3k   7   //   2930 Hz
+
+// Direct PWM change variables
+#define PWM5 OCR4A
+#define PWM6 OCR4D
+
+// Configure the PWM clock
+// The argument is one of the 7 previously defined modes
+void pwm_5_6_configure(int mode) {
+  // TCCR4A configuration
+  TCCR4A |= 0x42; // Activate the complementary channel A (Arduino pin 5)
+
+  // TCCR4B configuration
+  TCCR4B = mode;
+
+  // TCCR4C configuration
+  TCCR4C |= 0x09;  // Activate channel C
+
+  // TCCR4D configuration
+  TCCR4D = 0;      // operate in PWM mode
+
+  OCR4C = 255;     // Terminal count for Timer 4 PWM
+
+  // Configure Port C
+  DDRC |= 1 << 6;  // Set port C pin 6 (Arduino 5) to output mode
+  DDRD |= 1 << 7;  // Set port D pin 7 (Arduino 6) to output mode
+
+  // PLL Configuration
+  // Use 96MHz / 2 = 48MHz
+  PLLFRQ = (PLLFRQ & 0xCF)|0x30;
+  // PLLFRQ = (PLLFRQ & 0xCF)|0x10; // Will double all frequencies
+}
+
+void setup() {
+  // Configure Timer 1 (Pins 9, 10 and 11)
+  // It will operate at 8 kHz
+  // Valid options are:
+  //      PWM62k, PWM8k, PWM1k, PWM244 and PWM61
+  // This works with Arctic Cooling AF12 und Noctua NF-F12.
+  pwm91011configure(PWM8k);
+
+  // Configure Timer 4 (Pins 5 and 6)
+  // It will operate at 23 kHz
+  // Valid options are:
+  //     PWM187k, PWM94k, PWM47k, PWM23k, PWM12k, PWM6k and PWM3k
+  pwm_5_6_configure(PWM23k);
+
+  Serial.begin(9600);
+}
+
+int i = 0;
+
+void loop() {
+  // Variate throttle between 16 and 25 %
+  int value = 16 + i;
+  i = (i + 1) % 64;
+
+  // Those fast macros require a previous configuration
+  // of the channels using the pwmSet9 and pwmSet6
+  // functions
+  // PWMn macros are fast to execute
+  PWM5 = 255 - value;
+  PWM6 = value;
+  PWM9 = value;
+  PWM10 = value;
+  PWM11 = value; // TODO there is no pin 11 on the leonardo clones, I am using
+
+  Serial.println(value, DEC);
+
+  // Small delay
+  delay(100);
+}
+