mama playing MSE signal smoothing

mama playing MSE signal smoothing

/**********************************************************
                Fast PWM Test
Demostrates the generation of high speed PWM
using timers 1 and 4
There are two pieces of code:
One for pins 9, 10 and 11 using TIMER 1
with frequencies up to 62kHz
Other for pins 6 and 13 using TIMER 4
with frequencies up to 187kHz
History:
  12/12/2014 - Version 1.0
  22/12/2014 - Adding a missing OCR4C value

  http://r6500.blogspot.com/2014/12/fast-pwm-on-arduino-leonardo.html

***********************************************************/

// https://web.archive.org/web/20140101032749/http://coolarduino.wordpress.com/2012/09/19/quasi-real-time-oscilloscope-remix/

/**********************************************************
   Fast PWM on pins 9,10,11 (TIMER 1)

   Do not use analogWrite to pins 9, 10 or 11 if using
   this functions as they use the same timer.

   Those functions will probably conflict with the
   servo library.

   Uses 5 PWM frequencies between 61Hz and 62.5kHz

**********************************************************/

/**********************************************************
   Fast PWM on pins 6, 13 (High Speed TIMER 4)

   Do not use analogWrite to pins 6 or 13 if using
   this functions as they use the same timer.

   Those functions will conflict with the
   MSTIMER2 library.
   Uses 7 PWM frequencies between 2930Hz and 187.5kHz

   Timer 4 uses a PLL as input so that its clock frequency
   can be up to 96MHz on standard Arduino Leonardo.
   We limit imput frequency to 48MHz to generate 187.5kHz PWM
   If needed, we can double that up to 375kHz
**********************************************************/

// Frequency modes for TIMER4
#define PWM187k 1   // 187500 Hz
#define PWM94k  2   //  93750 Hz
#define PWM47k  3   //  46875 Hz
#define PWM23k  4   //  23437 Hz
#define PWM12k  5   //  11719 Hz
#define PWM6k   6   //   5859 Hz
#define PWM3k   7   //   2930 Hz

// Direct PWM change variables
#define PWM6        OCR4D
#define PWM13       OCR4A

// Terminal count
#define PWM6_13_MAX OCR4C

// Configure the PWM clock
// The argument is one of the 7 previously defined modes
void pwm613configure(int mode)
{
// TCCR4A configuration
TCCR4A=0;

// TCCR4B configuration
TCCR4B=mode;

// TCCR4C configuration
TCCR4C=0;

// TCCR4D configuration
TCCR4D=0;

// TCCR4D configuration
TCCR4D=0;

// PLL Configuration
// Use 96MHz / 2 = 48MHz
// PLLFRQ=(PLLFRQ&0xCF)|0x30;
 PLLFRQ=(PLLFRQ&0xCF)|0x10; // Will double all frequencies

// Terminal count for Timer 4 PWM
OCR4C=255;
}

// Set PWM to D6 (Timer4 D)
// Argument is PWM between 0 and 255
void pwmSet6(int value)
{
OCR4D=value;   // Set PWM value
DDRD|=1<<7;    // Set Output Mode D7
TCCR4C|=0x09;  // Activate channel D
}

// Set PWM to D13 (Timer4 A)
// Argument is PWM between 0 and 255
void pwmSet13(int value)
{
OCR4A=value;   // Set PWM value
DDRC|=1<<7;    // Set Output Mode C7
TCCR4A=0x82;  // Activate channel A
}

/*************** ADDITIONAL DEFINITIONS ******************/

// Macro to converts from duty (0..100) to PWM (0..255)
#define DUTY2PWM(x)  ((255*(x))/100)

/**********************************************************/

////////////////////////////////////////
//////////        WHOA        //////////
//////////        WHOA        //////////
//////////        WHOA        //////////
//////////        WHOA        //////////
//////////        WHOA        //////////
////////////////////////////////////////

// Pins

int hvDigitalIn = 19; // pf6 -> A1   D19
int hvClock = 18;     // pf7 -> A0   D18

int clearPin = 6;     // pd7 -> A7   D6#
int sense1 = A6;      // pd4 -> A6   D4
int sense2 = A11;     // pd6 -> A11  D12
int sense3 = 8;       // pb4 -> A8   D8
int sense4 = 9;       // pb5 -> A9   D9

int elEnable = 20;    // pf5 -> A2   D20

int detect = 5;

int rxled = 30;
int txled = 22;
int rstled = 7;

// This is hacky.
// Work around from this changing when the program is loaded from the IDE.
int capSenseFrequency = 1;

// State

#define channelCount 4
int switched[] = {0, 0, 0, 0};
bool glow[] = {true, true, true, true};
bool allGlow[] = {true, true, true, true};
bool noGlow[] = {false, false, false, false};

#define prevValSize 50
int prevVal[prevValSize][channelCount];

#define sampleCount 3
int sampleAll[channelCount][sampleCount];
int sampleAllVal[channelCount];

int samples[sampleCount];
int sampleVal = 0;

// Helpers

int tempGlow[channelCount];
byte tempGlow_unroll[channelCount * 2];
void switchOutputs(bool* glow) {
  // Make pins on the layout correspond to the pins on the switch
  tempGlow[2] = glow[0];
  tempGlow[3] = glow[1];
  tempGlow[1] = glow[2];
  tempGlow[0] = glow[3];

  // Process bit flips ahead of sending serial signal
  PORTF = PORTF | B10000000;
  for (int i = 0; i < 8; i++) {
    if (tempGlow[i / 2] == 1) {
      tempGlow_unroll[i] = PORTF | B01000000;
    }
    else {
      tempGlow_unroll[i] = PORTF & B10111111;
    }
  }

  for (int i = 0; i < 8; i++) {
    PORTF = tempGlow_unroll[i];
    //   digitalWrite(hvClock, LOW);
    PORTF = PORTF & B01111111;
    //   digitalWrite(hvClock, HIGH);
//    PORTF = PORTF | B10000000;
  }
  PORTF = PORTF | B10000000;

}

bool isSense_active[] = {true, true, true, true};
void switchHalfOutputsA() {
  for (int i = 0; i < 4; i++) {
    PORTF = PORTF | B01000000;
 //   PORTF = PORTF | (isSense_active[i] << 6);
    PORTF = PORTF & B01111111;
    PORTF = PORTF | B10000000;

    PORTF = PORTF & B10111111;
    PORTF = PORTF & B01111111;
    PORTF = PORTF | B10000000;
  }
}

void switchHalfOutputsB() {
  for (int i = 0; i < 4; i++) {
    PORTF = PORTF & B10111111;
    PORTF = PORTF & B01111111;
    PORTF = PORTF | B10000000;

    PORTF = PORTF | B01000000;
  //  PORTF = PORTF | (isSense_active[i] << 6);
    PORTF = PORTF & B01111111;
    PORTF = PORTF | B10000000;
  }
}

// This could be fancier...
void sort(int *a, int len)
{
   for (int i = 1; i < len; ++i)
   {
     int j = a[i];
     int k;
     for (k = i - 1; (k >= 0) && (j < a[k]); k--)
     {
       a[k + 1] = a[k];
     }
     a[k + 1] = j;
   }
}

// This mutates the input array! Beware!
float getMedian(int* array, int len) {
//  int len = sizeof(array);
  sort(array, len);
  float tempVal = 0;
  return array[(len / 2) + 1];

//  for (int i = (len / 2) - 1; i < (len / 2) + 2; i++) {
//    tempVal += array[i];
//  }
//  return tempVal / 3;
}

void ledsOff() {
  digitalWrite(rxled, LOW);
  digitalWrite(txled, LOW);
  digitalWrite(rstled, LOW);
}

void ledsOn() {
  digitalWrite(rxled, HIGH);
  digitalWrite(txled, HIGH);
  digitalWrite(rstled, HIGH);
}

unsigned long microsdelay;

// Arduino I/O is real slow.  Opaque bitwise port manipulation ftw!
int adcSensePorts[] = {B00000000, B00000001, B00000011, B00000100};

// this is internal, use the interface functions below!
bool toSense_internal[] = {true, true, true, true};
int senseResults_internal[] = {0, 0, 0, 0};

void initSense_withResistor(){
 // listen to resistor

    switchOutputs(noGlow);
    //  digitalWrite(elEnable, HIGH);
    PORTF = PORTF | B00100000;
    delayMicroseconds(100);

//    microsdelay = micros();
    while(bitRead(PINC, 6));
    switchOutputs(allGlow);
    switchHalfOutputsA();
    while(!bitRead(PINC, 6));
    while(bitRead(PINC, 6));
    while(!bitRead(PINC, 6));
    while(bitRead(PINC, 6));

    switchOutputs(noGlow);
    delayMicroseconds(30);

//    microsdelay = micros() - microsdelay;
}

int spinner = 0;
void initSense_withoutResistor() {
    // Hacky.  Allows charge to disappate faster - kills flicker.

//    switchOutputs(allGlow);
//    microsdelay = 0;
//    while(bitRead(PINC, 6) || microsdelay < 20){
//      microsdelay++;
//    }
    // digitalWrite(elEnable, LOW);
    PORTF = PORTF & B11011111;
    for (int i = 0; i < 30; i++) {
      switchHalfOutputsA();
      spinner = 0;
      while(spinner < 34) {
        spinner++;
      }

      switchHalfOutputsB();
      spinner = 0;
      while(spinner < 34) {
        spinner++;
      }
    }

    // Make EL lamps float
    switchOutputs(noGlow);
    delayMicroseconds(30);
}

void senseChannels_internal(int chargeDelay_micros = 1000) {
    noInterrupts();

    // make sure pwm oscillator is running.
    pwm613configure(capSenseFrequency);
    pwmSet13(127);

    // digitalWrite(clearPin, HIGH);
    PORTD = PORTD | B10000000;

    if (chargeDelay_micros < 1) {
      chargeDelay_micros = 1000;
    }

// Set ADC initialization bits - make sure things haven't gotten misconfigured.
    // 6: right adjust bits // last 5 bits select ADC.
    ADMUX = adcSensePorts[3];
    // high speed mode / 0 / analog selection, extra bit.
    ADCSRB = B10100000;
    // disable adc
    ADCSRA = B00000110;

    initSense_withoutResistor();

// Begin measurement sequence
    // digitalWrite(clearPin, LOW);
    PORTD = PORTD & B01111111;

    delayMicroseconds(chargeDelay_micros);
// start measurement
// Go backwords so that channel 4 has the lowest sensitivity and 1 has the highest.
    for(int i = 3; i >= 0; i--) {
      if (toSense_internal[i]) {
        // enable / start / auto trigger / interrupt flag / interrupt enable /// scale /// p.315
        ADCSRA = B11000110;
        delayMicroseconds(50);
        ADMUX = adcSensePorts[(i + 3) % 4];
        while ((ADCSRA & B01000000));
        sampleVal = ADCL;    // store lower byte ADC
        sampleVal += ADCH << 8;  // store higher bytes ADC
        senseResults_internal[i] = sampleVal;
      }
      else {
        ADMUX = adcSensePorts[(i + 3) % 4];
        senseResults_internal[i] = -1;
      }
    }

   //  digitalWrite(elEnable, HIGH);
   PORTF = PORTF | B00100000;
   interrupts();
   //    digitalWrite(clearPin, HIGH);
   PORTD = PORTD | B10000000;
   return;
}

// Sensing interfaces!
// Note that the channel here corresponds to the number written on the board,
// which is shifted up by one from the indicies in the senseResults array.
int senseChannel(int channel, int chargeDelay_micros = 1000, bool isGlow = true) {
  if (channel < 0 || channel > 4) {
    Serial.println("Warning: you might not be measuring the channel you intend to!");
    ledsOn();
  }
  channel = (channel - 1) % 4; // sanitize your inputs.
  for (int i = 0; i < 4; i++) {
    toSense_internal[i] = false;
  }
  toSense_internal[channel] = true;
  senseChannels_internal(chargeDelay_micros);
  if (isGlow) {
    switchOutputs(glow);
  }
  return senseResults_internal[channel];
}

