Added shofanduino2 program, much simpler since
some of the calculations are now done in the
sensor (filtering out noisy values).

Instead of 'avg' and 'max', we use envelope min
and max values that try to hug the humidity with
a slow moving function. The slow moving function
is based on the half-life equation, so the
parameters are more intuitive.

//#include <Time.h>
#include <DHT22.h>

#define DHT22_PIN 6

// consts for controlling relays
const int K1 = 11;
const int K2 = 12;
const int milliseconds_switch_delay = 100;
const int NormallyConnected = HIGH;
const int NormallyOpen = LOW;
typedef enum {FAN_OFF, FAN_NOCHANGE, FAN_ON};

// DHT consts/variables
DHT22 myDHT22(DHT22_PIN);

// consts/variables for humidity sensor and averages etc.
const int sensorPin = A0;    // select the input pin for the potentiometer
const int milliseconds_sleep = 5000;

float thresholdLow = 0.0;
float thresholdHigh = 0.0;
float env_min = 0.0;
float env_max = 0.0;
float humidity = 0.0;
float temperature = 0.0;
float on_off = 0;

// variables for decay
 // number of seconds after which the difference between the humidity and the max envelope should have been halved.
const float p_halflife_max = 604800.0;
const float p_halflife_min = 86400.0; // same for the min envelope. This is shorter because it needs to change faster.
float env_max_decay = 0.0;
float env_min_decay = 0.0;

// variables to decide the state of the fan
int state = FAN_OFF; // action to take, based on sensor reading

void getValues() {
  DHT22_ERROR_t errorCode;

  // The sensor can only be read from every 1-2s, and requires a minimum
  // 2s warm-up after power-on.
  delay(milliseconds_sleep);

  errorCode = myDHT22.readData();
  humidity = myDHT22.getHumidity();
  temperature = myDHT22.getTemperatureC();

  switch(errorCode) {
  case DHT_ERROR_NONE:
    break;
  case DHT_ERROR_CHECKSUM:
    Serial.print("E: checksum ");
    Serial.print(myDHT22._lastCheckSum);
    Serial.print(" != ");
    Serial.print(myDHT22._lastExpectedCheckSum);
    Serial.print(". ");
    Serial.print(temperature);
    Serial.print("C ");
    Serial.print(humidity);
    Serial.println("%. Are you really sure you set the clock to 8Mhz?");
    break;
  case DHT_BUS_HUNG:
    Serial.println("E: BUS Hung");
    break;
  case DHT_ERROR_NOT_PRESENT:
    Serial.println("E: Sensor not found");
    break;
  case DHT_ERROR_ACK_TOO_LONG:
    Serial.println("E: ACK time out");
    break;
  case DHT_ERROR_SYNC_TIMEOUT:
    Serial.println("E: Sync Timeout");
    break;
  case DHT_ERROR_DATA_TIMEOUT:
    Serial.println("E: Data Timeout");
    break;
  case DHT_ERROR_TOOQUICK:
    Serial.println("E: Polled to quick");
    break;
  }
}

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

  // set relays to normally connected
  pinMode(K1, OUTPUT);
  pinMode(K2, OUTPUT);
  digitalWrite(K1, NormallyConnected);
  digitalWrite(K2, NormallyConnected);

  Serial.println("DHT22 temperature/humidity. Did you set the clock to 8Mhz?");

  // initialize sensor
  pinMode(sensorPin, INPUT);
  getValues();
  env_min = humidity;
  env_max = humidity;

  // calculate decay
  float t = milliseconds_sleep / 1000.0f;

  // calculate what would happen after one step, to unit value (1.0)
  // the result is the scale factor we can apply to the envelope max/min
  env_max_decay = 1.0f * pow(2, -t / p_halflife_max);
  env_min_decay = 1.0f * pow(2, -t / p_halflife_min);
}

void loop() {
  getValues();

  // clamp the envelope min/max, decay otherwise
  if (env_min > humidity) {
    env_min = humidity;
  } else {
    // this actually decays the difference between humidity
    // and env_min, so this means env_min goes up!
    env_min = humidity - (humidity - env_min) * env_min_decay;
  }
  if (env_max < humidity) {
    env_max = humidity;
  } else {
    env_max = humidity + (env_max - humidity) * env_max_decay;
  }

  // New thresholds based on the envelope values. We
  // want the fan to turn on pretty quickly, but we don't
  // want it to turn off quickly. This explains the difference
  // in factors between low and high.
  thresholdLow = env_min + (env_max - env_min) / 20.0f;
  thresholdHigh = env_min + (env_max - env_min) / 2.0f;

  state = FAN_NOCHANGE;
  if (humidity < thresholdLow) {
    state = FAN_OFF;
  } else if (humidity > thresholdHigh) {
    state = FAN_ON;
  }

  // switch the relays!
  switch (state) {
    case FAN_OFF:
      // because we don't know the status of the 3-way switch, we switch both
      // relays at the same time and hope there is no short circuit. This should
      // not be an issue, but anyway...
      digitalWrite(K1, NormallyConnected);
      digitalWrite(K2, NormallyConnected);
      break;
    case FAN_ON:
      digitalWrite(K2, NormallyOpen);
      // since we don't know how the switch is switched, we first switch K2 to
      // non-connected, then wait a while for it to settle, before we switch
      // K1 to connected L. This should prevent any shorts (don't know if that
      // is actually an issue, but better safe than sorry).
      delay(milliseconds_switch_delay);
      digitalWrite(K1, NormallyOpen);
      break;
  }

  // display the current state in the graph
  // don't use absolute values, so the graph can zoom in and show more information
  switch (state) {
    case FAN_OFF:
      on_off = 0.0;
      break;
    case FAN_ON:
      on_off = 1.0;
      break;
    case FAN_NOCHANGE:
      on_off = 0.5;
      break;
  }

  // print out the values for debugging/plotting
  Serial.print("humidity = ");
  Serial.print(humidity, 1);
  Serial.print(", threshold_low = ");
  Serial.print(thresholdLow, 3);
  Serial.print(", threshold_hi = ");
  Serial.print(thresholdHigh, 3);
  Serial.print(", envelope_min = ");
  Serial.print(env_min, 3);
  Serial.print(", envelope_max = ");
  Serial.print(env_max, 3);
  Serial.print(", temperature = ");
  Serial.print(temperature, 1);
  Serial.print(", on_off = ");
  Serial.println(on_off, 1);
}

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


Create pin_change_interrupt.ino

Create pin_change_interrupt.ino

#include <Arduino.h>

#define INTERRUPT_PIN 9

/*
Pin Change Interrupt Example

James H. Bannock, 2017
Norges teknisk-naturvitenskapelige universitet (NTNU)

Notes:
  - A button is attached to Pin 9 and GND
  - INPUT_PULLUP is used to pin the voltage of the input to 5V while the Button
    is open
  - On the Uno there are three ports, Pin 9 is on PORT B (PORTB)
  - There are Pin Change Interrupts associated to each port, PCINT0 is for PORTB
  - PCINT0 must be activated by enabling Pin Change Interrupt Enable 0 (PCIE0)
    in the Pin Change Interrupt Control Register (PCICR)
  - Pin 9 corresponds to Pin Change Interrupt 1 (PCINT1) and must be enabled in
    the Pin Change Mask 0 (PCMSK0)
*/

void setup() {
  Serial.begin(9600); (!Serial); // setup the serial port
  pinMode(INTERRUPT_PIN, INPUT_PULLUP); // pull-up to pin voltage to 5V
  setupPinInterrupt(); // abstract pin interrupt setup
}

ISR (PCINT0_vect) { // Interrupt Service Routine (ISR) for Pin Change Interrupt
                    // Request 0 (PCINT0)
  Serial.println("Button State Change Detected!"); // print an output
}

void loop() {}

void setupPinInterrupt() {
  PCICR |= (1 << PCIE0); // enable PCINT0 ISR
  PCMSK0 |= (1 << PCINT1); // enable interrupt on PCINT1 (Pin 9)
}

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


Added MiniDora sketch for the Arduino Uno

#include <Servo.h>
  Servo posBack;
  Servo posFront;
  Servo driveR;
  Servo driveL;
  String SerialInput="";
  String Svalue;
  int value;
void setup()
{
  Serial.begin(9600);
  posBack.attach(7);// 1 dot
  posFront.attach(8);// 4 dot
  driveR.attach(9);// 2 dots
  driveL.attach(10);// 3 dots
}

/*
MiniDora EVX 2 (EVX 3014)
NOTE: Longer treads are the front treads; Shorter treads are the back treads.

driveR: Calibs for right side drive motors through the ESC.
FullSpeedForward:0-1349; x-y (x >> 10000)
Forward:1350(high speed)-1484 (lowest speed)
Braking:1485-1555
1556-1557: Not reliable
Reverse:1558(lowest speed)-1900 (highest speed)
FullSpeedReverse:1900-x

driveL: Calibs for left side drive motors through the ESC.
FullSpeedForward:1930-z
Forward:1572(slowest)-1930 (fastest)
Braking:1475-1570
1571-1572:Not reliable
Reverse:1474 (slowest)- 1320(fastest)
FullSpeedReverse:-1474
*/
void loop()
{

   if(Serial.available())
                              {
                               for(int i=1;i<=3;i++)
                               {
                                   SerialInput = Serial.readStringUntil(' ');
                                if(SerialInput!="")
                                {
                                  Serial.print("Processing Command:");Serial.print(SerialInput);Serial.println();
                                  char motor=SerialInput.charAt(0);
                                 // Serial.print("LED=");Serial.print(LED);Serial.println();
                                  for(int j=1;SerialInput.charAt(j)!='\0';j++)
                                   Svalue+=SerialInput.charAt(j);
                                  // Serial.print("Svalue=");Serial.print(Svalue);Serial.println();
                                   value=Svalue.toInt();//In case the value input is not in the range of 0-255, the input value is converted
                                  // into integer with truncation and written to the Pin(s).
                                  // Serial.print("value=");Serial.print(value);Serial.println();
                                   switch(motor)
                                       {
                                         case 'r': {Serial.print("Writing");Serial.print(value);Serial.print("to motor 'r' ");Serial.println();driveR.writeMicroseconds(value);break;}
                                         case 'l': {Serial.print("Writing");Serial.print(value);Serial.print("to motor 'l' ");Serial.println();driveL.writeMicroseconds(value);break;}
                                         //case 'b': {BlueValue=value;break;}
                                        default: {Serial.print("Wrong Command. Please check your input");Serial.println();break;}
                                       }
                                 }
                                 Svalue="";
                                }

                                SerialInput="";
                              }

}

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


Created sketch

Created sketch

This is still work in progress. Various code-sources are used to create
this. Current instance is unlikely to work.

/*--------------------------------------------------------------
  Adapted from : volt_measure
                 22 May 2013 by W.A. Smith, http://startingelectronics.com

  Modified by  : M. Hendrix
--------------------------------------------------------------*/

// number of samples per measurement
#define numSamples 10
#define measurePin A0

int sumSamples = 0;             // sum of samples taken
int cntSamples = 0;             // current sample number
float voltage = 0.0;            // calculated voltage

const float ref5V = 5.000;     // calibration of reference value for 5.0V ADC

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

void loop()
{
    // take a number of analog samples and add them up
    for (cntSamples = 0; cntSamples <= numSamples; cntSamples++) {
        sumSamples += analogRead(measurePin);
        delay(10);
    }
    // calculate the voltage
    // use 5.0 for a 5.0V ADC reference voltage
    // 5.015V is the calibrated reference voltage
    voltage = ((float)sumSamples / (float)numSamples * ref5V) / 1024.0;
    // send voltage for display on Serial Monitor
    // voltage multiplied by 11 when using voltage divider that
    // divides by 11. 11.132 is the calibrated voltage divide
    // value
    Serial.print(voltage * 11.000);
    Serial.println (" V");
    cntSamples = 0;
    sumSamples = 0;
}

