light raking

light raking

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/andydrop/klampfinator.git/'


Create HT16K33.ino

Create HT16K33.ino

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

--- firmware/examples/HT16K33/HT16K33.ino
+++ firmware/examples/HT16K33/HT16K33.ino
@@ -0,0 +1,50 @@
+/***************************************************
+  This is a library for our I2C LED Backpacks
+
+  Designed specifically to work with the Adafruit LED Matrix backpacks
+  ----> http://www.adafruit.com/products/872
+  ----> http://www.adafruit.com/products/871
+  ----> http://www.adafruit.com/products/870
+
+  These displays use I2C to communicate, 2 pins are required to
+  interface. There are multiple selectable I2C addresses. For backpacks
+  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
+  with 3 Address Select pins: 0x70 thru 0x77
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Limor Fried/Ladyada for Adafruit Industries.
+  BSD license, all text above must be included in any redistribution
+ ****************************************************/
+
+#include <Wire.h>
+#include "Adafruit_LEDBackpack.h"
+#include "Adafruit_GFX.h"
+
+Adafruit_LEDBackpack matrix = Adafruit_LEDBackpack();
+
+uint8_t counter = 0;
+
+void setup() {
+  Serial.begin(9600);
+  Serial.println("HT16K33 test");
+
+  matrix.begin(0x70);  // pass in the address
+}
+
+void loop() {
+  // paint one LED per row. The HT16K33 internal memory looks like
+  // a 8x16 bit matrix (8 rows, 16 columns)
+  for (uint8_t i=0; i<8; i++) {
+    // draw a diagonal row of pixels
+    matrix.displaybuffer[i] = _BV((counter+i) % 16) | _BV((counter+i+8) % 16)  ;
+  }
+  // write the changes we just made to the display
+  matrix.writeDisplay();
+  delay(100);
+
+  counter++;
+  if (counter >= 16) counter = 0;
+}


Added December_6_14.ino Arduino 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/lolisa/2014-15.git/'


First version by Lucas Soubeyrand "l'ino avec l'accéléra, le gyro et l'altimètre est dans Attitude_Altitude (c'est celui qui fonctionne à 57600 bauds mais pas 9600"

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

--- Arduino/Attitude_Altitude/Attitude_Altitude.ino
+++ Arduino/Attitude_Altitude/Attitude_Altitude.ino
@@ -0,0 +1,312 @@
+#include "I2Cdev.h"
+#include "MPU6050_6Axis_MotionApps20.h"
+
+#include "MS561101BA.h"
+#include "Wire.h"
+
+#include <MsTimer2.h>
+#include <VirtualWire.h>
+
+#define UPDATE_RATE 500
+#define BAUDRATE 57600
+
+
+#define MOVAVG_SIZE 32
+
+MPU6050 mpu(0x69); // <-- use for AD0 high
+MS561101BA baro = MS561101BA();
+
+// uncomment "OUTPUT_READABLE_YAWPITCHROLL" if you want to see the yaw/
+// pitch/roll angles (in degrees) calculated from the quaternions coming
+// from the FIFO. Note this also requires gravity vector calculations.
+// Also note that yaw/pitch/roll angles suffer from gimbal lock (for
+// more info, see: http://en.wikipedia.org/wiki/Gimbal_lock)
+#define OUTPUT_READABLE_YAWPITCHROLL
+
+// uncomment "OUTPUT_READABLE_WORLDACCEL" if you want to see acceleration
+// components with gravity removed and adjusted for the world frame of
+// reference (yaw is relative to initial orientation, since no magnetometer
+// is present in this case). Could be quite handy in some cases.
+#define OUTPUT_READABLE_WORLDACCEL
+
+
+///******* Acc+gyro
+#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
+bool blinkState = false;
+
+// MPU control/status vars
+bool dmpReady = false;  // set true if DMP init was successful
+uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
+uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
+uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
+uint16_t fifoCount;     // count of all bytes currently in FIFO
+uint8_t fifoBuffer[64]; // FIFO storage buffer
+
+// orientation/motion vars
+Quaternion q;           // [w, x, y, z]         quaternion container
+VectorInt16 aa;         // [x, y, z]            accel sensor measurements
+VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
+VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
+VectorFloat gravity;    // [x, y, z]            gravity vector
+float euler[3];         // [psi, theta, phi]    Euler angle container
+float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
+
+// packet structure for InvenSense teapot demo
+uint8_t teapotPacket[14] = { '$', 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, '\r', '\n' };
+
+///////********Baro
+float movavg_buff[MOVAVG_SIZE];
+int movavg_i=0;
+
+const float sea_press = 1013.25;
+float press, temp;
+///////************
+
+
+////*** Com
+
+struct Attitude {
+  int u;
+  int v;
+  int w;
+  int x;
+  int y;
+  int z;
+  int t;
+  int h;
+  int p;
+};
+
+Attitude attitude;
+// ================================================================
+// ===               INTERRUPT DETECTION ROUTINE                ===
+// ================================================================
+
+volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
+void dmpDataReady() {
+    mpuInterrupt = true;
+}
+
+// ================================================================
+// ===                      INITIAL SETUP                       ===
+// ================================================================
+
+void setup() {
+    // join I2C bus (I2Cdev library doesn't do this automatically)
+        Wire.begin();
+        TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)
+
+    // initialize serial communication
+    // (115200 chosen because it is required for Teapot Demo output, but it's
+    // really up to you depending on your project)
+    Serial.begin(BAUDRATE);
+    while (!Serial); // wait for Leonardo enumeration, others continue immediately
+
+    // NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
+    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
+    // the baud timing being too misaligned with processor ticks. You must use
+    // 38400 or slower in these cases, or use some kind of external separate
+    // crystal solution for the UART timer.
+
+    Serial.println(F("Initializing Barometer..."));
+    // Suppose that the CSB pin is connected to GND.
+    // You'll have to check this on your breakout schematics
+    baro.init(MS561101BA_ADDR_CSB_LOW);
+    delay(100);
+
+    // populate movavg_buff before starting loop
+    for(int i=0; i<MOVAVG_SIZE; i++) {
+    movavg_buff[i] = baro.getPressure(MS561101BA_OSR_4096);
+    }
+
+    // initialize device
+    Serial.println(F("Initializing Gyro+Acc..."));
+    mpu.initialize();
+
+    // verify connection
+    Serial.println(F("Testing device connections..."));
+    Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
+
+    while (Serial.available() && Serial.read()); // empty buffer
+
+    // load and configure the DMP
+    Serial.println(F("Initializing DMP..."));
+    devStatus = mpu.dmpInitialize();
+
+    // supply your own gyro offsets here, scaled for min sensitivity
+    mpu.setXGyroOffset(220);
+    mpu.setYGyroOffset(76);
+    mpu.setZGyroOffset(-85);
+    mpu.setZAccelOffset(1788); // 1688 factory default for my test chip
+
+    // make sure it worked (returns 0 if so)
+    if (devStatus == 0) {
+        // turn on the DMP, now that it's ready
+        Serial.println(F("Enabling DMP..."));
+        mpu.setDMPEnabled(true);
+
+        // enable Arduino interrupt detection
+        Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
+        attachInterrupt(0, dmpDataReady, RISING);
+        mpuIntStatus = mpu.getIntStatus();
+
+        // set our DMP Ready flag so the main loop() function knows it's okay to use it
+        Serial.println(F("DMP ready! Waiting for first interrupt..."));
+        dmpReady = true;
+
+        // get expected DMP packet size for later comparison
+        packetSize = mpu.dmpGetFIFOPacketSize();
+    } else {
+        // ERROR!
+        // 1 = initial memory load failed
+        // 2 = DMP configuration updates failed
+        // (if it's going to break, usually the code will be 1)
+        Serial.print(F("DMP Initialization failed (code "));
+        Serial.print(devStatus);
+        Serial.println(F(")"));
+    }
+
+    // configure LED for output
+    pinMode(LED_PIN, OUTPUT);
+
+}
+
+
+
+// ================================================================
+// ===                    MAIN PROGRAM LOOP                     ===
+// ================================================================
+long last_time =0;
+
+void loop() {
+    // if programming failed, don't try to do anything
+    if (!dmpReady) return;
+
+    // wait for MPU interrupt or extra packet(s) available
+    while (!mpuInterrupt && fifoCount < packetSize) {
+
+        // other program behavior stuff here
+        float temperature = baro.getTemperature(MS561101BA_OSR_4096);
+        if(temperature) { temp = temperature;   }
+        attitude.t = temp*100;
+        //Serial.print(" temp: "); Serial.print(temp);
+
+        press = baro.getPressure(MS561101BA_OSR_4096);
+        if(press!=NULL) {      pushAvg(press);      }
+        press = getAvg(movavg_buff, MOVAVG_SIZE);
+        attitude.p = press;
+        //Serial.print(" degC pres: "); Serial.print(press);//
+
+        float altitude = getAltitude(press, temp);
+        attitude.h = altitude;
+        //Serial.print(" mbar altitude: "); Serial.print(altitude); Serial.println(" m");
+
+        if (millis() > last_time +UPDATE_RATE)
+         { sendData();
+           last_time = millis();
+         }
+
+       // enf of other programm behavior
+    }
+
+    // reset interrupt flag and get INT_STATUS byte
+    mpuInterrupt = false;
+    mpuIntStatus = mpu.getIntStatus();
+
+    // get current FIFO count
+    fifoCount = mpu.getFIFOCount();
+
+    // check for overflow (this should never happen unless our code is too inefficient)
+    if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
+        // reset so we can continue cleanly
+        mpu.resetFIFO();
+        Serial.println(F("FIFO overflow!"));
+
+    // otherwise, check for DMP data ready interrupt (this should happen frequently)
+    } else if (mpuIntStatus & 0x02) {
+        // wait for correct available data length, should be a VERY short wait
+        while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
+
+        // read a packet from FIFO
+        mpu.getFIFOBytes(fifoBuffer, packetSize);
+
+        // track FIFO count here in case there is > 1 packet available
+        // (this lets us immediately read more without waiting for an interrupt)
+        fifoCount -= packetSize;
+
+            // display Euler angles in degrees
+            mpu.dmpGetQuaternion(&q, fifoBuffer);
+            mpu.dmpGetGravity(&gravity, &q);
+            mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
+            attitude.u = ypr[0] * 180/M_PI*100;
+            attitude.v = ypr[1] * 180/M_PI*100;
+            attitude.w= ypr[2] * 180/M_PI*100;
+            /*Serial.print("ypr\t");  Serial.print(ypr[0] * 180/M_PI);
+            Serial.print("\t");  Serial.print(ypr[1] * 180/M_PI);
+            Serial.print("\t"); Serial.println(ypr[2] * 180/M_PI);*/
+
+            // display initial world-frame acceleration, adjusted to remove gravity
+            // and rotated based on known orientation from quaternion
+            mpu.dmpGetQuaternion(&q, fifoBuffer);
+            mpu.dmpGetAccel(&aa, fifoBuffer);
+            mpu.dmpGetGravity(&gravity, &q);
+            mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
+            mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q);
+            attitude.x = aaWorld.x;
+            attitude.y = aaWorld.y;
+            attitude.z = aaWorld.z;
+            /*Serial.print("aworld\t");  Serial.print(aaWorld.x);
+            Serial.print("\t");  Serial.print(aaWorld.y);
+            Serial.print("\t");  Serial.println(aaWorld.z);*/
+
+        // blink LED to indicate activity
+        blinkState = !blinkState;
+        digitalWrite(LED_PIN, blinkState);
+    }
+}
+
+float getAltitude(float press, float temp) {
+  //return (1.0f - pow(press/101325.0f, 0.190295f)) * 4433000.0f;
+  return ((pow((sea_press / press), 1/5.257) - 1.0) * (temp + 273.15)) / 0.0065;
+}
+
+void pushAvg(float val) {
+  movavg_buff[movavg_i] = val;
+  movavg_i = (movavg_i + 1) % MOVAVG_SIZE;
+}
+
+float getAvg(float * buff, int size) {
+  float sum = 0.0;
+  for(int i=0; i<size; i++) {
+    sum += buff[i];
+  }
+  return sum / size;
+
+}
+
+
+void sendData()
+{
+  //Sending data to gbase
+        char SensorMsg1[7];
+        //itoa(attitude.u,SensorMsg1,10);
+        sprintf(SensorMsg1,"%c%d",'u',attitude.u);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'v',attitude.v);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'w',attitude.w);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'x',attitude.x);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'y',attitude.y);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'z',attitude.z);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'h',attitude.h);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'p',attitude.p);
+        Serial.println(SensorMsg1);
+        sprintf(SensorMsg1,"%c%d",'t',attitude.t);
+        Serial.println(SensorMsg1);
+        Serial.println();
+}


uploaded ensemble seven firmware

uploaded ensemble seven firmware

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