int* senseAll(int chargeDelay_micros = 1000, bool isGlow = true) {
  for (int i = 0; i < 4; i++) {
    toSense_internal[i] = true;
  }
  senseChannels_internal(chargeDelay_micros);

  if (isGlow) {
    switchOutputs(glow);
  }
  return senseResults_internal;
}

int inactiveMeasure[channelCount];
int activeProbe = 0;
// This function saves a bit of time by not measuring "inactive" channels each cycle.
// Makes the measurement go a bit faster, i.e. makes the EL dohickey brighter!
int* senseAllActive(int chargeDelay_micros = 1000, bool isGlow = true) {
  activeProbe = (activeProbe + 1) % channelCount;
  for (int i = 0; i < 4; i++) {
    if (isSense_active[activeProbe]) {
      activeProbe = (activeProbe + 1) % channelCount;
    }
    else {
      break;
    }
  }

  for (int i = 0; i < 4; i++) {
    toSense_internal[i] = isSense_active[i];
    if (i == activeProbe) {
      toSense_internal[i] = true;
    }
  }
  senseChannels_internal(chargeDelay_micros);

  if (isGlow) {
    switchOutputs(glow);
  }

  // Change threshold for activating, might want to make this smaller?
  if (inactiveMeasure[activeProbe] - senseResults_internal[activeProbe] > 50 ||
      senseResults_internal[activeProbe] < 400) {
    isSense_active[activeProbe] = true;
  }
  else {
    inactiveMeasure[activeProbe] = senseResults_internal[activeProbe];
  }

  for (int i = 0; i < 4; i++) {
    if (!toSense_internal[i]) {
      senseResults_internal[i] = inactiveMeasure[i];
    }
  }

 // Serial.println(isSense_active[2] << 6);

  return senseResults_internal;
}

// The ardunio IDE insists on changing the frequency of the fast pwm when the board is programmed
// This is a hack that accounts for that.
void ensureCorrectFrequency() {
  switchOutputs(noGlow);
  ledsOff();

  capSenseFrequency = PWM187k;
  int read187k = senseChannel(1, 5000);
  read187k = senseChannel(1, 5000);
  read187k = senseChannel(1, 5000);
//  Serial.print("187: ");
//  Serial.println(read187k);

  capSenseFrequency = PWM94k;
  int read94k = senseChannel(1, 5000);
  read94k = senseChannel(1, 5000);
  read94k = senseChannel(1, 5000);
//  Serial.print("94: ");
//  Serial.println(read94k);

  if (read94k > read187k) {
    capSenseFrequency = PWM94k;
    digitalWrite(rxled, HIGH);
    if (read94k > 150) {
      digitalWrite(txled, HIGH);
    }
    delay(200);
  }
  else{
    capSenseFrequency = PWM187k;
    digitalWrite(rstled, HIGH);
    if (read187k > 150) {
      digitalWrite(txled, HIGH);
    }
    delay(200);
  }
  ledsOff();
}

//////////~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///////////

int* senseResults;

void setup() {
  Serial.begin(9600);

  // hvSwitch communication
  pinMode(hvDigitalIn, OUTPUT);
  pinMode(hvClock, OUTPUT);

  pinMode(clearPin, OUTPUT);
  digitalWrite(clearPin, LOW);

  pinMode(10, OUTPUT);

  pinMode(elEnable, OUTPUT);
  digitalWrite(elEnable, HIGH);

  pinMode(detect, INPUT);

  pinMode(sense1, INPUT);
  pinMode(sense2, INPUT);
  pinMode(sense3, INPUT);
  pinMode(sense4, INPUT);

  pinMode(rxled, OUTPUT);
  pinMode(txled, OUTPUT);
  pinMode(rstled, OUTPUT);

  analogReference(DEFAULT);

  // this should be called after the clear pin is set low
  ensureCorrectFrequency();

  // Disables channels without EL plugged in.
  senseResults = senseAll(2300, true);
  for (int i = 0; i < 4; i++) {
    if (senseResults[i] > 620) {
      isSense_active[i] = false;
    }
  }

  senseResults = senseAll(1000, true);
  for (int i = 0; i < 4; i++) {
    if (isSense_active[i]) {
      inactiveMeasure[i] = senseResults[i];
    }
  }
}

// Do this instead of using a bunch of individual Serial.print statements to save time!
// If your wire starts flashing when you are logging, this might be why!
#define printLineSize 200
char logBuffer[printLineSize];
char tempLogBuffer[printLineSize];

 #define ENABLE_LOGGING

#ifdef ENABLE_LOGGING

#define subBufferSize 50
char signalBuffer[subBufferSize];
char impulseBuffer[subBufferSize];
// These are in reference to the impulse, which is itself a funny denoising derivative-y thing
char extraBuffer[subBufferSize];
char derivativeBuffer[subBufferSize];

#endif

int val = 0;

int minimum = 10000;
int maximum = 0;

#define senseSize 23
int senseHistory[channelCount][senseSize];
int senseHistoryTemp[senseSize];
int senseHistoryIter = 0;

bool isTouched = false;
bool whereTouched[] = {false, false, false, false};

float change = 0;

bool shouldGlow = true;

bool isOn = true;
bool justSwitched = false;
int switchedCount = 0;

#define smoothedSenseSize 21
int smoothedSenseHistory[channelCount][smoothedSenseSize];
int smoothedSenseIter = 0;

#define smoothedTouchWindow 4
float smoothedSampleMedian = 0;
float smoothedSampleMin = 0;
float smoothedSampleNew = 0;
int smoothedSampleTemp[smoothedSenseSize - smoothedTouchWindow];

int channelMean[] = {0, 0, 0, 0};
int chanImpulse;
int chanPrevImpulse;
int chanChangeCount;

// Here are the main levers which control the operation of this program
#define increaseWindow 17
#define pureIncreaseThreshold 6
#define increaseThresholdWithImpulse 4
#define impulseThreshold 3
#define bigImpulseThreshold 8
#define glowTime_us 1300

void loop() {
    senseResults = senseAllActive(1500, true);

    smoothedSenseIter = (smoothedSenseIter + 1) % smoothedSenseSize;

    // Get new smoothed value
    for (int channel = 0; channel < channelCount; channel++) {
      senseHistory[channel][senseHistoryIter] = senseResults[channel];
      senseHistoryIter++;
      if (senseHistoryIter == senseSize) {
        senseHistoryIter = 0;
      }

      for (int i = 0; i < senseSize; i++) {
        senseHistoryTemp[i] = senseHistory[channel][i];
      }

      sort(senseHistoryTemp, senseSize);

      int prevMeasure = smoothedSenseHistory[channel][(smoothedSenseIter - 1 + smoothedSenseSize) % smoothedSenseSize];
      int bestSquaredError = 10000;
      int bestMatchIndex = 0;
      for (int i = 0; i < 8; i++) {
        int currSquaredError = (prevMeasure - senseHistoryTemp[i]) * (prevMeasure - senseHistoryTemp[i]);
        if (currSquaredError < bestSquaredError) {
          bestSquaredError = currSquaredError;
          smoothedSenseHistory[channel][smoothedSenseIter] = senseHistoryTemp[i];
        }

      }
      if (bestSquaredError < 3) {
        smoothedSenseHistory[channel][smoothedSenseIter] = prevMeasure;
      }

//    if(senseHistoryIter==0  && channel == 2){
//      for(int i=0; i<25; i++){
//        Serial.print(senseHistoryTemp[i]);
//        Serial.print(", ");
//      }
//      Serial.println();
//
//    }

    }

    for (int channel = 0; channel < channelCount; channel++) {
      channelMean[channel] = (channelMean[channel] * 2 +
                              smoothedSenseHistory[channel][(smoothedSenseIter + 1 + smoothedSenseSize) % smoothedSenseSize]) / 3;

      chanImpulse =  channelMean[channel] - smoothedSenseHistory[channel][smoothedSenseIter];
      chanPrevImpulse = channelMean[channel] - smoothedSenseHistory[channel][(smoothedSenseIter + smoothedSenseSize - 1) % smoothedSenseSize];
      chanChangeCount = 0;

      int senseDiff;
      for (int steps = 0; steps < increaseWindow; steps++) {
        senseDiff = smoothedSenseHistory[channel][(smoothedSenseIter - (steps + 1) + smoothedSenseSize) % smoothedSenseSize]
            - smoothedSenseHistory[channel][(smoothedSenseIter - (steps) + smoothedSenseSize) % smoothedSenseSize];

        if (senseDiff > 0) {
          chanChangeCount += 1;
        }
//        if (senseDiff < -5) {
//          chanChangeCount = -1;
//          break;
//        }
      }

      if (chanChangeCount == impulseThreshold + 1) {
        chanImpulse += 5;
      }

      if (switchedCount == 0 && isSense_active[channel] &&
           ((chanImpulse > impulseThreshold && chanChangeCount >= increaseThresholdWithImpulse) ||
            (chanImpulse > bigImpulseThreshold && chanChangeCount + 1 >= increaseThresholdWithImpulse) ||
            (chanChangeCount >= pureIncreaseThreshold)) ){
        isTouched = true;
        whereTouched[channel] = true;
#ifndef ENABLE_LOGGING
        sprintf(logBuffer, "Switched channel: %d Measurement: %d Impulse: %d Adj transition count: %d Big Impulse: %d",
          channel, smoothedSenseHistory[channel][smoothedSenseIter], chanImpulse, chanChangeCount, chanImpulse > bigImpulseThreshold);
        Serial.println(logBuffer);
#endif
      }

#ifdef ENABLE_LOGGING

    // EXEX - Logging inline - pull into a function!
    int tailMeanlen;
    int derivativelen;
    int impulselen;

    switch (channel) {
      case 0:
        impulselen = sprintf(impulseBuffer, "Imp: %d, ",
                             chanImpulse);
        derivativelen = sprintf(derivativeBuffer, "Change: %d, ",
                                chanChangeCount);
        tailMeanlen = sprintf(extraBuffer, "Is Active: %d, ",isSense_active[channel]);
                         //     chanImpulse > bigImpulseThreshold && chanChangeCount + 1 >= increaseThresholdWithImpulse);

        break;

      case 1:
      case 2:
      case 3:
        impulselen += sprintf(impulseBuffer + impulselen, "%d, ",
                              chanImpulse);
        derivativelen += sprintf(derivativeBuffer + derivativelen, "%d, ",
                                 chanChangeCount);
        tailMeanlen += sprintf(extraBuffer + tailMeanlen, "%d, ", isSense_active[channel]);
                        //       chanImpulse > bigImpulseThreshold && chanChangeCount + 1 >= increaseThresholdWithImpulse);

        break;

      default:
        break;
    }
#endif

    }

#ifdef ENABLE_LOGGING
  int signallen;
  for (int chan = 0; chan < channelCount; chan++) {
    switch (chan) {
      case 0:
        for (int l = 0; l < printLineSize; l++) {
          tempLogBuffer[l] = logBuffer[l];
        }
        signallen = sprintf(signalBuffer, "Signal: %d, ", smoothedSenseHistory[chan][smoothedSenseIter]);
        break;

      case 1:
      case 2:
      case 3:
        signallen += sprintf(signalBuffer + signallen, "%d, ", smoothedSenseHistory[chan][smoothedSenseIter]);
        break;

      default:
        Serial.print("blah ");
        break;
    }
  }

  snprintf(logBuffer, printLineSize, "%20s %23s %20s %20s %s",
           signalBuffer,
           impulseBuffer,
           derivativeBuffer,
           extraBuffer, "");

  Serial.println(logBuffer);
#endif

    if (isTouched && switchedCount == 0) {
      isTouched = false;
      for (int chan = 0; chan < channelCount; chan++) {
        if (whereTouched[chan]) {
#ifdef ENABLE_LOGGING
          Serial.println("SWITCHED CHANNEL!");
          Serial.println(chan);
#endif
          whereTouched[chan] = false;
          glow[chan] = !glow[chan];
        }
      }
      switchedCount = senseSize + smoothedSenseSize;
    }

    switchOutputs(glow);

    if (switchedCount > 0) {
      switchedCount--;
    }

    delayMicroseconds(glowTime_us);
}

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