/*
  DisplayMoreThan5V sketch
  prints the voltage on analog pin to the serial port
  Do not connect more than 5 volts directly to an Arduino pin.
+/
const float referenceVolts = 5;        // the default reference on a 5-volt board

const float R1 = 1000; // value for a maximum voltage of 10 volts
const float R2 = 1000;
// determine by voltage divider resistors, see text
const float resistorFactor = 1023.0 * (R2/(R1 + R2));
const int batteryPin = A0;         // +V from battery is connected to analog pin 0

const int led[6] = {3, 5, 6, 9, 10, 11};
const int sensPin = A0;
const int maxoutput = 191;
const float factor = (6.0*maxoutput)/1024.0;

void setup() {
  Serial.begin(9600);
  for (int i = 0; i<=5; i++) {
    pinMode(led[i],OUTPUT);
    digitalWrite(led[i],HIGH);
  }
  delay(500);
  ledsoff();
}

void loop() {

   int val = analogRead(sensPin);  // read the value from the sensor
   Serial.print(val);
   Serial.print(" = ");
   float volts = (val / resistorFactor) * referenceVolts ; // calculate the ratio
   Serial.println(volts);  // print the value in volts
  ledon(val * factor);
  /* pulse
  for (int i = 0; i <= 6*maxoutput; i++) {
    ledon(i);
    //delay(0.5);
  }
  for (int i = 6*maxoutput; i >= 0; i--) {
    ledon(i);
    delay(1);
  }
  +/
  delay(1000);
}

void ledsoff() {
  for (int i = 0; i<=5; i++) {
    digitalWrite(led[i],LOW);
  }
}

void ledon(int v) {
  int w;
  //Serial.print(v);
  //Serial.print(": ");
  if (v > 6* maxoutput) { v=6*maxoutput; }

  for (int out=5; out >= 0; out = out -1) {
    if (v > out * maxoutput) {
      w = v - out * maxoutput;
   //     Serial.print(w);
   //     Serial.print(" ");
      analogWrite(led[out], w);
      v = v- w;
    }
    else { analogWrite(led[out],0); }
  }
  //Serial.println(".");
}

*/

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


Training Mix With Pin Change Interrupts, Servo Control, and Relay Control

/*
 * Include libraries at the top of the source document. These signal the compiler
 * to look in the the specified libraries for keywords and function calls that we
 * will be using.
 *
 * Servo.h:         allows us to easily write a PWM signal directly to servos.
 *
 * PinChangeInt.h:  extends the Arduino unit's capabilities by "listening" for
 *                  changes in the incoming signals. The attachInterrupt() function
 *                  in the base library will listen for an entire duty cycle. For
 *                  our purposes this is a waste of resources and will not allow us
 *                  to realize control of the 12 actuators necessary for the full
 *                  project. More on how to use it later in the file.
 */

#include <Servo.h>
#include <PinChangeInt.h>

/*
 * Pre-define the pins used on the Arduino board. All pins defined are digital pins.
 *
 * REL_IN_PIN:      Input pin receiveing the incoming PWM signal from the X8R
 *                  receiver(the remote control) that controls the linear actuator.
 *
 * RELAY1_OUT_PIN:  Pin outputting to relay 1.
 * RELAY2_OUT_PIN:  Pin outputting to relay 2.
 *
 * REL_FLAG:        Bit flag to let the Arduino system know there is a change in the
 *                  state of the incoming signal (Changing from HIGH to LOW,
 *                  or vice versa).
 *
 * **Note:  BIT FLAGS are represented in base 10 in this source code
 *          (1, 2, 4, up to 256). In base 2 we can treat a 8-bit unsigned integer as
 *          a quick and dirty 8-element boolean array. In this version of the code.
 *
 *          EX: 1     = 00000001
 *              2     = 00000010
 *              1 + 2 = 00000011
 *
 *          We may use a 16-bit number for double the flags, however we only two
 *          flags for this project.
 */

#define REL_IN_PIN 10
#define RELAY1_OUT_PIN 7
#define RELAY2_OUT_PIN 8
#define REL_FLAG 2

/*
 * END_IN_PIN:    Input pin receiveing the incoming PWM signal from X8R receiver
 *                (the remote control) that controls the end effector.
 *
 * END_OUT_PIN:   Pin outputting to end effector.
 *
 * END_FLAG:      Bit flag to let the Arduino system know there is a change in the
 *                state of the incoming signal (Changing from HIGH to LOW,
 *                or vice versa).
 */

#define END_IN_PIN 11
#define END_OUT_PIN 2
#define END_FLAG 1

/*
 * bUpdateFlagsShared is the variable that holds the bit flags.
 *
 * **NOTE:  "volatile" keyword tells the compiler to allow this variable to be
 *          modified outside of the MAIN control loop. Normally, the Arduino will
 *          "lock-out" other processes. We need these variables to be open so we can
 *          allow sensors to intrrupt the main loop and modify them.
 */

volatile uint8_t bUpdateFlagsShared;

/*
 * volatile uint16_t usEndInShared: 16-bit, unsigned, integer that stores how long
 *                                  the incloming PWM signalfor the end effector is
 *                                  HIGH. A 16-bit variable is called a 'short'.
 *
 * volatile uint16_t usRelInShared: 16-bit unsigned integer that stores how long the
 *                                  incloming PWM signal for the relay is high.
 *
 * **NOTE:  On the naming convention,
 *          [if unsigned][bits][what it does][if shared (read volatile)]
 *          So, usEndInShared means [unsigned][short][end effector input][shared]
 *
 * **NOTE:  The duty cycle of these servos is 20,000 microseconds. Therefore, an
 *          8-bit, unsigned variable will not work because the maximum value it can
 *          hold is 256. The next size variable available is 16-bits which can store
 *          an unsigned integer between 0 and 65,536.
 */

volatile uint16_t usEndInShared;
volatile uint16_t usRelInShared;

/*
 * uint32_t ulEndStart: [unsigned][long][end effector signal start-time]
 *                      When the Arduino "senses" a change in the end effector input
 *                      pin from LOW to HIGH, the system time in microseconds, is
 *                      saveded to the 32-bit integer variable ulEndStart. More on
 *                      this later in the code.
 *
 * uint32_t ulRelStart: [unsigned][long][relay signal start-time]
 *                      Just like the end effector, this is the variable that saves
 *                      the start-time for the realy controlling the linear actuator
 *
 *                      Later,
 *                      when the signal changes back from HIGH to LOW, the ulEndStart
 *                      is subtracted from the current time. Like a timer, the
 *                      difference gives us the signal time length to tell the end
 *                      effector servo. I
 */

uint32_t ulEndStart;
uint32_t ulRelStart;

/*
 * Servo servoEnd: [class][name of instance]
 *                 Here we are telling the compiler that there will be a instance of
 *                 the Servo class. Creating servoEnd and attaching it to the output
 *                 pin for the end effector will allow us to control the servo in it.
 *                 The methods in the Servo class will handle all of the background
 *                 magic to make it all happen.
 */

Servo servoEnd;

void setup()
{
  /*
   * Start the default serial port at standard baudrate 9600.
   * This opens communication with the serial monitor on
   * the computer connected to the arduino unit through the
   * USB port.
  */
  Serial.begin(9600);

  /*
   * Before we can begin communication to the end effector, we must "attach" the
   * output pin to the instance of the Servo class we created earlier. This will
   * allow us to manipulate the servo.
   */

  servoEnd.attach(END_OUT_PIN);

  /*
   * Because the linear actuator is controlled by two relays, we cannot use the Servo
   * class to manage how we control it. Instead, we must control the relays directly.
   * Don't worry, it's very simple. Much like the Servo class, first we much declare
   * which pins are the outputs for the two relays.
   */

  pinMode(RELAY1_OUT_PIN, OUTPUT);
  pinMode(RELAY2_OUT_PIN, OUTPUT);

  /*
   * This code tells the compiler that we will be listeing to REL_IN_PIN and
   * END_IN_PIN for changes in the signal (remember, LOW to HIGH). When there is a
   * change in signal, execute the function calcRel or calcEnd, respective to the
   * pin.
   */

  PCintPort::attachInterrupt(REL_IN_PIN, calcRel, CHANGE);
  PCintPort::attachInterrupt(END_IN_PIN, calcEnd, CHANGE);
}