--- Firmeware/EnsembleSeven/EnsembleSeven.ino
+++ Firmeware/EnsembleSeven/EnsembleSeven.ino
@@ -0,0 +1,250 @@
+/* PHOBOS - EnsembleSeven firmware v.0.2 (27.05.2017)
+ *
+ * using:
+ * Arduino v1.8.0
+ * MIDI_Library v.4.3.1 by fortyseveneffects
+ * Servo Library v.1.1.2
+ * EEPROM Library v.2.0.0
+ *
+ * plays:
+ * A - 2 motors rubbing strings
+ * B - 4 solenoids plucking strings
+ * C - 4 solenoids plucking strings
+ * D - 2 servos plucking strings
+ */
+
+#include <EEPROM.h>
+#include <Servo.h>
+#include <MIDI.h>
+#define MIDICH 7
+
+// MOTORS PINS
+#define A1 9
+#define A2 10
+// SOLENOIDS_1 PINS
+#define B1 5
+#define B2 6
+#define B3 7
+#define B4 8
+// SOLENOIDS_2 PINS
+#define C1 44
+#define C2 2
+#define C3 3
+#define C4 4
+// SERVOS' PINS
+#define D1 45
+#define D2 46
+
+/* Addresses on Arduino EEPROM for servo control parameters*/
+#define S1MININC 0 // servo1 min increment (cc=120)
+#define S1MAXINC 1 // servo1 max increment (cc=121)
+
+#define S2MININC 2 // servo2 min increment (cc=122)
+#define S2MAXINC 3 // servo2 max increment (cc=123)
+
+#define S1MINANG 4 // servo1 min angle (cc=124)
+#define S1MAXANG 5 // servo1 max angle (cc=125)
+
+#define S2MINANG 6 // servo2 min angle (cc=126)
+#define S2MAXANG 7 // servo2 max angle (cc=127)
+
+// servos
+Servo servo1, servo2;
+bool servoState[2]; // servo state to control servos out of MIDI loop
+float servoPos[2]; // servo current position
+float servoInc[2]; //servo increment value which relates to movement speed
+float servoMinInc[2]; // servo min increment values
+float servoMaxInc[2]; // servo min increment values
+float servoMinAng[2]; // servo min angle
+float servoMaxAng[2]; // servo max angle
+
+// make note to pin array
+byte note2pin[38];
+byte vel, pitch, val, cc;
+
+MIDI_CREATE_DEFAULT_INSTANCE();
+
+void setup() {
+  MIDI.begin(MIDICH); // Launch MIDI and listen to channel 1
+  MIDI.turnThruOn();
+
+  // set output pins
+  pinMode(A1, OUTPUT);
+  pinMode(A2, OUTPUT);
+
+  pinMode(B1, OUTPUT);
+  pinMode(B2, OUTPUT);
+  pinMode(B3, OUTPUT);
+  pinMode(B4, OUTPUT);
+
+  pinMode(C1, OUTPUT);
+  pinMode(C2, OUTPUT);
+  pinMode(C3, OUTPUT);
+  pinMode(C4, OUTPUT);
+
+  servo1.attach(D1);
+  servo2.attach(D2);
+
+  // set servos to initial position
+  servoPos[0] = midi2angle(EEPROM.read(S1MINANG));
+  servo1.write(servoPos[0]);
+
+  servoPos[1] = midi2angle(EEPROM.read(S2MINANG));
+  servo2.write(servoPos[1]);
+
+  // set servos' min&max increment values
+  // NOTE: min/max inc values are between 0 and 127 (after mapped correspond to 0.1 to 10 degrees per millisecond)
+  servoMinInc[0] = EEPROM.read(S1MININC);
+  servoMaxInc[0] = EEPROM.read(S1MAXINC);
+
+  servoMinInc[1] = EEPROM.read(S2MININC);
+  servoMaxInc[1] = EEPROM.read(S2MAXINC);
+
+  // set servos0 min&max angle
+  // NOTE: min/max angle values are already converted to angles
+  servoMinAng[0] = midi2angle( EEPROM.read(S1MINANG) );
+  servoMaxAng[0] = midi2angle( EEPROM.read(S1MAXANG) );
+
+  servoMinAng[1] = midi2angle( EEPROM.read(S2MINANG) );
+  servoMaxAng[1] = midi2angle( EEPROM.read(S2MAXANG) );
+
+  // set note2pin array
+  note2pin[1] = A1;
+  note2pin[3] = A2;
+
+  note2pin[0] = B1;
+  note2pin[2] = B2;
+  note2pin[12] = B3;
+  note2pin[13] = B4;
+
+  note2pin[25] = C1;
+  note2pin[26] = C1;
+  note2pin[27] = C1;
+  note2pin[36] = C1;
+
+  note2pin[14] = D1;
+  note2pin[24] = D2;
+  //note2pin[37] —> there was no servo for this!!!
+}
+
+void loop() {
+  if(MIDI.read()){
+      switch(MIDI.getType()){
+        case midi::NoteOn:
+          pitch = MIDI.getData1();
+          vel = MIDI.getData2();
+          switch(pitch){
+            // set servos' values only (activation is done in runServos function)
+            case 14:
+              servoInc[0] = velocity2inc( servoMinInc[0], servoMaxInc[0], vel);
+              servoState[0] = true;
+            break;
+            case 24:
+              servoInc[1] = velocity2inc( servoMinInc[1], servoMaxInc[1], vel);
+              servoState[1] = true;
+            break;
+            // activate motors and solenoids
+            default:
+              analogWrite(note2pin[pitch], vel << 1);
+            break;
+          }
+
+        case midi::NoteOff:
+          pitch = MIDI.getData1();
+          switch(pitch){
+            // deactivate servos
+            case 14:
+              servoState[0] = false;
+            break;
+            case 24:
+              servoState[1] = false;
+            break;
+            // deactivate motors and solenoids
+            default:
+              analogWrite(note2pin[pitch], LOW);
+            break;
+          }
+          break;
+
+        // CONTROL CHANGE (SET SERVO PARAMETERS)
+        case midi::ControlChange:
+          cc = MIDI.getData1();
+          val = MIDI.getData2();
+          // starting on cc=120
+          EEPROM.write(cc-120, val); // store...
+          updateServoParams(cc, val);//...and update
+      }
+  }
+
+  runServos(); // activate servos
+  delay(1); // (used only to set servo increments in a millisecond basis)
+}
+
+/***************** FUNTCIONS *****************/
+byte voltage2byte(float v){
+  return v*255/5.f;
+}
+
+float midi2angle(byte m){
+  return 180/127.f*m;
+}
+
+float velocity2inc(byte _min, byte _max, byte v){ // translate velocity values into position increments usign a min/max inc.
+  return map(v, 0, 127, _min, _max);
+}
+
+void runServos(){
+  // servo1 attack
+  if( servoState[0]==true && servoPos[0] < servoMaxAng[0] ){
+    servo1.write(servoPos[0]);
+    servoPos[0] += servoInc[0];
+  }
+  // servo1 release
+  else if (servoState[0] == false){
+    servoPos[0] = servoMinAng[0];
+    servo1.write( servoPos[0] );
+  }
+
+  // servo2 attack
+  if( servoState[1]==true && servoPos[1] < servoMaxAng[1] ){
+    servo2.write(servoPos[1]);
+    servoPos[1] += servoInc[1];
+  }
+  // servo2 release
+  else if (servoState[1] == false){
+    servoPos[1] = servoMinAng[1];
+    servo2.write( servoPos[1] );
+  }
+}
+
+void updateServoParams(byte addr, byte v){
+  switch(addr){
+    case 120:
+      servoMinInc[0] = v;
+      break;
+    case 121:
+      servoMaxInc[0] = v;
+      break;
+    case 122:
+      servoMinInc[1] = v;
+      break;
+    case 123:
+      servoMaxInc[1] = v;
+      break;
+    case 124:
+      servoMinAng[0] = midi2angle(v);
+      break;
+    case 125:
+      servoMaxAng[0] = midi2angle(v);
+      break;
+    case 126:
+      servoMinAng[1] = midi2angle(v);
+      break;
+    case 127:
+      servoMaxAng[1] = midi2angle(v);
+      break;
+
+    default:
+    break;
+  }
+}


Fixed backlight setting

Fixed backlight setting

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/TFTLibraries/TFT.git/'


This code runs the motor tester within the lunchbox

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

--- Lunchbot.ino
+++ Lunchbot.ino
@@ -0,0 +1,61 @@
+#include <Servo.h>
+
+// Define variables
+int sensorPin = A0;    // select the input pin for the potentiometer
+int sensorValue = 0;  // variable to store the value coming from the sensor
+int sensorValueAdjusted = 0;
+int sensorValueDrive = 0;
+int forward = 6;
+int forwardnum = 0;
+int backward = 7;
+int backwardnum = 0;
+Servo myservo;
+
+// Setup
+void setup() {//If you are reading this, then something is wrong then it is TOTALLY NOT LOGAN NO'S FAULT
+
+  pinMode(forward, INPUT_PULLUP);
+  pinMode(backward, INPUT_PULLUP);
+  pinMode(sensorPin, INPUT);
+  Serial.begin(9600);
+  myservo.attach(3);
+}
+
+//Main loop
+void loop() {
+  // read the value from the sensor:
+  sensorValue = analogRead(sensorPin);
+
+  // adjusting value to 0 - 89
+  sensorValueAdjusted = sensorValue / 11.4943820225;
+
+  // get direction switch value
+  forwardnum = digitalRead(forward);
+  backwardnum = digitalRead(backward);
+
+  // drive logic
+  if(forwardnum == 0)
+  {
+     sensorValueDrive = 180 - sensorValueAdjusted;//91-180 (forward values) clockwise
+     myservo.write(sensorValueDrive);
+  }
+  else if(backwardnum == 0)
+  {
+     sensorValueDrive = sensorValueAdjusted;//0-89 (backward values) c.clockwise
+     myservo.write(sensorValueDrive);
+  }
+  else
+     myservo.write(90);
+
+  // print information
+  Serial.print(forwardnum);
+  Serial.print("\t");
+  Serial.print(backwardnum);
+  Serial.print("\t");
+  Serial.print(sensorValue);
+  Serial.print("\t");
+  Serial.print(sensorValueAdjusted);
+  Serial.print("\t");
+  Serial.println(sensorValueDrive);
+
+}


Stupid Files inside Folder for Arduino

Stupid Files inside Folder for Arduino

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/Duke-Medical-Instrumentation/InceptionTI.git/'


Added TestCode file

Added TestCode file

error: pathspec '2018-Firefighter-TestCode/2018-Firefighter-TestCode.ino' did not match any file(s) known to git