:electric_plug: add arduino script

:electric_plug: add arduino script

#include <NewRemoteReceiver.h>
#include <NewRemoteTransmitter.h>

int inputPins[] = {3, 4};
int transmitterPin = 11;

// is light on or off, false means off
int currentStates[] = {false, false};

NewRemoteTransmitter transmitter(19925766, transmitterPin, 258);

void setup() {
  for (int i = 0; i < (sizeof(inputPins) / sizeof(int)); i++) {
    pinMode(inputPins[i], INPUT_PULLUP);
  }
  Serial.begin(115200);
}

void loop() {
  for (int i = 0; i < (sizeof(inputPins) / sizeof(int)); i++) {
    int reading = digitalRead(inputPins[i]);

    if (reading == HIGH && currentStates[i] == false) {
      toggle(true, i);
    }

    if (reading == LOW && currentStates[i] == true) {
      toggle(false, i);
    }
  }
}

void toggle(int state, int index) {
  currentStates[index] = state;
  transmitter.sendUnit(index, state);
}

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


Tool: I2C Scanner.

Tool: I2C Scanner.

//Below program comes from http://www.geek-workshop.com/thread-287-1-1.html
//According to that page I have fiexed some bugs :
// 1. " rc = twi_writeTo(addr, &data, 0, 1);"
// 2. addr = addr<<1;  This line should be removed
// I have tested below code with my I2C LCD.

#include "Wire.h"
extern "C" {
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}

byte start_address = 1;
byte end_address = 127;

// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr,
                void(*callback)(byte address, byte result) )
{
  byte rc;
  byte data = 0; // not used, just an address to feed to twi_writeTo()
  for( byte addr = from_addr; addr <= to_addr; addr++ ) {
    rc = twi_writeTo(addr,&data,0,1,1);
    if(rc==0) callback( addr, rc );
  }
}

// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
  Serial.print("addr: ");
  Serial.print(addr,DEC);
  //ZT Debug addr = addr<<1;
  Serial.print("\t HEX: 0x");
  Serial.print(addr,HEX);
  Serial.println( (result==0) ? "\t found!":"   ");
//  Serial.print( (addr%4) ? "\t":"\n");
}

// standard Arduino setup()
void setup()
{
    pinMode(13,OUTPUT);
    Wire.begin();

    Serial.begin(9600);
    Serial.println("--- I2C Bus Scanner Test ---");
    Serial.print("starting scanning of I2C bus from ");
    Serial.print(start_address,DEC);
    Serial.print(" to ");
    Serial.print(end_address,DEC);
    Serial.println("...");
    Serial.println();

    // start the scan, will call "scanFunc()" on result from each address
    scanI2CBus( start_address, end_address, scanFunc );

    Serial.print("\n");
    Serial.println("--- I2C Bus Scanner Complete ---");

    digitalWrite(13,HIGH); delay(500); digitalWrite(13,LOW); delay(500);
    digitalWrite(13,HIGH); delay(500); digitalWrite(13,LOW); delay(500);
    digitalWrite(13,HIGH); delay(500); digitalWrite(13,LOW); delay(500);
}

void loop()
{
}

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


Codigo

Codigo

Codigo do Arduino

 #include <Servo.h>

 Servo rodaDireita;
 Servo rodaEsquerda;

 int echoFrontal = 2;
 int trigFrontal = 3;
 int echoLateral = 8;
 int trigLateral = 7;

 void setup() {
   // configura pino GATILHO como saÃda
   pinMode(trigFrontal,OUTPUT);
   pinMode(echoFrontal,INPUT);
   pinMode(trigLateral,OUTPUT);
   pinMode(echoLateral,INPUT);
   digitalWrite(trigFrontal,LOW);
   digitalWrite(trigLateral,LOW);
   rodaEsquerda.attach(5);
   delay(1);
   rodaDireita.attach(6);
   rodaEsquerda.write(90);
   rodaDireita.write(90);
 // configura pino ECHO como entrad
}
int dispararPulso (int pinEcho, int pinTrig){
  float tempo;
  // disparar pulso ultrassÃ´nico

  digitalWrite(pinTrig, HIGH);
  delayMicroseconds(10);
  digitalWrite(pinTrig, LOW);
  // medir tempo de ida e volta do pulso ultrassÃ´nico
  tempo = pulseIn(pinEcho, HIGH,4200);
  return tempo;
}

int calcularDistancia (int pinEcho, int pinTrig){
  return dispararPulso(pinEcho,pinTrig)/29.4/2;
}

void esquerda(int velocidade,int velocidade2){
  rodaEsquerda.write((90-velocidade));
  rodaDireita.write((90-velocidade2));

}
void direita(int velocidade, int velocidade2){
  rodaEsquerda.write((90+velocidade));
  rodaDireita.write((velocidade2));

}
void frente(int velocidade, int velocidade2){
  rodaEsquerda.write((90+velocidade));
  rodaDireita.write((90-velocidade2));

}
int distancia;
int ultimaDistancia;
int erro,x,y,dt;
int kd=10,kp=1;
float i,ki = 0.001;
int cons = 15;
void definirErro(int setPoint){
  distancia = calcularDistancia(echoLateral,trigLateral);
  if(distancia > 0){
    ultimaDistancia = distancia;
    erro =  setPoint - distancia;
    i += (erro*dt*ki);
    x = cons + ((erro*kp) + (kd*(distancia - ultimaDistancia)/dt) + i);
    y = cons - ((erro*kp) + (kd*(distancia - ultimaDistancia)/dt) + i);
  }
}
int temp ;
int tempFinal = millis();
void calcularTempo(){
  temp = tempFinal;
  tempFinal = millis();
  dt = (tempFinal - temp);
}

void loop() {
  calcularTempo();
  //Serial.println(calcularDistancia(echoFrontal,trigFrontal));
  //Serial.println(calcularDistancia(echoLateral,trigLateral));
  definirErro(20);
  frente(y,x);

}

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


add source code for version that does not use Entropy.h

#include <StackList.h>//need a stack to evaluate our expression; easier than writing an infix parser or doing it myself. bog-standard stack implemented using linked list

unsigned long g_last_random; // last random value
//i dont know why i'm doing this on an arduino, but the due is kinda neat for math stuff like this
//don't bother trying this on anything but a 32-bit board (e.g. the Due); the loss of precision from floats would be egregious in addition to the considerably slower clock speed et al.
void setup() {
  Serial.begin(9600);
  init_real_random();
  monte_carlo_integrate("x2^", 0, 10, 5000000, 1);
}
void loop(){  }
//expression must be postfix, at current time only supports one digit numbers and one variable [a-zA-z]
//lower_bound is self explanatory, as is upper_bound
//counter is a number specifying how many times you want to put a point in the box, basically. It's a long in case you want to do more than max_int calculations (recommended)
//I found good results with 100,000 to 200,000 iterations; be warned that beyond that it takes a _very_ long time to calculate the result (or at least more time than I was willing to wait)
//interval is the delta used for finding the approximate max value of the function over the interval; 0.01 is probably a good place to start
double monte_carlo_integrate(String expression, int lower_bound, int upper_bound, long counter, double interval){
  Serial.print("Doing Monte Carlo integration of ");
  Serial.println(expression);
  Serial.print("Lower bound: ");
  Serial.println(lower_bound);
  Serial.print("Upper bound: ");
  Serial.println(upper_bound);
  Serial.print("Check count: ");
  Serial.println(counter);
  int hits = 0;
  Serial.print("Finding approx max: ");
  double approx_max = find_max(expression, interval, lower_bound, upper_bound);
  Serial.println(approx_max);
  for (long i = 0; i < counter; i++) {
    double rand_x;
    do{
      rand_x = random_number() * upper_bound;
    }
    while (rand_x < lower_bound);
    double rand_y = random_number() * approx_max;

      double result = postfix_eval(expression, rand_x);
    if (rand_y <= result){
      hits++;
    }
  }
  Serial.print("hits: ");
  Serial.println(hits);
  Serial.print("total number of attempts: ");
  Serial.println(counter);
  double proportion = (double(hits)/double(counter));
  Serial.print("Proportion of hits: ");
  Serial.println(proportion,5);
  double box_area = ((upper_bound - lower_bound) * approx_max);
  Serial.print("Area of rectangle: ");
  Serial.println(box_area, 5);
  double estimated_result = proportion * box_area;
  Serial.print("Estimated result: ");
  Serial.println(estimated_result,5);
  return estimated_result;
}

double postfix_eval(String expression, double var){ //use a stack to evaluate a postfix expression. var is what it will put on the stack if it finds a character other than an operator or a digit.
  double y;
  double y1;
  double y2;
  StackList<double> stack;
  char ch;
  for (int i = 0; i < expression.length(); i++){
    ch = expression.charAt(i);
    if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')
    {
      stack.push(var);
    }
    else
      if(ch >= '0' && ch <= '9'){
        stack.push(ch - 48);
      }
      else
        if(ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '^')
      {
        y2 = stack.pop();
        y1 = stack.pop();
        if(ch == '+')
        {
          y = y1 + y2;
          stack.push(y);
        }
        if(ch == '-')
        {
          y = y1 - y2;
          stack.push(y);
        }
        if(ch == '^')
        {
          y = pow(y1, y2); //^ is the bitwise xor op for some asinine reason, so pow is used. returns a double so no loss of precision.
          stack.push(y);
        }
        if(ch == '*')
        {
          y = y1 * y2;
          stack.push(y);
        }
        if(ch=='/')
        {
          y = y1 / y2;
          stack.push(y);
        }
      }
  }
  double r = stack.pop();
  return r;
}

double find_max(String expression, double interval, int lower_bound, int upper_bound){ //find the max value so we have a vertical size for our box
  double return_this = 0;
  double current_val = lower_bound;
  double temp;
  while (current_val <= upper_bound){
    temp = postfix_eval(expression, current_val);
    if(temp >= return_this){
      return_this = temp;
    }
    current_val+=interval;
  }
  return return_this;
}

void init_real_random()//initialize our prng
{
  g_last_random = millis();//reasonably random seed; not perfect but better than the godawful builtin random algo
}

double random_number() //random() (the default arduino prng) is a pos, this provides more "random" results and also returns a double between 0 and 1, which is more useful
{
  unsigned long temp;
  temp = 663608941*g_last_random; //multiply a big number by our last random number
  g_last_random = temp; //new random
  return(((double)temp)/((double)4294967295)); //make it a small number; this is essentially a prototypical prng but other implementations (i.e. seed based on a0 voltage) didn't pan out
}

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


added start of 433 recieving code

added start of 433 recieving code

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/ekwoodrich/nirha.git/'


Gyro L3G4200D

Gyro L3G4200D

#include <Wire.h>
#include <L3G.h>

L3G gyro;

void setup(){
  Serial.begin(9600);
  Wire.begin();

  if(!gyro.init()){
    Serial.println("Failed to autodetect gyro type!");
    while(1)
      ;
  }

  gyro.enableDefault();
}

char aa1;

void loop(){
  gyro.read();

  Serial.print("G ");
  Serial.print("X: ");
  Serial.print((int)gyro.g.x);
  Serial.print(" Y: ");
  Serial.print((int)gyro.g.y);
  Serial.print(" Z: ");
  Serial.println((int)gyro.g.z);

  delay(500);
}

char bb1;

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


New Sketch: isReceive

New Sketch: isReceive

Fix https://github.com/gmacario/learning-arduino/issues/36

Signed-off-by: Gianpaolo Macario <f8885408b8c3d931b330bae3c3a28a3af912c463@gmail.com>

#include <IRremote.h>

const int irReceiverPin = 2;
const int ledPin = 13;

//IRrecv irrecv(irReceiverPin);
extern IRrecv irrecv;
extern decode_results results;

void setup()
{
  pinMode(ledPin,OUTPUT);
  Serial.begin(115200);
  irrecv.enableIRIn();
}