void loop() {

  /*
   * static uint16_t usEndIn: [unsigned][short: 16-bit][end effector input]
   * static uint16_t usRelIn: [unsigned][short: 16-bit][end relay input]
   *                          Local variables get created and destroyed every time
   *                          the function they reside in is called, so the value is
   *                          not retained. Making the variable 'static' retains the
   *                          variable through subsequent iterations of the main
   *                          loop, so the value inside is intact.
   *
   * **NOTE:  We will be using these variables to hold copies of the raw input values
   *          from the receiver. We have to hold copies of the input values in
   *          usEndInShared, usRelInShared, and bUpdateFlagsShared because we cannot
   *          guarantee we will have read access to these variables when it comes
   *          time to use them; also, we cannot guarantee the values won't be updated
   *          mid-loop.
   */

  static uint16_t usEndIn;
  static uint16_t usRelIn;

  static uint8_t bUpdateFlags;

  /*
   * This is an if statement. It means
   * if (such and such is true) {
   *     do is...
   *     and this...
   * }
   *
   * In the following statement there is some programming trickery.
   * if(bUpdateFlagsShared), means: if bUpdateFlagsShared has any value other than
   * 0, do the following code. In Arduino, indeed in all of the languages I've
   * encountered, false is represented as 0. So the following code will be executed
   * provided there are bit-flags indicating there are values to process.
   */

  if(bUpdateFlagsShared) {

    /*
     * Remember those copies I mentioned just before? This is where we do it.
     * "noInterrupts()" tells the system that we won't be taking any new values while
     * we make our copies.
     */
    noInterrupts();

    //make a copy of the bit-flags
    bUpdateFlags = bUpdateFlagsShared;

    /*
     * Here we are checking if there is flag for the relay input.
     * "bUpdateFlags & REL_FLAG", is a Bitwise AND operation. The condition checks if
     * there is bit-flag for the relay operation.
     *
     * To visualize:
     *
     * If there was only one flag indicating we had a new input signal for the relay
     *
     * 0  0  1  0    bUpdateFlags
     * 0  0  1  0    REL_FLAG
     * ----------
     * 0  0  1  0    (bUpdateFlags & REL_FLAG) = returned result
     *
     * (4 in binary which is not 0, so the result is TRUE)
     *
     * We now will go and get a copy of the input value for the relay.
     *
     * What if bUpdateFlags was 0?
     *
     * 0  0  0  0    bUpdateFlags
     * 0  0  1  0    REL_FLAG
     * ----------
     * 0  0  0  0    (bUpdateFlags & REL_FLAG) = returned result
     *
     * (0 in binary, so the result is FALSE)
     *
     * What if bUpdateFlags only had a bit flag for the end effector?
     *
     * 0  0  0  1    bUpdateFlags
     * 0  0  1  0    REL_FLAG
     * ----------
     * 0  0  0  0    (bUpdateFlags & REL_FLAG) = returned result
     *
     * (0 in binary, so the result is FALSE)
     */
    if(bUpdateFlags & REL_FLAG)
    {
      usRelIn = usRelInShared;
    }

    if(bUpdateFlags & END_FLAG)
    {
      usEndIn = usEndInShared;
    }

    //We've processed all of the necessary flags. Reset bUpdateFlagsShared to 0 so it
    //can receive new flags from the interrupts.
    bUpdateFlagsShared = 0;

    //resume allowing interrupts to write data.
    interrupts();
  }

  /*
   * Now that we have shiny new values to play with, lets use them to control our
   * end effector and relay.
   *
   * First we check for a flag to process the respective data.
   */

  if(bUpdateFlags & REL_FLAG)
  {
    // This line is commented out because it was used for debug purposes
    // Serial.println(usRelIn);

    /*
     * usRelIn has holds the length of time the input signal was HIGH. If the input
     * signal is HIGH for less than 1100 microseconds, we retract the linear actuator
     * connected to the relay. if the signal is greater than 1900 microseconds, we
     * extend the linear actuator. If the value is anwhere in between, we simply turn
     * both relays off and the linear actuator will not move.
     *
     * digitalWrite(RELAY2_OUT_PIN,1);          // Turns Relay Off
     * digitalWrite(RELAY1_OUT_PIN,0);          // Turns ON Relay 1
     *
     * The linear actuator exends and retracts depending on the polarity of the
     * eletricity flowing to it. To "flip" the polarity, we connected 2 relays in an
     * H-Bridge configuration. Turning relay 1 on and relay 2 off makes the
     * the electricity flow in one direction. if we turn relay 1 off and relay 2 on,
     * the polarity reverses. If we turn both relays off, the circuit is broken and
     * the linear actuator does nothing.
     */

    if(usRelIn < 1100) {
      //sometimes the signal is missed between toggles
      //confirm relay 2 is off. otherwise no movement, relays cancel out
      digitalWrite(RELAY2_OUT_PIN,1);          // Turns Relay Off
      digitalWrite(RELAY1_OUT_PIN,0);          // Turns ON Relay 1
    }
    else if(usRelIn > 1900) {
      //cofnirm relay 1 is off
      digitalWrite(RELAY1_OUT_PIN,1);          // Turns Relay Off
      digitalWrite(RELAY2_OUT_PIN,0);          // Turns ON Relay 2
    }
    else {
      digitalWrite(RELAY1_OUT_PIN,1);          // Turns Relay 1 Off
      digitalWrite(RELAY2_OUT_PIN,1);          // Turns Relay 2 Off
    }
  }

  //check for an end effector flag
  if(bUpdateFlags & END_FLAG)
  {
    /*
     * Here we are checking fit the old value for servoEnd is not equal to the new
     * If there is no change, there is no reason to update the value we are sending
     * to the end effector servo.
     */

    if(servoEnd.readMicroseconds() != usEndIn)
    {
      /*
       * The servo in the end effector can only handle signal values that are natural
       * numbers between 1000 and and 2000. being an unsigned integer automatically
       * handles the natural number part. But what about the upper and lower bounds?
       * Sometimes the receiver will get pulses that are less than 1000 and greater
       * than 2000 (on testing, I received signals ranging from 994 and 2015
       * microseconds). Sending a signal that exceeds the bounds of the servo could
       * damage it. The following conditions automatically set any incoming signal
       * that is excessive or deficient to its respective bound. All other values in
       * between are untouched.
       */
      if(usEndIn < 1000)
        usEndIn = 1000;
      else if(usEndIn > 2000)
        usEndIn = 2000;

      /*
       * The end effector is tough but it's not tough enough to withstand constant
       * pressure from the servo within. We can't limit the servo with conditions
       * like we did before because the dial would only work within conditions
       * So, we have to limit servo yet again witout losing the range of output of
       * the dial controlling the opening and closing of the fingers. If the fingers
       * close too tight, we risk damaging the lower plate, washer, and spacers.
       * If the servo opens too wide, we risk cracking the casing and damaging the
       * lower plate.
       *
       * The solution is to map the values between valid inputs, 1000 and 2000, to a
       * restricted, safe range. After testing, I found the acceptable ranges to be
       * 1220 to 1480.
       */

      usEndIn = map(usEndIn, 1000, 2000, 1220, 1480);

      //print the final output for debugging purposes.
      //Serial.println(usEndIn);

      //And finally, we update the servo with the new signal value, and it will
      //rotate to the new position.
      servoEnd.writeMicroseconds(usEndIn);
    }
  }

  //Now that we've processed the incoming signals, zero out the bit-flag variable
  //so it's ready for the next loop.
  bUpdateFlags = 0;
}

/*
 * These are the functions called when a new inturrupt arrives. Remember these?
 *
 * PCintPort::attachInterrupt(REL_IN_PIN, calcRel, CHANGE);
 * PCintPort::attachInterrupt(END_IN_PIN, calcEnd, CHANGE);
 */

void calcRel()
{

  //if the input signal is HIGH,
  if(digitalRead(REL_IN_PIN) == HIGH)
  {
    //get the current system time in microseconds and save it
    ulRelStart = micros();
  }
  else
  {
    /*
     * Else the signal must be LOW and we can calculate the signal length
     * Get the current system time, subtract the start time we saved earlier,
     * and save the result for processing.
     */
    usRelInShared = (uint16_t)(micros() - ulRelStart);

    //Remove the relay bit flag from the bit-flag variable.
    bUpdateFlagsShared |= REL_FLAG;
  }
}

/*
 * calcEnd does the same thing as calcRel, just with different variables.
 * See the previous function for details.
 */
void calcEnd()
{
  if(digitalRead(END_IN_PIN) == HIGH)
  {
    ulEndStart = micros();
  }
  else
  {
    usEndInShared = (uint16_t)(micros() - ulEndStart);
    bUpdateFlagsShared |= END_FLAG;
  }
}

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


Update pt_remote controlled car2.ino

Update pt_remote controlled car2.ino

pt_remote controlled car/pt_remote controlled car2.ino

error: pathspec 'pt_remote' did not match any file(s) known to git
error: pathspec 'controlled' did not match any file(s) known to git
error: pathspec 'car/pt_remote' did not match any file(s) known to git
error: pathspec 'controlled' did not match any file(s) known to git
error: pathspec 'car2.ino' did not match any file(s) known to git


Update wemos_remote.ino

Update wemos_remote.ino

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


Added runt rover controller code; not tested or debugged.

/*
 * Title: Runt_Rover
 *
 * Author: EEJeffMan
 *
 * Description: Receives joystick direction data from xbee, and drives runt rover motors.
 *
 *    Hardware:
 *        Controller: Arduino pro mini 3.3V
 *        Receiver: Xbee series 1 w/xbee explorer regulated
 *        Motor driver: DROK DC-DC w/dual L298N Motor Driver Module
 *
 *    Motor Driver Module output connections to motors:
 *        OUT1 = back left blk
 *        OUT2 = back left red
 *        OUT3 = front left blk
 *        OUT4 = front left red
 *        OUT5 = front right blk
 *        OUT6 = front right red
 *        OUT7 = rear right blk
 *        OUT8 = rear right red
 *
 *    Arduino I/O:
 *        D2-9: Digital outputs to IN1-8, Motor Driver Module
 *        D10: SW serial RX from xbee explorer, 9600 baud 8N1
 *
 *    Flow:
 *        Read xbee data
 *        Determine desired motor drive
 *        Update drive to motors
 *
 * Status:
 *
 */

#include <SoftwareSerial.h>

#define XBEE_COMMAND_STOP           0
#define XBEE_COMMAND_FORWARD        8
#define XBEE_COMMAND_FORWARD_LEFT   9
#define XBEE_COMMAND_FORWARD_RIGHT  10
#define XBEE_COMMAND_REVERSE        4
#define XBEE_COMMAND_REVERSE_LEFT   5
#define XBEE_COMMAND_REVERSE_RIGHT  6
#define XBEE_COMMAND_TURN_LEFT      1
#define XBEE_COMMAND_TURN_RIGHT     2

#define FULL_SPEED                  50
#define TURN_SPEED                  25

#define LEFT_MOTORS                 0
#define RIGHT_MOTORS                1

#define MOTOR_OFF                   11
#define MOTOR_FORWARD_FULL          22
#define MOTOR_FORWARD_TURN          33
#define MOTOR_REVERSE_FULL          44
#define MOTOR_REVERSE_TURN          55

SoftwareSerial xbee(10,A4);   //RX, TX

/*
 * array 0 = left, array 1 = right
 *
 * PWM can only be on pins 3, 5, 6, 9, and 10, use all but 10 for PWM:
 * 2 = front left a
 * 3 = front left en
 * 4 = front right a
 * 5 = front right en
 * 6 = rear right en
 * 7 = rear right a
 * 8 = rear left a
 * 9 = rear left en
 * A0 = front left b
 * A1 = front right b
 * A2 = rear right b
 * A3 = rear left b
 */
unsigned int front_motor_a[2] = {2, 4};
unsigned int front_motor_b[2] = {A0, A1};
unsigned int rear_motor_a[2] = {8, 7};
unsigned int rear_motor_b[2] = {A3, A2};
unsigned int front_motor_en[2] = {3, 5};
unsigned int rear_motor_en[2] = {9, 6};

unsigned int motor_state[2];

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);

  // xbee data input
  xbee.begin(9600);

  // motor drive outputs
  pinMode(front_motor_a[LEFT_MOTORS], OUTPUT);
  pinMode(front_motor_a[RIGHT_MOTORS], OUTPUT);
  pinMode(front_motor_b[LEFT_MOTORS], OUTPUT);
  pinMode(front_motor_b[RIGHT_MOTORS], OUTPUT);
  pinMode(rear_motor_a[LEFT_MOTORS], OUTPUT);
  pinMode(rear_motor_a[RIGHT_MOTORS], OUTPUT);
  pinMode(rear_motor_b[LEFT_MOTORS], OUTPUT);
  pinMode(rear_motor_b[RIGHT_MOTORS], OUTPUT);

  Serial.println("Begin.");
}