--- 2018-Firefighter-TestCode/2018-Firefighter-TestCode.ino
+++ 2018-Firefighter-TestCode/2018-Firefighter-TestCode.ino
@@ -0,0 +1,253 @@
+#include <Servo.h>
+
+#include <Ultrasonic.h>
+
+#include "FreqCount.h"
+
+#define LEFT_SERVO_PIN  4
+#define RIGHT_SERVO_PIN 5
+#define IR_PIN_LEFT 6
+#define IR_PIN_RIGHT 20
+#define EXTINGUISHER_PIN 7
+#define FLAME_LED 9
+#define MIC_LED 11
+#define BABY_LED 17
+#define CAMERA 15
+#define CAMERA_LED 16
+#define GYRO_INPUT_PIN 18
+
+//Ultrasonic Trigger and Echo pins (30-39)
+#define F_L_ECHO  30  //Front-left Ultrasonic
+#define F_L_TRIG  31
+#define F_R_ECHO  32  //Front-right Ultrasonic
+#define F_R_TRIG  33
+#define R_ECHO  34  //Right Ultrasonic
+#define R_TRIG  35
+#define B_ECHO  36  //Back Ultrasonic
+#define B_TRIG  37
+#define L_ECHO  38  //Left Ultrasonic
+#define L_TRIG  39
+
+// Bounds for start sound frequency:
+#define LOW_START 3306
+#define HIGH_START 4294
+
+Servo leftServo;
+Servo rightServo;
+Servo extinguisher;
+
+Ultrasonic frontLeftUltrasonic(F_L_ECHO, F_L_TRIG, true);
+Ultrasonic frontRightUltrasonic(F_R_ECHO, F_R_TRIG, true);
+Ultrasonic leftUltrasonic(L_ECHO, L_TRIG, true);
+Ultrasonic rightUltrasonic(R_ECHO, R_TRIG, true);
+Ultrasonic backUltrasonic(B_ECHO, B_TRIG, true);
+
+//Gyroscope controls
+float gyroStartAngle;
+float gyroTargetAngle = 0;
+
+bool checkingMicrophone = true;
+bool hearingStartSound = false;
+bool robotOn = false;
+unsigned long freqCount;
+double closeToWall = 2;   //defines how close the robot should be (inches) to the wall to register as being "too close"
+
+void rollForward() {
+  leftServo.write(180);
+  rightServo.write(0);
+}
+
+void rollBackward() {
+  leftServo.write(0);
+  rightServo.write(180);
+}
+
+void moveSlightLeft() {
+  leftServo.write(135);
+  rightServo.write(20); //Half power plus additional 25
+  delay(100);
+}
+
+void moveSlightRight() {
+  leftServo.write(160); //Half power plus additional 25
+  rightServo.write(45);
+  delay(100);
+}
+
+void stopRobot() {
+  leftServo.write(90);
+  rightServo.write(90);
+}
+
+boolean detectFire(){
+  if(digitalRead(IR_PIN_RIGHT || IR_PIN_RIGHT)){
+    return true;
+  } else {
+    return false;
+  }
+}
+
+void startExtinguisher(){
+  extinguisher.write(180);
+}
+
+void stopExtinguisher(){
+  extinguisher.write(90);
+}
+
+//Gyro functions
+//Resets the gyro so that the current positioning is angle "0"
+void resetGyro(){
+  gyroStartAngle = digitalRead(GYRO_PIN);
+  gyroTargetAngle = 0;
+}
+
+//Returns the current angle of the robot relative to its starting angle
+float getGyroAngle(){
+  return digitalRead(GYRO_PIN)-gyroStartAngle;
+}
+
+//adjusts the target angle based on how much we want to turn and turns the robot until that target is reached
+//use turn(0) to simply get the gyro back on track if it's off target
+void turn(int angle){
+  gyroTargetAngle += angle;
+  if(gyroTargetAngle > 360){
+    gyroTargetAngle = 360 - gyroTargetAngle;
+  }
+  if(gyroTargetAngle < 0){
+    gyroTargetAngle = 360 + gyroTargetAngle
+  }
+  if(gyroTargetAngle < getGyroAngle()){
+    leftServo.write(180);
+    rightServo.write(180);
+    while(gyroTargetAngle < getGyroAngle()){
+      delay(50);
+    }
+    stopRobot();
+  }else if(gyroTargetAngle > getGyroAngle()){
+    leftServo.write(0);
+    rightServo.write(0);
+    while(gyroTargetAngle > getGyroAngle()){
+      delay(50);
+    }
+    stopRobot();
+  }
+}
+
+int detectBaby(){return 0;}
+int usingCamera(){return 0;}
+
+void extinguishFire(){
+  while (detectFire()) {
+     if (detectFire()){
+      digitalWrite(FLAME_LED, HIGH);
+     } else {
+     digitalWrite(FLAME_LED, LOW);
+     }
+
+    if (frontLeftUltrasonic.getDistance() > 3) {
+      rollForward();
+    } else {
+      stopRobot();
+      delay(500);
+
+      startExtinguisher();
+      delay(500);
+
+      if (!detectFire()) {
+        stopExtinguisher();
+      }
+    }
+    delay(100);
+  }
+}
+
+void checkMicrophone() {
+  // Measure sound:
+  if (FreqCount.available()) {
+    freqCount = FreqCount.read();
+  } else {
+    freqCount = 0;
+  }
+
+  // If the sound frequency is within start sound bounds, turn on robot:
+  if (freqCount > LOW_START && freqCount < HIGH_START) {
+    robotOn = true; // Set the robot to on
+    hearingStartSound = true;
+  } else {
+    hearingStartSound = false;
+    if (robotOn) {
+      checkingMicrophone = false;
+      FreqCount.end();
+    }
+  }
+}
+
+float calcAvg(float x,float y){
+  float avg=(x+y)/2;
+  return avg;
+}
+
+
+void startUp(){
+  //ping ultrasonics twice and average the values to get (hopefully) accurate values
+  float right=calcAvg(rightUltrasonic.getDistance(),rightUltrasonic.getDistance());
+  float left=calcAvg(leftUltrasonic.getDistance(),leftUltrasonic.getDistance());
+  float front=calcAvg(frontLeftUltrasonic.getDistance(),frontRightUltrasonic.getDistance());
+  float back=calcAvg(backUltrasonic.getDistance(),backUltrasonic.getDistance());
+
+  if(right < closeToWall && back < closeToWall && left < closeToWall) {  //robot is facing downward WITH DOG
+    turn(0);
+  } else if(right < closeToWall && front < closeToWall && back < closeToWall){  //robot is facing backward WITH DOG
+    turn(90);
+  } else if(front < closeToWall && left < closeToWall && right < closeToWall){ //robot is facing upward WITH DOG
+    turn(180);
+  } else if(front < closeToWall && left < closeToWall && back < closeToWall){   //robot is facing the correct direction WITH DOG
+    turn(-90);
+  } else if(right < closeToWall && back < closeToWall) { //downward, no dog
+    turn(90);
+  } else if(right < closeToWall && front < closeToWall) { //backward, no dog
+    turn(180);
+  } else if(front < closeToWall && left < closeToWall) { //upward, no dog
+    turn(-90);
+  } else {  //forward, no dog
+    turn(0);
+  }
+
+  while(rightUltrasonic.getDistance() > closeToWall){   //roll forward until the first room is encountered, then kick out of function
+    rollForward();
+  }
+}
+
+void setup() {
+  // put your setup code here, to run once:
+  leftServo.attach(LEFT_SERVO_PIN);
+  rightServo.attach(RIGHT_SERVO_PIN);
+  extinguisher.attach(EXTINGUISHER_PIN);
+  stopRobot();
+  extinguisher.write(90);
+
+
+  pinMode(IR_PIN_LEFT, INPUT);
+  pinMode(IR_PIN_RIGHT, INPUT);
+
+  attachInterrupt(digitalPinToInterrupt(IR_PIN_LEFT), extinguishFire, RISING);
+  attachInterrupt(digitalPinToInterrupt(IR_PIN_RIGHT), extinguishFire, RISING);
+
+  pinMode(FLAME_LED, OUTPUT);
+
+  pinMode(MIC_LED, OUTPUT);
+
+  pinMode(BABY_LED, OUTPUT);
+
+  pinMode(CAMERA_LED, OUTPUT);
+
+  pinMode(GYRO, INPUT);
+
+  FreqCount.begin(1000); // Begin measuring sound
+}
+
+void loop() {
+// put your main code here, to run repeatedly
+
+}


Add demo which uses the Wire library

Add demo which uses the Wire library

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

--- examples/HIH61xx_Wire_demo/HIH61xx_Wire_demo.ino
+++ examples/HIH61xx_Wire_demo/HIH61xx_Wire_demo.ino
@@ -0,0 +1,55 @@
+// This example demonstrates how to use the HIH61xx class with the Wire library. The HIH61xx state machine
+// enables others tasks to run whilst the HIH61xx is powering up etc.
+
+#include <Wire.h>
+#include <HIH61xx.h>
+#include <AsyncDelay.h>
+
+// The "hih" object must be created with a reference to the "Wire" object which represents the I2C bus it is using.
+// Note that the class for the Wire object is called "TwoWire", and must be included in the templated class name.
+HIH61xx<TwoWire> hih(Wire);
+
+AsyncDelay samplingInterval;
+
+void setup(void)
+{
+#if F_CPU >= 12000000UL
+    Serial.begin(115200);
+#else
+	Serial.begin(9600);
+#endif
+
+
+	Wire.begin();
+
+	hih.initialise();
+	samplingInterval.start(3000, AsyncDelay::MILLIS);
+}
+
+
+bool printed = true;
+void loop(void)
+{
+	if (samplingInterval.isExpired() && !hih.isSampling()) {
+		hih.start();
+		printed = false;
+		samplingInterval.repeat();
+		Serial.println("Sampling started (using Wire library)");
+	}
+
+	hih.process();
+
+	if (hih.isFinished() && !printed) {
+		printed = true;
+		// Print saved values
+		Serial.print("RH: ");
+		Serial.print(hih.getRelHumidity() / 100.0);
+		Serial.println(" %");
+		Serial.print("Ambient: ");
+		Serial.print(hih.getAmbientTemp() / 100.0);
+		Serial.println(" deg C");
+		Serial.print("Status: ");
+		Serial.println(hih.getStatus());
+	}
+
+}


Fixed type cast bug.

Fixed type cast bug.

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/FirstBuild/pizzaduino.git/'


Fixed buffer overflow error

Fixed buffer overflow error

There was a buffer overflow happening with the pitchAdjust, rollAdjust, and yawAdjust pins.  Corrected by lowering the ramp factor to +/-111 from +/-INT8_MAX.

--- KSPboard.ino
+++ KSPboard.ino
@@ -46,7 +46,7 @@
 #define PIN_OP_ACG5 0

 // delays
-#define DELAY_LOOP 500
+#define DELAY_LOOP 100
 #define DELAY_START 30
 #define DELAY_OP 100

@@ -54,9 +54,9 @@
 #define OPS (sizeof(opPin) / sizeof(uint8_t))

 // helm
-#define RAMP_ADJUST 7
-#define RAMP_MAX 175
-#define RAMP_MIN -175
+#define RAMP_ADJUST 3
+#define RAMP_MAX 111
+#define RAMP_MIN -RAMP_MAX
 #define DIR_MAX 1023
 #define DIR_MIN -1023

@@ -109,12 +109,12 @@
   switch (digitalRead(pinH) ? HIGH : (digitalRead(pinL) ? LOW : NEUTRAL))
   {
     case HIGH:
-      if ((adj += RAMP_ADJUST) >= RAMP_MAX)
+      if ((adj += RAMP_ADJUST) > RAMP_MAX)
         adj = RAMP_MAX;
       break;

     case LOW:
-      if ((adj -= RAMP_ADJUST) <= RAMP_MIN)
+      if ((adj -= RAMP_ADJUST) < RAMP_MIN)
         adj = RAMP_MIN;
       break;

@@ -130,16 +130,19 @@
 {
   // reset current if no stick flag or if adj and current are opposite signs
   if (!(adj || stick) || (current > 0 && adj < 0) || (current < 0 && adj > 0))
+  {
     current = 0;
-
-  current += adj;
-
-
-  if (current > DIR_MAX)
-    current = DIR_MAX;
-
-  if (current < DIR_MIN)
-    current = DIR_MIN;
+  }
+  else
+  {
+    current += adj;
+
+    if (current > DIR_MAX)
+      current = DIR_MAX;
+    else
+      if (current < DIR_MIN)
+        current = DIR_MIN;
+  }

   return (current);
 }
@@ -189,9 +192,9 @@
 void setupOps()
 { // disabled while building the joystick control
   /*pinMode(PIN_OP_LAUNCH, INPUT_PULLUP);
-  pinMode(PIN_OP_STAGE, INPUT_PULLUP);
-  pinMode(PIN_OP_ACG3, INPUT_PULLUP);
-  pinMode(PIN_OP_ACG5, INPUT_PULLUP);*/
+    pinMode(PIN_OP_STAGE, INPUT_PULLUP);
+    pinMode(PIN_OP_ACG3, INPUT_PULLUP);
+    pinMode(PIN_OP_ACG5, INPUT_PULLUP);*/
 }

@@ -287,6 +290,7 @@

   delay(DELAY_LOOP);

+  Serial.println();
   Serial.flush();
 }


Adding a simple LCD/RTC (DS3231) clock and temperature display example sketch.

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

--- examples/Sandbox/CosaLCDclock/CosaLCDclock.ino
+++ examples/Sandbox/CosaLCDclock/CosaLCDclock.ino
@@ -0,0 +1,83 @@
+/**
+ * @file CosaLCDclock.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.
+ *
+ * @section Description
+ * Cosa LCD demo with RTC.
+ *
+ * This file is part of the Arduino Che Cosa project.
+ */
+
+#include "Cosa/Watchdog.hh"
+#include "Cosa/IOStream.hh"
+#include "Cosa/LCD/Driver/HD44780.hh"
+#include "Cosa/TWI/Driver/DS3231.hh"
+
+// Remove comment to set real-time clock (update below)
+// #define RTC_SET_TIME
+DS3231 rtc;
+
+// Select the access port for the LCD
+// HD44780::Port port;
+// HD44780::MJKDZ port;
+HD44780::DFRobot port;
+HD44780 lcd(&port);
+IOStream console(&lcd);
+
+void setup()
+{
+  Watchdog::begin();
+  lcd.begin();
+  console << PSTR("CosaLCDclock: started");
+
+#ifdef RTC_SET_TIME
+  time_t now;
+  now.seconds = 0x00;
+  now.minutes = 0x50;
+  now.hours = 0x20;
+  now.day = 0x01;
+  now.date = 0x21;
+  now.month = 0x07;
+  now.year = 0x13;
+  rtc.set_time(now);
+#endif
+
+  SLEEP(2);
+}
+
+void loop()
+{
+  // Read clock and temperature
+  time_t now;
+  rtc.get_time(now);
+  int16_t temp = rtc.get_temperature();
+
+  // Update the LCD with the reading
+  console << clear;
+
+  // First line with date and temperature
+  console << PSTR("20") << bcd << now.year << '-'
+	  << bcd << now.month << '-'
+	  << bcd << now.date;
+  console << PSTR("  ");
+  console << (temp >> 2) << PSTR(" C");
+
+  // Second line with time
+  console << bcd << now.hours << ':'
+	  << bcd << now.minutes << ':'
+	  << bcd << now.seconds;
+  SLEEP(1);
+}