void loop()
{
  if (irrecv.decode(&results)) {
    Serial.print("irCode: ");
    Serial.print(results.value, HEX);
    Serial.print(",  bits: ");
    Serial.println(results.bits);
    irrecv.resume();
  }
  delay(600);
  if(results.value == 0xFFA25D)
  {
    digitalWrite(ledPin,HIGH);
  }
  else
  {
    digitalWrite(ledPin,LOW);
  }
}

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


initial version of 433 to mqtt bridge for esp

// Copyright 2016 the project authors as listed in the AUTHORS file.
// All rights reserved. Use of this source code is governed by the
// license that can be found in the LICENSE file.

#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include "WirelessConfig.h"
#include "Device2262n.h"
#include "MqttBridge.h"
#include "RXCore433.h"

#define RX_433_PIN D4

IPAddress server(mqttServer[0], mqttServer[1],
                 mqttServer[2], mqttServer[3]);

WiFiClient wclient;
ESP8266WiFiGenericClass wifi;
PubSubClient client(wclient, server);
MqttBridge bridge(&client, "house/esp");

RXCore433 receiver(RX_433_PIN);

void setup() {
  Serial.begin(9600);
  Serial.println("Started\n");

  Device2262n* device2262 = new Device2262n(200,50,4);
  device2262->registerMessageHandler(&bridge);
  receiver.registerDevice(device2262);

  // turn of the Access Point as we are not using it
  wifi.mode(WIFI_STA);
}

void loop() {
  delay(2000);

  if (WiFi.status() != WL_CONNECTED) {
    Serial.print("Connecting to ");
    Serial.print(ssid);
    Serial.println("...");
    WiFi.begin(ssid, pass);

    if (WiFi.waitForConnectResult() != WL_CONNECTED) {
      return;
      Serial.println("WiFi connected");
    }
  }

  if (!client.connected()) {
    if (client.connect("arduinoClient")) {
    }
  }

  receiver.handleMessage();

}

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


board/: Add .ino board

board/: Add .ino board

#include <Servo.h>
#include <time.h>
#include <stdlib.h>

/* threshold for updates.
   Applies to both servo Motor communiction ans Serial port. */
#define updateMilliThreshold 100

/* General global value definitions */
#define ARDUINO_ID 201
#define C_ID 200
#define BUFFER_DATA_LENGTH 5
#define BAUDRATE 9600

long updateTime = 0;

/* Main setup loop for BAoBOS. */
void setup() {
  /* Begin communication over Serial Port with a baud
     rate of 9600*/
  Serial.begin(BAUDRATE);
}

/* Main Arduino loop */
void loop() {
  /* Temporary bool to handle serial port writing. By default set to
     true, will be invalidated should the write speed be faster than a
     given threshold */
  bool writeToSerial = true;

  /* Retrieve the mmilliseconds elapsed since the beginning of the
     sessioon. */
  long curMillis = millis();

  /* Trigger every updateMilliThreshold */
  if (!(curMillis - updateTime >= updateMilliThreshold)) {
    /* Prevent writing to serial to avoid serial port data overflow */
    writeToSerial = false;
  }

  /* Wait for 6 bytes of data to have been sent over serial */
  if (Serial.available() >= BUFFER_DATA_LENGTH + 1) {
    /* Peek at the first byte to determine if it's a valid read ID */
    uint8_t peekVal = Serial.peek();

    /* ID of 200 is used by BAoBUI */
    if (peekVal == C_ID) {
      /* Read the servoAngles */
      Serial.read();

      for (int i = 0; i < BUFFER_DATA_LENGTH; i++) {
        uint8_t data = (uint8_t) Serial.read();

        // TODO: Do something with data
      }

      /* Force a reply */
      writeToSerial = true;
    } else {
      Serial.read();
    }
  }

  /* When it is possible to reply to serial */
  if (writeToSerial) {
    /* Identification byte */
    Serial.write(ARDUINO_ID);

    for (int i = 0; i < BUFFER_DATA_LENGTH; i++) {
        Serial.write((uint8_t) 0);

        // TODO: Instead of writing zero, write something else
      }
  }
}

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


Initial Arduino code samples

Initial Arduino code samples

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

const int leftFwd = 9; // green
const int leftRev = 10; // blue
const int rightFwd = 5; // grey
const int rightRev = 6; // purple

boolean ran = false;
byte velocity = 255;

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("Start your engines!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  byte b = 0;
  if (mySerial.available())
    b = mySerial.read();

  if (b != 0)
    Serial.write(b);
  else
    return;

  // Not connected right now
  /*if (Serial.available())
    mySerial.write(Serial.read());*/

  int commandDelay = 20;
  switch (b)
  {
    case 'F':
    case 'w':
      Serial.println("Forward");
      analogWrite(leftFwd, velocity);
      analogWrite(rightFwd, velocity);
      delay(commandDelay);
      analogWrite(leftFwd, 0);
      analogWrite(rightFwd, 0);
      break;
    case 'B':
    case 's':
      Serial.println("Backward");
      analogWrite(leftRev, velocity);
      analogWrite(rightRev, velocity);
      delay(commandDelay);
      analogWrite(leftRev, 0);
      analogWrite(rightRev, 0);
      break;
    case 'L':
    case 'a':
      Serial.println("Left");
      analogWrite(leftRev, velocity);
      analogWrite(rightFwd, velocity);
      delay(commandDelay);
      analogWrite(leftRev, 0);
      analogWrite(rightFwd, 0);
      break;
    case 'R':
    case 'd':
      Serial.println("Right");
      analogWrite(leftFwd, velocity);
      analogWrite(rightRev, velocity);
      delay(commandDelay);
      analogWrite(leftFwd, 0);
      analogWrite(rightRev, 0);
      break;
    default:
      Serial.print("Set speed: ");
      Serial.println(b);
      if (b > 0 && b < 255)
        velocity = b;
      break;
  }
}

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


USE string table for program memory

USE string table for program memory

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/upperman/Wireless-Led-Display.git/'


Added RTC support

Added RTC support

Added an RTC for time keeping

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/Tomo-/Arduino-Tortoise-Habitat-Controller.git/'


* Add AD9850 example

* Add AD9850 example

//                 +--------+
//                 | millis |
//+------------+---+--------+--------+--------+--------+--------+
//| Chip       |   | Timer0 | Timer1 | Timer2 | Timer3 | Timer4 |
//+------------+---+--------+--------+--------+--------+--------+
//| ATmega328p | A |   D6   | M=D9   |  D12   |   --   |   --   |
//|            | B |   D5   |  D10   | C=D3   |   --   |   --   |
//+------------+---+--------+--------+--------+--------+--------+
//| ATmega32u4 | A |  D11   | C=D9   |   --   | M=D5   |  D13   |
//+------------+---+--------+--------+--------+--------+--------+
// C = carrier pin
// M = modulation pin

#define _DEBUG 1

//#define WWVB_TIMECODE 0 // JJY

//#define WWVB_JJY_PAM

//#define WWVB_JJY_MILLIS_ISR

#define DEFINE_TIMEDATETOOLS

#include <TimeLib.h> //https://github.com/PaulStoffregen/Time
#include <wwvb_jjy.h>
#include <AD9850.h>

const int W_CLK_PIN = 7;
const int FQ_UD_PIN = 8;
const int DATA_PIN = 10;
const int RESET_PIN = 11;

double freq = 60000;
double trimFreq = 124999500;

int phase = 0;

void setup()
{
#if (_DEBUG > 0)
  Serial.begin(9600);
  Serial.println(F("<setup>"));
#endif

  //wwvb_jjy.set_time(__DATE__, __TIME__);
  wwvb_jjy.set_time(8, 43, 00, 7, 2, 05);

  wwvb_jjy.init(); // default : (isJJY, carrier_Hz) = (false, 60000) - wwvb @ 60kHz

  DDS.begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN);
  DDS.calibrate(trimFreq);
  DDS.down();

#ifndef WWVB_JJY_MILLIS_ISR
  #if defined(__AVR_ATmega168__) | defined(__AVR_ATmega168P__) | defined(__AVR_ATmega328P__)
    pwm.attachInterrupt(1, 'o', DDS_overflow_ISR);
    pwm.attachInterrupt(1, 'a', DDS_compare_ISR);
  #elif defined(__AVR_ATmega16U4__) | defined(__AVR_ATmega32U4__)
    pwm.attachInterrupt(3, 'o', DDS_overflow_ISR);
    pwm.attachInterrupt(3, 'a', DDS_compare_ISR);
  #endif
#endif

  //wait for a minute to start
  //while(second() > 0);

  wwvb_jjy.start();

  //wwvb_jjy.print_timecode();
  wwvb_jjy.print_timecode_serial();

#if (_DEBUG > 0)
  Serial.println(F("</setup>"));
#endif
}

void loop()
{
  // print the timecode serial every minute
  if (wwvb_jjy.is_updated())
  {
    //wwvb_jjy.set_time(12, mins, 00, 28, 3, 17);
    //wwvb_jjy.print_timecode();
    wwvb_jjy.print_timecode_serial();
  }

  #if defined(WWVB_JJY_MILLIS_ISR)
  // the main loop is used to call the ISR without a timer (uses calls to millis())
  wwvb_jjy.wwvb_jjy_millis_ISR();
  #endif
}

static void DDS_compare_ISR()
{
    wwvb_jjy.output_state = WWVB_TIMECODE;

    #if (WWVB_JJY_PULSE_LED)
    digitalWrite(LED_BUILTIN, wwvb_jjy.output_state);
    #endif

    if (wwvb_jjy.output_state)
    {
      DDS.setfreq(freq, phase);
    }
    else
    {
      DDS.down();
    }
}

static void DDS_overflow_ISR()
{
    wwvb_jjy.output_state = !WWVB_TIMECODE;

    #if (WWVB_JJY_PULSE_LED)
    digitalWrite(LED_BUILTIN, wwvb_jjy.output_state);
    #endif

    if (wwvb_jjy.output_state)
    {
      DDS.down();
    }
    else
    {
      DDS.setfreq(freq, phase);
    }

    const uint8_t chip = wwvb_jjy.get_timecode(wwvb_jjy.WWVB_JJY_TIMECODE_INDEX);

    ++wwvb_jjy.WWVB_JJY_TIMECODE_INDEX; // increment the TIMECODE INDEX

    if (wwvb_jjy.WWVB_JJY_TIMECODE_INDEX == 1)
    {
      wwvb_jjy.timecode_isnew = false;
    }
    // increment the TIMECODE index
    else if (wwvb_jjy.WWVB_JJY_TIMECODE_INDEX > 59)
    {
      wwvb_jjy.WWVB_JJY_TIMECODE_INDEX = 0;

      wwvb_jjy.set_timecode(); // sync the timecode to the current time
      wwvb_jjy.timecode_isnew = true;
    }
}

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


New example with temperature sensing.

New example with temperature sensing.

git-svn-id: 59b6b80b3f28683e9a006dffc41d8db225db1926@47 ed0607b5-9f2d-40cd-ad1e-287a16c2e87a

/*
 * HCSR04Ultrasonic/examples/UltrasonicTemp/UltrasonicTemp.ino
 *
 * SVN Keywords
 * ----------------------------------
 * $Author: $
 * $Date: $
 * $Revision: $
 * ----------------------------------
 */

#include <Ultrasonic.h>
#include <OneWire.h>

typedef enum {
  SUCCESS,
  SEARCH_ERROR,
  CRC_ERROR,
  DEVICE_ERROR,
  UNKNOWN_ERROR
} TemperatureCodes;

#define TEMP_PIN    10
#define DS18S20_ID  0x10
#define DS18B20_ID  0x28

float temp;
OneWire ds(TEMP_PIN);