void loop() {
  // put your main code here, to run repeatedly:
    unsigned int i;
    unsigned int xbee_command;

    delay(500);    // TODO: Replace this with something more deterministic, perhaps based on a timer.

    // read xbee data and update motor states
    xbee_command = xbee.read();
    Serial.print("Command = ");
    Serial.println(xbee_command, DEC);
    switch(xbee_command)
    {
      case XBEE_COMMAND_STOP:
        // stop position: all off
        motor_state[LEFT_MOTORS] = MOTOR_OFF;
        motor_state[RIGHT_MOTORS] = MOTOR_OFF;
      break;

      case XBEE_COMMAND_FORWARD:
        // forward position: all forward full speed
        motor_state[LEFT_MOTORS] = MOTOR_FORWARD_FULL;
        motor_state[RIGHT_MOTORS] = MOTOR_FORWARD_FULL;
      break;

      case XBEE_COMMAND_FORWARD_LEFT:
        // forward left: left motors forward turn speed, right motors forward full speed
        motor_state[LEFT_MOTORS] = MOTOR_FORWARD_TURN;
        motor_state[RIGHT_MOTORS] = MOTOR_FORWARD_FULL;
      break;

      case XBEE_COMMAND_FORWARD_RIGHT:
        // forward right: left motors forward full speed, right motors forward turn speed
        motor_state[LEFT_MOTORS] = MOTOR_FORWARD_FULL;
        motor_state[RIGHT_MOTORS] = MOTOR_FORWARD_TURN;
      break;

      case XBEE_COMMAND_REVERSE:
        // reverse position: all reverse full speed
        motor_state[LEFT_MOTORS] = MOTOR_REVERSE_FULL;
        motor_state[RIGHT_MOTORS] = MOTOR_REVERSE_FULL;
      break;

      case XBEE_COMMAND_REVERSE_LEFT:
        // reverse left: left motors reverse turn speed, right motors reverse full speed
        motor_state[LEFT_MOTORS] = MOTOR_REVERSE_TURN;
        motor_state[RIGHT_MOTORS] = MOTOR_REVERSE_FULL;
      break;

      case XBEE_COMMAND_REVERSE_RIGHT:
        // reverse right: left motors reverse full speed, right motors reverse turn speed
        motor_state[LEFT_MOTORS] = MOTOR_REVERSE_FULL;
        motor_state[RIGHT_MOTORS] = MOTOR_REVERSE_TURN;
      break;

      case XBEE_COMMAND_TURN_LEFT:
        // turn left position: left motors reverse full speed, right motors forward full speed
        motor_state[LEFT_MOTORS] = MOTOR_REVERSE_FULL;
        motor_state[RIGHT_MOTORS] = MOTOR_FORWARD_FULL;
      break;

      case XBEE_COMMAND_TURN_RIGHT:
        // turn right position: left motors forward full speed, right motors reverse full speed
        motor_state[LEFT_MOTORS] = MOTOR_FORWARD_FULL;
        motor_state[RIGHT_MOTORS] = MOTOR_REVERSE_FULL;
      break;

      default:
        // default is stop: all off
        motor_state[LEFT_MOTORS] = MOTOR_OFF;
        motor_state[RIGHT_MOTORS] = MOTOR_OFF;
      break;
    }

    // read motor states and drive motors
    for(i = 0; i < 2; i++)
    {
      switch(motor_state[i])
      {
        // drive motors: forward: a = high, b = low; reverse: a = low, b = high; off: both low
        case MOTOR_OFF:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], LOW);
          analogWrite(front_motor_en[i], 0);
          analogWrite(rear_motor_en[i], 0);
        break;

        case MOTOR_FORWARD_FULL:
          digitalWrite(front_motor_a[i], HIGH);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], HIGH);
          digitalWrite(rear_motor_b[i], LOW);
          analogWrite(front_motor_en[i], FULL_SPEED);
          analogWrite(rear_motor_en[i], FULL_SPEED);
        break;

        case MOTOR_FORWARD_TURN:
          digitalWrite(front_motor_a[i], HIGH);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], HIGH);
          digitalWrite(rear_motor_b[i], LOW);
          analogWrite(front_motor_en[i], TURN_SPEED);
          analogWrite(rear_motor_en[i], TURN_SPEED);
        break;

        case MOTOR_REVERSE_FULL:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], HIGH);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], HIGH);
          analogWrite(front_motor_en[i], FULL_SPEED);
          analogWrite(rear_motor_en[i], FULL_SPEED);
        break;

        case MOTOR_REVERSE_TURN:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], HIGH);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], HIGH);
          analogWrite(front_motor_en[i], TURN_SPEED);
          analogWrite(rear_motor_en[i], TURN_SPEED);
        break;

        default:
          digitalWrite(front_motor_a[i], LOW);
          digitalWrite(front_motor_b[i], LOW);
          digitalWrite(rear_motor_a[i], LOW);
          digitalWrite(rear_motor_b[i], LOW);
          analogWrite(front_motor_en[i], 0);
          analogWrite(rear_motor_en[i], 0);
        break;
      }
    }
}

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


Add simple Arduino test program

Add simple Arduino test program

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Keyboard.begin();
  //setup buttons
  pinMode(2, INPUT_PULLUP); //Button 1
  pinMode(3, INPUT_PULLUP); //Button 2
  pinMode(4, INPUT_PULLUP); //Button 3
  pinMode(5, INPUT_PULLUP); //Button 4
  //setup mainboard connection
  pinMode(6, OUTPUT); //Reset pin
  digitalWrite(6, LOW); //active high pulse
  pinMode(7, OUTPUT); //Power on pin
  digitalWrite(7, LOW); //active high pulse
  //setup coin detector
  pinMode(8, INPUT_PULLUP); //Coin 1
  pinMode(9, INPUT_PULLUP); //Coin 2
  pinMode(10, INPUT_PULLUP); //Coin 3
  pinMode(11, INPUT_PULLUP); //Reject button
  pinMode(12, OUTPUT); //Accept all coins
  digitalWrite(12, LOW);
}

void loop() {
  // read the input pin:
  int buttonState2 = digitalRead(2);
  int buttonState3 = digitalRead(3);
  int buttonState4 = digitalRead(4);
  int buttonState5 = digitalRead(5);
  int buttonState8 = digitalRead(8);
  int buttonState9 = digitalRead(9);
  int buttonState10 = digitalRead(10);
  int buttonState11 = digitalRead(11);
  // print out the state of the buttons:
  Serial.print(buttonState2);
  Serial.print(buttonState3);
  Serial.print(buttonState4);
  Serial.print(buttonState5);
  Serial.print(buttonState8);
  Serial.print(buttonState9);
  Serial.print(buttonState10);
  Serial.print(buttonState11);
  Serial.print('\n');
  delay(25);        // delay in between reads for stability
  if(buttonState2 == LOW) {
    Keyboard.write('A');
    digitalWrite(6, HIGH); //push reset
  }
  else {
    digitalWrite(6, LOW);
  }
  if(buttonState3 == LOW) {
    Keyboard.write('B');
    digitalWrite(7, HIGH); //push power
  }
  else {
    digitalWrite(7, LOW);
  }
  if(buttonState4 == LOW) {
    Keyboard.write('C');
  }
  if(buttonState5 == LOW) {
    Keyboard.write('D');
  }
  if(buttonState8 == LOW) {
    Keyboard.write('1');
  }
  if(buttonState9 == LOW) {
    Keyboard.write('2');
  }
  if(buttonState10 == LOW) {
    Keyboard.write('3');
  }
}

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


Added code to control one BLDC to the motion sensor board test 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/ocean-x/erikson-1.git/'


library test

library test

#include "Arduino.h"
#include "NewPing.h"

// defines pins numbers
const uint8_t trigPin = 9;
const uint8_t echoPin = 10;
const uint8_t maxSenstorDistance = 200; // cm

const uint8_t motorPin1_1 = 4;
const uint8_t motorPin1_2 = 5;
const uint8_t motorPin1_speed = 3;
const uint8_t motorPin1_A = A7;

const uint8_t motorPin2_1 = 7;
const uint8_t motorPin2_2 = 8;
const uint8_t motorPin2_speed = 6;
const uint8_t motorPin2_A = A6;

/*
const uint8_t motorPin3_1 = 10;
const uint8_t motorPin3_2 = 11;
const uint8_t motorPin3_speed = 9;
const uint8_t motorPin3_A = A5;
*/

const uint8_t rangeLimit = 15;

bool spinCompleted = true;
uint8_t nullResultCount = 0;

NewPing sensor1(trigPin, echoPin, maxSenstorDistance);

void setup()
{
    // Motor
    pinMode(motorPin1_1, OUTPUT);
    pinMode(motorPin1_2, OUTPUT);
    pinMode(motorPin1_speed, OUTPUT);
    pinMode(motorPin1_A, INPUT);

    pinMode(motorPin2_1, OUTPUT);
    pinMode(motorPin2_2, OUTPUT);
    pinMode(motorPin2_speed, OUTPUT);
    pinMode(motorPin2_A, INPUT);

    /*
    pinMode(motorPin3_1, OUTPUT);
    pinMode(motorPin3_2, OUTPUT);
    pinMode(motorPin3_speed, OUTPUT);
    pinMode(motorPin3_A, INPUT);
	*/

    Serial.begin(9600); // Starts the serial communication
}

void SetMotor(int pinSpeed, int pin1, int pin2, int speed)
{
    analogWrite(pinSpeed, abs(speed));
    if (speed < 0)
    {
        analogWrite(pin1, 0);
        analogWrite(pin2, 255);
    }
    else
    {
        analogWrite(pin1, 255);
        analogWrite(pin2, 0);
    }

    if (speed == 0)
    {
        analogWrite(pin1, 0);
        analogWrite(pin2, 0);
    }
}

void loop()
{
	long range = sensor1.ping_cm()
	if (range == 0)
	{
		nullResultCount++;
		if(nullResultCount < 10)
		{
			delay(30);
			return;
		}
	}

	// obstacle is further away than X cm
	if(spinCompleted && range > 0 && range > rangeLimit)
	{
		nullResultCount = 0;

		// drive
	    SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, 255);
	    SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, 255);
    	//SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, 0);
	}
	else
	{
		spinCompleted = false;

		// rotate
	    SetMotor(motorPin1_speed, motorPin1_1, motorPin1_2, 255);
    	SetMotor(motorPin2_speed, motorPin2_1, motorPin2_2, 0);
    	//SetMotor(motorPin3_speed, motorPin3_1, motorPin3_2, 0);

    	if(range > (rangeLimit * 2))
    	{
    		spinCompleted = true;
    	}
	}

	delay(50);  // 29ms should be min between scans
}

error: pathspec 'testing/arduino/self-driving-lib.ino' did not match any file(s) known to git


Added Button ADC Tester

Added Button ADC Tester

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


Add MT9M034 RAW catpure example

Add MT9M034 RAW catpure example

// ArduCAM demo (C)2018 Lee
// Web: http://www.ArduCAM.com
// This program is a demo of how to use most of the functions
// of the library with a supported camera modules.
// This demo was made for MT9M034 sensor.
// It will turn the ArduCAM into a real digital camera with capture and playback functions.
// 1.Continuous shooting and store the image to Micro SD/TF card with RAW format.
//IF the FRAMES_NUM is 0X00, take one photos
//IF the FRAMES_NUM is 0X01, take two photos
//IF the FRAMES_NUM is 0X02, take three photos
//IF the FRAMES_NUM is 0X03, take four photos
//IF the FRAMES_NUM is 0X04, take five photos
//IF the FRAMES_NUM is 0X05, take six photos
//IF the FRAMES_NUM is 0X06, take seven photos
//IF the FRAMES_NUM is 0X07, continue shooting until the FIFO is full
// This program requires the ArduCAM V4.0.0 (or above) library and ArduCAM shield V2
// and use Arduino IDE 1.6.8 compiler or above

#define   FRAMES_NUM    0x07
#include <SD.h>
#include <Wire.h>
#include <ArduCAM.h>
#include <SPI.h>

#if !(defined (MT9M034_CAM))
#error This demo can only support  MT9M034_CAM.
#endif
#if !(defined ARDUCAM_SHIELD_V2 && defined MT9M034_CAM )
#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file
#endif

#define SD_CS 9
const int SPI_CS = 10;

ArduCAM myCAM(MT9M034, SPI_CS);
uint32_t length = 0;
char str[8];
void setup()
{
  uint16_t vid;
  uint8_t temp = 0;
  Wire.begin();
  Serial.begin(115200);
  Serial.println(F("ArduCAM Start!"));
  // set the SPI_CS as an output:
  pinMode(SPI_CS, OUTPUT);
  // initialize SPI:
  SPI.begin();
  while (1) {
    //Check if the ArduCAM SPI bus is OK
    myCAM.write_reg(ARDUCHIP_TEST1, 0x55);
    temp = myCAM.read_reg(ARDUCHIP_TEST1);
    if (temp != 0x55) {
      Serial.println(F("SPI interface Error!"));
      delay(1000); continue;
    } else {
      Serial.println(F("SPI interface OK!")); break;
    }
  }
  myCAM.InitCAM();
  myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM);
  //Initialize SD Card
  while (!SD.begin(SD_CS)) {
    Serial.println(F("SD Card Error")); delay(1000);
  }
  Serial.println(F("SD Card detected!"));
}
void loop()
{
  GrabImage(str);
}
void GrabImage(char* str)
{
  File outFile;
  char VL;
  byte buf[256];
  static int k = 0;
  //Flush the FIFO
  myCAM.flush_fifo();
  //Start capture
  myCAM.start_capture();
  Serial.println(F("Start Capture"));
  //Polling the capture done flag
  while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK));
  length = myCAM.read_fifo_length();
  Serial.print(F("The fifo length is :"));
  Serial.println(length, DEC);
  int PIC_CNT = length / 1233920; //1233920 = 1280*960
  Serial.println(PIC_CNT, DEC);
  Serial.println(F("Capture Done."));
  while (PIC_CNT--) {
    k = k + 1;
    itoa(k, str, 10);
    strcat(str, ".raw");      //Generate file name
    static int k = 0;
    int i, j = 0;
    outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC);
    if (! outFile)
    {
      Serial.println(F("File open error"));
      return;
    }
    Serial.println("Writting the image data in RAW format...");
    k = 0;
    //Read 1280x960 byte from FIFO
    //Save as RAW format
    for (i = 0; i < 1280; i++)
      for (j = 0; j < 964; j++)
      {
        VL = myCAM.read_fifo();
        buf[k++] = VL;
        //Write image data to bufer if not full
        if (k >= 256)
        {
          //Write 256 bytes image data to file from buffer
          outFile.write(buf, 256);
          k = 0;
        }
      }
    //Close the file
    outFile.close();
  }
  //Clear the capture done flag
  myCAM.clear_fifo_flag();
  Serial.println("Image save OK!");
  return;
}

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