added voteino_client program

added voteino_client program

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

--- voteino_client.ino
+++ voteino_client.ino
@@ -0,0 +1,92 @@
+/**
+ * Arduino voting system client
+ *
+ * Pins:
+ * Hardware SPI:
+ * MISO -> 12
+ * MOSI -> 11
+ * SCK -> 13
+ *
+ * Configurable:
+ * CE -> 8
+ * CSN -> 7
+ *
+ * Note: To see best case latency comment out all Serial.println
+ */
+
+#include <SPI.h>
+#include <Mirf.h>
+#include <nRF24L01.h>
+#include <MirfHardwareSpiDriver.h>
+
+void setup() {
+  Serial.begin( 9600 );
+  /* Get the instance of the Mirf object */
+  Mirf.spi = &MirfHardwareSpi;
+
+  /* Setup the SPI pins CE and CSN */
+  Mirf.cePin = 8;
+  Mirf.csnPin = 7;
+
+  /* Set the payload length, 1 data packet size (5 bytes)
+   * IMPORTANT!: payload on client and server must be the same
+   */
+  Mirf.payload = sizeof( byte ) * 5;
+
+  /* Set transmission channel
+   * IMPORTANT!: make sure channel is legal in your area
+   */
+  Mirf.channel = 1;
+
+  /* Initialize SPI communication to tranceiver */
+  Mirf.init();
+  /* Set our device address */
+  Mirf.setRADDR( (byte *) "voting_client" );
+  /* Set server address */
+  Mirf.setTADDR( (byte *) "voting_server" );
+  /* Configure and power up tranceiver */
+  Mirf.config();
+
+  /* Initialize button */
+  pinMode( 2, INPUT );
+  digitalWrite( 2, HIGH );
+  Serial.println( "Beginning ... " );
+}
+
+void loop() {
+  /* Timeout for receiving */
+  long time = millis();
+  /* Transmission data packet */
+  byte data[Mirf.payload] = ['s', 'i', 'l', 'b', 'o'];
+
+  /* Wait for button to be pressed, TODO: implement interrupt */
+  while ( digitalRead( 2 ) == HIGH );
+
+  /* Send the data packet */
+  Mirf.send(data);
+
+  /* While data is still transmitted */
+  while ( Mirf.isSending() );
+  Serial.println( "Finished sending" );
+  delay( 10 );
+
+  /* While we are receiving the data packet */
+  while ( !Mirf.dataReady() ) {
+    /* Get the byte from the tranceiver */
+    Mirf.getData( data );
+    /* TODO: do something useful */
+    Serial.println( (char) data );
+
+    /* Timeout when data packet was not received within 1 second */
+    if ( ( millis() - time ) > 1000 ) {
+        Serial.println("Timeout on response from server!");
+        return;
+    }
+  }
+
+  /* When transmission was successful */
+  delay(1000);
+}
+
+
+


Initial commit

Initial commit

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

--- magbot_test/magbot_test.ino
+++ magbot_test/magbot_test.ino
@@ -0,0 +1,101 @@
+/**
+ HC-SR04 Ultrasonic Range Finder attached to the servo.
+ Two motors attached to the motor shield.
+ */
+
+#include <NewPing.h> // From https://code.google.com/p/arduino-new-ping/
+#include <Servo.h>
+
+// Motor attached to channel A:
+const byte motorA_direction = 12;
+const byte motorA_pwm = 3;
+const byte motorA_brake = 9;
+const byte motorA_sensor = A0;
+// Motor attached to channel B:
+const byte motorB_direction = 13;
+const byte motorB_pwm = 11;
+const byte motorB_brake = 8;
+const byte motorB_sensor = A1;
+
+// Sonar configuration
+const byte sonar_trigger = 7;  // Arduino pin tied to trigger pin on the ultrasonic sensor.
+const byte sonar_echo = 4;  // Arduino pin tied to echo pin on the ultrasonic sensor.
+const int sonar_distance = 80; // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
+const byte sonar_delay = 50; // Number of milliseconds to wait before next ping
+unsigned long sonar_last = 0; // When the last ping happened.
+NewPing sonar(sonar_trigger, sonar_echo, sonar_distance); // NewPing setup of pins and maximum distance.
+
+// Servo configuration
+const byte servo_pin = 6;
+byte servo_sweep_direction = 0; // The current direction the servo is sweeping; 0 or 1
+const byte servo_delay = 25; // Number of milliseconds to wait before next move
+unsigned long servo_last = 0; // When the last move happened.
+Servo servo;  // create servo object to control a servo
+
+unsigned long millis_now;
+
+void setup() {
+  Serial.begin(9600); // Open serial monitor at 9600 baud to see ping results.
+
+  servo.attach(servo_pin);  // attaches the sonar servo to the servo object
+
+    // Setup Channel A
+  pinMode(motorA_direction, OUTPUT); // Initiates motor pin for channel A
+  pinMode(motorA_brake, OUTPUT); // Initiates break pin for channel A
+
+  // Setup Channel B
+  pinMode(motorB_direction, OUTPUT); // Initiates motor pin for channel B
+  pinMode(motorB_brake, OUTPUT);  // Initiates break pin for channel B
+
+  // Ensure the brakes are off
+  digitalWrite(motorA_brake, LOW);   // Disengage the Brake for Channel A
+  digitalWrite(motorB_brake, LOW);   // Disengage the Brake for Channel B
+
+
+  // Turn in place
+  digitalWrite(motorA_direction, HIGH); // Channel A forward
+  digitalWrite(motorB_direction, LOW); // Channel B backward
+
+  analogWrite(motorA_pwm, 255); // Channel A at max speed
+  analogWrite(motorB_pwm, 255); // Channel B at max speed
+}
+
+void loop() {
+  millis_now = millis();
+
+  // Check to see if it's time for another ping.
+  if (millis_now - sonar_last > sonar_delay) {
+    // Remeber when this ping was done, so we know when to do the next one.
+    sonar_last = millis_now;
+
+    unsigned int cm = sonar.ping_cm(); // Send a ping, get ping time in microseconds (uS).
+    Serial.print("Ping: ");
+    Serial.print(cm);
+    Serial.println("cm");
+  }
+
+  // Check to see if it's time for another soanr servo move.
+  if (millis_now - servo_last > servo_delay) {
+    // Remember when this move was done, so we know when to do the next one.
+    servo_last = millis_now;
+
+    // Sweep
+    // Get the last angle the servo was set to.
+    int servo_pos = servo.read();
+    if (servo_sweep_direction == 0) {
+      servo_pos++; // Add 1 degree to the servo's position.
+    } else {
+      servo_pos--; // Remove 1 degree to the servo's position.
+    }
+
+    // At the end of the sweep, change directions for the next move.
+    if (servo_pos == 170) {
+      servo_sweep_direction = 1;
+    } else if (servo_pos == 10) {
+      servo_sweep_direction = 0;
+    }
+    servo.write(servo_pos);
+  }
+
+}
+


added code for serial controlled, 30 second, 8 segment LED countdown display

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

--- range/arduino/led_8seg_countdown/led_8seg_countdown.ino
+++ range/arduino/led_8seg_countdown/led_8seg_countdown.ino
@@ -0,0 +1,121 @@
+/* Serial controlled countdown timer for bit.ly/big-7-seg displays
+
+  Accepted input
+    H - display accepted inputs
+    S - start
+    R - reset the time (call before Start)
+    X - stop the current coutdown
+    Z - zero the timer
+
+*/
+
+#define NOE 9 //pwm
+#define LE 8 //latch
+#define CLK 10 //clock
+#define SDO 11 //serial data
+#define LED 13 //indicator led on arduino
+
+#define BAUD 9600
+#define TIMER 300 // 30.0 seconds
+#define TIMER_RESOLUTION 10 // 10 ms = 0.01 sec
+#define HOLD_TIME 1000 // ms
+#define DIGITS 3
+#define DECIMAL_PLACES 1
+
+byte segments[] =
+  {
+    0b11111100, //0
+    0b01100000, //1
+    0b11011010, //2
+    0b11110010, //3
+    0b01100110, //4
+    0b10110110, //5
+    0b10111110, //6
+    0b11100000, //7
+    0b11111110, //8
+    0b11100110, //9
+    0b00000001, //dot
+  };
+
+boolean run_flag = false;
+unsigned long counter = 0UL;
+
+void setup() {
+  Serial.begin(BAUD);
+  pinMode(LED,OUTPUT);
+  pinMode(LE,OUTPUT);
+  analogWrite(NOE,LOW);
+  pinMode(CLK,OUTPUT);
+  pinMode(SDO,OUTPUT);
+
+  digitalWrite(LE,false);
+
+  Serial.println(F("Coutdown Timer"));
+  Serial.println(F("=============="));
+
+  displayTime(0);
+}
+
+void loop() {
+  // if there's any serial available, read it:
+  while (Serial.available() > 0) {
+    char character = Serial.read();
+
+    if (character == 'h' || character == 'H') {
+      Serial.println(F("Accepted input"));
+      Serial.println(F("  H - display this message"));
+      Serial.println(F("  S - start"));
+      Serial.println(F("  R - reset the time (call before Start)"));
+      Serial.println(F("  X - stop the current coutdown"));
+      Serial.println(F("  Z - zero the timer"));
+    }
+
+    if (character == 'S' || character == 's') {
+      displayTime(TIMER);
+      run_flag = true;
+      counter = millis();
+    }
+
+    if (character == 'r' || character == 'R') {
+      run_flag = false;
+      displayTime(TIMER);
+    }
+
+    if (character == 'x' || character == 'X') {
+      run_flag = false;
+    }
+
+    if (character == 'z' || character == '|') {
+      run_flag = false;
+      displayTime(0);
+    }
+  }
+
+  if (run_flag == true) {
+    if (millis() - counter < TIMER * 100) {
+      int time_to_display = TIMER - ((millis() - counter)/100);
+      displayTime(time_to_display);
+      //Serial.println(time_to_display);
+    } else {
+      displayTime(0);
+      run_flag = false;
+    }
+  }
+}
+
+void displayTime(int number) {
+  digitalWrite(LE,LOW);
+  // calculate each digit for sending
+  for (byte i=0; i<DIGITS; i++) {
+    byte output = number % 10;
+    if (i == DECIMAL_PLACES) {
+      // add decimal place if specified digit
+      shiftOut(SDO, CLK, LSBFIRST, segments[output] | segments[10]);
+    } else {
+      shiftOut(SDO, CLK, LSBFIRST, segments[output]);
+    }
+    number = number / 10;
+  }
+  digitalWrite(LE,HIGH);
+}
+


EBPMK2-Game.ino

EBPMK2-Game.ino

Added ino file.

error: pathspec 'EBPMK2-Game.ino' did not match any file(s) known to git

--- EBPMK2-Game.ino
+++ EBPMK2-Game.ino
@@ -0,0 +1,111 @@
+///
+/// @mainpage	LCD_Joystick
+///
+/// @details	Joystick controlled cursor
+/// @n
+/// @n @a		Developed with [embedXcode+](http://embedXcode.weebly.com)
+///
+/// @author		Rei Vilo
+/// @author		http://embeddedcomputing.weebly.com
+/// @date		11/12/2013 10:19
+/// @version	101
+///
+/// @copyright	(c) Rei Vilo, 2013
+/// @copyright	CC = BY SA NC
+///
+/// @see		ReadMe.txt for references
+///
+
+
+///
+/// @file		LCD_Joystick.ino
+/// @brief		Main sketch
+///
+/// @details	Joystick controlled cursor
+/// @n @a		Developed with [embedXcode+](http://embedXcode.weebly.com)
+///
+/// @author		Rei Vilo
+/// @author		http://embeddedcomputing.weebly.com
+/// @date		11/12/2013 10:19
+/// @version	101
+///
+/// @copyright	(c) Rei Vilo, 2013
+/// @copyright	CC = BY SA NC
+///
+/// @see		ReadMe.txt for references
+/// @n
+///
+
+
+// Core library for code-sense
+#if defined(ENERGIA) // LaunchPad MSP430, Stellaris and Tiva, Experimeter Board FR5739 specific
+#include "Energia.h"
+#else // error
+#error Platform not defined
+#endif
+
+// Prototypes
+
+
+// Include application, user and local libraries
+#include <SPI.h>
+
+#include <LCD_screen.h>
+#include <LCD_screen_font.h>
+#include <LCD_utilities.h>
+#include <Screen_HX8353E.h>
+#include <Terminal12e.h>
+#include <Terminal6e.h>
+#include <Terminal8e.h>
+Screen_HX8353E myScreen;
+
+
+// Define variables and constants
+#define joystickX 2
+#define joystickY 26
+uint16_t x, y, x00, y00;
+uint16_t colour;
+uint32_t z;
+
+
+// Add setup code
+void setup()
+{
+    // By default MSP432 has analogRead() set to 10 bits.
+    // This Sketch assumes 12 bits. Uncomment to line below to set analogRead()
+    // to 12 bit resolution for MSP432.
+    //analogReadResolution(12);
+
+    myScreen.begin();
+    x00 = 0;
+    y00 = 0;
+
+}
+
+// Add loop code
+void loop()
+{
+    x = map(analogRead(joystickX), 0, 4096, 0, 128);
+    y = map(analogRead(joystickY), 0, 4096, 128, 0);
+    if (x < 1)      x = 1;
+    if (x > 126)    x = 126;
+    if (y < 1)      y = 1;
+    if (y > 126)    y = 126;
+
+    if ((x00 != x) || (y00 != y)) {
+        z = (uint32_t)((x-64)*(x-64)+(y-64)*(y-64)) >> 8;
+        if (z > 4)      colour = redColour;
+        else if (z > 1) colour = yellowColour;
+        else            colour = greenColour;
+
+        myScreen.dRectangle(x00-1, y00-1, 3, 3, blackColour);
+        myScreen.dRectangle(x-1, y-1, 3, 3, colour);
+        x00 = x;
+        y00 = y;
+    }
+
+
+    myScreen.gText(0, myScreen.screenSizeY()-myScreen.fontSizeY(),
+                   "x=" + i32toa((int16_t)x-64, 10, 1, 6) +" y=" + i32toa(64-(int16_t)y, 10, 1, 6),
+                   colour);
+}