int getTemperature(void) {
  byte present = 0;
  byte data[12];
  byte addr[8];
  TemperatureCodes result = SUCCESS;

  // Find a device
  if(ds.search(addr)) {
    if(OneWire::crc8(addr, 7) == addr[7]) {
      if(addr[0] == DS18S20_ID || addr[0] == DS18B20_ID) {
        ds.reset();
        ds.select(addr);
        // Start conversion
        ds.write(0x44, 1);
        // Wait some time...
        delay(850);
        present = ds.reset();
        ds.select(addr);
        // Issue Read scratchpad command
        ds.write(0xBE);

        // Receive 9 bytes
        for(byte i = 0; i < 9; i++) {
          data[i] = ds.read();
        }

        // Calculate temperature value
        temp = ((data[1] << 8) + data[0]) * 0.0625;
      } else {
        result = DEVICE_ERROR;
      }
    } else {
      result = CRC_ERROR;
    }
  } else {
    result = SEARCH_ERROR;
  }

  ds.reset_search();
  return result;
}

#define TRIGGER_PIN     12
#define ECHO_PIN        13

#define NUMBER_BUFFERS  3
#define BUFFER_SIZE     3

#define BUFFER_01       0
#define BUFFER_02       1
#define BUFFER_03       2
// The max distance to read.
#define MAX_CM_DISTANCE	400
// Set multiplier, used to correct the non-linear result from the sensor.
#define MULTIPLIER      1.0905

/*
 * The constructors needs to be passed arguments for the trigger pin and
 * echo pin.
 */
Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);
bool disableSD = false;

// Only run 50 time so we can re-burn the code easily.
#define CYCLES         50
size_t count = 0;

void setup()
  {
  Serial.begin(9600);
  Serial.println("Starting Ultrasonic Test using standard deviation ...");
  // The multiplier must be a float.
  ultrasonic.setMultiplier(MULTIPLIER);
  // The maximum distance that will be detected.
  ultrasonic.setMaxDistance(MAX_CM_DISTANCE);

  /*
   * If NUMBER_BUFFERS is 2 then it must be followed by two size variables
   * one for each buffer to be created. The size variables do not need to be
   * the same value.
   *
   * Example: ultrasonic.sampleCreate(3, 20, 10, 3) is valid.
   *
   * Note: The minimum size for any buffer is 2. Using less than 2 will waist
   *       resources and the buffer will be ignored.
   */
  if(!ultrasonic.sampleCreate(NUMBER_BUFFERS, BUFFER_SIZE, BUFFER_SIZE,
      BUFFER_SIZE))
    {
    disableSD = true;
    Serial.println("Could not allocate memory.");
    }

  // Give time for settings to take effect before starting the loop.
  delay(100);
  }

void loop()
  {
  float cmMsec, inMsec;
  float msStdDev, cmStdDev, inStdDev;
  long microsec = ultrasonic.timing();
  int code = UNKNOWN_ERROR;

  if((code = getTemperature()) != SUCCESS)
    {
    Serial.print("Could not read temperature, return code: ");
    Serial.println(code);
    }

  // The temperature value must be in Celsius.
  ultrasonic.setTemperature(temp);

  cmMsec = ultrasonic.convert(microsec, Ultrasonic::CM);
  inMsec = ultrasonic.convert(microsec, Ultrasonic::IN);

  if(count < CYCLES)
    {
    if(disableSD)
      {
      Serial.print("CM: ");
      Serial.print(cmMsec);
      Serial.print(", IN: ");
      Serial.println(inMsec);
      }
    else
      {
      msStdDev = ultrasonic.unbiasedStdDev((float) microsec, BUFFER_01);
      cmStdDev = ultrasonic.unbiasedStdDev(cmMsec, BUFFER_02);
      inStdDev = ultrasonic.unbiasedStdDev(inMsec, BUFFER_03);
      Serial.print(count + 1);
      Serial.print(") MS: ");
      Serial.print(microsec);
      Serial.print(", SD: ");
      Serial.print(msStdDev);
      Serial.print(", CM: ");
      Serial.print(cmMsec);
      Serial.print(", SD: ");
      Serial.print(cmStdDev, 2);
      Serial.print(", IN: ");
      Serial.print(inMsec);
      Serial.print(", SD: ");
      Serial.print(inStdDev, 2);
      Serial.print(", C: ");
      Serial.println(temp);
      }

    count++;
    }
  }

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


test branch gestart

test branch gestart

#include<math.h>

#define SIBLINGDISTANCE 4.7 //afstand tussen sensoren zelfde zijde.
#define TWINDISTANCE    60.0 //afstand tussen sensoren weerszijden.

#define S1TRIGGER 12
#define S1ECHO 13
#define S2TRIGGER 0
#define S2ECHO 1

void setup(){
  Serial.begin(9600);

  pinMode(S1TRIGGER, OUTPUT);
  pinMode(S2TRIGGER, OUTPUT);
  pinMode(S1ECHO, INPUT);
  pinMode(S2ECHO, INPUT);

  Serial.println("einde setup");
}

void loop(){
  pulse(S1TRIGGER, 20);
  long frontDist = pulseIn(S1ECHO, HIGH);
  delay(10);
  pulse(S2TRIGGER, 20);
  long backDist = pulseIn(S2ECHO, HIGH);

  //Serial.println(frontDist);

  printDist("First: ", frontDist / 58.0);
  printDist("Second: ", backDist / 58.0);
  Serial.println(" ");
  float test = calcDeviation(frontDist / 58.0, backDist / 58.0);
  printDist("Deviation in rad: ", test);
  //printDist("test ", calcDeviation(75.0, 50.0));

  Serial.print("++++++++++++++++++++++++++++++++");
  Serial.println(" ");
  delay(2000);
}

//geeft terug, in radialen, hoeveel de robot gedraaid is ten opzichte van de rechte lijn hij moet volgen.
float calcDeviation(float distFront, float distBack){
  float opposite = distFront - distBack;
  float adjacent = SIBLINGDISTANCE;
  float ratio = opposite / adjacent;

  return atan(ratio);
}

void pulse(int outputPin, int duration){
  digitalWrite(outputPin, HIGH);
  delayMicroseconds(duration);
  digitalWrite(outputPin, LOW);
}

void printDist(char* message, float dist){
  Serial.print(message);
  Serial.println(dist);
}

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


Create test.ino

Create test.ino

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* ssid     = "***********";
const char* password = "***********";

//const char* host = "www.adafruit.com";
ESP8266WebServer server(80);
String webString="";
void handle_root() {
  server.send(200, "text/plain", "Hello from the otter side");
  delay(100);
}
void setup() {
  Serial.begin(115200);
  delay(100);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 server.on("/", handle_root);
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  server.begin();
}

int value = 0;

void loop() {
  server.handleClient();
  }

error: pathspec 'Webclient-Update/src/test.ino' did not match any file(s) known to git


Micros to Millis. Whoops!

Micros to Millis. Whoops!

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/spoollord/MyOurWeather.git/'


Changed executeSetProgram() to configure the pins after creating the program. Commented hack in setup()

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/RichoM/Uzi.git/'


comienzo rreglo bool int

comienzo rreglo bool int

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/eariassoto/RFModuloArduino.git/'


add sending data after touch the furthest obstacle; improve with isWithWall function to check current pos

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


Using Adafruit's shield_sdlog example

Using Adafruit's shield_sdlog example

#include <SPI.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <SD.h>
#include <avr/sleep.h>

// Ladyada's logger modified by Bill Greiman to use the SdFat library
//
// This code shows how to listen to the GPS module in an interrupt
// which allows the program to have more 'freedom' - just parse
// when a new NMEA sentence is available! Then access data when
// desired.
//
// Tested and works great with the Adafruit Ultimate GPS Shield
// using MTK33x9 chipset
//    ------> http://www.adafruit.com/products/
// Pick one up today at the Adafruit electronics shop
// and help support open source hardware & software! -ada
// Fllybob added 10 sec logging option
SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);

// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO  true
/* set to true to only log to SD when GPS has a fix, for debugging, keep it false */
#define LOG_FIXONLY false

// this keeps track of whether we're using the interrupt
// off by default!
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy

// Set the pins used
#define chipSelect 10
#define ledPin 13

File logfile;

// read a Hex value and return the decimal equivalent
uint8_t parseHex(char c) {
  if (c < '0')
    return 0;
  if (c <= '9')
    return c - '0';
  if (c < 'A')
    return 0;
  if (c <= 'F')
    return (c - 'A')+10;
}

// blink out an error code
void error(uint8_t errno) {
  /*
  if (SD.errorCode()) {
   putstring("SD error: ");
   Serial.print(card.errorCode(), HEX);
   Serial.print(',');
   Serial.println(card.errorData(), HEX);
   }
   */
  while(1) {
    uint8_t i;
    for (i=0; i<errno; i++) {
      digitalWrite(ledPin, HIGH);
      delay(100);
      digitalWrite(ledPin, LOW);
      delay(100);
    }
    for (i=errno; i<10; i++) {
      delay(200);
    }
  }
}

void setup() {
  // for Leonardos, if you want to debug SD issues, uncomment this line
  // to see serial output
  //while (!Serial);

  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
  // also spit it out
  Serial.begin(115200);
  Serial.println("\r\nUltimate GPSlogger Shield");
  pinMode(ledPin, OUTPUT);

  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect, 11, 12, 13)) {
    //if (!SD.begin(chipSelect)) {      // if you're using an UNO, you can use this line instead
    Serial.println("Card init. failed!");
    error(2);
  }
  char filename[15];
  strcpy(filename, "GPSLOG00.TXT");
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = '0' + i/10;
    filename[7] = '0' + i%10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {
      break;
    }
  }

  logfile = SD.open(filename, FILE_WRITE);
  if( ! logfile ) {
    Serial.print("Couldnt create ");
    Serial.println(filename);
    error(3);
  }
  Serial.print("Writing to ");
  Serial.println(filename);

  // connect to the GPS at the desired rate
  GPS.begin(9600);

  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  // uncomment this line to turn on only the "minimum recommended" data
  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  // For logging data, we don't suggest using anything but either RMC only or RMC+GGA
  // to keep the log files at a reasonable size
  // Set the update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 100 millihertz (once every 10 seconds), 1Hz or 5Hz update rate

  // Turn off updates on antenna status, if the firmware permits it
  GPS.sendCommand(PGCMD_NOANTENNA);

  // the nice thing about this code is you can have a timer0 interrupt go off
  // every 1 millisecond, and read data from the GPS for you. that makes the
  // loop code a heck of a lot easier!
  useInterrupt(true);

  Serial.println("Ready!");
}

// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect) {
  char c = GPS.read();
  // if you want to debug, this is a good time to do it!
  #ifdef UDR0
      if (GPSECHO)
        if (c) UDR0 = c;
      // writing direct to UDR0 is much much faster than Serial.print
      // but only one character can be written at a time.
  #endif
}