add arduino code

add arduino code

// set pin numbers:
const int button1Pin = 2;     // the number of the pushbutton pin
const int button2Pin = 7;
const int button3Pin = 12;
const int button4Pin = 13;

const int led1Pin =  4;       // the number of the LED pin
const int led2Pin =  8;
const int led3Pin =  10;
const int led4Pin =  11;

bool button1Active = true;
int button1State = 0;         // variable for reading the pushbutton status

bool button2Active = true;
int button2State = 0;

bool button3Active = true;
int button3State = 0;

bool button4Active = true;
int button4State = 0;

String writeBuffer;
String readBuffer;

void setup() {
  // initialize the LED pin as an output:
  pinMode(led1Pin, OUTPUT);
  pinMode(led2Pin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(button1Pin, INPUT);
  pinMode(button2Pin, INPUT);
  // initialize serial communication:
  Serial.begin(9600);
}

void serialEvent() {
  readBuffer = Serial.readString();
  Serial.println("------------");
  Serial.println(readBuffer);
  Serial.println("------------");
  if (readBuffer.length() == 4) {
    button1Active = readBuffer.charAt(0) == '0' ? false : true;
    button2Active = readBuffer.charAt(1) == '0' ? false : true;
    button3Active = readBuffer.charAt(2) == '0' ? false : true;
    button4Active = readBuffer.charAt(3) == '0' ? false : true;
  }
}

void loop() {
  // read the state of the pushbutton value:
  button1State = digitalRead(button1Pin);
  button2State = digitalRead(button2Pin);
  button3State = digitalRead(button3Pin);
  button4State = digitalRead(button4Pin);

  if (button1Active == true) {
    // check if the pushbutton is pressed.
    // if it is, the buttonState is HIGH:
    if (button1State == HIGH) {
      // turn LED on:
      digitalWrite(led1Pin, HIGH);
    } else {
      // turn LED off:
      digitalWrite(led1Pin, LOW);
    }
  }

  if (button2Active == true) {
    if (button2State == HIGH) {
      digitalWrite(led2Pin, HIGH);
    } else {
      digitalWrite(led2Pin, LOW);
    }
  }

  if (button3Active == true) {
    if (button3State == HIGH) {
      digitalWrite(led3Pin, HIGH);
    } else {
      digitalWrite(led3Pin, LOW);
    }
  }

  if (button4Active == true) {
    if (button4State == HIGH) {
      digitalWrite(led4Pin, HIGH);
    } else {
      digitalWrite(led4Pin, LOW);
    }
  }

  // send button status
  writeBuffer = String(button1Active) + String(button1State)
                + String(button2Active) + String(button2State)
                + String(button3Active) + String(button3State)
                + String(button4Active) + String(button4State);
  Serial.println(writeBuffer);
}

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


second

second

  void setup() {
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
}

  void loop() {
  digitalWrite(8, HIGH);
  delay(1000);
  digitalWrite(7, HIGH);
  delay(1000);
  digitalWrite(8, LOW);
  delay(1000);
  digitalWrite(7, LOW);
  delay(1000);
 }

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


Build test sketch

Build test sketch

/**************************************************************
 * This is just a test of Blynk library build in Arduino IDE
 *
 *         You should NOT flash this program
 *         to your hardware or try to run it.
 *
 **************************************************************/

#if defined(ARDUINO_AVR_GEMMA) \
    || defined(ARDUINO_attiny)

  #define BLYNK_NO_INFO
  #define BLYNK_NO_BUILTIN

  #define SKIP_WRITES_TEST

#endif

#include <BlynkSimpleUserDefined.h>

char auth[] = "12345678901234567890123456789012";

volatile uint8_t test;

// This function is used by Blynk to receive data
size_t BlynkStreamRead(void* buf, size_t len)
{
  uint8_t* byte_buff = (uint8_t*)buf;
  size_t res = len;
  while (len--) {
    *byte_buff++ = test;
  }
  return res;
}

// This function is used by Blynk to send data
size_t BlynkStreamWrite(const void* buf, size_t len)
{
  uint8_t* byte_buff = (uint8_t*)buf;
  size_t res = len;
  while (len--) {
    test = *byte_buff++;
  }
  return res;
}

void setup()
{
  Blynk.begin(auth);
  Blynk.connect();
}

BLYNK_WRITE(V3)
{
  test = param.asInt();
}

BLYNK_READ(V4)
{
  Blynk.virtualWrite(V10, millis(), BlynkFreeRam());

  Blynk.virtualWrite(V10, 1,   1U);
  Blynk.virtualWrite(V10, 1L,  1UL);
  Blynk.virtualWrite(V10, 1LL, 1ULL);

#ifndef SKIP_WRITES_TEST

  Blynk.virtualWrite(V10,  (int8_t)1,  (uint8_t)1);
  Blynk.virtualWrite(V10, (int16_t)1, (uint16_t)1);
  Blynk.virtualWrite(V10, (int32_t)1, (uint32_t)1);
  //Blynk.virtualWrite(V10, (int64_t)1, (uint64_t)1);

  Blynk.virtualWrite(V10, (size_t)1);

  Blynk.virtualWrite(V10, (float)1.0F);
  Blynk.virtualWrite(V10, (double)1.0);

  Blynk.virtualWrite(V10, String("Some string as String)"));
  Blynk.virtualWrite(V10, "Some string from RAM");

  Blynk.virtualWrite(V10, BLYNK_F("Some string from Flash"));

  BlynkParamAllocated param(128);
  Blynk.virtualWrite(V10, param);

  Blynk.virtualWriteBinary(V10, "buffer", 6);

#endif

}

void loop()
{
  bool hasIncomingData = (test > 0);

  if (!Blynk.run(hasIncomingData)) {

  }
}

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


Add user button input to 7segment

Add user button input to 7segment

Remove infinite loop through numbers. Accept user button input to display next number

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


Add button example

Add button example

error: pathspec 'Arduino' did not match any file(s) known to git
error: pathspec 'Libraries/KBOT/examples/Button/Button.ino' did not match any file(s) known to git


src: start to rough in mqtt LED control

src: start to rough in mqtt LED control

// Copyright 2016-2017 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 <Wire.h>
#include <Adafruit_NeoPixel.h>

// device specifics
#include "WirelessConfig.h"

#define LED_PIN D6
#define LED_TOPIC "house/led"

WiFiClient wclient;
ESP8266WiFiGenericClass wifi;

const char* OFF = "off";
const char* RANGE = "range";

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, LED_PIN, NEO_GRB + NEO_KHZ800);

void callback(char* topic, uint8_t* message, unsigned int length) {
  std::string messageBuffer((const char*) message, length);
  Serial.println(messageBuffer.c_str());

  if (0 == strcmp(messageBuffer.c_str(), OFF)) {
    for(uint16_t i=0; i <strip.numPixels(); i++) {
      strip.setPixelColor(i, strip.Color(0,0,0));
    }
  } else if (0 == strncmp(RANGE, messageBuffer.c_str(), strlen(RANGE))) {
    char* next = strtok((char*) messageBuffer.c_str()," ");
    next = strtok(nullptr," ");
    int start = atoi(next);
    next = strtok(nullptr," ");
    int end = atoi(next);
    next = strtok(nullptr," ");
    int R = atoi(next);
    next = strtok(nullptr," ");
    int G = atoi(next);
    next = strtok(nullptr," ");
    int B = atoi(next);
    if ((start < 0)  ||
        (start >= strip.numPixels()) ||
        (end >= strip.numPixels()) ||
        (end < 0) ||
        (end >= strip.numPixels()) ||
        (end < 0) ||
        (R > 255) ||
        (R < 0) ||
        (G > 255) ||
        (G < 0) ||
        (B > 255) ||
        (B < 0)) {
      Serial.println("Message Invalid");
      return;
    }

    end = end + 1;
    for(uint16_t i = start; i < end; i++) {
      strip.setPixelColor(i, strip.Color(R, G, B));
    }
  } else {
    Serial.println("Message Invalid");
    return;
  }

  strip.show();
};

PubSubClient client(mqttServerString, mqttServerPort, callback, wclient);

void setup() {
  strip.begin();
  for(uint16_t i=0; i <strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(0,0,0));
  }
  strip.show(); // Initialize all pixels to 'off'

  Serial.begin(115200);
  Serial.println("starting");

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

  WiFi.begin(ssid, pass);
  if (WiFi.waitForConnectResult() == WL_CONNECTED) {
    Serial.println("WiFi connected");
  }
}

int count = 0;

void loop() {
  client.loop();

  // make sure we are good for wifi
  if (WiFi.status() != WL_CONNECTED) {
    Serial.print("Connecting to ");
    Serial.println(ssid);
    WiFi.reconnect();

    if (WiFi.waitForConnectResult() != WL_CONNECTED) {
      Serial.println("Failed to reconnect WIFI");
      Serial.println(WiFi.waitForConnectResult());
      delay(100);
      return;
    }
    Serial.println("WiFi connected");
  }

  if (!client.connected()) {
    Serial.println("PubSub not connected");
    if (client.connect("irclient")) {
      Serial.println("PubSub connected");
      client.subscribe(LED_TOPIC);
    } else {
      Serial.println("PubSub failed to connect");
    }
  }

  delay(100);
}

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


Initial commit

Initial commit


Added Motor Code

Added Motor Code

3 axis multi-axis support
note: joysticks are meant to be mounted at 45 degree angle in control
box

/*
  Receiving Motor Code
  Attempt 1 of mutliaxis support in order to make JP happy

  Written for the Sea Sweepers ROV Club
  Michael Georgariou 2016
*/

#include <Servo.h>
Servo H1;
Servo H2;
Servo H3;
Servo H4;
Servo V1;
Servo V2;
Servo V3;
Servo V4;

int Joystick1A; //vertical
  int 1AMap;
int Joystick1B;
  int 1BMap;
int Joystick1C;
  int 1CMap;
int Joystick2A; //horizontal
  int 2AMap;
int Joystick2B;
  int 2BMap;
int Joystick2C;
  int 2CMap;

int Crab;
int Pitch;

void setup() {

  H1.attach(2); // left front
  H2.attach(3); // right front
  H3.attach(4); // right back
  H4.attach(5); // left back
  V1.attach(6);
  V2.attach(7);
  V3.attach(8);
  V4.attach(9);
}