added ESP32 protobadge test

added ESP32 protobadge test

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

--- Arduino/ESP32_badge_RGB-OLED_test2.ino
+++ Arduino/ESP32_badge_RGB-OLED_test2.ino
@@ -0,0 +1,88 @@
+#include <Adafruit_NeoPixel.h>
+#ifdef __AVR__
+  #include <avr/power.h>
+#endif
+
+#define LEDPIN 27
+
+#include <U8x8lib.h>
+
+const int btn_up = 34;
+const int btn_dn = 14;
+const int btn_rt = 12;
+const int btn_lt = 13;
+const int btn_enter = 35;
+
+// the OLED used
+U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 15, /* data=*/ 4, /* reset=*/ 16);
+
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(3, LEDPIN, NEO_GRB + NEO_KHZ800);
+
+
+void setup() {
+  // put your setup code here, to run once:
+strip.begin();
+strip.setBrightness(10);
+  strip.show();
+
+  pinMode(btn_up, INPUT);
+  pinMode(btn_dn, INPUT_PULLUP);
+  pinMode(btn_lt, INPUT_PULLUP);
+  pinMode(btn_rt, INPUT_PULLUP);
+  pinMode(btn_enter, INPUT);
+
+  u8x8.begin();
+  u8x8.setFont(u8x8_font_chroma48medium8_r);
+  u8x8.setFlipMode(1);
+}
+
+
+void loop() {
+  // put your main code here, to run repeatedly:
+//rainbowCycle(20);
+// if (digitalRead(btn_dn) == LOW)
+ // { // Check if button has been pressed
+  // u8x8.drawString(0, 1, "Down Button");
+ // }
+  if (digitalRead(btn_lt) == LOW)
+  { // Check if button has been pressed
+    u8x8.drawString(0, 1, "Left Button");
+  }
+  else if (digitalRead(btn_rt) == LOW)
+  { // Check if button has been pressed
+    u8x8.drawString(0, 1, "Right Button");
+  }
+//  else if (digitalRead(btn_enter) == LOW)
+//  { // Check if button has been pressed
+//    u8x8.drawString(0, 1, "Enter Button");
+//  }
+  else {
+    u8x8.drawString(0,1,"no buttons");
+  }
+u8x8.drawString(0, 0, "Button Checker");
+}
+
+void rainbowCycle(uint8_t wait) {
+  uint16_t i, j;
+
+  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
+    for(i=0; i< strip.numPixels(); i++) {
+      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
+    }
+    strip.show();
+    delay(wait);
+  }
+}
+
+uint32_t Wheel(byte WheelPos) {
+  WheelPos = 255 - WheelPos;
+  if(WheelPos < 85) {
+    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
+  }
+  if(WheelPos < 170) {
+    WheelPos -= 85;
+    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
+  }
+  WheelPos -= 170;
+  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
+}


New Example

New Example

demo showing pinDefEncoder

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/philbowles/esparto.git/'


使用l293d驱动一个马达

使用l293d驱动一个马达

error: pathspec 'hardware/arduino_uno/l293d-one-motor/l293d-one-motor.ino' did not match any file(s) known to git

--- hardware/arduino_uno/l293d-one-motor/l293d-one-motor.ino
+++ hardware/arduino_uno/l293d-one-motor/l293d-one-motor.ino
@@ -0,0 +1,34 @@
+/*
+* 四驱车代码 －单电机
+*/
+int enablePin = 11; // pwm
+int in1Pin = 8;
+int in2Pin =9;
+
+// 速度
+int speed = 234;
+
+void setMotor() {
+  analogWrite(enablePin, speed);
+  //digitalWrite(enable1Pin,HIGH);
+  digitalWrite(in1Pin, HIGH);
+  digitalWrite(in2Pin, LOW);
+}
+
+void setup() {
+  pinMode(in1Pin, OUTPUT);
+  pinMode(in2Pin, OUTPUT);
+  pinMode(enablePin, OUTPUT);
+  // light led
+  pinMode(13, OUTPUT);
+}
+
+void loop() {
+  // 设置 电机的速度 和 方向
+  setMotor();
+  // light led
+  digitalWrite(13, HIGH);
+}
+
+
+


Added version that works for DHT11 sensor

I tried to make the code so it can be made for DHT22 again as well.

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

--- shofanduino2_dht11/shofanduino2_dht11.ino
+++ shofanduino2_dht11/shofanduino2_dht11.ino
@@ -0,0 +1,248 @@
+/* Shofanduino 2 DHT11, a shower fan arduino project with a digital humidity sensor
+ *
+ * Copyright (c) 2013, Michiel Holtkamp, see attached LICENSE file for licensing.
+ *
+ * I used a library from http://playground.arduino.cc/main/DHT11Lib
+ *
+ * For more information, see README
+ */
+
+#include <dht11.h> // see above for URLs
+#include <runningmedian.h>
+
+#define DHT11_PIN 23
+
+// consts for controlling relays
+const int K1 = 5;
+const int K2 = 6;
+const int milliseconds_switch_delay = 100;
+const int NormallyConnected = HIGH;
+const int NormallyOpen = LOW;
+typedef enum {FAN_OFF, FAN_NOCHANGE, FAN_ON};
+
+// DHT consts/variables
+dht11 DHT11;
+
+// consts/variables for humidity sensor and averages etc.
+const int sensorPin = A0;    // select the input pin for the potentiometer
+const int milliseconds_sleep = 5000;
+const float min_humidity_diff= 10.0; // RH %
+const float max_humidity = 100.0; // needed because we add min_humidity_diff
+
+RunningMedian samples = RunningMedian(3);
+
+float thresholdLow = 0.0;
+float thresholdHigh = 0.0;
+float env_min = 0.0;
+float env_max = 0.0;
+float humidity = 0.0;
+float temperature = 0.0;
+float on_off = 0;
+
+// variables for decay
+ // number of seconds after which the difference between the humidity and the max envelope should have been halved.
+const float p_halflife_max = 604800.0;
+//const float p_halflife_min = 86400.0; // same for the min envelope. This is shorter because it needs to change faster.
+const float p_halflife_min = 43200.0; // same for the min envelope. This is shorter because it needs to change faster.
+float env_max_decay = 0.0;
+float env_min_decay = 0.0;
+
+// variables to decide the state of the fan
+int state = FAN_OFF; // action to take, based on sensor reading
+
+void getValues() {
+  // The sensor can only be read from every 1-2s, and requires a minimum
+  // 2s warm-up after power-on.
+  delay(milliseconds_sleep);
+
+#ifdef USE_DHT22
+  DHT22_ERROR_t errorCode = myDHT22.readData();
+  humidity = myDHT22.getHumidity();
+  temperature = myDHT22.getTemperatureC();
+#else
+  int errorCode = DHT11.read(DHT11_PIN);
+  humidity = DHT11.humidity;
+  temperature = DHT11.temperature;
+#endif
+
+  // clamp humidity
+  humidity = max(humidity, 0);
+  humidity = min(humidity, 100);
+  samples.add(humidity);
+  humidity = samples.getMedian();
+
+  switch(errorCode) {
+#ifdef USE_DHT22
+  case DHT_ERROR_NONE:
+    break;
+  case DHT_ERROR_CHECKSUM:
+    Serial.print("E: checksum ");
+    Serial.print(myDHT22._lastCheckSum);
+    Serial.print(" != ");
+    Serial.print(myDHT22._lastExpectedCheckSum);
+    Serial.print(". ");
+    Serial.print(temperature);
+    Serial.print("C ");
+    Serial.print(humidity);
+    Serial.println("%. Are you really sure you set the clock to 8Mhz?");
+    break;
+  case DHT_BUS_HUNG:
+    Serial.println("E: BUS Hung");
+    break;
+  case DHT_ERROR_NOT_PRESENT:
+    Serial.println("E: Sensor not found");
+    break;
+  case DHT_ERROR_ACK_TOO_LONG:
+    Serial.println("E: ACK time out");
+    break;
+  case DHT_ERROR_SYNC_TIMEOUT:
+    Serial.println("E: Sync Timeout");
+    break;
+  case DHT_ERROR_DATA_TIMEOUT:
+    Serial.println("E: Data Timeout");
+    break;
+  case DHT_ERROR_TOOQUICK:
+    Serial.println("E: Polled to quick");
+    break;
+#else
+  case DHTLIB_OK:
+    break;
+  case DHTLIB_ERROR_CHECKSUM:
+    Serial.println("E: Checksum error");
+    break;
+  case DHTLIB_ERROR_TIMEOUT:
+    Serial.println("E: timeout");
+    break;
+  default:
+    Serial.println("E: unknown error");
+    break;
+#endif
+  }
+}
+
+void setup() {
+  Serial.begin(9600);
+
+  // set relays to normally connected
+  pinMode(K1, OUTPUT);
+  pinMode(K2, OUTPUT);
+  digitalWrite(K1, NormallyConnected);
+  digitalWrite(K2, NormallyConnected);
+
+  Serial.println("DHT11 temperature/humidity. Did you set the clock to 8Mhz?");
+
+  // initialize sensor
+  pinMode(sensorPin, INPUT);
+  getValues();
+  env_min = humidity;
+  env_max = humidity + min_humidity_diff;
+  env_max = min(env_max, max_humidity);
+
+  // calculate decay
+  float t = milliseconds_sleep / 1000.0f;
+
+  // calculate what would happen after one step, to unit value (1.0)
+  // the result is the scale factor we can apply to the envelope max/min
+  env_max_decay = 1.0f * pow(2, -t / p_halflife_max);
+  env_min_decay = 1.0f * pow(2, -t / p_halflife_min);
+}
+
+void loop() {
+  getValues();
+
+  /*
+   * Calculate limits
+   */
+
+  // clamp the envelope min/max, decay otherwise
+  if (env_min > humidity) {
+    env_min -= (env_min - humidity) * 0.51;
+  } else {
+    // this actually decays the difference between humidity
+    // and env_min, so this means env_min goes up!
+    env_min = humidity - (humidity - env_min) * env_min_decay;
+  }
+  if (env_max < humidity) {
+    // add little over a half of the difference
+    // to prevent very large changes because of
+    // salt and pepper noise.
+    env_max += (humidity - env_max) * 0.51;
+  } else {
+    env_max = humidity + (env_max - humidity) * env_max_decay;
+  }
+
+  // New thresholds based on the envelope values. We
+  // want the fan to turn on pretty quickly, but we don't
+  // want it to turn off quickly. This explains the difference
+  // in factors between low and high.
+  thresholdLow = env_min + (env_max - env_min) / 8.0f;
+  thresholdHigh = env_min + (env_max - env_min) / 2.0f;
+
+  /*
+   * Check state
+   */
+  int new_state = FAN_NOCHANGE;
+  if (humidity < thresholdLow) {
+    new_state = FAN_OFF;
+  } else if (humidity > thresholdHigh) {
+    new_state = FAN_ON;
+  }
+
+  if (new_state != state) {
+    // switch the relays!
+    switch (new_state) {
+      case FAN_OFF:
+        // because we don't know the status of the 3-way switch, we switch both
+        // relays at the same time and hope there is no short circuit. This should
+        // not be an issue, but anyway...
+        digitalWrite(K1, NormallyConnected);
+        digitalWrite(K2, NormallyConnected);
+        break;
+      case FAN_ON:
+        digitalWrite(K2, NormallyOpen);
+        // since we don't know how the switch is switched, we first switch K2 to
+        // non-connected, then wait a while for it to settle, before we switch
+        // K1 to connected L. This should prevent any shorts (don't know if that
+        // is actually an issue, but better safe than sorry).
+        delay(milliseconds_switch_delay);
+        digitalWrite(K1, NormallyOpen);
+        break;
+    }
+  }
+  state = new_state;
+
+  // display the current state in the graph
+  // don't use absolute values, so the graph can zoom in and show more information
+  switch (state) {
+    case FAN_OFF:
+      on_off = 0.0;
+      break;
+    case FAN_ON:
+      on_off = 1.0;
+      break;
+    case FAN_NOCHANGE:
+      on_off = 0.5;
+      break;
+  }
+
+  /*
+   * Output for debugging/graphing
+   */
+
+  // print out the values for debugging/plotting
+  Serial.print("humidity = ");
+  Serial.print(humidity, 1);
+  Serial.print(", threshold_low = ");
+  Serial.print(thresholdLow, 3);
+  Serial.print(", threshold_hi = ");
+  Serial.print(thresholdHigh, 3);
+  Serial.print(", envelope_min = ");
+  Serial.print(env_min, 3);
+  Serial.print(", envelope_max = ");
+  Serial.print(env_max, 3);
+  Serial.print(", temperature = ");
+  Serial.print(temperature, 1);
+  Serial.print(", on_off = ");
+  Serial.println(on_off, 1);
+}
+