void useInterrupt(boolean v) {
  if (v) {
    // Timer0 is already used for millis() - we'll just interrupt somewhere
    // in the middle and call the "Compare A" function above
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  }
  else {
    // do not call the interrupt function COMPA anymore
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}

void loop() {
  if (! usingInterrupt) {
    // read data from the GPS in the 'main loop'
    char c = GPS.read();
    // if you want to debug, this is a good time to do it!
    if (GPSECHO)
      if (c) Serial.print(c);
  }

  // if a sentence is received, we can check the checksum, parse it...
  if (GPS.newNMEAreceived()) {
    // a tricky thing here is if we print the NMEA sentence, or data
    // we end up not listening and catching other sentences!
    // so be very wary if using OUTPUT_ALLDATA and trying to print out data

    // Don't call lastNMEA more than once between parse calls!  Calling lastNMEA
    // will clear the received flag and can cause very subtle race conditions if
    // new data comes in before parse is called again.
    char *stringptr = GPS.lastNMEA();

    if (!GPS.parse(stringptr))   // this also sets the newNMEAreceived() flag to false
      return;  // we can fail to parse a sentence in which case we should just wait for another

    // Sentence parsed!
    Serial.println("OK");
    if (LOG_FIXONLY && !GPS.fix) {
      Serial.print("No Fix");
      return;
    }

    // Rad. lets log it!
    Serial.println("Log");

    uint8_t stringsize = strlen(stringptr);
    if (stringsize != logfile.write((uint8_t *)stringptr, stringsize))    //write the string to the SD file
        error(4);
    if (strstr(stringptr, "RMC") || strstr(stringptr, "GGA"))   logfile.flush();
    Serial.println();
  }
}

/* End code */

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


It's working! Had to correct many of my int->long->int typecasting because I did them wrong. Updated circuit diagram. Fixed pin fight between LCD and external ISR (external ISR won). Reduced stats hunger from 100 to 3. Added motor calculations and setup #defines for measurements. Fixed call to get_mV_from_adc() to what it actually needs. Made emf function dumber until I get smarter. Added 2X scaling in adc measurements to account for 2:1 voltage dividers. ... And probably some other things.

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


add led array example

add led array example

// Analog Pin 0 is what is used to read the voltage levels from the analog pin of the PCB.
// Possible values are 0 - 1023 where 0 is the brightest and 1023 is the darkest
#define SENSOR_ANALONG_PIN 0

// Digital Pin used to read the digital output (dark = 0, not-dark = 1) from the PCB.
#define SENSOR_DIGITAL_PIN 8

// We will drive pin 9 based on the input from the photoresitor. When using the analog
// output from the PCB, drive the pin as a PWM so that reflects the brightness of the
// room. When using the digital output of the PCB, drive pin 9 high or low depending
// to turn the LED on or off - acts as a 'trip sensor'
#define LED_PWM_PIN        9

void setup() {
  // Init the serial communications for debugging messages
  Serial.begin(9600);

  // Make the digital pin an input so we can read the values from the PCB D0 output
  pinMode(SENSOR_DIGITAL_PIN, INPUT);

  // Make the PWM pin output so we can drive the LED
  pinMode(LED_PWM_PIN, OUTPUT);
}

void loop() {
  // *** Uncomment this line if the data line runs from A0 on the PCB to A0 on the Arduino
  //analogSensorPin();

  // *** Uncomment this line if the data line runs from D0 on the PCB to pin 8 of the Arduino
  //digitalSensorPin();

  // Add this delay so the output is trottled to something reasonable
  delay(1000);
}

void analogSensorPin() {
  // Read the value on the Analog pin - represents the value from the photoresistor PCB. Values are
  // 0 (bright) to 1023 (dark)
  int analogVal = analogRead(SENSOR_ANALONG_PIN);

  // The PWM is 0-255, where 255 is 100% duty cycle and 0 is 0% duty cycle. To dim the LED when the
  // photoresitor has the highest resistence (brightest) first divide by 4 (1024 scale to 256 scale)
  // and then subtract that value from 255 (highest value) to convert from the photoresistor scale
  // to the LED scale (0 is the brightest on the photoresistor, but 255 is brightest for the LED).
  analogWrite(LED_PWM_PIN, 255 - (analogVal / 4));

  Serial.println(analogVal);
}

void digitalSensorPin() {
  // This pin will either be on or off (1 or 0). You can adjust the screw on the PCB to adjust when the line is driven high or low.
  int digitalVal = digitalRead(SENSOR_DIGITAL_PIN);

  // Write the respective value to the digital Arudino pin to turn the LED on or off
  digitalWrite(LED_PWM_PIN, digitalVal);

  Serial.println(digitalVal);
}

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


added forward command

added forward command

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/manashmndl/bluebrain.git/'


Changed thrust smoothing code to instantly drop to target thrust when that is a reduction in power.

#include <Servo.h>
#include <Arduino.h>
#include "Motors.h"
#include "Command.h"
#include "Device.h"
#include "Timer.h"
#include "FreeMem.h"

Motors motors(9, 10, 11);
Command cmd;
Device vout("vout", 0, vout.analog, vout.in);
Device iout("iout", 3, iout.analog, iout.in);
Device light("light", 5, light.analog, light.out);
Timer time;
Timer statustime;
Timer controltime;

Servo tilt;
// IMPORTANT!
// array[0] will be the number of arguments in the command
int array[MAX_ARGS];

// Define the number of samples to keep track of.  The higher the number,
// the more the readings will be smoothed, but the slower the output will
// respond to the input.  Using a constant rather than a normal variable lets
// use this value to determine the size of the readings array.
const int numReadings = 30;

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int new_tilt = MIDPOINT;
int new_p = MIDPOINT;
int new_s = MIDPOINT;
int new_v = MIDPOINT;
int tilt_val = MIDPOINT;
int p = MIDPOINT;
int v = MIDPOINT;
int s = MIDPOINT;
int smoothingIncriment = 5; //How aggressive the throttle changes
void setup(){

  Serial.begin(115200);

  pinMode(13, OUTPUT);

  tilt.attach(3);

  motors.reset();

  time.reset();
  statustime.reset();
  controltime.reset();

// initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;
}

int smoothAdjustedServoPosition(int target, int current){
  // if the MIDPOINT is betwen the change requested in velocity we want to go to MIDPOINT first, and right away.
  if (((current < MIDPOINT) && (MIDPOINT < target)) || ((target < MIDPOINT) && (MIDPOINT < current))){
    return MIDPOINT;
  }
  // if the change is moving us closer to MIDPOINT it is a reduction of power and we can move all the way to the target
  // in one command
  if (abs(MIDPOINT-target) < abs(MIDPOINT-current)){
    return target;
  }
  // else, we need to smooth out amp spikes by making a series of incrimental changes in the motors, so only move part of
  // the way to the target this time.
  double x = target - current;
  int sign = (x>0) - (x<0);
  return(current + sign * (min(abs(target - current), smoothingIncriment)));
}

void loop(){

  if (Serial.available()) {
    // blocks output data... TODO: need a way of calculating frequency for device data
    delay(30);
    // Get command from serial buffer
    cmd.get();

    // do something with the command, what command is it?
    if (cmd.cmp("tilt")) {
      cmd.parse(array);
      tilt_val = array[1];
    }
    else if (cmd.cmp("go")) {
      cmd.parse(array);
      p = array[1];
      v = array[2];
      s = array[3];
    }
    else if (cmd.cmp("light")) {
      cmd.parse(array);
      int value = array[1];
      light.write(value);
    }
    else if (cmd.cmp("start")) {
      motors.reset();
    }
    else if (cmd.cmp("stop")) {
      motors.stop();
    }
    else {
      motors.stop();
    }
  }

  //to reduce AMP spikes, smooth large power adjustments out. This incirmentally adjusts the motors and servo
  //to their new positions in increments.  The incriment should eventually be adjustable from the cockpit so that
  //the pilot could have more aggressive response profiles for the ROV.
  if (controltime.elapsed (50)) {
    new_p = smoothAdjustedServoPosition(p,new_p);
    new_v = smoothAdjustedServoPosition(v,new_v);
    new_s = smoothAdjustedServoPosition(s,new_s);
    new_tilt = smoothAdjustedServoPosition(tilt_val,new_tilt);
    tilt.writeMicroseconds(new_tilt);
    motors.go(new_p, new_v, new_s);
  }

  if (time.elapsed (100)) {
    // subtract the last reading:
    total= total - readings[index];
    // read from the sensor:
    readings[index] = iout.read();
    delay(1);
    // add the reading to the total:
    total= total + readings[index];
    // advance to the next position in the array:
    index = index + 1;

    // if we're at the end of the array...
    if (index >= numReadings)
      // ...wrap around to the beginning:
      index = 0;

    // calculate the average:
    average = total / numReadings;
  }

  // send voltage and current
  if (statustime.elapsed(1000)) {
    vout.send(vout.read());
    iout.send(average);
    Serial.print("fmem:");
    Serial.print(freeMemory());
    Serial.print(";");
    Serial.print("motors:");
    Serial.print(new_p);
    Serial.print(",");
    Serial.print(new_v);
    Serial.print(",");
    Serial.print(new_s);
    Serial.print(";");
    Serial.print("mtarg:");
    Serial.print(p);
    Serial.print(",");
    Serial.print(v);
    Serial.print(",");
    Serial.print(s);
    Serial.print(";");
    Serial.print("servo:");
    Serial.print(new_tilt);
    Serial.print(";");
    Serial.print("starg:");
    Serial.print(tilt_val);
    Serial.print(";");
    Serial.print("ver:");
    //Version Number of last change from UTC date: .YYYYMMDDHHMMSS. If you make a change between this and the cockpit that requires the firmware to be in sync or it breaks the system your should update this version number
    // and update the cockpit software lib/OpenROVControler.js to check and ensure the firmware is at this version.
    Serial.print(".20130314034900");
    Serial.print(";");
    Serial.print("time:");
    Serial.println(millis());
  }

}

#include <Servo.h>
#include <Arduino.h>
#include "Motors.h"
#include "Command.h"
#include "Device.h"
#include "Timer.h"
#include "FreeMem.h"

Motors motors(9, 10, 11);
Command cmd;
Device vout("vout", 0, vout.analog, vout.in);
Device iout("iout", 3, iout.analog, iout.in);
Device light("light", 5, light.analog, light.out);
Timer time;
Timer statustime;
Timer controltime;

Servo tilt;
// IMPORTANT!
// array[0] will be the number of arguments in the command
int array[MAX_ARGS];

// Define the number of samples to keep track of.  The higher the number,
// the more the readings will be smoothed, but the slower the output will
// respond to the input.  Using a constant rather than a normal variable lets
// use this value to determine the size of the readings array.
const int numReadings = 30;

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int new_tilt = MIDPOINT;
int new_p = MIDPOINT;
int new_s = MIDPOINT;
int new_v = MIDPOINT;
int tilt_val = MIDPOINT;
int p = MIDPOINT;
int v = MIDPOINT;
int s = MIDPOINT;
int smoothingIncriment = 5; //How aggressive the throttle changes
void setup(){

  Serial.begin(115200);

  pinMode(13, OUTPUT);

  tilt.attach(3);

  motors.reset();

  time.reset();
  statustime.reset();
  controltime.reset();

// initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;
}

void loop(){

  if (Serial.available()) {
    // blocks output data... TODO: need a way of calculating frequency for device data
    delay(30);
    // Get command from serial buffer
    cmd.get();

    // do something with the command, what command is it?
    if (cmd.cmp("tilt")) {
      cmd.parse(array);
      tilt_val = array[1];
    }
    else if (cmd.cmp("go")) {
      cmd.parse(array);
      p = array[1];
      v = array[2];
      s = array[3];
    }
    else if (cmd.cmp("light")) {
      cmd.parse(array);
      int value = array[1];
      light.write(value);
    }
    else if (cmd.cmp("start")) {
      motors.reset();
    }
    else if (cmd.cmp("stop")) {
      motors.stop();
    }
    else {
      motors.stop();
    }
  }

  //to reduce AMP spikes, smooth large power adjustments out. This incirmentally adjusts the motors and servo
  //to their new positions in increments.  The incriment should eventually be adjustable from the cockpit so that
  //the pilot could have more aggressive response profiles for the ROV.
  if (controltime.elapsed (50)) {
    if (p<new_p) new_p -= min(smoothingIncriment,new_p-p);
    if (p>new_p) new_p += min(smoothingIncriment,p-new_p);
    if (v<new_v) new_v -= min(smoothingIncriment,new_v-v);
    if (v>new_v) new_v += min(smoothingIncriment,v-new_v);
    if (s<new_s) new_s -= min(smoothingIncriment,new_s-s);
    if (s>new_s) new_s += min(smoothingIncriment,s-new_s);
    if (tilt_val<new_tilt) new_tilt -= min(smoothingIncriment,new_tilt-tilt_val);
    if (tilt_val>new_tilt) new_tilt += min(smoothingIncriment,tilt_val-new_tilt);
    tilt.writeMicroseconds(new_tilt);
    motors.go(new_p, new_v, new_s);
  }

  if (time.elapsed (100)) {
    // subtract the last reading:
    total= total - readings[index];
    // read from the sensor:
    readings[index] = iout.read();
    delay(1);
    // add the reading to the total:
    total= total + readings[index];
    // advance to the next position in the array:
    index = index + 1;

    // if we're at the end of the array...
    if (index >= numReadings)
      // ...wrap around to the beginning:
      index = 0;

    // calculate the average:
    average = total / numReadings;
  }

  // send voltage and current
  if (statustime.elapsed(1000)) {
    vout.send(vout.read());
    iout.send(average);
    Serial.print("fmem:");
    Serial.print(freeMemory());
    Serial.print(";");
    Serial.print("motors:");
    Serial.print(new_p);
    Serial.print(",");
    Serial.print(new_v);
    Serial.print(",");
    Serial.print(new_s);
    Serial.print(";");
    Serial.print("mtarg:");
    Serial.print(p);
    Serial.print(",");
    Serial.print(v);
    Serial.print(",");
    Serial.print(s);
    Serial.print(";");
    Serial.print("servo:");
    Serial.print(new_tilt);
    Serial.print(";");
    Serial.print("starg:");
    Serial.print(tilt_val);
    Serial.print(";");
    Serial.print("ver:");
    //Version Number of last change from UTC date: .YYYYMMDDHHMMSS. If you make a change between this and the cockpit that requires the firmware to be in sync or it breaks the system your should update this version number
    // and update the cockpit software lib/OpenROVControler.js to check and ensure the firmware is at this version.
    Serial.print(".20130314034900");
    Serial.print(";");
    Serial.print("time:");
    Serial.println(millis());
  }

}


Update RC5Decode.ino

Update RC5Decode.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/pascaltippelt/RC5_chinch.git/'


hopefully this works

hopefully this works

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/sassystacks/DASS.git/'


Add stepper_speedControl

Add stepper_speedControl

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/JulianNicholls/Arduino.git/'


Time DS1307 version 2.0 - new project for DS1307RTC

/*
 Time v2
 Time and date on lcd display (used rtc timer) with control by keypad 4x4

 Hardware:
 Trickle-Charge Timekeeping Chip DS1302
 http://www.maximintegrated.com/en/products/digital/real-time-clocks/DS1302.html
 http://playground.arduino.cc/Main/DS1302RTC
 LCD I2C PCF8574
 http://habrahabr.ru/post/219137/
 http://arduino-info.wikispaces.com/file/detail/LiquidCrystal_I2C1602V1.zip/341635514
 Keypad 4x4

 created 18.01.2015
 modifid 24.01.2015
 by Fust Vitaliy
 with Arduino 1.5.8 (tested on Arduino Uno)
*/
/*
Sketch uses 14 592 bytes (45%) of program storage space. Maximum is 32 256 bytes.
Global variables use 422 bytes (20%) of dynamic memory, leaving 1 626 bytes for local variables. Maximum is 2 048 bytes.
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <CyrI2c.h>
CyrI2c* lcd;

#include <Keypad.h>
const byte numRows = 5;
const byte numCols = 4;
char keymap[numRows][numCols] = {
  {'+', '-', '#', '*'},
  {'1', '2', '3', 'W'},
  {'4', '5', '6', 'S'},
  {'7', '8', '9', 'B'},
  {'A', '0', 'D', 'E'}
};
byte rowPins[numRows] = {4, 5, 6, 7, 8};
byte colPins[numCols] = {12, 11, 10, 9};
Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

#include "RTClib.h"
RTC_DS1307 rtc;

#include <dht.h>
dht DHT;

#define DHT11_PIN 2

void setup() {
  lcd = new CyrI2c(0x27, 16, 2);
  lcd->backlight();

  rtc.begin();
  DateTime now = rtc.now();
  hello(now.hour());
}

void loop() {
  DateTime now = rtc.now();
  DHT.read11(DHT11_PIN);

  lcd->init(F("Нд\rПн\rВт\rСр\rЧт\rПт\rСб"));
  lcd->printn(now.dayOfWeek(), -1, 0);
  lcd->init(F("січня\rлютого\rберезня\rквітня\rтравня\rчервня\rлипня\rсерпня\rвересня\rжовтня\rлистопада\rгрудня"));
  lcd->printn(now.month() - 1, 3, 0);

  char buffer[9];
  buffer[8] = 0;
  sprintf(buffer, "%02d", now.day());
  lcd->print(buffer, 0, 0);
  sprintf(buffer, "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
  lcd->print(buffer, -1, 1);
  char suf[3]{223, 'C'};
  sprintf(buffer, "%d%s", (byte) DHT.temperature, suf);
  lcd->print(buffer, 0, 1);

  unsigned long prevtime = now.unixtime();
  while(prevtime == rtc.now().unixtime()){
    char keypressed = myKeypad.getKey();
    if (keypressed != NO_KEY){
      switch (keypressed) {
        case '+':
          lcd->backlight();
          break;
        default:
          hello(now.hour());
      }
    }
  }
}

void hello(uint8_t hour){
  lcd->clear();
  lcd->init(F("Доброї ночі!\rДоброго ранку!\rДоброго дня!\rДоброго вечора!\rЯ годинник :)"));
  lcd->printn((hour + 1) / 6, 0, 0);
  lcd->printn(4, 3, 1);
  delay(2000);
  lcd->clear();
}

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


Initial commit

Initial commit

error: pathspec 'arduino-lora-master/ATT_Lora_IOT/examples/sensor' did not match any file(s) known to git
error: pathspec 'tests/TPH_SENSOR/TPH_SENSOR.ino' did not match any file(s) known to git


Added comments

Added comments

There is a discrepancy between the wiring as shown in the schematic vs the ones in the demonstration. I hope these comments will reduce any confusion.

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


Add: arduino DC_motor_voltage_control.

Add: arduino DC_motor_voltage_control.

// demo: CAN-BUS Shield, send data
// loovee@seeed.cc

#include <mcp_can.h>
#include <SPI.h>
#include <string.h>

float float_value = 13;

void float2Bytes(byte* bytes_temp, float float_variable) {
  memcpy(bytes_temp, (unsigned char*) (&float_variable), 4);
}

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

unsigned char motor_1_front[4] = {0x1C, 0x72, 0x00, 0x01};
unsigned char motor_1_back[4] = {0x00, 0x00, 0x00, 0x00};
unsigned char rotate[8] =      {0x1C, 0x72, 0x00, 0x01, 0x00, 0x00, 0x50, 0x41};
unsigned char st[8] =          {0x1C, 0x72, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00};

unsigned char motor_1_on[8] =  {0x14, 0x65, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00};
unsigned char motor_1_off[8] = {0x14, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00};

unsigned char motor_1_quick_stop[6] = {0x14, 0x65, 0x00, 0x01, 0x00, 0x07};

int statement_flag = 1;
//0: motor power on
//1: motor power stop
//2: quick stop (like emergency stop)

void setup() {
  Serial.begin(9600);

  while (CAN_OK != CAN.begin(CAN_500KBPS)) {
    Serial.println("CAN BUS Shield init fail");
    Serial.println(" Init CAN BUS Shield again");
    delay(100);
  }
  Serial.println("CAN BUS Shield init ok!");
  //  CAN.sendMsgBuf(0x01, 0, 8, motor_1_on);
}

void loop() {
  //  CAN.sendMsgBuf(0x01, 0, 8, rotate);
  if (Serial.available() > 0) {
    float_value = Serial.parseFloat();
  }

  float2Bytes(motor_1_back, float_value);
  unsigned char* total_rotate = (unsigned char*)malloc(8 * sizeof(char)); // array to hold the result
  memcpy(total_rotate,     motor_1_front, 4 * sizeof(unsigned char)); // copy 4 floats from x to total[0]...total[3]
  memcpy(total_rotate + 4, motor_1_back, 4 * sizeof(unsigned char)); // copy 4 floats from y to total[4]...total[7]

  CAN.sendMsgBuf(0x01, 0, 8, total_rotate);
  for (int i = 0; i < 8; i++) {
    Serial.print(total_rotate[i], HEX);
    Serial.print('\t');
  }

  Serial.println('\n');
  free(total_rotate);
  delay(10);
}

// END FILE

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


Look i added somthin

Look i added somthin

1I begynnelsen var Ordet, och Ordet var hos Gud, och Ordet var Gud. 2 Han var i begynnelsen hos Gud. 3 Genom honom har allt blivit till, och utan honom har inget blivit till, som är till. 4 I honom var liv, och livet var människornas ljus. 5 Och ljuset lyser i mörkret, och mörkret har inte övervunnit det.
6En man trädde fram, sänd av Gud. Hans namn var Johannes. 7 Han kom som ett vittne för att vittna om ljuset, för att alla skulle komma till tro genom honom. 8 Själv var han inte ljuset, men han kom för att vittna om ljuset.
9Det sanna ljuset, som ger ljus åt alla människor, skulle nu komma till världen. 10 Han var i världen och världen hade blivit till genom honom, och världen kände honom inte. 11 Han kom till sitt eget, och hans egna tog inte emot honom. 12 Men åt alla som tog emot honom gav han rätt att bli Guds barn, åt dem som tror på hans namn. 13 De är inte födda av blod eller av köttets vilja eller av någon mans vilja utan av Gud.
14Och Ordet blev kött och bodde bland oss,bodde bland oss Ordagrant: "tältade bland oss". Tälthelgedomen, tabernaklet, var i det gamla förbundet platsen för Guds uppenbarelse (2 Mos 25). och vi såg hans härlighet, en härlighet som den Enfödde har av Fadern, och han var full av nåd och sanning. 15 Johannes vittnar om honom och ropar: "Det var om honom jag sade: Han som kommer efter mig är före mig, eftersom han var före mig." 16 Av hans fullhet har vi alla fått, nåd och åter nåd. 17 Ty lagen gavs genom Mose, nåden och sanningen kom genom Jesus Kristus. 18 Ingen har någonsin sett Gud. Den Enfödde, som själv är Gud,Den Enfödde, som själv är Gud Andra handskrifter: "Den enfödde Sonen". och är hos Fadern, har gjort honom känd.
Johannes Döparens vittnesbörd
19Detta är Johannes vittnesbörd, när judarnajudarna Här, liksom ofta i detta evangelium, åsyftas närmast det judiska folkets ledare, dvs medlemmarna i Stora rådet. hade sänt till honom präster och leviter från Jerusalem för att fråga honom vem han var. 20 Han bekände och förnekade inte sanningen. Han bekände: "Jag är inte Messias." 21 De frågade honom: "Vad är du då? Är du Elia?" Han sade: "Nej, det är jag inte." "Är du Profeten?"Profeten Den i 5 Mos 18:15, 18 utlovade Profeten har av judarnas skriftlärda uppfattats som en från Messias skild person (v. 25). Denne profet identifieras emellertid av Johannes Döparen (liksom av aposteln Petrus i Apg 3:22) med Messias. Han svarade: "Nej." 22 Då sade de till honom: "Vem är du då? Vi måste ge ett svar till dem som har sänt oss. Vad säger du om dig själv?" 23 Han svarade med profeten Jesajas ord: "Jag är "rösten som ropar i öknen: Gör vägen rak för Herren!"" Jes 40:3
24Några fariseer hade också sänts ut, 25 och de frågade honom: "Varför döper du, om du inte är Messias och inte heller Elia eller Profeten?" 26 Johannes svarade dem: "Jag döper i vatten. Men mitt ibland er står en som ni inte känner, 27 han som kommer efter mig. Jag är inte värd att knyta upp remmen på hans sandaler." 28 Detta hände i Betania på andra sidan Jordan, där Johannes döpte.
29Nästa dag såg han Jesus komma, och han sade: "Se Guds lamm,Guds lamm Detta uttryck kan ses i ljuset av GT:s profetior om 1) offerlammet (3 Mos 4:32f), 2) påskalammet (2 Mos 12:3f) och 3) lammet som bild av den ställföreträdande Herrens tjänare, som "likt ett lamm förs bort att slaktas" (Jes 53:7, Jer 11:19). som tar bort världens synd. 30 Det var om honom jag sade: Efter mig kommer en man som är före mig, ty han var före mig. 31 Och jag kände honom inte. Men för att han skulle uppenbaras för Israel har jag kommit och döper i vatten."
32Johannes vittnade och sade: "Jag såg Anden komma ner som en duva från himlen och bli kvar över honom. 33 Jag kände honom inte, men han som sände mig att döpa i vatten sade till mig: Den som du ser Anden komma ner och bli kvar över, han är den som döper i den helige Ande. 34 Och jag har sett det och har vittnat att han är Guds Son."
Jesu första lärjungar
35Nästa dag stod Johannes där igen med två av sina lärjungar. 36 När han såg Jesus komma sade han: "Se Guds lamm!" 37 De båda lärjungarna hörde vad han sade och följde Jesus. 38 Jesus vände sig om, och när han såg att de följde honom, frågade han dem vad de ville. De svarade: "Rabbi" - det betyder lärare - "var bor du?" 39 Han sade till dem: "Kom och se!" Då gick de med honom och såg var han bodde och stannade hos honom den dagen. Det var omkring tionde timmen.
40Andreas, Simon Petrus bror, var en av de två som hade hört vad Johannes sade och som hade följt Jesus. 41 Han fann först sin bror Simon och sade till honom: "Vi har funnit Messias" - det betyder Kristus. 42 Och han förde honom till Jesus. Jesus såg på honom och sade: "Du är Simon, Johannes son, du skall heta Kefas"Kefas Se not till Matt 16:18. - det betyder Petrus.
43Nästa dag beslöt Jesus att gå därifrån till Galileen. Han fann då Filippus och sade till honom: "Följ mig!" 44 Filippus var från Betsaida, från samma stad som Andreas och Petrus. 45 Filippus fann Natanael och sade till honom: "Den som Mose har skrivit om i lagen och som profeterna har skrivit om, honom har vi funnit, Jesus, Josefs son, från Nasaret." 46 Natanael sade till honom: "Kan något gott komma från Nasaret?" Filippus svarade: "Kom och se!" 47 När Jesus såg Natanael komma sade han om honom: "Se, han är en verklig israelit. I honom finns inget svek." 48 Natanael frågade honom: "Hur kan du känna mig?" Jesus svarade: "Innan Filippus kallade på dig, såg jag dig där du var under fikonträdet." 49 Natanael svarade: "Rabbi, du är Guds Son, du är Israels konung." 50 Jesus svarade honom: "Därför att jag sade att jag såg dig under fikonträdet, tror du. Det som är större än detta skall du få se." 51 Sedan sade han till honom: "Amen, amenAmen, amen Se not till Matt 5:18. säger jag er: Ni kommer att få se himlen öppen och Guds änglar stiga upp och stiga ner över Människosonen." Bibeln

int micPin = A0;
int gndPin = A1;
int powerPin = A2;
int micValue1 = 0;
int micValue2 = 0;
int led1 = 11;
int eventstatus = 0;

void setup() {

  pinMode(led1, OUTPUT);
  pinMode(powerPin, OUTPUT);
  pinMode(gndPin, OUTPUT);
  pinMode(micPin, INPUT);
  digitalWrite(gndPin,LOW);
  delay(500);
  digitalWrite(powerPin,HIGH);
  Serial.begin(9600);
}
//micValue1-micValue2 < 2||micValue2-micValue1 < 2
//micValue1 < 60
void loop() {
  // put your main code here, to run repeatedly:
  micValue1 = analogRead(micPin);
    micValue2 = analogRead(micPin);
  delay(1);

  if(micValue1 > 44||micValue1 > 44 && eventstatus == 0){
    Serial.println("0");
    eventstatus = 1;
  }

      if(eventstatus==1){
    for(int k =10; k>0;k--){
      delay(10);
        micValue1 = analogRead(micPin);
    micValue2 = analogRead(micPin);
      if(micValue1 < 44){
        eventstatus=2;
        Serial.println("1");
        break;
      }
    }
      }

        if(eventstatus==2){
    for(int n=25;n>0;n--){
      delay(1);
        micValue1 = analogRead(micPin);
    micValue2 = analogRead(micPin);
      if(micValue1 > 44){
        eventstatus=3;
        Serial.println("2");
      break;
      }
    }
        }

        if(eventstatus==3){
            myservo.write(100);
            delay(1000);
    Serial.println("Nice");
    eventstatus = 0;
    digitalWrite(led1,HIGH);
    delay(2000);
        digitalWrite(led1,LOW);
        delay(1000);
  }
  }

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


Fixed #3. Added ArduinoUnit tests in SimpleTimeoutTest.ino

#line 2 "SimpleTimeoutTest.ino"
// Tests for the SimpleTimeoutTemplate class
// normally instantiated with the millis() function
// TestClock::getTicks() will be our test function.

#include <ArduinoUnit.h>
#include <SimpleTimeout.h>

class TestClock {
 public:
  static unsigned long getTicks(void) {
    return ticks;
  }

  static void setTicks(unsigned long newTicks) {
    ticks = newTicks;
  }

  static void add(unsigned long addTicks) {
    ticks += addTicks;
  }

 private:
  static unsigned long ticks;
};

unsigned long TestClock::ticks = 0;

// Define the TestTimeout type to use our clock function.
typedef SimpleTimeoutTemplate<TestClock::getTicks> TestTimeout;

// A timeout with a negative value waits forever
test(forever)
{
  TestClock::setTicks(100);

  TestTimeout timeout(TestTimeout::FOREVER);

  assertTrue(timeout.isForever());
  assertEqual(TestClock::getTicks(), timeout.getStart());
  assertEqual(TestClock::getTicks(), timeout.getEnd());

  assertFalse(timeout.expired());
  TestClock::add(100);
  assertFalse(timeout.expired());
  TestClock::setTicks(0);
  assertFalse(timeout.expired());

  timeout.cancel();
  assertTrue(timeout.expired());
  assertFalse(timeout.isForever());

  timeout.restart();
  assertFalse(timeout.expired());
  assertTrue(timeout.isForever());
}

// A timeout under normal conditions
test(normal_timeout)
{
  TestClock::setTicks(100);

  TestTimeout timeout(1000);

  // Now = 100
  // Expiry time = 100 + 1000 = 1100
  assertFalse(timeout.isForever());
  assertEqual(TestClock::getTicks(), timeout.getStart());
  assertEqual(1100, timeout.getEnd());
  assertFalse(timeout.expired());

  // One tick before expiry
  TestClock::setTicks(1099);
  assertFalse(timeout.expired());

  // Expiry time
  TestClock::setTicks(1100);
  assertTrue(timeout.expired());
}

// Test when the length of the timeout causes the millis() counter
// to overflow
test(timeout_overflow)
{
  TestClock::setTicks(ULONG_MAX - 100);

  TestTimeout timeout(1000);

  assertFalse(timeout.isForever());
  assertEqual(TestClock::getTicks(), timeout.getStart());
  assertEqual(899, timeout.getEnd());

  assertFalse(timeout.expired());
  TestClock::setTicks(ULONG_MAX);
  assertFalse(timeout.expired());
  TestClock::setTicks(0);
  assertFalse(timeout.expired());
  TestClock::setTicks(899);
  assertTrue(timeout.expired());
}

// Test when the clock overflows before the timeout is detected
test(clock_overflow_timeout)
{
  TestClock::setTicks(ULONG_MAX - 100);

  TestTimeout timeout(50);

  assertFalse(timeout.isForever());
  assertEqual(TestClock::getTicks(), timeout.getStart());
  assertEqual(ULONG_MAX - 50, timeout.getEnd());

  assertFalse(timeout.expired());
  TestClock::setTicks(ULONG_MAX); // Just before clock overflow, already timed out
  assertTrue(timeout.expired());
  TestClock::setTicks(timeout.getStart() - 1); // After clock overflow
  assertTrue(timeout.expired());
}

// Test when the timeout is zero. The timeout has always expired
test(zero_timeout)
{
  TestClock::setTicks(100);

  TestTimeout timeout(0);

  assertFalse(timeout.isForever());
  assertEqual(TestClock::getTicks(), timeout.getStart());
  assertEqual(TestClock::getTicks(), timeout.getEnd());

  assertTrue(timeout.expired());
  TestClock::setTicks(ULONG_MAX);
  assertTrue(timeout.expired());
  TestClock::setTicks(0);
  assertTrue(timeout.expired());
}

test(disabled_restart)
{
  TestClock::setTicks(100);

  TestTimeout timeout(1000);

  assertFalse(timeout.isForever());
  assertEqual(TestClock::getTicks(), timeout.getStart());
  assertEqual(1100, timeout.getEnd());
  assertFalse(timeout.expired());

  TestClock::setTicks(1099);
  assertFalse(timeout.expired());
  assertFalse(timeout.isDisabled());

  TestClock::setTicks(1101);
  assertTrue(timeout.expired());
  assertTrue(timeout.isDisabled());

  timeout.restart();
  assertFalse(timeout.expired());
  assertFalse(timeout.isDisabled());
  assertEqual(2101, timeout.getEnd());

  timeout.cancel();
  assertTrue(timeout.isDisabled());
  assertEqual(1101, timeout.getEnd());
  assertFalse(timeout.isForever());

  timeout.restart(TestTimeout::FOREVER);
  assertTrue(timeout.isForever());
}

void setup() {
  Serial.begin(9600);
  while (!Serial) { }
}

void loop() {
  Test::run();
}

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


Added delay to KeyboardReprogram to make backspace more obvious

build/shared/examples/09. USB (Leonardo only)/Keyboard/KeyboardReprogram/KeyboardReprogram.ino

/bin/sh: 1: Syntax error: "(" unexpected


Update MIDI_to_BLE-MIDI_nRF51822.ino

Update MIDI_to_BLE-MIDI_nRF51822.ino

error: pathspec 'MIDI_to_BLE-MIDI_bridge' did not match any file(s) known to git
error: pathspec 'nRF51822/MIDI_to_BLE-MIDI_nRF51822.ino' did not match any file(s) known to git


TI Stellaris Launchpad example

TI Stellaris Launchpad example

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to use ordinary Arduino Serial
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 * 1. Optional, but recommended.
 *    Connect additional USB-serial adapter to see the prints.
 *
 * 2. Edit auth token and upload this sketch.
 *
 * 3. Run the script (script located in "scripts" folder of library root,
 *    e.g. 'blynk-library/scripts') for redirecting traffic to server:
 *
 *      for Windows:
 *                     1. Open cmd.exe
 *                     2. write : (your way to blynk-ser.bat folder) example: "cd C:\blynk-library-0.3.1\blynk-library-0.3.1\scripts"
 *                     3. write : "blynk-ser.bat -c COM4" (where COM4 is port with your Arduino)
 *                     4. And press "Enter" , press "Enter" and press "Enter"
 *
 *      for Linux and OSX:
 *
 *                    ./blynk-ser.sh (may need to run with sudo)
 *
 *    You can specify port, baud rate, and server endpoint like this:
 *      ./blynk-ser.sh -c <serial port> -b <baud rate> -s <server address> -p <server port>
 *
 *    For instance :
 *      ./blynk-ser.sh -c /dev/ttyACM0 -b 9600 -s cloud.blynk.cc -p 8442
 *
 *    Run blynk-ser.sh -h for more information
 *
 *    Be sure to select the right serial port (there may be multiple).
 *
 *    Attention!
 *        Arduino IDE may complain with "programmer is not responding".
 *        You need to terminate script before uploading new sketch.
 *
 * 4. Start blynking! :)
 *
 **************************************************************/

#define BLYNK_PRINT Serial1
#include <BlynkSimpleSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

void setup()
{
  Serial1.begin(9600);
  Blynk.begin(auth);
  // Default baud rate is 9600. You could specify it like this:
  //Blynk.begin(auth, 57600);
}

void loop()
{
  Blynk.run();
}

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


new example

new example

demonstartes timer functions

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


add the lite version

add the lite version

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/drifterz28/drizzle-maker.git/'


Add Source

Add Source

Begin van de source voor de Shrimp

// Pins
const int ledPin = 13;
const int buttonPin = 2;
const int thermometerPin = 0;

// Variables
int travelTime = 0; // Total travel time in s
int logInterval = 0; // Hoe vaak willen we loggen?

void setup() {
  // Initialize pins
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  pinMode(thermometerPin, INPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

}

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


Added watchdog capability.

Added watchdog capability.

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


Added arduino-code

Added arduino-code

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/tihlde/ircbot.git/'