void loop() {
  1AMap = map(Joystick1A, 0, 1023, 1100, 1900);
  1BMap = map(Joystick1B, 0, 1023, 1100, 1900);
  1CMap = map(Joystick1C, 0, 1023, 1100, 1900);
  2AMap = map(Joystick2A, 0, 1023, 1100, 1900);
  2BMap = map(Joystick2B, 0, 1023, 1100, 1900);
  2CMap = map(Joystick2C, 0, 1023, 1100, 1900);

  if ((2CMap < 1600) && (2CMap > 1400)) { //if 2CMap is neutral
    H2.write(2AMap);
    H3.write(2AMap);
    H1.write(2BMap);
    H4.write(2BMap);
  }

  if (2CMap > 1600) {
    Crab = map(2CMap, 1600, 1900, 0, 400);
    if ((2AMap - Crab) > 1100){
      H2.write(2AMap + Crab);
      H3.write(2AMap + Crab);
    }
    else {
      H2.write(2AMap);
      H3.write(2AMap);
    }
    if ((2BMap + Crab) < 1900) {
      H1.write(2BMap - Crab);
      H4.write(2BMap - Crab);
    }
    else {
      H1.write(2BMap);
      H4.write(2BMap);
    }
  }

  if (2CMap < 1400) {
    Crab = map(2CMap, 1400, 1100, 0, 400);
    if ((2AMap - Crab) > 1100){
      H2.write(2AMap - Crab);
      H3.write(2AMap - Crab);
    }
    else {
      H2.write(2AMap);
      H3.write(2AMap);
    }
    if ((2BMap + Crab) < 1900) {
      H1.write(2BMap + Crab);
      H4.write(2BMap + Crab);
    }
    else {
      H1.write(2BMap);
      H4.write(2BMap);
    }
  }

  if ((1CMap < 1600) && (1CMap > 1400)) { //if 2CMap is neutral
    V2.write(1AMap);
    V3.write(1AMap);
    V1.write(1BMap);
    V4.write(1BMap);
  }
  if (1CMap > 1600) {
    Pitch = map(1CMap, 1600, 1900, 0, 400);
    if ((2AMap + Pitch) < 1900){
      H1.write(2AMap + Pitch);
      H2.write(2AMap + Pitch);
    }
    else {
      H1.write(2AMap);
      H2.write(2AMap);
    }
    if ((2BMap - Pitch) > 1100) {
      H3.write(2BMap - Pitch);
      H4.write(2BMap - Pitch);
    }
    else {
      H3.write(2BMap);
      H4.write(2BMap);
    }
  }

  if (2CMap < 1400) {
    Pitch = map(2CMap, 1400, 1100, 0, 400);
    if ((2AMap - Pitch) > 1100){
      H1.write(2AMap - Pitch);
      H2.write(2AMap - Pitch);
    }
    else {
      H1.write(2AMap);
      H2.write(2AMap);
    }
    if ((2BMap + Pitch) < 1900) {
      H3.write(2BMap + Pitch);
      H4.write(2BMap + Pitch);
    }
    else {
      H3.write(2BMap);
      H4.write(2BMap);
    }
  }
}

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


Base code

Base code

Uses simple random number to randomly fade the colour red in and out. Need to compartmentalize the mechanism into a function and add green and blue.

// Salt Lamp neopixel lights random colour crossfade
// By Chris Barrett - Polaris Interplanetary - Special Projects Division

#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      133
#define LOWPIXELS      87

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second
int potVal = 9;                                     //integer to store the value from the potentiometer
int potPin = 2;                                     //integer to store the potentiometer pin
int rcount;                                         // Counter for red
int gcount;                                         // Counter for green
int bcount;                                         // Counter for blue
int rval;                                           //int stores red brightness
int gval;                                           //int stores green brightness
int bval;                                           //int stores blue brightness
int rgo;                                            // red go int, 0 for off, 1 for upwards, 2 for downwards
int ggo;                                            // green go int, 0 for off, 1 for upwards, 2 for downwards
int bgo;                                            // blue go int, 0 for off, 1 for upwards, 2 for downwards
int magicnumber;                                    // magic number determines when to fire colours

void setup() {

Serial.begin(9600);
  pixels.begin();                                   // This initializes the NeoPixel library.
}

void loop() {

magicnumber = random(0,3);                          //creates a magic number

if (magicnumber == 1 && rgo == 0){                  //checks to see if magic number has selected red and red is not currently firing
  rgo = 1;                                          //sets the red go bit to 1 meaning positive alternation
}

if (magicnumber == 2 && ggo == 0){                   //checks to see if magic number has selected green
  ggo = 1;
}

if (magicnumber == 1 && bgo == 0){                   //checks to see if magic number has selected blue
  bgo = 1;
}

if (rgo == 1){                                      //checks for ascent stage bit, adds one to red brightness
  rval = rval + 1;
}

if (rgo == 2){
  rval = rval - 1;
}

if (rval >= 255){
  rgo == 2;
}

if (rval == 0 && rgo == 2){
  rgo = 0;
  rval = 0;
}

potVal = analogRead(potPin);                     //determine delay
potVal = map(potVal, 0, 1024, 0, 500);

for(int i=LOWPIXELS;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(rval,bval,gval));
}

pixels.show(); // This sends the updated pixel color to the hardware.

Serial.println(rval);

delay(potVal);
}

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


MQ7 rewritten, interrupt only, 4s interval

see worklong in Google Drive for details

error: pathspec 'Individual' did not match any file(s) known to git
error: pathspec 'sensor' did not match any file(s) known to git
error: pathspec 'rewritten/MQ7.ino' did not match any file(s) known to git


Fixed encoder demo index functionality. Needs its own interrupt.

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


Create RedBear_Duo_BLE.ino

Create RedBear_Duo_BLE.ino

/**************************************************************
 * 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 RedBear Duo BLE
 * to connect your project to Blynk.
 *
 * NOTE: BLE support is in beta!
 *
 **************************************************************/

#if defined(ARDUINO)
  SYSTEM_MODE(MANUAL);    // If Arduino - do not connect to Particle cloud
#else
  SYSTEM_MODE(AUTOMATIC); // Otherwise, connect to Particle cloud
#endif

//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial

//#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleRedBear_Duo_BLE.h>

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

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

  Blynk.begin(auth);

  Serial.println("Waiting for connections...");
}

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

// Next functions are optional.
// Add ZeRGBa Widget on V0 to control onboard LED.
BLYNK_CONNECTED() {
  RGB.control(true);
}

BLYNK_WRITE(V0) {
  int r = param[0].asInt();
  int g = param[1].asInt();
  int b = param[2].asInt();
  RGB.color(r, g, b);
}

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


Arduino - LED brightness.

Arduino - LED brightness.

/**
 * Copyright (c) 2020, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com>
 * Arduino/006
 * Blinking LED with BasicLED class.
 */

#include <stdint.h>

/**
 * The instance of this class can control single LED.
 * - on, off, toggle (any digital pin)
 * - brightness (only PWM pins; i.e. for Arduino Uno: 3, 5, 6, 9, 10, 11)
 */
class BasicLed {
public:
  BasicLed(uint8_t pin): pin_(pin) {
    pinMode(pin, OUTPUT);
  }
  /**
   * Light the LED up
   */
  void on(void) {
    digitalWrite(pin_, HIGH);
  }
  /**
   * Turn the LED off
   */
  void off(void) {
    digitalWrite(pin_, LOW);
  }
  /**
   * Toogle LED on/off
   */
  void toggle(void) {
    digitalWrite(pin_, !digitalRead(pin_));
  }
  /**
   * Set LED brightness from range <0, 255>
   */
  void setBrightness(uint8_t value) {
    analogWrite(pin_, value);
  }
private:
  uint8_t pin_;
}; /* End of class BasicLed */

BasicLed led(11);

void setup() {
  // do nothing
}

void loop() {
    led.setBrightness(10); // 10/255 ~= 4%
}

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


4D display working

4D display working

#define DisplaySerial Serial

#include "Picaso_Serial_4DLib.h"
#include "BigDemo.h"
#include "Picaso_Const4D.h"

void setup()
{
  pinMode(13,OUTPUT);
  pinMode(RESETLINE, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
  digitalWrite(RESETLINE, 1);  // Reset the Display via D4
  delay(100);
  digitalWrite(RESETLINE, 0);  // unReset the Display via D4
  delay(5000);
    DisplaySerial.begin(9600) ;
  Display.TimeLimit4D   = 5000 ; // 5 second timeout on all commands
  Display.gfx_Cls() ;
    Display.putstr("Lunokhod loading...") ;
}

void loop()
{

}

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


Create ArduinoButtonServer.ino

Create ArduinoButtonServer.ino

// This sends the state of a button, connected between the pin and GROUND to the serial connection
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
boolean firstPushed = true;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(57600);
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed.
  // if the button is not pushed the state is 'HIGH', it's more stable I guess.... pullup something
  if (buttonState == HIGH) {
    Serial.println("1");
    firstPushed = true;
  }
  else {
    // turn LED off:
    if(firstPushed){
      Serial.println("2");
      firstPushed = false;
    }
    else{
      Serial.println("3");
    }

  }

}

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


Minor fixes

Minor fixes

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/Denzo77/OTRadioLink.git/'


Started to create a version for testing on Gemma.

/* NFC.ino  02/04/2015  D.J.Whale
 *
 * Please note: This program is a hardware test program only.
 * It was written under extreme time pressure, and should only
 * be used as a reference that defines a set of sequences that
 * are known to work with the boards listed below. It is not
 * in any way a representation of good programming practice...
 * ... that takes more than a couple of hours to achieve.
 *
 * Test program for Arduino Uno to read a URI NDEF record from M24SR.
 * Wire up a X-NUCLEO-NFC01A1 to the SCL/SCA pins.
 * Download this program and run it.
 * On the serial monitor, you should see a series of trace messages
 * for each step, plus the URL near the end that is read back from the
 * NDEF record.
 * If you get loads of 00 or FF data back, you probably don't have
 * 4.7K pullup resistors on both of SCL and SDA.
 */

//Modified for testing on Gemma.

//#include <Wire.h>
#include <TinyWireM.h>
#define Wire TinyWireM

// LEDs on X-NUCLEO board
//#define LED1 5
//#define LED2 4
//#define LED3 2

// LEDs on Gemma
#define LED 1

// LED is used to put a capture region around the NDEF read, so that
// a scope or logic analyser can easily find the frames of interest
// by triggering on rising-high of that pin.
#define CAPTURE LED

#define NFC_ADDR_7BIT 0x56

void setup()
{
  pinMode(LED, OUTPUT);
  //pinMode(LED2, OUTPUT);
  //pinMode(LED3, OUTPUT);
  Wire.begin();
  //Serial.begin(9600);
}

byte selectI2C[]      = {0x52};
byte selectNFCApp[]   = {0x02,0x00,0xA4,0x04,0x00,0x07,0xD2,0x76,0x00,0x00,0x85,0x01,0x01,0x00,0x35,0xC0};
byte selectCCFile[]   = {0x03,0x00,0xA4,0x00,0x0C,0x02,0xE1,0x03,0xD2,0xAF};
byte readCCLen[]      = {0x02,0x00,0xB0,0x00,0x00,0x02,0x6B,0x7D};
byte readCCFile[]     = {0x03,0x00,0xB0,0x00,0x00,0x0F,0xA5,0xA2};
byte selectNDEFFile[] = {0x02,0x00,0xA4,0x00,0x0C,0x02,0x00,0x01,0x3E,0xFD};
byte readNDEFLen[]    = {0x03,0x00,0xB0,0x00,0x00,0x02,0x40,0x79};
byte readNDEFMsg[]    = {0x02,0x00,0xB0,0x00,0x02,0x0C,0xA5,0xA7};
byte deselectI2C[]    = {0xC2,0xE0,0xB4};