wifi light switch: initial version

wifi light switch: initial version

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

--- arduino/wifi_light_switch/wifi_light_switch.ino
+++ arduino/wifi_light_switch/wifi_light_switch.ino
@@ -0,0 +1,49 @@
+#include <ESP8266WiFi.h>
+#include <ESP8266HTTPClient.h>
+
+const char wifi_ssid[]      = "cherdak";
+const char wifi_password[]  = "rodchenko";
+
+const char openhab_ip[]  = "192.168.2.2";
+
+
+HTTPClient http;
+
+void setup() {
+
+    Serial.begin(9600);
+
+    WiFi.begin(wifi_ssid, wifi_password);
+
+    http.setReuse(true);
+    // pinMode(BUILTIN_LED, OUTPUT);
+}
+
+void loop() {
+    // wait for WiFi connection
+    while ( WiFi.status() != WL_CONNECTED ) {
+        Serial.print(".");
+        delay(500);
+    }
+
+    http.begin(openhab_ip, 8080, "/CMD?Light_4=TOGGLE");
+
+    http.addHeader("Content-Type", "text/plain");
+    http.addHeader("Accept", "application/json");
+
+
+    int httpCode = http.GET();
+    if(httpCode > 0) {
+        Serial.print("[HTTP] GET... code: ");
+        Serial.println(httpCode);
+
+    } else {
+      Serial.print("[HTTP] GET... failed, error: ");
+      Serial.println( http.errorToString(httpCode).c_str() );
+    }
+
+    http.end();
+
+    delay(5000);
+}
+


Cleanup.

Cleanup.

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


DDEC X DB

DDEC X DB

Fixing fuel temperature to read 70°F

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/SynerconTechnologies/SmartSensorSimulator.git/'


Added L6 floorboard

Added L6 floorboard

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