// The delays are required, to allow the M24SR time to process commands.

void loop()
{
  //Serial.println("\nstarting");
  //digitalWrite(LED1, HIGH);

  // kill RF, select I2C
  //Serial.println("selectI2C");
  digitalWrite(CAPTURE, HIGH);
  Wire.beginTransmission(NFC_ADDR_7BIT);
  Wire.write(selectI2C, sizeof(selectI2C));
  Wire.endTransmission();
  digitalWrite(CAPTURE, LOW);
  delay(1);

  //select NFC app
  //Serial.println("selectNFCApp");
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  //Wire.write(selectNFCApp, sizeof(selectNFCApp));
  //Wire.endTransmission();
  //delay(1);
  //readAndDisplay(5);

  //select CC file
  //Serial.println("selectCCFile");
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  //Wire.write(selectCCFile, sizeof(selectCCFile));
  //Wire.endTransmission();
  //delay(1);
  //readAndDisplay(5);

  //readCCLen
  //Serial.println("readCCLen");
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  //Wire.write(readCCLen, sizeof(readCCLen));
  //Wire.endTransmission();
  //delay(1);
  //readAndDisplay(7);

  //int len=20; //TODO get from above payload, not overly critical

  //readCCFile
  //Serial.println("readCCFile");
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  //Wire.write(readCCFile, sizeof(readCCFile));
  //Wire.endTransmission();
  //delay(1);
  //readAndDisplay(len);

  //selectNDEFFile
  //Serial.println("selectNDEFFile");
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  //Wire.write(selectNDEFFile, sizeof(selectNDEFFile));
  //Wire.endTransmission();
  //delay(1);
  //readAndDisplay(5);

  //readNDEFLen
  //Serial.println("readNDEFLen");
  //digitalWrite(CAPTURE, HIGH); // so we can capture on logic analyser
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  //Wire.write(readNDEFLen, sizeof(readNDEFLen));
  //Wire.endTransmission();
  //delay(1);

  //Wire.requestFrom(NFC_ADDR_7BIT, 7);
  //int idx = 0;
  //while (Wire.available())
  //{
  //  byte b = Wire.read();
  //  //Serial.print(b, HEX);
  //  //Serial.write(' ');
  //  if (idx == 2) // TODO max len is 255?
  //  {
  //    len = b;
  //  }
  //  idx++;
  //}
  //Serial.println();

  //readNDEFMsg
  //len = full NDEF length, (5 byte prefix+actual URI)
  //Serial.println("readNDEFMsg");
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  // Patch in the length and fix the broken CRC
  //readNDEFMsg[5] = len; // this is the len returned from ReadNDEFLen
  //ComputeCrc(readNDEFMsg, sizeof(readNDEFMsg)-2, &(readNDEFMsg[6]), &(readNDEFMsg[7]));
  //Wire.write(readNDEFMsg, sizeof(readNDEFMsg));
  //Wire.endTransmission();
  //delay(1);

// (PCB,SW1,SW2,CRC0,CRC1)
//#define PROTO_OVERHEAD 5
// 5 bytes for NDEF header (in URI format)
//#define HEADER_LEN 5

  //int msgStart = 1 + HEADER_LEN;
  //int msgEnd   = 1 + HEADER_LEN + (len-HEADER_LEN);

  //Wire.requestFrom(NFC_ADDR_7BIT, len+PROTO_OVERHEAD);
  //idx = 0;
  //while (Wire.available())
  //{
  //  byte b = Wire.read();
  //  if (idx >= msgStart && idx <= msgEnd)
  //  {
  //    //Serial.write(b);
  //  }
  //  idx++;
  //}
  //Serial.println();
  //readAndDisplay(len+PROTO_OVERHEAD);

  //digitalWrite(CAPTURE, LOW); // marks end of capture region for logic analyser

  //deselectI2C
  //Serial.println("deselectI2C");
  //Wire.beginTransmission(NFC_ADDR_7BIT);
  //Wire.write(deselectI2C, sizeof(deselectI2C));
  //Wire.endTransmission();
  //delay(1);
  //readAndDisplay(3);

  //digitalWrite(LED1, LOW);
  //delay(1000);
}

//void readAndDisplay(int len)
//{
//  Wire.requestFrom(NFC_ADDR_7BIT, len);
//  while (Wire.available())
//  {
//    Serial.print(Wire.read(), HEX);
//    Serial.write(' ');
//  }
//  Serial.println();
//}

word UpdateCrc(byte data, word *pwCrc)
{
  data = (data^(byte)((*pwCrc) & 0x00FF));
  data = (data^(data << 4));
  *pwCrc = (*pwCrc >> 8)
         ^ ((word)data << 8)
         ^ ((word)data << 3)
         ^ ((word)data >> 4);
  return *pwCrc;
}

word ComputeCrc(byte *data, unsigned int len, byte *crc0, byte *crc1)
{
  byte bBlock;
  word wCrc;

  wCrc = 0x6363;

  do
  {
    bBlock = *data++;
    UpdateCrc(bBlock, &wCrc);
  }
  while (--len);

  *crc0 = (byte) (wCrc & 0xFF);
  *crc1 = (byte) ((wCrc >> 8) & 0xFF);
  return wCrc;
}

/* END OF FILE */

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


First pass: set pins to a known state and let human decide if tests pass/fail.

void func*[] tests;

void setup () {
  // init pins

  // register tests

}

void smokeTest() {

}

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


Add chap7 - bt_relay code

Add chap7 - bt_relay code

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(2, 3); //Connect HC-06. Use your (TX, RX) settings

void setup()
{
  Serial.begin(9600);
  Serial.println("Hello!");

  BTSerial.begin(9600);  // set the data rate for the BT port
}

void loop()
{
  // BT –> Data –> Serial
  if (BTSerial.available()) {
    Serial.write(BTSerial.read());
  }
  // Serial –> Data –> BT
  if (Serial.available()) {
    BTSerial.write(Serial.read());
  }
}

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


String-messages to step sequencer

String-messages to step sequencer

#include <Process.h>

String instruments[] = {"PS", "BD", "SD","KI","SN","CR"};
//PS: play sample, BD: bass drum, SD: snare, KI: kick,SN: snare, CR: crash
const int numIns = 6;
byte patterns[numIns-1];
// length
const int patternL = 8;

const unsigned long MINUTE = 60000;
int bpm = 120;
// nextBeat
unsigned long nextB;
// time increase
int nextBInc;
// pos in the sequence
int pos;
// sequence-bits
int bs[] = {1, 2, 4, 8, 16, 32, 64, 128, 256};

const String sampleFolder = "/mnt/twitterOrchestra/samples/";

void setup() {
  Bridge.begin();
  Serial.begin(9600);
  while (!Serial);
  String msg = "#BD 10001000";
  parseMessage(msg);
  String msg2 = "#SD 01010101";
  parseMessage(msg2);
  String msg3 = "#KI 10001010";
  parseMessage(msg3);
  String msg4 = "#CR 01000000";
  parseMessage(msg4);

  nextBInc = MINUTE / bpm;
}

void loop() {
  unsigned long time = millis();
  if (time > nextB) {
    nextB += nextBInc;
    for (int i = 1; i < numIns; i++) {
      if (patterns[i-1] & bs[pos])
        Serial.print(instruments[i]);
      else
        Serial.print("..");
        Serial.print("-");
    }
    Serial.println("");
    pos = (pos + 1) % patternL;
  }
}

void parseMessage(String msg) {
  int hashInd = msg.indexOf('#');
  // instrument
  if (hashInd == -1)
    return;
  int instrument = 0;
  String s = msg.substring(hashInd + 1, hashInd + 3);
  for (int i = 0; i < numIns; i++) {
    if (s == instruments[i]) {
      instrument = i;
      Serial.println(s);
      break;
    }
  }
  if (instrument == 0)
    playSample(msg.substring(hashInd + 4));
  else {
    instrument--;
    // pattern
    String pa = msg.substring(hashInd + 4, hashInd + 4 + patternL);
    byte pattern = 0;
    Serial.println(pa);
    for (int i = 0; i < patternL; i++) {
      pattern = pattern << 1;
      byte b = pa.charAt(i) == '1' ? 1 : 0;
      pattern += b;
    }
    Serial.println(pattern);
    patterns[instrument] = pattern;
  }
}

void playSample(String msg) {
  Process p;
  p.runShellCommandAsynchronously("madplay "+sampleFolder+msg);
}

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


edited

edited

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/ocean-x/erikson-1.git/'


Create Main_draft_11.ino

Create Main_draft_11.ino

//**************************************************************//
//  Name    : LAGERLOGGER! (With IC2 display)
//  Author  : Paul Jarvey
//  Date    : 5 Oct, 2013
//  Modified: 17 Jan, 2017
//  Version : BETA 0.8
//  Notes   : 20x4 lc2 display, DHT22 temp/hum mon,
//          : control via rotary encoder, and 4 output controls
//          : note to self - control backlight with   lcd.setBacklight(1)
//          : screen connected  : SDA >> A4 , SCL >> A5
//****************************************************************

//redefine how compiler understands "B_SIG", "A_SIg"
unsigned int pulses = 0, A_SIG=0, B_SIG=1;
int pulseAdjust = 4;

// Call libraries for display, sensor, I2C, and memory. Library setup included as well.
#include <avr/pgmspace.h>
char buffer[20];

#include <OneWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);
#include <DHT.h>
#include <EEPROM.h>
#include "EEPROMAnything.h"

// Special Characters for the display and display animations
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args)  write(args);
#else
#define printByte(args)  print(args,BYTE);
#endif

uint8_t heart[8] = { 0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
uint8_t deg[8] = { 0x1c,0x14,0x1c,0x0,0x3,0x4,0x4,0x3};
uint8_t hum[8] = { 0x12,0x4,0x9,0x0,0x4,0x7,0x5,0x5};
uint8_t up1[8] = { 0x10,0x14,0x2,0x10,0x0,0x2,0x10,0x0};
uint8_t up2[8] = { 0x0,0x2,0x10,0x0,0x2,0x10,0xa,0x0};
uint8_t up3[8] = { 0x2,0x10,0x0,0x2,0x10,0x0,0x2,0x10};
uint8_t Pv[8] = { 0x1c,0x14,0x1c,0x10,0x10,0x5,0x5,0x2};
uint8_t Sv[8] = { 0xc,0x10,0x8,0x4,0x18,0x5,0x5,0x2};
// end special chars

// Sensor pins:
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

//user i/o pins
const int buttonPin = 11;    // the pin that the pushbutton is attached to
const int ledPin = 13;       // the pin that the LED is attached to (for status)

//************* Begin Libraries Setup ***************//

const char* OnOff[3] = {
"ON  ",
"OFF ",
"AUTO"};

const char* YesNo[2] = {
"Yes",
"No "};

const char* mainMenu[9] = {
"Exit            ",
"Program sequence",
"Set temp/hum    ",
"Options & PID",
"Fan timer    ",
"Light timer     ",
"View sensor data",
"Brew/grow mode  ",
"Save settings "};

//************* Begin Variables Setup ***************//

//Sensors (ds18s20 needs additional chatter)
int DS18S20_Pin = 5; //DS18S20 Signal pin on digital 2
  byte addr1[8]= {0x28, 0x48, 0xAE, 0x3C, 0x05, 0x00, 0x00, 0x34};
  byte addr2[8]= {0x28, 0xC7, 0xCD, 0x4C, 0x05, 0x00, 0x00, 0x0D};
  byte data1[12];
  byte data2[12];
  byte MSB = 0;
  byte LSB = 0;
  float tempRead = 0;
  float TemperatureSum = 0;
  OneWire ds(DS18S20_Pin);

//controller outputs
int ControlCpin = 9; // control to fridge
int ControlTpin = 7; // control to temperature/heater  (get aquarium heater)
int ControlHpin = 8; // control to humidifier
int ControlLpin = 6; // control to light
int ControlApin = 10; // control to airflow

//operational vars (the button)
//int buttonPushCounter = 0;   // counter for the number of button presses DEPRACATED
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button
boolean buttonstate = false; // calculastate of the button (includes timer delay. use this in menus)
int buttontime = 0;          // press length measure
int buttontimeon = 0;        // necessary for press length measure

//operational vars (the rotary)
int pulseMod = 0;            // modulus to reduce scroll speed
int pulseprev = 0;         // to measure change in rotary position
int pulselast = 0;         // backlight onoff
//operational vars (the menus and presets)
byte menu = 0;               // defines current screen (used in cases in main loop)
byte submenu = 0;            // defines submenu screen (used in cases in main loop)
byte Mode = 0;               // define mode: brew = 0, myc = 1 COULD JUST USE MENU
//byte preset = 0;             // Active Preset (grow and brew)
int selector = 0;            // could change to byte
int selectorprev = 0;        // Must be int. Maybe long. Defines the next menu position by changing pulses

//operational vars (sensors and timing)
unsigned int sensorInterval = 5000;         // time between readings
unsigned long int sensorTime = 0;           // current time
unsigned long int sensorTime2 = 0;          // time of last sensor reading
unsigned long int backlighton = 0;
unsigned long int backlighttime = 120000;

// fans, lights, and timers
byte FanAuto = 0;
unsigned long int fanONmillis = 0;
unsigned long int fanOFFmillis = 0;
byte fanON = 0;
byte fanOFF = 0;
boolean fanstate = false;
unsigned long int Time = 0;
unsigned long int TimeAdjust = 0;
int brewtimer = 0;
double brewtimerRef = 0;
byte brewtimerON = 0;
float brewtimerSv = 20;
unsigned long int LightON = 0;
unsigned long int LightOFF = 0;
unsigned int Hours = 0;
unsigned int Minutes = 0;
unsigned int Seconds = 0;
byte daysAdj = 0; //not implemented yet

//key var storage
float PvH = 0;
double PvT = 0;
float SvH = 0;
double SvT = 0;

//Reading averaging
//const int numReadings = 4;   // number of readings to average (rolling average) ALSO changes loading screen length (as values are populated twice per second)
//float readingsT[numReadings];// Temp readings to average
//float readingsH[numReadings];// Hum readings to average

//byte readingsCount = 0;
//byte index = 0;               // index of the current reading
//byte index2 = 0;
//float totalT = 0;            // current Temp total
//float totalH = 0;            // current Hum total
//float totalIT = 0;            // current Temp total
//fafloat totalIH = 0;

float Temp1;                   //Current readings
float Temp2;                   //Current readings
float Temp3;                   //Current readings
float Hum;
int Day = 0;                //Current day in program (for calcs)
int DayPrev = 0;            //Previous day for counting and eeprom NOT SET UP YET

// Fridge limits
int dutyCycle = 2; // in minutes
int minCool = 10; // in minutes
byte coolON = 0;  // PID attached to this

// Heat limits
byte heatON = 0;  // PID attached to this

//PID  variables
#include <PID_v1.h>
byte autotune = 0;

//cool
double Kp = 8;
double Ki = 2;
double Kd = 2;
double Output;
PID coolPID(&PvT, &Output, &SvT ,Kp,Ki,Kd, REVERSE);
double coolWindowSize = 1800000;  //  60k = 1min
unsigned long coolWindowStartTime;
unsigned long coolOffElapsed = 0;

//heat
double Outputh;
PID heatPID(&PvT, &Outputh, &SvT ,4,0.8,0.8, DIRECT);
double heatWindowSize = 600000;  // 60k = 1min
unsigned long heatWindowStartTime;
unsigned long heatOffElapsed = 0;

// ensure setpoint, input, and outpit are defined

//************* End Variables Setup ***************//

void setup(){

//Sensor start
  dht.begin();

//Interrupts initialize
  attachInterrupt(0, A_RISE, RISING);
  attachInterrupt(1, B_RISE, RISING);
  pinMode(buttonPin, INPUT); // initialize momentary button input

//Pin declarations
  pinMode(ControlTpin, OUTPUT); //set outputs
  pinMode(ControlHpin, OUTPUT);
  pinMode(ControlLpin, OUTPUT);
  pinMode(ControlApin, OUTPUT);
  pinMode(ControlCpin, OUTPUT);
  digitalWrite(ControlTpin, HIGH); // write outputs HIGH (off in this case) FIRST to prevent startup jitters.
  digitalWrite(ControlHpin, HIGH);
  digitalWrite(ControlLpin, HIGH);
  digitalWrite(ControlApin, HIGH);
  digitalWrite(ControlCpin, HIGH);

//LCD and special chars
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  lcd.createChar(0, heart);
  lcd.createChar(1, deg);
  lcd.createChar(2, hum);
  lcd.createChar(3, up1);
  lcd.createChar(4, up2);
  lcd.createChar(5, up3);
  lcd.createChar(6, Pv);
  lcd.createChar(7, Sv);
  lcd.clear();
  LoadScreen();

// load all the saved values from EEPROM
  EEPROM_recall();

  //fanONmillis = 0;
  fanOFFmillis = millis();
  HomeSetup();

  //PID shit
  //coolWindowSize = dutyCycle * 60000;
  coolPID.SetOutputLimits(0, coolWindowSize/1000);
  coolPID.SetMode(AUTOMATIC);
  coolOffElapsed = millis();
  heatPID.SetOutputLimits(0, heatWindowSize/1000);
  heatPID.SetMode(AUTOMATIC);
  coolOffElapsed = millis();
}

void loop(){

  Button();
  Menus ();

  /* //TESTING OUTPUT (enable this line to print interrupt data to the serial port
  Serial.print(pulses);
  Serial.print(" : ");
  Serial.println(pulseMod);*/

}

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


Demonstrating MM3 usage with interrupts for convert and reading.

/*
 * MicroMagConvGetRes.ino
 * Author: Steve Marple
 * License: GNU Lesser General Public License, version 2.1
 *
 * Example sketch to demonstrate reading from a MicroMag2 or MicroMag3
 * module using the convert() and getResult() functions. The initial
 * convert is started from a match interrupt generated by
 * timer/counter2.
 *
 * Requirements:
 *   Arduino >= 1.0
 *   Calunium (standard Arduino cannot access the DRDY pin and the
 *     Arduino Mega(2560) doesn't have timer/counter2 connected to the
 *     shield headers.
 *   MicroMag library, see https://github.com/stevemarple/MicroMag
 *   MicroMag2 or MicroMag3 module
 *
 *   Calunium configuration:
 *     RTC (DS1307 or similar) fitted, with battery
 *     RTC square wave routed to D15 (JP1 fitted)
 */

#include <Wire.h>
#include <RealTimeClockDS1307.h>

#include <SPI.h>
#include <MicroMag.h>

#include <util/atomic.h>

// Adjust these pin definitions to suit your hardware. They are chosen
// to match the RN-XV and SD shield with the MicroMag3 module option
// on Calunium. Ensure the correct interrupt service routine is
// defined for the DRDY pin.
#define DRDY_PIN 14
const uint8_t mmResetPin = A3;
const uint8_t mmDrdyPin = DRDY_PIN;
const uint8_t mmSsPin = A0; // This is the chip select pin on the MM3

// Change this to suit your version.
const uint8_t model = 3;

// The sampling period
uint8_t period = MM_PERIOD_4096;

// Create a MicroMag object
MicroMag MM = MicroMag::MicroMag3(mmSsPin, mmDrdyPin, mmResetPin);

// Use an 8-bit variable to obtain atomic read/write access. Disabling
// interrupts is therefore not needed.
/// volatile uint8_t dataReady = false;

// The 2 or 3 samples are taken in different invocations of loop() so
// use static variables to hold the results until all 2 or 3 have been
// taken and can be printed.
volatile uint8_t axis = 0;
volatile uint8_t sampleInProgess = false;
volatile int16_t data[model];
volatile unsigned long timestamps[model] = {0};

// This ISR is called when the state has *changed*. Act only when the
// current state is high (data is ready)
ISR(PCINT2_vect){
  ATOMIC_BLOCK(ATOMIC_FORCEON) {
    if (!digitalRead(DRDY_PIN))
      return; // Data not ready (new sample started?)

    data[axis] = MM.getResult();
    ++axis;
    if (axis == model)
      sampleInProgess = false;
    else {
      timestamps[axis] = millis();
      MM.convert(axis, period); // Start sampling next axis
    }
    return;
  }
}

void setupPinChangeInterrupts(void)
{
  *(digitalPinToPCMSK(DRDY_PIN)) |= _BV(digitalPinToPCMSKbit(DRDY_PIN));
  *(digitalPinToPCIR(DRDY_PIN)) |= _BV(digitalPinToPCICRbit(DRDY_PIN));
}

// When the counter matches sample X
ISR(TIMER2_COMPA_vect)
{
  ATOMIC_BLOCK(ATOMIC_FORCEON) {
    if (sampleInProgess)
      return;
    sampleInProgess = true;
    axis = 0;
    timestamps[axis] = millis();
    MM.convert(axis, period);
    return;
  }
}

// Configure counter/timer2 in asynchronous mode, counting the rising
// edge of signals on TOSC1. This always triggers on the rising edge;
// if connecting SQW from a DS1307 then this means the ticks occur
// halfway through the second.
void setupTimer2(void)
{
  noInterrupts();
  ASSR = (_BV(EXCLK) | _BV(AS2));
  TCCR2A = 0;
  TCCR2B = 0;
  TCNT2 = 0;
  OCR2A = 3; // Have the ISR called every 10th (n+1) tick
  TCCR2A |= _BV(WGM21); // CTC mode
  TCCR2B |= _BV(CS20);
  TIMSK2 |= _BV(OCIE2A);
  interrupts();
}

void setup()
{
  pinMode(SS, OUTPUT); // Prevent SPI slave mode from happening
  Wire.begin();
  Serial.begin(9600);

  // For calunium: enable inputs on pin 6 in case JP4 is fitted and
  // routing SQW there also
  pinMode(6, INPUT);

  // On Calunium timer/counter2 is connected to digital pin 15.
  pinMode(15, INPUT);
  setupTimer2();

  if (MM.begin() != 0) {
    Serial.println("Could not initialise MicroMag");
    while (1)
      ; // no point in continuing
  }
  setupPinChangeInterrupts();

  // Set up the RTC output
  RTC.sqwEnable(RealTimeClockDS1307::SQW_1Hz);
}

unsigned long lastDisplayed = 0;
void loop()
{
  // Check if new data is ready
  if (!sampleInProgess && axis == model && timestamps[0] != lastDisplayed) {
    lastDisplayed = timestamps[0];
    double total = 0.0;

    // Display the results
    for (uint8_t i = 0; i < model; ++i) {
      if (i)
	Serial.print("   ");
      Serial.print(char('X' + i));
      Serial.print(" = ");
      Serial.print(data[i]);
      total += sqrt(double(data[i]) * data[i]);
    }
    Serial.print("   Total = ");
    Serial.println(total);

    for (uint8_t i = 0; i < model; ++i) {
      if (i)
	Serial.print("   ");
      Serial.print(timestamps[i]);
    }
    Serial.println();
  }

}

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


Removed deprecated parameters

Removed deprecated parameters

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/TheBeachMaster/AfricasTalkingIOT.git/'


add morse code dictionary

add morse code dictionary

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/kdomen/Morse-Code.git/'