--- Floorboard/floorboard.ino
+++ Floorboard/floorboard.ino
@@ -0,0 +1,779 @@
+/*
+  Optimized digital functions for AVR microcontrollers
+  by Watterott electronic (www.watterott.com)
+  based on http://code.google.com/p/digitalwritefast
+ */
+
+#ifndef __digitalWriteFast_h_
+#define __digitalWriteFast_h_ 1
+
+#define ERROR_SEQUENCE 0b10101010 //digitalReadFast will return this value if pin number is not constant
+// general macros/defines
+#ifndef BIT_READ
+# define BIT_READ(value, bit)            ((value) &   (1UL << (bit)))
+#endif
+#ifndef BIT_SET
+# define BIT_SET(value, bit)             ((value) |=  (1UL << (bit)))
+#endif
+#ifndef BIT_CLEAR
+# define BIT_CLEAR(value, bit)           ((value) &= ~(1UL << (bit)))
+#endif
+#ifndef BIT_WRITE
+# define BIT_WRITE(value, bit, bitvalue) (bitvalue ? BIT_SET(value, bit) : BIT_CLEAR(value, bit))
+#endif
+
+#ifndef SWAP
+#define SWAP(x,y) do{ (x)=(x)^(y); (y)=(x)^(y); (x)=(x)^(y); }while(0)
+#endif
+
+/* //not needed, rather it produces annoying warnings when compiled
+#ifndef DEC
+# define DEC (10)
+#endif
+#ifndef HEX
+# define HEX (16)
+#endif
+#ifndef OCT
+# define OCT (8)
+#endif
+#ifndef BIN
+# define BIN (2)
+#endif
+*/
+
+// workarounds for ARM microcontrollers
+#if (!defined(__AVR__) || defined(ARDUINO_ARCH_SAM))
+#ifndef PROGMEM
+# define PROGMEM
+#endif
+#ifndef PGM_P
+# define PGM_P const char *
+#endif
+#ifndef PSTR
+# define PSTR(str) (str)
+#endif
+
+#ifndef memcpy_P
+# define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
+#endif
+#ifndef strcpy_P
+# define strcpy_P(dst, src)       strcpy((dst), (src))
+#endif
+#ifndef strcat_P
+# define strcat_P(dst, src)       strcat((dst), (src))
+#endif
+#ifndef strcmp_P
+# define strcmp_P(a, b)           strcmp((a), (b))
+#endif
+#ifndef strcasecmp_P
+# define strcasecmp_P(a, b)       strcasecmp((a), (b))
+#endif
+#ifndef strncmp_P
+# define strncmp_P(a, b, n)       strncmp((a), (b), (n))
+#endif
+#ifndef strncasecmp_P
+# define strncasecmp_P(a, b, n)   strncasecmp((a), (b), (n))
+#endif
+#ifndef strstr_P
+# define strstr_P(a, b)           strstr((a), (b))
+#endif
+#ifndef strlen_P
+# define strlen_P(a)              strlen((a))
+#endif
+#ifndef sprintf_P
+# define sprintf_P(s, f, ...)     sprintf((s), (f), __VA_ARGS__)
+#endif
+
+#ifndef pgm_read_byte
+# define pgm_read_byte(addr)      (*(const unsigned char *)(addr))
+#endif
+#ifndef pgm_read_word
+# define pgm_read_word(addr)      (*(const unsigned short *)(addr))
+#endif
+#ifndef pgm_read_dword
+# define pgm_read_dword(addr)     (*(const unsigned long *)(addr))
+#endif
+
+#endif
+
+
+// digital functions
+//#ifndef digitalPinToPortReg
+#define SPI_SW_SS_PIN   (10) //SS on Uno (for software SPI)
+#define SPI_SW_MOSI_PIN (11) //MOSI on Uno (for software SPI)
+#define SPI_SW_MISO_PIN (12) //MISO on Uno (for software SPI)
+#define SPI_SW_SCK_PIN  (13) //SCK on Uno (for software SPI)
+
+
+// --- Arduino Due ---
+#if (defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__))
+
+#define UART_RX_PIN     (0)
+#define UART_TX_PIN     (1)
+
+#define I2C_SDA_PIN     (20)
+#define I2C_SCL_PIN     (21)
+
+#define SPI_HW_SS_PIN   (78) //SS0:77, SS1:87, SS2:86, SS3:78
+#define SPI_HW_MOSI_PIN (75) //75
+#define SPI_HW_MISO_PIN (74) //74
+#define SPI_HW_SCK_PIN  (76) //76
+
+
+// --- Arduino Zero ---
+#elif (defined(ARDUINO_SAM_ZERO) || defined(__SAMD21G18A__))
+
+#define UART_RX_PIN     (0)
+#define UART_TX_PIN     (1)
+
+#define I2C_SDA_PIN     (16)
+#define I2C_SCL_PIN     (17)
+
+#define SPI_HW_SS_PIN   (14) //14
+#define SPI_HW_MOSI_PIN (21) //21
+#define SPI_HW_MISO_PIN (18) //18
+#define SPI_HW_SCK_PIN  (20) //20
+
+
+// --- Arduino Mega ---
+#elif (defined(ARDUINO_AVR_MEGA) || \
+       defined(ARDUINO_AVR_MEGA1280) || \
+       defined(ARDUINO_AVR_MEGA2560) || \
+       defined(__AVR_ATmega1280__) || \
+       defined(__AVR_ATmega1281__) || \
+       defined(__AVR_ATmega2560__) || \
+       defined(__AVR_ATmega2561__))
+
+#define UART_RX_PIN     (0) //PE0
+#define UART_TX_PIN     (1) //PE1
+
+#define I2C_SDA_PIN     (20)
+#define I2C_SCL_PIN     (21)
+
+#define SPI_HW_SS_PIN   (53) //PB0
+#define SPI_HW_MOSI_PIN (51) //PB2
+#define SPI_HW_MISO_PIN (50) //PB3
+#define SPI_HW_SCK_PIN  (52) //PB1
+
+#define __digitalPinToPortReg(P) \
+(((P) >= 22 && (P) <= 29) ? &PORTA : \
+((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PORTB : \
+(((P) >= 30 && (P) <= 37) ? &PORTC : \
+((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PORTD : \
+((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PORTE : \
+(((P) >= 54 && (P) <= 61) ? &PORTF : \
+((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PORTG : \
+((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PORTH : \
+(((P) == 14 || (P) == 15) ? &PORTJ : \
+(((P) >= 62 && (P) <= 69) ? &PORTK : &PORTL))))))))))
+
+#define __digitalPinToDDRReg(P) \
+(((P) >= 22 && (P) <= 29) ? &DDRA : \
+((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &DDRB : \
+(((P) >= 30 && (P) <= 37) ? &DDRC : \
+((((P) >= 18 && (P) <= 21) || (P) == 38) ? &DDRD : \
+((((P) >= 0 && (P) <= 3) || (P) == 5) ? &DDRE : \
+(((P) >= 54 && (P) <= 61) ? &DDRF : \
+((((P) >= 39 && (P) <= 41) || (P) == 4) ? &DDRG : \
+((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &DDRH : \
+(((P) == 14 || (P) == 15) ? &DDRJ : \
+(((P) >= 62 && (P) <= 69) ? &DDRK : &DDRL))))))))))
+
+#define __digitalPinToPINReg(P) \
+(((P) >= 22 && (P) <= 29) ? &PINA : \
+((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PINB : \
+(((P) >= 30 && (P) <= 37) ? &PINC : \
+((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PIND : \
+((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PINE : \
+(((P) >= 54 && (P) <= 61) ? &PINF : \
+((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PING : \
+((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PINH : \
+(((P) == 14 || (P) == 15) ? &PINJ : \
+(((P) >= 62 && (P) <= 69) ? &PINK : &PINL))))))))))
+
+#define __digitalPinToBit(P) \
+(((P) >=  7 && (P) <=  9) ? (P) - 3 : \
+(((P) >= 10 && (P) <= 13) ? (P) - 6 : \
+(((P) >= 22 && (P) <= 29) ? (P) - 22 : \
+(((P) >= 30 && (P) <= 37) ? 37 - (P) : \
+(((P) >= 39 && (P) <= 41) ? 41 - (P) : \
+(((P) >= 42 && (P) <= 49) ? 49 - (P) : \
+(((P) >= 50 && (P) <= 53) ? 53 - (P) : \
+(((P) >= 54 && (P) <= 61) ? (P) - 54 : \
+(((P) >= 62 && (P) <= 69) ? (P) - 62 : \
+(((P) == 0 || (P) == 15 || (P) == 17 || (P) == 21) ? 0 : \
+(((P) == 1 || (P) == 14 || (P) == 16 || (P) == 20) ? 1 : \
+(((P) == 19) ? 2 : \
+(((P) == 5 || (P) == 6 || (P) == 18) ? 3 : \
+(((P) == 2) ? 4 : \
+(((P) == 3 || (P) == 4) ? 5 : 7)))))))))))))))
+
+
+// --- Arduino 644 ---
+#elif (defined(__AVR_ATmega644__) || \
+       defined(__AVR_ATmega644P__))
+
+#define UART_RX_PIN     (8) //PD0
+#define UART_TX_PIN     (9) //PD1
+
+#define I2C_SDA_PIN     (17) //PC1
+#define I2C_SCL_PIN     (16) //PC0
+
+#define SPI_HW_SS_PIN   (4) //PB4
+#define SPI_HW_MOSI_PIN (5) //PB5
+#define SPI_HW_MISO_PIN (6) //PB6
+#define SPI_HW_SCK_PIN  (7) //PB7
+
+#define __digitalPinToPortReg(P) \
+(((P) >= 0 && (P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : &PORTA)))
+#define __digitalPinToDDRReg(P) \
+(((P) >= 0 && (P) <= 7) ? &DDRB : (((P) >= 8 && (P) <= 15) ? &DDRD : (((P) >= 8 && (P) <= 15) ? &DDRC : &DDRA)))
+#define __digitalPinToPINReg(P) \
+(((P) >= 0 && (P) <= 7) ? &PINB : (((P) >= 8 && (P) <= 15) ? &PIND : (((P) >= 8 && (P) <= 15) ? &PINC : &PINA)))
+#define __digitalPinToBit(P) \
+(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (P) - 24)))
+
+
+// --- Arduino Leonardo ---
+#elif (defined(ARDUINO_AVR_LEONARDO) || \
+       defined(__AVR_ATmega16U4__) || \
+       defined(__AVR_ATmega32U4__))
+
+#define UART_RX_PIN     (0) //PD2
+#define UART_TX_PIN     (1) //PD3
+
+#define I2C_SDA_PIN     (2) //PD1
+#define I2C_SCL_PIN     (3) //PD0
+
+#define SPI_HW_SS_PIN   (17) //PB0
+#define SPI_HW_MOSI_PIN (16) //PB2
+#define SPI_HW_MISO_PIN (14) //PB3
+#define SPI_HW_SCK_PIN  (15) //PB1
+
+#define __digitalPinToPortReg(P) \
+((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PORTD : (((P) == 5 || (P) == 13) ? &PORTC : (((P) >= 18 && (P) <= 23)) ? &PORTF : (((P) == 7) ? &PORTE : &PORTB)))
+#define __digitalPinToDDRReg(P) \
+((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &DDRD : (((P) == 5 || (P) == 13) ? &DDRC : (((P) >= 18 && (P) <= 23)) ? &DDRF : (((P) == 7) ? &DDRE : &DDRB)))
+#define __digitalPinToPINReg(P) \
+((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PIND : (((P) == 5 || (P) == 13) ? &PINC : (((P) >= 18 && (P) <= 23)) ? &PINF : (((P) == 7) ? &PINE : &PINB)))
+#define __digitalPinToBit(P) \
+(((P) >= 8 && (P) <= 11) ? (P) - 4 : (((P) >= 18 && (P) <= 21) ? 25 - (P) : (((P) == 0) ? 2 : (((P) == 1) ? 3 : (((P) == 2) ? 1 : (((P) == 3) ? 0 : (((P) == 4) ? 4 : (((P) == 6) ? 7 : (((P) == 13) ? 7 : (((P) == 14) ? 3 : (((P) == 15) ? 1 : (((P) == 16) ? 2 : (((P) == 17) ? 0 : (((P) == 22) ? 1 : (((P) == 23) ? 0 : (((P) == 24) ? 4 : (((P) == 25) ? 7 : (((P) == 26) ? 4 : (((P) == 27) ? 5 : 6 )))))))))))))))))))
+
+
+// --- Arduino Uno ---
+#elif (defined(ARDUINO_AVR_UNO) || \
+       defined(ARDUINO_AVR_DUEMILANOVE) || \
+       defined(ARDUINO_ARCH_AVR) || \
+       defined(__AVR_ATmega328__) || \
+       defined(__AVR_ATmega328P__) || \
+       defined(__AVR__))
+
+#define UART_RX_PIN     (0) //PD0
+#define UART_TX_PIN     (1) //PD1
+
+#define I2C_SDA_PIN     (18) //A4
+#define I2C_SCL_PIN     (19) //A5
+
+#define SPI_HW_SS_PIN   (10) //PB0
+#define SPI_HW_MOSI_PIN (11) //PB2
+#define SPI_HW_MISO_PIN (12) //PB3
+#define SPI_HW_SCK_PIN  (13) //PB1
+
+#define __digitalPinToPortReg(P) \
+(((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))
+#define __digitalPinToDDRReg(P) \
+(((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))
+#define __digitalPinToPINReg(P) \
+(((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))
+#define __digitalPinToBit(P) \
+(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (P) - 14))
+
+
+// --- Other ---
+#else
+
+#define SPI_HW_SS_PIN   SS
+#define SPI_HW_MOSI_PIN MOSI
+#define SPI_HW_MISO_PIN MISO
+#define SPI_HW_SCK_PIN  SCK
+
+
+#endif
+//#endif  //#ifndef digitalPinToPortReg
+
+
+//ref: http://forum.arduino.cc/index.php?topic=140409.msg1054868#msg1054868
+//void OutputsErrorIfCalled( void ) __attribute__ (( error( "Line: "__line__ "Variable used for digitalWriteFast") ));
+void NonConstantUsed( void )  __attribute__ (( error("") ));
+
+
+#ifndef digitalWriteFast
+#if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
+#define digitalWriteFast(P, V) \
+if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
+  BIT_WRITE(*__digitalPinToPortReg(P), __digitalPinToBit(P), (V)); \
+} else { \
+  NonConstantUsed(); \
+}
+#else
+//#define digitalWriteFast digitalWrite
+#error Non-AVR device, unsupported.
+#endif
+#endif
+
+
+#ifndef pinModeFast
+#if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
+#define pinModeFast(P, V) \
+if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
+  BIT_WRITE(*__digitalPinToDDRReg(P), __digitalPinToBit(P), (V)); \
+} else { \
+  NonConstantUsed(); \
+}
+#else
+//#define pinModeFast pinMode
+#error Non-AVR device, unsupported.
+#endif
+#endif
+
+
+#ifndef digitalReadFast
+#if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
+#define digitalReadFast(P) ( (byte) __digitalReadFast((P)) )
+#define __digitalReadFast(P ) \
+  (__builtin_constant_p(P) ) ? ( \
+  ( BIT_READ(*__digitalPinToPINReg(P), __digitalPinToBit(P))) ) : \
+  ERROR_SEQUENCE
+#else
+//#define digitalReadFast digitalRead
+#error Non-AVR device, unsupported.
+#endif
+#endif
+
+#endif //__digitalWriteFast_h_
+/**
+ * Arduino interfacing with the Line 6 Floorboard
+ *
+ * Thanks to Mark Lavelle for deciphering how this floorboard works and publishing on his website.
+ * Go here for the document: http://harmonicappliances.com/floorboard/floorboard.html
+ *
+ * The following is a description of how to make the connection to the floorboard
+ * (which I copied from the website linked above, because I am lazy as hell.)
+ *
+ * ==============================================================
+ * The POD & Floor Board use standard "Category 5" network cables for connection.
+ * The connectors on these cables (and the receptacles in the POD and Floor Board) are known as RJ-45s.
+ * They're just like standard phone jacks, but with 8 pins.
+ *
+ * The pin numbering I'll use for RJ-type jacks starts at 1 and goes from left to right
+ * looking into the receptacle (the female socket on the POD or Floor Board)
+ * with the locking tab slot on the bottom, like the diagram below.
+ * "Standard" or not, that's the numbering I'll be using here.
+ * ==============================================================
+ *
+ * And here is a very lame ASCII interpretation of the connection drawing.
+ * (Again, for details visit that website linked above.)
+ *
+ *                                              1: Ground
+ *                _________________             2: Wah
+ *               | = = = = = = = = |            3: Ground
+ *               | 1 2 3 4 5 6 7 8 |            4: Volume
+ *               |_____       _____|            5: LEDs
+ *                     |_____|                  6: Switches
+ *                                              7: +5V
+ *                                              8: +5V
+ *
+ * So, what we'll be doing is connectiong those lines directly to our arduino.
+ * And, basically, besides the power lines, we'll only be using 3 analog and 1 digital
+ * pins which is Awesome!
+ *
+ * Analog pins will be 3, 4 and 5 for switches, wah and volume respectively.
+ * The LED output will go to digital pin 8 (but it can be any from 8 to 13 since I'm using a method I stole
+ * from the internet -don't remember where, sorry- for writing faster than digitalWrite in which all digital
+ * output is written to all those pins.)
+ *
+ * A quick tip:
+ * Take a Cat5 cable and cut one end, just to lose the connector, then strip like 1/4" from each wire.
+ * You can easily use this wires with a protoboard to connect with your arduino, and use the connector in
+ * the other end and plug your floorboard.
+ */
+
+// This are the analog pins, used for the switches and expression pedals.
+const int pinSw  = 3; // to pin 6 in the RJ45 connector
+const int pinWah = 4; // to pin 2 in the RJ45 ...
+const int pinVol = 5; // to 4 in ...
+const int pinLED = 8;
+
+// This constants are the bit positions for each of the LEDs.
+const int DIST  = (8*0)+7;
+const int DOWN  = (8*1)+7;
+const int POINT = (8*2)+7;
+const int TAP   = (8*3)+7;
+const int WAH   = (8*3)+6;
+const int SEL   = (8*3)+5;
+const int DRV   = (8*3)+4;
+const int CHD   = (8*3)+3;
+const int CHC   = (8*3)+2;
+const int CHB   = (8*3)+1;
+const int CHA   = (8*3)+0;
+
+// I made a fancy presentation and use this variable to run it only the first time I engage the thing.
+bool presentation;
+
+// We use these to remember what input we had in the previous read.
+byte swValue  = 0;
+byte volValue = 0;
+byte wahValue = 0;
+
+// We have to move all the foot to calibrate the wah
+int readBounds[2][2] = {{420,780},{380,780}};
+
+// Smoothing the expression pedals
+const int numReadings = 6;
+
+// We use arrays of 2 because that's the number of variable resistors we have
+int readings[2][numReadings];      // the readings from the analog input
+int readIndex = 0;              // the index of the current reading
+int readTotal[2];                  // the running total
+int readAverage[2];                // the average
+
+
+// We use these to eliminate bouncing (stolen from here: https://www.arduino.cc/en/Tutorial/Debounce)
+int buttonState;             // the current reading from the input pin
+int lastButtonState = LOW;   // the previous reading from the input pin
+// the following variables are unsigned long's because the time, measured in miliseconds,
+// will quickly become a bigger number than can be stored in an int.
+unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
+unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers
+
+// The values of each LED are stored here.
+byte leds[] = {0,0,0,0};
+
+// This is the character map for the LCD display
+// Source: http://harmonicappliances.com/floorboard/floorboard.html
+byte digit[255];
+void initChars() {
+  digit['A'] = B11101110;
+  digit['B'] = B00111110;
+  digit['C'] = B10011100;
+  digit['D'] = B01111010;
+  digit['E'] = B10011110;
+  digit['F'] = B10001110;
+  digit['G'] = B11110110;
+  digit['H'] = B01101110;
+  digit['I'] = B00001100;
+  digit['J'] = B01111000;
+  digit['k'] = B01001110;
+  digit['L'] = B00011100;
+  digit['M'] = B10101000;
+  digit['N'] = B00101010;
+  digit['O'] = B00111010;
+  digit['P'] = B11001110;
+  digit['Q'] = B11100110;
+  digit['R'] = B00001010;
+  digit['S'] = B10110110;
+  digit['T'] = B00011110;
+  digit['U'] = B01111100;
+  digit['V'] = B00111000;
+  digit['W'] = B01010100;
+  digit['X'] = B01011110;
+  digit['Y'] = B01110110;
+  digit['Z'] = B10011010;
+  digit['-'] = B00000010;
+  digit['_'] = B00010000;
+  digit['0'] = B11111100;
+  digit['1'] = B01100000;
+  digit['2'] = B11011010;
+  digit['3'] = B11110010;
+  digit['4'] = B01100110;
+  digit['5'] = B10110110;
+  digit['6'] = B10111110;
+  digit['7'] = B11100000;
+  digit['8'] = B11111110;
+  digit['9'] = B11110110;
+}
+
+void sendPulses() {
+  for (int i = 0; i< 32; i++) {
+      // We always send one on and one off for each led or display segment.
+    // The duration of each pulse tells the floorboard if the led is on or off.
+    byte time1 = ((leds[i/8]>>(i%8))&1) ? 2 : 5;
+    byte time2 = 6 - time1;
+
+    digitalWriteFast(pinLED, HIGH);
+    //digitalWrite(pinLED, HIGH);
+    delayMicroseconds(time1);
+    digitalWriteFast(pinLED, LOW);
+    //digitalWrite(pinLED, LOW);
+    delayMicroseconds(time2);
+  }
+}
+
+
+void debugPulses() {
+  Serial.println("DEBUG PULSES START");
+
+  for (int i = 0; i< 32; i++) {
+      // We always send one on and one off for each led or display segment.
+    // The duration of each pulse tells the floorboard if the led is on or off.
+    byte time1 = ((leds[i/8]>>(i%8))&1) ? 1 : 5;
+    byte time2 = 6 - time1;
+
+    //Serial.print("time1: ");
+    //Serial.println(time1);
+
+    //Serial.print("time2: ");
+    //Serial.println(time2);
+    Serial.print(time1 == 5 ? "0" : "1");
+  }
+      Serial.println();
+
+  Serial.println("DEBUG PULSES END");
+}
+
+// Sets the char chr in the pos position of the 3 char display
+void setChar(char chr, int pos) {
+  leds[pos] = (leds[pos] & 1) | digit[chr];
+}
+
+// Update a LED
+void writeLed(int pos, bool val) {
+  int byt = floor(pos / 8);
+  int shft  = pos % 8;
+  byte msk = ~(1<<(7-shft));
+  leds[byt] = (leds[byt] & msk) | (val<<(7-shft));
+  sendPulses();
+}
+
+// Puts the first 3 chars of the string on the 3-digit display
+void writeScreen(String text) {
+  for(int i = 0; i<3; i++) {
+    if (i+1>text.length()) {
+      setChar(0,i);
+    } else {
+      setChar(text.charAt(2-i),i);
+    }
+  }
+ sendPulses();
+}
+
+// My fancy 3-digit-7-segment-only-numbers-and-some-letters-marquee function
+void typeText (String str, int repeat, byte spd) {
+  String  newText = "   " + str + "   ";
+  newText.toUpperCase();
+  int ms = map(spd, 0, 255, 1000, 50);
+  for (int i = 0; i < repeat; i++) {
+    for (int chr = 0; chr < str.length()+3; chr++) {
+      String segment = newText.substring(chr, chr+3);
+      writeScreen(segment);
+      Serial.println(segment);
+      delay(ms);
+    }
+  }
+  writeScreen("   ");
+}
+
+void setup() {
+  // Initialize fast digital write, needed for sending the LED pulses.
+  DDRB = 255;
+  pinModeFast(pinLED, OUTPUT);
+  //pinMode(pinLED, OUTPUT);
+  pinMode(pinSw, INPUT);
+  initChars();
+  presentation = 1;
+  Serial.begin(9600);
+  // initialize all the readings to 0:
+  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
+    readings[0][thisReading] = 0;
+    readings[1][thisReading] = 0;
+  }
+}
+
+// All switches use the same analog input but with different resistance values,
+// so we have a different voltage for each switch
+byte buttonValue2(int value) {
+  if (value < 50)
+    return 8;    // TAP BUTTON
+  if (value < 130)
+    return 7; // CHANNEL SELECT
+  if (value < 250)
+    return 9; // WAH
+  if (value < 350)
+    return 3; // CHANNEL A
+  if (value < 430)
+    return 4; // CHANNEL B
+  if (value < 500)
+    return 5; // CHANNEL C
+  if (value < 600)
+    return 6; // CHANNEL D
+  if (value < 780)
+    return 10; // PRESET ( UP + DOWN)
+  if (value < 830)
+    return 2; // UP
+  if (value < 880)
+    return 1; // DOWN
+   return 0; // NO BUTTON PRESSED
+}
+
+byte buttonValue(int value) {
+  #define CHECK(V) (abs(value - V) < 3)
+
+  if (CHECK(85)) return DOWN;
+  if (CHECK(37)) return DIST;
+  if (CHECK(99)) return DRV;
+
+  return 0; // NO BUTTON PRESSED
+  #undef CHECK
+}
+
+// I made this function at the begining for testing the LEDS, but I liked so much that
+// I left it here and use it as part fancy presentation.
+void test(bool val) {
+  int dl=80;
+  writeLed(DIST, val);
+  delay(dl);
+  writeLed(DOWN, val);
+  delay(dl);
+  writeLed(POINT, val);
+  delay(dl);
+  writeLed(TAP, val);
+  delay(dl);
+  writeLed(WAH, val);
+  delay(dl);
+  writeLed(SEL, val);
+  delay(dl);
+  writeLed(DRV, val);
+  delay(dl);
+  writeLed(CHD, val);
+  delay(dl);
+  writeLed(CHC, val);
+  delay(dl);
+  writeLed(CHB, val);
+  delay(dl);
+  writeLed(CHA,val);
+}
+
+byte parseFromMax(byte data) {
+  // Digits in max are represented with their ASCII value, the floorboard uses a lcd segment
+  // map described in the document linked in the description at the top of this file.
+  return digit[data & ~(128)] | data>>7;
+}
+
+void badassPresentation() {
+    test(1);
+    test(0);
+    typeText("IMBIREk JEST NAJLEPSZY", 1, 220);
+    test(1);
+    test(0);
+}
+
+int smooth(int pos, int value) {
+  value = constrain(map(value, readBounds[pos][0], readBounds[pos][1], 0, 255), 0, 255);
+  readTotal[pos] = readTotal[pos] - readings[pos][readIndex];
+  readTotal[pos] += value;
+  readings[pos][readIndex] = value;
+  readAverage[pos] = readTotal[pos] / numReadings;
+  return readAverage[pos];
+}
+
+int lastReadSw;
+
+void loop() {
+  //Serial.println("loop");
+  if (presentation) {
+    presentation = false;
+    Serial.println("presentation");
+    //test(true);
+  }
+
+  writeLed(POINT, false);
+  writeScreen("CAT");
+
+
+  byte readSw = analogRead(pinSw);
+  //Serial.println(readSw);
+  if (abs(lastReadSw - readSw) < 3) {
+    // successful press
+
+    int bv = buttonValue(readSw);
+    if (bv) {
+      writeLed(bv, true);
+    }
+  }
+  lastReadSw = readSw;
+
+  delay(10);
+}
+
+
+void loop2() {
+  // My badass presentation!!!
+  if (presentation) {
+    presentation = 0;
+    badassPresentation();
+  }
+
+  // Start reading the analog inputs.
+  byte readSw = buttonValue(analogRead(pinSw));
+
+  byte byteWah = 0;//smooth(0,analogRead(pinWah));
+  byte byteVol = 0;//smooth(1,analogRead(pinVol));
+  readIndex = readIndex + 1 == numReadings ? 0 : readIndex + 1;
+
+  // And again, All of this debouncing stuff was taken from here:
+  //   https://www.arduino.cc/en/Tutorial/Debounce
+  // check to see if you just pressed the button
+  // (i.e. the input went from LOW to HIGH),  and you've waited
+  // long enough since the last press to ignore any noise:
+
+  // If the switch changed, due to noise or pressing:
+  if (readSw != lastButtonState) {
+    // reset the debouncing timer
+    lastDebounceTime = millis();
+  }
+
+  if ((millis() - lastDebounceTime) > debounceDelay){
+    // whatever the reading is at, it's been there for longer
+    // than the debounce delay, so take it as the actual current state:
+
+    // if the button state has changed
+    if (readSw != buttonState) {
+      // only toggle the LED if the new button state is HIGH
+      buttonState = readSw;
+    }
+  }
+
+  // save the reading.  Next time through the loop,
+  // it'll be the lastButtonState:
+  lastButtonState = readSw;
+
+  // Now if somenthing changed since the last time we proceed to process the input data.
+  if ((byteVol != volValue) || (byteWah != wahValue) || (buttonState != swValue)) {
+    // update the globals, to remember the nex time.
+    wahValue = byteWah;
+    volValue = byteVol;
+    swValue  = buttonState;
+
+    // With this I can send the three input bytes to the serial port, which i happen to read back  there on Max7
+    Serial.print(swValue);
+    Serial.print(" ");
+    Serial.print(wahValue);
+    Serial.print(" ");
+    Serial.println(volValue);
+    delay(20);
+
+  }
+
+  // Check if we have input in the serial port
+  if (Serial.available()) {
+    // Led info is represented in 4 bytes
+    char buf[4];
+    Serial.readBytes(buf, 4);
+    leds[0] = parseFromMax(buf[0]);
+    leds[1] = parseFromMax(buf[1]);
+    leds[2] = parseFromMax(buf[2]);
+    leds[3] = buf[3];
+    // Finally send all these bits as a pulse train to the floorboard.
+    sendPulses();
+  }
+}


Update MasterModule.ino

Update MasterModule.ino

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


updated examples

updated examples

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

--- DAC8760/examples/Freq2Volt/Freq2Volt.ino
+++ DAC8760/examples/Freq2Volt/Freq2Volt.ino
@@ -0,0 +1,186 @@
+/*
+  Frequency to Voltage Converter
+
+  Frequency-Input - D8/PB0/ICP1
+
+  DAC8760
+  CLR   - connected to GND
+  LATCH - D10
+  DIN   - D11/MOSI
+  SDO   - D12/MISO
+  SCLK  - D13/CLK
+ */
+
+#include <util/delay.h>
+#include <SPI.h>
+#include <DAC8760.h>
+
+
+//#define DEBUG //enable serial debug output (9600 baud)
+
+#define INPUT_PIN 8 //D8/PB0/ICP1
+
+//F_CPU = 16000000 Hz = 62.5ns
+//t = 800.....16000 (*62.5ns)
+//f = 20kHz...1kHz  (f = 1/((1/F_CPU)*t))
+//v = 10V.....0V
+//n = 65535...0
+#define F_MIN  1000 // 1000Hz, 250...100000Hz (min. frequency -> 0V)
+#define F_MAX 20000 //20000Hz, 250...100000Hz (max. frequency -> 10V)
+#define N_MIN     0 // 0V = 0
+#define N_MAX 65535 //10V = 65535
+
+
+DAC8760 dac;
+
+volatile uint_least16_t t_avg=0;
+uint_least8_t t_over=0;
+
+
+ISR(TIMER1_OVF_vect) //overflow after about 4ms
+{
+  t_over = 1;
+  t_avg  = F_CPU/F_MIN; //set to min. freq.
+}
+
+
+ISR(TIMER1_CAPT_vect) //input capture irq
+{
+  uint_least16_t t;
+  static uint_least16_t t_last=0;
+
+  TCNT1 = 0x0000; //reset timer
+  t = ICR1; //get input capture value
+
+  if(t_over) //overflow?
+  {
+    t_over = 0;
+    t_last = 0;
+  }
+  else
+  {
+    if(t == t_last) //current value = last value
+    {
+      //set avg to t
+      t_avg = t;
+
+      //make avg from last and current
+      // t_avg  += t;
+      // t_avg >>= 1; //div by 2
+    }
+    t_last = t;
+  }
+}
+
+
+void print(char *s)
+{
+#ifdef DEBUG
+  while(*s)
+  {
+    loop_until_bit_is_set(UCSR0A, UDRE0);
+    UDR0 = *s++;
+  }
+#endif
+}
+
+
+void print(uint_least16_t i)
+{
+#ifdef DEBUG
+  char tmp[8];
+
+  sprintf(tmp, "%u", i);
+  print(tmp);
+#endif
+}
+
+
+void setup()
+{
+  //init Serial port
+#ifdef DEBUG
+  Serial.begin(9600);
+  while(!Serial); //wait for serial port to connect - needed for Leonardo only
+#endif
+
+  //init Pins
+  print("Init Pins...\n");
+  pinMode(INPUT_PIN, INPUT);
+  digitalWrite(INPUT_PIN, HIGH); //pull-up
+
+  //init DAC
+  print("Init DAC...\n");
+  dac.begin();
+  dac.write(0);
+
+  //disable Arduino interrupts and init timer
+  print("Init IRQs...\n");
+  cli(); //disable all interrupts
+  //disable UART interrupts
+  UCSR0B &= ~((1<<RXCIE0) | (1<<TXCIE0));
+  //reset presaclers
+  GTCCR = (1<<PSRASY);
+  //disable timer 0 (8 bit)
+  TCNT0  = 0;
+  TIMSK0 = 0;
+  TCCR0A = 0x00;
+  TCCR0B = 0x00;
+  //enable timer 1 (16 bit)
+  TCNT1  = 0x0000;
+  TIMSK1 = (1<<ICIE1) | (1<<TOIE1);
+  TCCR1A = 0x00;
+  TCCR1B = (1<<ICNC1) | (1<<ICES1) | (0<<CS12) | (0<<CS11) | (1<<CS10); //ICP1 rising, clk=F_CPU/1
+  TCCR1C = 0x00;
+  //disable timer 2 (8 bit)
+  TCNT2  = 0x00;
+  TIMSK2 = 0x00;
+  TCCR2A = 0x00;
+  TCCR2B = 0x00;
+  sei(); //enable all interrupts
+}
+
+
+void loop()
+{
+  uint_least16_t t, n;
+  static uint_least16_t t_last=0, n_last=0;
+  uint_least32_t f;
+  uint8_t oldSREG;
+
+  oldSREG = SREG;
+  cli();
+  t = t_avg;
+  SREG = oldSREG;
+
+  if(t != t_last) //t changed?
+  {
+    t_last = t;
+
+    f = F_CPU/(uint_least32_t)t; //calculate f from t
+         if(f < F_MIN){ f = F_MIN; } //freq. to low?
+    else if(f > F_MAX){ f = F_MAX; } //freq. to high?
+    n = map(f, F_MIN, F_MAX, N_MIN, N_MAX); //map freq. to voltage
+
+    if(n != n_last) //n changed?
+    {
+      n_last = n;
+
+      //set DAC output
+      dac.write(n); //set DAC output
+
+#ifdef DEBUG
+      //print("t:");
+      //print(t);
+      print(" f:");
+      print(f);
+      //print(" n:");
+      //print(n);
+      print(" mV:");
+      n = map(n, 0, 65535, 0, 10000); //map n to voltage
+      print(n);
+      print("\n");
+#endif
+    }
+  }
+}


Update wemos_remote.ino

Update wemos_remote.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/vaskovasilev/webcontrol.git/'


Wiring seems to be in good working order

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


ok, that is how we move twice as far as needed …

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/'


rename commands

rename commands

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/wsnook/farm.git/'