added Arduino showing how to read from the i2c port.

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

--- arduino_i2c/Lepton.ino
+++ arduino_i2c/Lepton.ino
@@ -0,0 +1,332 @@
+/*
+Copyright (c) 2014, Pure Engineering LLC
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <Wire.h>
+#include <SPI.h>
+
+byte x = 0;
+#define ADDRESS  (0x2A)
+
+#define AGC (0x01)
+#define SYS (0x02)
+#define VID (0x03)
+#define OEM (0x08)
+
+#define GET (0x00)
+#define SET (0x01)
+#define RUN (0x02)
+
+#define VOSPI_FRAME_SIZE (164)
+
+void setup()
+{
+  //pinMode(pin, INPUT);           // set pin to input
+  //digitalWrite(pin, HIGH);
+
+  Wire.begin();
+  Serial.begin(115200);
+
+  pinMode(10, OUTPUT);
+  SPI.setDataMode(SPI_MODE3);
+  SPI.setClockDivider(0);
+
+  SPI.begin();
+
+  Serial.println("setup complete");
+}
+
+int spi_read_word(int data)
+{
+  int read_data;
+  // take the SS pin low to select the chip:
+  digitalWrite(10, LOW);
+  //  send in the address and value via SPI:
+  read_data = SPI.transfer(data >> 8) << 8;
+  read_data |= SPI.transfer(data);
+  // take the SS pin high to de-select the chip:
+  digitalWrite(10, HIGH);
+  return read_data;
+}
+
+byte lepton_frame_packet[VOSPI_FRAME_SIZE];
+
+#define IMAGE_SIZE (800)
+byte image[IMAGE_SIZE];
+int image_index;
+void read_lepton_frame(void)
+{
+  int i;
+  for (i = 0; i < (VOSPI_FRAME_SIZE / 2); i++)
+  {
+    //digitalWrite(10, LOW);
+    PORTB &= ~(1 << 2);
+    //  send in the address and value via SPI:
+    lepton_frame_packet[2 * i] = SPI.transfer(0x00);
+    lepton_frame_packet[2 * i + 1] = SPI.transfer(0x00);
+
+
+    // take the SS pin high to de-select the chip:
+    //digitalWrite(10, HIGH);
+    PORTB |= 1 << 2;
+  }
+}
+
+void lepton_sync(void)
+{
+  int i;
+  int data = 0x0f;
+
+  PORTB |= 1 << 2;
+  delay(185);
+  while (data & 0x0f == 0x0f)
+{
+  PORTB &= ~(1 << 2);
+    data = SPI.transfer(0x00) << 8;
+    data |= SPI.transfer(0x00);
+    PORTB |= 1 << 2;
+
+    for (i = 0; i < ((VOSPI_FRAME_SIZE - 2) / 2); i++)
+    {
+
+      PORTB &= ~(1 << 2);
+
+      SPI.transfer(0x00);
+      SPI.transfer(0x00);
+
+      PORTB |= 1 << 2;
+    }
+  }
+
+}
+
+void print_lepton_frame(void)
+{
+  int i;
+  for (i = 0; i < (VOSPI_FRAME_SIZE); i++)
+  {
+    Serial.print(lepton_frame_packet[i], HEX);
+    Serial.print(",");
+
+  }
+  Serial.println(" ");
+}
+
+void print_image(void)
+{
+  int i;
+  for (i = 0; i < (IMAGE_SIZE); i++)
+  {
+    Serial.print(image[i], HEX);
+    Serial.print(",");
+
+  }
+  Serial.println(" ");
+}
+
+void lepton_command(unsigned int moduleID, unsigned int commandID, unsigned int command)
+{
+  byte error;
+  Wire.beginTransmission(ADDRESS);
+
+  // Command Register is a 16-bit register located at Register Address 0x0004
+  Wire.write(0x00);
+  Wire.write(0x04);
+
+  if (moduleID == 0x08) //OEM module ID
+  {
+    Wire.write(0x48);
+  }
+  else
+  {
+    Wire.write(moduleID & 0x0f);
+  }
+  Wire.write( ((commandID << 2 ) & 0xfc) | (command & 0x3));
+
+  error = Wire.endTransmission();    // stop transmitting
+  if (error != 0)
+  {
+    Serial.print("error=");
+    Serial.println(error);
+  }
+}
+
+void agc_enable()
+{
+  byte error;
+  Wire.beginTransmission(ADDRESS); // transmit to device #4
+  Wire.write(0x01);
+  Wire.write(0x05);
+  Wire.write(0x00);
+  Wire.write(0x01);
+
+  error = Wire.endTransmission();    // stop transmitting
+  if (error != 0)
+  {
+    Serial.print("error=");
+    Serial.println(error);
+  }
+}
+
+void set_reg(unsigned int reg)
+{
+  byte error;
+  Wire.beginTransmission(ADDRESS); // transmit to device #4
+  Wire.write(reg >> 8 & 0xff);
+  Wire.write(reg & 0xff);            // sends one byte
+
+  error = Wire.endTransmission();    // stop transmitting
+  if (error != 0)
+  {
+    Serial.print("error=");
+    Serial.println(error);
+  }
+}
+
+//Status reg 15:8 Error Code  7:3 Reserved 2:Boot Status 1:Boot Mode 0:busy
+
+int read_reg(unsigned int reg)
+{
+  int reading = 0;
+  set_reg(reg);
+
+  Wire.requestFrom(ADDRESS, 2);
+
+  reading = Wire.read();  // receive high byte (overwrites previous reading)
+  //Serial.println(reading);
+  reading = reading << 8;    // shift high byte to be high 8 bits
+
+  reading |= Wire.read(); // receive low byte as lower 8 bits
+  Serial.print("reg:");
+  Serial.print(reg);
+  Serial.print("==0x");
+  Serial.print(reading, HEX);
+  Serial.print(" binary:");
+  Serial.println(reading, BIN);
+  return reading;
+}
+
+int read_data()
+{
+  int i;
+  int data;
+  int payload_length;
+
+  while (read_reg(0x2) & 0x01)
+  {
+    Serial.println("busy");
+  }
+
+  payload_length = read_reg(0x6);
+  Serial.print("payload_length=");
+  Serial.println(payload_length);
+
+  Wire.requestFrom(ADDRESS, payload_length);
+  //set_reg(0x08);
+  for (i = 0; i < (payload_length / 2); i++)
+  {
+    data = Wire.read() << 8;
+    data |= Wire.read();
+    Serial.println(data, HEX);
+  }
+
+}
+
+
+void loop()
+{
+  int i;
+  int reading = 0;
+  String debugString;
+  Serial.println("beginTransmission");
+
+  //set_reg(0);
+
+  //read_reg(0x0);
+
+  read_reg(0x2);
+
+
+  Serial.println("SYS Camera Customer Serial Number");
+  lepton_command(SYS, 0x28 >> 2 , GET);
+  read_data();
+
+  Serial.println("SYS Flir Serial Number");
+  lepton_command(SYS, 0x2 , GET);
+  read_data();
+
+  Serial.println("SYS Camera Uptime");
+  lepton_command(SYS, 0x0C >> 2 , GET);
+  read_data();
+
+  Serial.println("SYS Fpa Temperature Kelvin");
+  lepton_command(SYS, 0x14 >> 2 , GET);
+  read_data();
+
+  Serial.println("SYS Aux Temperature Kelvin");
+  lepton_command(SYS, 0x10 >> 2 , GET);
+  read_data();
+
+  Serial.println("OEM Chip Mask Revision");
+  lepton_command(OEM, 0x14 >> 2 , GET);
+  read_data();
+
+  //Serial.println("OEM Part Number");
+  //lepton_command(OEM, 0x1C >> 2 , GET);
+  //read_data();
+
+  Serial.println("OEM Camera Software Revision");
+  lepton_command(OEM, 0x20 >> 2 , GET);
+  read_data();
+
+  Serial.println("AGC Enable");
+  //lepton_command(AGC, 0x01  , SET);
+  agc_enable();
+  read_data();
+
+  Serial.println("AGC READ");
+  lepton_command(AGC, 0x00  , GET);
+  read_data();
+
+  // Serial.println("SYS Telemetry Enable State");
+  //lepton_command(SYS, 0x19>>2 ,GET);
+  // read_data();
+
+  while (1)
+  {
+    //lepton_sync();
+    read_lepton_frame();
+    //if(lepton_frame_packet[i]&0x0f != 0x0f )
+    {
+      //print_lepton_frame();
+    }
+
+  }
+
+
+
+  x++;
+  delay(10000);
+}


Cerveau: AI - ajout test funny action

Cerveau: AI - ajout test funny action

error: pathspec 'Module' did not match any file(s) known to git
error: pathspec 'Cerveau/Artificial' did not match any file(s) known to git
error: pathspec 'Intelligence/ai/ai/ai.ino' did not match any file(s) known to git


Added rudimentary analogue controls for 3 motors.

These controls include up, down, along with translational motion horizontally.

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


修复了转向提前停止的问题

修复了转向提前停止的问题

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/qsheeeeen/shopping-robot.git/'


Added simple danger-avoiding example.

Added simple danger-avoiding example.

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

--- examples/AvoidDanger/AvoidDanger.ino
+++ examples/AvoidDanger/AvoidDanger.ino
@@ -0,0 +1,95 @@
+#include <Servo.h>
+
+const int ONBOARD_SWITCH_PIN = A7;
+const int ONBOARD_LED_PIN = 13;
+
+const int SERVO_PIN = 9;
+const int IR_PIN = A4;
+const int LEFT_TRACK_SENSOR_PIN = A2;
+const int RIGHT_TRACK_SENSOR_PIN = A3;
+
+// The pins for motor control on the Romeo BLE.
+const int M1_DIRECTION = 4;
+const int M1_SPEED = 5;
+const int M2_SPEED = 6;
+const int M2_DIRECTION = 7;
+
+Servo irServo;
+
+void setup() {
+  Serial.begin(38400);
+  irServo.attach(SERVO_PIN);
+  setServoAngle(0);
+
+  pinMode(ONBOARD_LED_PIN, OUTPUT);
+  pinMode(M1_DIRECTION, OUTPUT);
+  pinMode(M2_DIRECTION, OUTPUT);
+  pinMode(LEFT_TRACK_SENSOR_PIN, INPUT);
+  pinMode(RIGHT_TRACK_SENSOR_PIN, INPUT);
+
+  while (readSwitch() != 1) {
+    // Do nothing.
+  }
+}
+
+void loop() {
+  if (!digitalRead(LEFT_TRACK_SENSOR_PIN)) {
+    // Hit edge on left. Spin back round right wheel.
+    setSpeed(-128, 0);
+    delay(2200);
+  } else if (!digitalRead(RIGHT_TRACK_SENSOR_PIN)) {
+    // Hit edge on right. Spin back around left wheel.
+    setSpeed(0, -128);
+    delay(2200);
+  } else if (analogRead(IR_PIN) >= 375) {
+    // Obstacle straight ahead. Pivot left.
+    setSpeed(-128, 128);
+    delay(750);
+  } else {
+    // No obstacles, go straight.
+    setSpeed(128, 128);
+  }
+}
+
+// Reads the built-in switches on the Romeo and returns a value indicating
+// which switch, if any, is depressed. The analog read value thresholds used
+// were determined empirically and fall roughly mid-way between the actual
+// value you can read for each switch.
+//
+// Return value:
+//   0 - no switches
+//   1 - S1
+//   2 - S2
+//   3 - S3
+//   4 - S4
+//   5 - S5
+int readSwitch() {
+  int value = analogRead(ONBOARD_SWITCH_PIN);
+
+  if (value > 800) {
+    return 0;
+  } else if (value > 600) {
+    return 5;
+  } else if (value > 400) {
+    return 4;
+  } else if (value > 250) {
+    return 3;
+  } else if (value > 75) {
+    return 2;
+  } else {
+    return 1;
+  }
+}
+
+// Sets the left and right motor speeds.
+void setSpeed(int leftSpeed, int rightSpeed) {
+  digitalWrite(M1_DIRECTION, (leftSpeed >= 0 ? HIGH : LOW));
+  analogWrite(M1_SPEED, abs(leftSpeed));
+  digitalWrite(M2_DIRECTION, (rightSpeed >= 0 ? HIGH : LOW));
+  analogWrite(M2_SPEED, abs(rightSpeed));
+}
+
+// Sets the servo angle, as an angle from center.
+void setServoAngle(int angle) {
+  irServo.write(90 + angle);
+}


update delay

update delay

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/stevelacy/LEDFade.git/'


Added blank file

Added blank file

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


Add arduino sketches

Add arduino sketches

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

--- arduino/wifi_shield_test.ino
+++ arduino/wifi_shield_test.ino
@@ -0,0 +1,118 @@
+#include <Adafruit_CC3000.h>
+#include <Adafruit_CC3000_Server.h>
+#include <ccspi.h>
+
+/***************************************************
+  CC3000 Low Power Datalogging
+
+  Example 1: No Low Power Optimizations
+
+  Created by Tony DiCola (tony@tonydicola.com)
+
+  Designed specifically to work with the Adafruit WiFi products:
+  ----> https://www.adafruit.com/products/1469
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Based on CC3000 examples written by Limor Fried & Kevin Townsend
+  for Adafruit Industries and released under a BSD license.
+  All text above must be included in any redistribution.
+
+ ****************************************************/
+
+#include <Adafruit_CC3000.h>
+#include <SPI.h>
+
+// CC3000 configuration.
+#define ADAFRUIT_CC3000_IRQ    3
+#define ADAFRUIT_CC3000_VBAT   5
+#define ADAFRUIT_CC3000_CS     10
+
+// Wifi network configuration.
+#define WLAN_SSID              "FlatironSchool"
+#define WLAN_PASS              "33west26"
+#define WLAN_SECURITY          WLAN_SEC_WPA2
+
+// Data logging configuration.
+#define LOGGING_FREQ_SECONDS   30       // Seconds to wait before a new sensor reading is logged.
+
+#define SENSOR_PIN             0        // Analog pin to read sensor values from (for example
+                                        // from a photocell or other resistive sensor).
+
+#define SERVER_IP              192, 168, 3, 71    // Logging server IP address.  Note that this
+                                                   // should be separated with commas and NOT periods!
+
+#define SERVER_PORT            8000                // Logging server listening port.
+
+// Internal state used by the sketch.
+Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT);
+uint32_t ip;
+unsigned long lastSend = 0;
+
+// Take a sensor reading and send it to the server.
+void logSensorReading() {
+  // Take a sensor reading
+  int reading = analogRead(SENSOR_PIN);
+
+  // Connect to the server and send the reading.
+  Serial.print(F("Sending measurement: ")); Serial.println(reading, DEC);
+  Adafruit_CC3000_Client server = cc3000.connectTCP(ip, SERVER_PORT);
+  if (server.connected()) {
+    Serial.println("Connected!!");
+    server.println(reading);
+  }
+  else {
+    Serial.println(F("Error sending measurement!"));
+  }
+
+  // Wait a small period of time before closing the connection
+  // so the message is sent to the server.
+  delay(100);
+
+  // Close the connection to the server.
+  server.close();
+}
+
+void setup(void)
+{
+  Serial.begin(115200);
+
+  // Initialize the CC3000.
+  Serial.println(F("\nInitializing CC3000..."));
+  if (!cc3000.begin())
+  {
+    Serial.println(F("Couldn't begin()! Check your wiring?"));
+    while(1);
+  }
+  Serial.println(F("\nInitialized!"));
+  // Connect to AP.
+  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
+    Serial.println(F("Failed!"));
+    while(1);
+  }
+  Serial.println(F("Connected!"));
+
+  // Wait for DHCP to be complete.
+  Serial.println(F("Request DHCP"));
+  while (!cc3000.checkDHCP())
+  {
+    delay(100);
+  }
+
+  // Store the IP of the server.
+  ip = cc3000.IP2U32(SERVER_IP);
+
+  Serial.println(F("Setup complete."));
+}
+
+void loop(void)
+{
+  unsigned long time = millis();
+  if (time - lastSend >= (1000 * (unsigned long)LOGGING_FREQ_SECONDS)) {
+    logSensorReading();
+    lastSend = time;
+  }
+}
+


Added current Arduino control file

Added current Arduino control file

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

--- ReFilament/ReFilament.ino
+++ ReFilament/ReFilament.ino
@@ -0,0 +1,109 @@
+#define EXT_PIN 6
+#define SPL_PIN 5
+#define HTR_PIN 3
+
+// Set up global variables
+boolean input_complete = false;
+float input_param = 0;
+String input = "";
+boolean active = true;
+int shaft_speed = 80;
+long start_millis = 0;
+long over_temp_mv = 2480;
+long temp_mv = 0;
+long temp_deg = 0;
+boolean heater_activated = true;
+boolean heater_on = false;
+
+void setup() {
+  // put your setup code here, to run once:
+  pinMode(EXT_PIN, OUTPUT); // Extrusion Motor
+  pinMode(SPL_PIN, OUTPUT); // Spooling Motor
+  pinMode(HTR_PIN, OUTPUT); // Heater
+
+  //write all control pins low
+  digitalWrite(EXT_PIN, LOW);
+  digitalWrite(SPL_PIN, LOW);
+  digitalWrite(HTR_PIN, LOW);
+
+  Serial.begin(9600);
+  Serial.println("Initiating vehicle...");
+  start_millis = millis();
+
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  temp_mv = analogRead(0) / 1024.0 * 5000;
+  if (temp_mv >= over_temp_mv) {
+    heater_shutdown();
+  }
+  long temp_deg = temp_mv / 0.9181 - 2483;
+  Serial.print(String(temp_mv) + "/");
+  Serial.print(String(temp_deg) + "/");
+  Serial.println(heater_activated);
+
+  // get serial input here, change global variables
+  get_serial();
+  if (heater_activated) {
+    update_temp();
+  }
+  analogWrite(SPL_PIN, 3);
+  analogWrite(EXT_PIN, 0);
+  delay(10);
+}
+
+void heater_shutdown() {
+  digitalWrite(HTR_PIN, LOW);
+  heater_activated = false;
+}
+
+void update_temp() {
+  if (temp_deg <= 180) {
+    digitalWrite(HTR_PIN, HIGH);
+    heater_on = true;
+  } else if (temp_deg >= 220) {
+    digitalWrite(HTR_PIN, LOW);
+    heater_on = false;
+  }
+}
+
+void get_serial(){
+  if (input_complete) {
+    Serial.println(input);
+    Serial.println(input_param);
+    if (input.indexOf("speed")) {
+      shaft_speed = input_param;
+    } else if (input.indexOf("stop") > -1) {
+      active = false;
+    } else if (input.indexOf("go") > -1) {
+      active = true;
+    }
+    input_complete = false;
+    input = "";
+    input_param = 0;
+  }
+}
+
+void update_speed()
+{
+  if (!active) {
+    analogWrite(9, 0);
+  } else {
+    analogWrite(9, shaft_speed);
+  }
+}
+
+void serialEvent()
+{
+  while (Serial.available()) {
+    char input_char = (char)Serial.read();
+    if (input_char == ':') {
+      input_param = Serial.parseFloat();
+      input_complete = true;
+    }
+    else {
+      input += input_char;
+    }
+  }
+}


Improved accuracy of timing with micros() for no good reason. Now you can watch the LED blink a few times during the test as it loops through several times instead of just once. Discovered that asm("") is not optimized away by the compiler, so putting it inside of otherwise empty loops forces them to stay put. Useful when measuring empty loop time.

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


ultrasonic added

ultrasonic added

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

--- RosChatter.ino
+++ RosChatter.ino
@@ -0,0 +1,124 @@
+/*
+ * rosserial Publisher Example
+ * Prints "hello world!"
+ */
+
+#include <ros.h>
+#include <geometry_msgs/Twist.h>
+#include <std_msgs/String.h>
+
+class NewHardware : public ArduinoHardware {
+public : NewHardware () : ArduinoHardware (&Serial1, 57600){ };
+}; ros::NodeHandle_<NewHardware> nh;
+
+std_msgs::String str_msg;
+ros::Publisher debug("debug", &str_msg);
+char msg[30];
+int messagedelay = 0;
+
+float ultrasonic(void) {
+  digitalWrite(23, LOW);
+  delayMicroseconds(2);
+  digitalWrite(23, HIGH);
+  delayMicroseconds(10);
+  digitalWrite(23, LOW);
+
+  duration = pulseIn(22,HIGH,1740);   // 1740 uS => 30 cm
+  distacne_cm = duration / 58;
+
+  if (distacne_cm > 0 && distacne_cm < 15) {
+    return 0;
+  }
+  else if (distacne_cm < 30) {
+    return (distacne_cm-15)/15;
+  }
+  else {
+    return 1;
+  }
+}
+
+void twistMsg(const geometry_msgs::Twist& twist_msg) {
+  messagedelay = 0;
+
+
+  int lspd = (int) (twist_msg.linear.x * 255.0);
+  int rspd = lspd;
+  int rot = (int)(twist_msg.angular.z * 255.0);
+  lspd -= rot;
+  rspd += rot;
+
+  dist_factor = (int) ultrasonic();
+
+  if (rspd > 255)
+    rspd = dist_factor * 255;
+  if (rspd < -255)
+    rspd = dist_factor * -255;
+  if (lspd > 255)
+    lspd = dist_factor * 255;
+  if (lspd < -255)
+    lspd = dist_factor * -255;
+
+  sprintf(msg, "l=%d, r=%d", lspd, rspd);
+  str_msg.data = msg;
+  debug.publish(&str_msg);
+
+  if (lspd < 0) {
+    analogWrite(6, 0);
+    analogWrite(7, -lspd);
+  } else {
+    analogWrite(7, 0);
+    analogWrite(6, lspd);
+  }
+  if (rspd < 0) {
+    analogWrite(2, 0);
+    analogWrite(3, -rspd);
+  } else {
+    analogWrite(3, 0);
+    analogWrite(2, rspd);
+  }
+}
+
+ros::Subscriber<geometry_msgs::Twist> twist("cmd_vel", &twistMsg);
+
+void setup()
+{
+  // LCHB-100 Bridge & LED
+  pinMode(7, OUTPUT);   // 1REV
+  pinMode(24, OUTPUT);  // 1EN
+  pinMode(6, OUTPUT);   // 1FWD
+  pinMode(3, OUTPUT);   // 2REV
+  pinMode(25, OUTPUT);  // 2EN
+  pinMode(2, OUTPUT);   // 2FWD
+  pinMode(13, OUTPUT);  // Yellow LED
+  digitalWrite(13, LOW);
+
+  //HC-SR04 ultrasonic sensor
+  pinMode(22, INPUT);   // Echo
+  pinMode(23, OUTPUT);  // Trigger
+
+  nh.initNode();
+  nh.subscribe(twist);
+  nh.advertise(debug);
+  digitalWrite(24, HIGH);
+  digitalWrite(25, HIGH);
+}
+
+void fail() {
+  digitalWrite(13, HIGH);
+  analogWrite(6, 0);
+  analogWrite(7, 0);
+  analogWrite(2, 0);
+  analogWrite(3, 0);
+}
+
+void loop()
+{
+  nh.spinOnce();
+  delay(1);
+  if (messagedelay > 2000) {
+    fail();
+  } else {
+   digitalWrite(13, LOW); //led off
+   messagedelay++;
+  }
+}


Upload of Arduino Code

Upload of Arduino Code

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


Whitespace foo

Whitespace foo

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/MitchellJThomas/medir.git/'


Final commit - pending future updgrades

Final commit - pending future updgrades

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

--- a_g_system/a_g_system.ino
+++ a_g_system/a_g_system.ino
@@ -0,0 +1,41 @@
+/*
+   Created by Kang'alia Isaac Nyamu
+   P15/1325/2011
+   The University of Nairobi
+   School of Computing and Informatics
+   Fourth Year BSc Computer Science Project
+   The Automated Greenhouse Monitoring System (Temperature and Humidity Control)
+*/
+
+#include <Thc.h>
+#include "DHT.h"
+#include <LCD.h>
+#include <LiquidCrystal_I2C.h>
+#include <Wire.h>
+
+
+#define DHTPIN 2     	// what pin we're connected to
+
+#define DHTTYPE DHT11   // DHT 11
+
+//Initialize DHT sensor for normal 16mhz Arduino
+DHT dht(DHTPIN, DHTTYPE);
+
+Thc Thc(5, 9, 10, 11, 13); //This bracket will contain the pin numbers we are to use,It is meant to initialize them to output/input mode
+//Thc Thc(Fan In,Fan Out, Heater,Humidifier,Error Pin)
+
+void setup()
+{
+  Serial.begin(9600);
+  dht.begin();
+  Thc.Init();
+}
+
+void loop()
+{
+  delay(2000);
+
+  float TEMP = dht.readTemperature();
+  float HUM = dht.readHumidity();
+  Thc.GodsCommand(HUM,TEMP);
+}


Add accelerometer orientation example

Add accelerometer orientation example

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

--- libraries/CurieImu/examples/AccelerometerOrientation/AccelerometerOrientation.ino
+++ libraries/CurieImu/examples/AccelerometerOrientation/AccelerometerOrientation.ino
@@ -0,0 +1,100 @@
+/*
+   Copyright (c) 2015 Intel Corporation.  All rights reserved.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
+
+/*
+   This sketch example demonstrates how the BMI160 on the
+   Intel(R) Curie(TM) module can be used to read accelerometer data
+   and translate it to an orientation
+*/
+
+#include "CurieImu.h"
+
+int lastOrientation = - 1; // previous orientation (for comparison)
+
+void setup() {
+  Serial.begin(9600); // initialize Serial communication
+  while (!Serial);    // wait for the serial port to open
+
+  // initialize device
+  Serial.println("Initializing IMU device...");
+  CurieIMU.begin();
+
+  // Set the accelerometer range to 2G
+  CurieIMU.setAccelerometerRange(CURIE_IMU_ACCELEROMETER_RANGE_2G);
+}
+
+void loop() {
+int orientation = - 1;   // the board's orientation
+  String orientationString; // string for printing description of orientation
+  /*
+    The orientations of the board:
+    0: flat, processor facing up
+    1: flat, processor facing down
+    2: landscape, analog pins down
+    3: landscape, analog pins up
+    4: portrait, USB connector up
+    5: portrait, USB connector down
+  */
+  // read accelerometer:
+  short x = CurieIMU.readAccelerometer(X_AXIS);
+  short y = CurieIMU.readAccelerometer(Y_AXIS);
+  short z = CurieIMU.readAccelerometer(Z_AXIS);
+
+  // calculate the absolute values, to determine the largest
+  int absX = abs(x);
+  int absY = abs(y);
+  int absZ = abs(z);
+
+  if ( (absZ > absX) && (absZ > absY)) {
+    // base orientation on Z
+    if (z > 0) {
+      orientationString = "up";
+      orientation = 0;
+    } else {
+      orientationString = "down";
+      orientation = 1;
+    }
+  } else if ( (absY > absX) && (absY > absZ)) {
+    // base orientation on Y
+    if (y > 0) {
+      orientationString = "digital pins up";
+      orientation = 2;
+    } else {
+      orientationString = "analog pins up";
+      orientation = 3;
+    }
+  } else {
+    // base orientation on X
+    if (x < 0) {
+      orientationString = "connector up";
+      orientation = 4;
+    } else {
+      orientationString = "connector up";
+      orientation = 4;
+    }
+  }
+
+  // if the orientation has changed, print out a description:
+  if (orientation != lastOrientation) {
+    Serial.println(orientationString);
+    lastOrientation = orientation;
+  }
+}
+
+


Added Arduino code

Added Arduino code

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

--- arduino/fasnacht/fasnacht.ino
+++ arduino/fasnacht/fasnacht.ino
@@ -0,0 +1,74 @@
+
+void setup() {
+    // The EL channels are on pins 2 through 9
+    // Initialize the pins as outputs
+    pinMode(0, INPUT);
+    pinMode(1, INPUT);
+    pinMode(2, OUTPUT);    // channel A
+    pinMode(3, OUTPUT);    // channel B
+    pinMode(4, OUTPUT);    // channel C
+    pinMode(5, OUTPUT);    // channel D
+    pinMode(6, OUTPUT);    // channel E
+    pinMode(7, OUTPUT);    // channel F
+    pinMode(8, OUTPUT);    // channel G
+    pinMode(9, OUTPUT);    // channel H
+    // We also have two status LEDs, pin 10 on the Escudo,
+    // and pin 13 on the Arduino itself
+    pinMode(10, OUTPUT);
+    pinMode(13, OUTPUT);
+    Serial.begin(9600);
+    Serial.println("Fasnacht 2014");
+}
+
+void loop()
+{
+    unsigned long start, count, finish, time, frq;
+    unsigned int x, b, last, value, avg, highest = 0, lowest = 1023;
+    int brightness;
+
+    digitalWrite(13, 1);
+
+    start = millis();
+    count = 0;
+
+    for (x = 0; x < 500; x++) {
+        value = analogRead(3);
+        if (value > highest) {
+            highest = value;
+        }
+        if (value < lowest) {
+            lowest = value;
+        }
+        avg = (highest + lowest) / 2;
+
+        if (value > avg) {
+          b = 1;
+        } else {
+          b = 0;
+        }
+        if (b != last) {
+            count++;
+        }
+        last = b;
+    }
+
+    finish = millis();
+    time = finish - start;
+    frq = count * 100 / time / 2 * 10;
+    brightness = (int) (frq - 100) / 2;
+
+    if (brightness >= 255) {
+        brightness = 255;
+    }
+    if (brightness < 0) {
+        brightness = 0;
+    }
+
+    Serial.print("Frequenz: ");
+    Serial.println(frq);
+    Serial.print("Brightness: ");
+    Serial.println(brightness);
+
+    digitalWrite(13, 0);
+}
+


Add UdbSendReceive example

Add UdbSendReceive example

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


ATMEGA328P

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

--- arduino/PortableTHLE.ino
+++ arduino/PortableTHLE.ino
@@ -0,0 +1,403 @@
+/*
+ * Programma per la lettura di una sonda DHT11, ovvero, Temperatura e Umidita`.
+ * Oltre alla visualizzazione su schermo TFT LCD dei valori in formato testo,
+ * viene realizzato un grafico temporale, con l'ausilio di un integrato DS1302
+ * con relativo modulo completo di batteria tampone.
+ * Se possibile, sara` aggiunto un ESP8266 per la trasmissione dei dati o
+ * per la lettura tramite pagina web, da decidere ...
+ *
+ * PortableTHLE:
+ * . Temperatura
+ * . Umidita`
+ * . LCD
+ * . ESP8266
+ */
+
+#include <TFT.h>  // Arduino LCD library
+#include <SPI.h>
+#include <dht.h>
+#include <DS1302RTC.h>
+#include <Time.h>
+#include <SoftwareSerial.h>
+
+// TFT LCD
+// pin definition for the LCD (Uno, Nano)
+#define cs   10
+#define dc   8
+#define rst  9
+
+// create an instance of the library
+TFT TFTscreen = TFT(cs, dc, rst);
+
+// DHT11, Sensore di temperatura e umidita`
+dht DHT;
+#define DHT11_PIN 4
+
+float Humidity;
+float Temperature;
+float MemHumidity = 0;
+float MemTemperature = 0;
+
+// Init the DS1302
+// Set pins:  CE, IO,CLK
+DS1302RTC RTC(5, 6, 7);
+
+// ESP8266
+SoftwareSerial ESP(2,3); // RX e` il 2,TX e` il 3, collegati a ESP8266
+
+/*
+ * Variabili accessorie per stampe sul display e memorizzazioni
+ */
+// char array to print to the screen, only Humidity & Temperature ?
+char SensorTPrintout[6];
+char SensorHPrintout[6];
+char DataPrintout[11];
+char TimePrintout[9];
+
+// e memorie ..
+char MemSensorHPrintout[6];
+char MemSensorTPrintout[6];
+char MemDataPrintout[11];
+char MemTimePrintout[9];
+
+//int Second = 0;
+//int Minute = 0;
+//int Day = 0;
+int MemSecond = 0;
+int MemMinute = 0;
+int MemDay = 0;
+
+// int array per creazione grafico
+/*
+ * Ho dovuto usare degli interi, sia per limitare l'uso di memoria
+ * che per ragioni pratiche di stampa del grafico tramite accensione
+ * dei pixel dello schermo LCD
+ */
+int ArrayTemperature[128];
+int ArrayHumidity[128];
+int CycleArray = 0; // Valori ciclici da 0 a 127
+
+void writeTextStatic() {
+  // write the static text to the screen
+  // set the font color to white
+  TFTscreen.stroke(255, 255, 255);
+  // set the font size
+  TFTscreen.setTextSize(1);
+  // write the text to the top left corner of the screen
+  // write the text
+  TFTscreen.text("Data       Ora\n ", 0, 0);
+  // write the text
+  TFTscreen.text("Umidita`\n ", 0, 16);
+  // write the text
+  TFTscreen.text("Temperatura\n ", 0, 32);
+}
+
+void print2digits(int number) {
+  if (number >= 0 && number < 10)
+    Serial.write('0');
+  Serial.print(number);
+}
+
+void setup() {
+  // Setup Serial connection
+  Serial.begin(9600);
+
+  // Setup serial ESP8266
+  ESP.begin(115200);
+  ESP.setTimeout(15000);
+
+  Serial.println("DS1302RTC Read Test");
+  Serial.println("-------------------");
+
+  // Activate RTC module
+  Serial.println("RTC module activated");
+  Serial.println();
+  delay(500);
+
+  if (RTC.haltRTC()) {
+    Serial.println("The DS1302 is stopped.  Please run the SetTime");
+    Serial.println("example to initialize the time and begin running.");
+    Serial.println();
+  }
+  if (!RTC.writeEN()) {
+    Serial.println("The DS1302 is write protected. This normal.");
+    Serial.println();
+  }
+
+  //delay(5000);
+
+  // TFT
+  // Put this line at the beginning of every sketch that uses the GLCD:
+  TFTscreen.begin();
+
+  // clear the screen with a black background
+  TFTscreen.background(0, 0, 0);
+
+  writeTextStatic();
+
+  delay(2000);
+}
+
+void loop() {
+
+  //RTC
+  tmElements_t tm;
+
+  Serial.print("UNIX Time: ");
+  Serial.print(RTC.get());
+
+  if (! RTC.read(tm)) {
+    Serial.print("  Time = ");
+    print2digits(tm.Hour);
+    Serial.write(':');
+    print2digits(tm.Minute);
+    Serial.write(':');
+    print2digits(tm.Second);
+    Serial.print(", Date (D/M/Y) = ");
+    Serial.print(tm.Day);
+    Serial.write('/');
+    Serial.print(tm.Month);
+    Serial.write('/');
+    Serial.print(tmYearToCalendar(tm.Year));
+    Serial.print(", DoW = ");
+    Serial.print(tm.Wday);
+    Serial.println();
+  } else {
+    Serial.println("DS1302 read error!  Please check the circuitry.");
+    Serial.println();
+    delay(9000);
+  }
+
+  // DHT11
+  // READ DATA
+  Serial.print("DHT11, \t");
+  int chk = DHT.read11(DHT11_PIN);
+  switch (chk)
+  {
+    case DHTLIB_OK:
+      Serial.print("OK,\t");
+      break;
+    case DHTLIB_ERROR_CHECKSUM:
+      Serial.print("Checksum error,\t");
+      break;
+    case DHTLIB_ERROR_TIMEOUT:
+      Serial.print("Time out error,\t");
+      break;
+    default:
+      Serial.print("Unknown error,\t");
+      break;
+  }
+  // DISPLAY DATA
+  Temperature = DHT.temperature;
+  Humidity = DHT.humidity;
+  Serial.print(Humidity, 1);
+  Serial.print(",\t");
+  Serial.println(Temperature, 1);
+
+  // LCD
+  // Read the value from DHT11
+  String sensorValH = String(Humidity);
+  String sensorValT = String(Temperature);
+
+  // convert the reading to a char array
+  sensorValH.toCharArray(SensorHPrintout, 6);
+  sensorValT.toCharArray(SensorTPrintout, 6);
+
+  // Read the value from
+  // String DataValT = String(tmYearToCalendar(tm.Year) + tm.Month + tm.Day + tm.Hour + tm.Minute + tm.Second); CALCOLA INVECE DI CONCATENARE !
+  String DataVal1 = String(tmYearToCalendar(tm.Year));
+  String DataVal2 = String(DataVal1 + "-" + tm.Month);
+  String DataValDay = String(DataVal2 + "-" + tm.Day);
+  String DataVal3 = String(tm.Hour);
+  String DataVal4 = String(DataVal3 + ":" + tm.Minute);
+  String DataValTime = String(DataVal4 + ":" + tm.Second);
+  int Second = tm.Second;
+  DataValDay.toCharArray(DataPrintout, 11);
+  DataValTime.toCharArray(TimePrintout, 9);
+
+  // ste the font size for date/time
+  TFTscreen.setTextSize(1);
+
+  // Date/time
+  /*
+   *  Se valore e` diverso dalla memoria,
+   *  [ri]scrivo la memoria e poi il valore,
+   *  poi metto la memoria uguale al valore
+   */
+  if (tm.Day != MemDay) {
+    // erase the text you just wrote
+    TFTscreen.stroke(0, 0, 0);
+    TFTscreen.text(MemDataPrintout, 0, 8);
+    // set the font color
+    TFTscreen.stroke(255, 255, 0);
+    // print
+    TFTscreen.text(DataPrintout, 0, 8);
+    // Memorie
+    MemDay = tm.Day;
+    strcpy (MemDataPrintout, DataPrintout);
+  }
+
+  if (tm.Second != MemSecond) {
+    // erase the text you just wrote
+    TFTscreen.stroke(0, 0, 0);
+    TFTscreen.text(MemTimePrintout, 66, 8);
+    // set the font color
+    TFTscreen.stroke(255, 255, 0);
+    // print
+    TFTscreen.text(TimePrintout, 66, 8);
+    // Memorie
+    MemSecond = tm.Second;
+    strcpy (MemTimePrintout, TimePrintout);
+  }
+
+  // ste the font size for date/time
+  TFTscreen.setTextSize(2);
+
+  // Humidity
+  if (Humidity != MemHumidity) {
+    // erase the text you just wrote
+    TFTscreen.stroke(0, 0, 0);
+    TFTscreen.text(MemSensorHPrintout, 66, 16);
+    // set the font color
+    TFTscreen.stroke(0, 255, 0);
+    // print the sensor value
+    TFTscreen.text(SensorHPrintout, 66, 16);
+    MemHumidity = Humidity;
+    strcpy (MemSensorHPrintout, SensorHPrintout);
+  }
+
+  // Temperature
+  if (Temperature != MemTemperature) {
+    // erase the text you just wrote
+    TFTscreen.stroke(0, 0, 0);
+    TFTscreen.text(MemSensorTPrintout, 66, 32);
+    // set the font color
+    TFTscreen.stroke(255, 0, 0);
+    // print the sensor value
+    TFTscreen.text(SensorTPrintout, 66, 32);
+    ESP.println(SensorTPrintout); // ESP8266
+    MemTemperature = Temperature;
+    strcpy (MemSensorTPrintout, SensorTPrintout);
+  }
+
+
+  // Adesso ho messo SECONDI, solo per velocizzare i test
+  //if (Minute != MemMinute) {
+  if (tm.Minute != MemMinute) {
+    // Stampa array su LCD
+    /*
+    * Stampa i 128 (come i pixel) valori di temperatura e umidita`,
+    * creando un grafico.
+    * Al solito, devo prima eliminare la scritta precedente
+    * e poi mettere la nuova.
+    */
+    // Prima cancello le scritte
+    TFTscreen.stroke(0, 0, 0);
+    for (CycleArray = 127; CycleArray >= 0; CycleArray--) {
+      TFTscreen.point(CycleArray, 127 - ArrayHumidity[CycleArray]);
+      TFTscreen.point(CycleArray, 127 - ArrayTemperature[CycleArray]);
+    }
+    // Poi shifto e aggiorno con l'ultimo valore
+    for (CycleArray = 0; CycleArray <= 126; CycleArray++) {
+      ArrayHumidity[CycleArray] = ArrayHumidity[CycleArray+1];
+      ArrayTemperature[CycleArray] = ArrayTemperature[CycleArray+1];
+    }
+    // Quando finisce e` al 127 e posso scrivere il dato nuovo
+    ArrayHumidity[CycleArray] = Humidity;
+    ArrayTemperature[CycleArray] = Temperature;
+    MemMinute = tm.Minute;
+    // Scrivo ..
+    for (CycleArray = 127; CycleArray >= 0; CycleArray--) {
+      TFTscreen.stroke(0, 255, 0);
+      TFTscreen.point(CycleArray, 127 - ArrayHumidity[CycleArray]);
+      TFTscreen.stroke(255, 0, 0);
+      TFTscreen.point(CycleArray, 127 - ArrayTemperature[CycleArray]);
+    }
+  }
+
+/*
+  // Stampe a video (seriale) per verifiche
+  Serial.print("\n");
+  Serial.print(DHT.humidity);
+  Serial.print(",\t");
+  Serial.print(DHT.temperature);
+
+  Serial.print("\n");
+  Serial.print(sensorValH);
+  Serial.print(",\t");
+  Serial.print(sensorValT);
+
+  Serial.print("\n");
+  Serial.print(SensorHPrintout);
+  Serial.print(",\t");
+  Serial.print(SensorTPrintout);
+
+  Serial.print("\n");
+  Serial.print(MemSensorHPrintout);
+  Serial.print(",\t");
+  Serial.print(MemSensorTPrintout);
+
+  Serial.print("\nHumidity, Temperature\n");
+  Serial.print(Humidity);
+  Serial.print(",\t");
+  Serial.print(Temperature);
+
+  Serial.print("\n");
+  Serial.print(MemHumidity);
+  Serial.print(",\t");
+  Serial.print(MemTemperature);
+
+  Serial.print("\nDataValT, DataPrintout\n");
+  Serial.print(DataValT);
+  Serial.print(",\t");
+  Serial.print(DataPrintout);
+
+  Serial.print("\nSecond, Memory\n");
+  Serial.print(Second);
+  Serial.print(",\t");
+  Serial.print(MemSecond);
+  Serial.print("\n");
+
+  Serial.print("\nLarghezza, Altezza\n");
+  Serial.print(TFTscreen.width());
+  Serial.print(",\t");
+  Serial.print(TFTscreen.height());
+  Serial.print("\n");
+
+  Serial.print("\nMinuti,\n");
+  Serial.print(tm.Minute);
+  Serial.print(",\t");
+  Serial.print(MemMinute);
+  Serial.print(",\t");
+  Serial.print(CycleArray);
+  Serial.print("\n");
+
+  Serial.print("\nArray ...\n");
+  int i;
+  for (i = 0; i < 128; i = i + 1) {
+    Serial.print(ArrayTemperature[i]);
+    Serial.print(",");
+  }
+  Serial.print("\n");
+  //int i;
+  for (i = 0; i < 128; i = i + 1) {
+    Serial.print(ArrayHumidity[i]);
+    Serial.print(",");
+  }
+  Serial.print("\n");
+
+  /*
+  TFTscreen.stroke(255, 0, 0);
+  // draw a pixel in the screen's center
+  TFTscreen.point(TFTscreen.width()/2, TFTscreen.height()/2);
+  TFTscreen.point(64, 64);
+  TFTscreen.point(65, 65);
+  TFTscreen.point(66, 66);
+  */
+
+  /*
+   * Mi sa che i delay serva per la stabilita` delle letture
+   * Cerco di tenerlo il piu` basso possibile, a 200 funziona, metto 300 per sicurezza
+   */
+  delay(300);
+}


v1.0  Initial release

v1.0  Initial release

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

--- GPSLCD.ino
+++ GPSLCD.ino
@@ -0,0 +1,642 @@
+/* GPS LCD
+
+    By GK Grotsky
+    8/30/16
+
+  This program communicate with the u-blox NEO-6M GPS module
+  through a software serial interface. It then displays certain GPS
+  parameters on a I2C 16x2 (or 20x4) character LCD display module. The
+  GPS messages are received by the on-board Arduino UART circuit using
+  the SoftwareSerial library. It then uses the TinyGPS++ library to
+  decode the GPS NMEA messages. The parameters are then displayed on a
+  16x4 (or 20x4) LCD using the LiquidCrystal_I2C library.
+
+  Note: Both the 16x2 and 20x4 LCDs are supported as these are the most popular
+        LCDs available.
+*/
+#include "GPSLCD.h"
+#include <TinyGPS++.h>
+#include <SoftwareSerial.h>
+#include <LiquidCrystal_I2C.h>
+
+TinyGPSPlus gps; // This is the GPS object that will pretty much do all the grunt work with the NMEA data
+SoftwareSerial GPSModule(10, 11); // RX, TX
+LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin); // Initializes class variables and defines the I2C address of the LCD
+bool dataValid; // Data is valid from the GPS module
+GPSStruct GPSData; // Holds the GPS data coming from the GPS module
+
+// The setup (runs once at start up)
+void setup()
+{
+  pinMode(BACKLIGHT_SW, INPUT);
+
+#ifdef _16x2
+  // Selects either speed or heading to be displayed
+  pinMode(SPEED_ALTITUDE_SW, INPUT);
+#else
+  // Selects either altitude or the date/time to be displayed
+  pinMode(ALTITUDE_DATE_TIME_SW, INPUT);
+#endif
+
+#ifdef DEBUG
+  Serial.begin(9600); // This opens up communications to the serial monitor in the Arduino IDE
+  Serial.flush();
+#endif
+  GPSModule.begin(9600); // This opens up communications to the software serial tx and rx lines
+  GPSModule.flush();
+
+  lcd.begin (COLUMN, ROW); // Defines LCD type
+  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE); // Sets the pin to control the backlight
+  lcd.clear(); // Clear the LCD
+  lcd.home (); // Go to the home position on the LCD
+} // setup
+
+// The loop (runs forever and a day :-))
+void loop()
+{
+  static uint32_t pastSatellites = 0;
+  static byte initializingCounter = 0;
+  static unsigned long prevInitializationTime = INITIALIZATION_INTERVAL;
+  static unsigned long prevCreditTime = TOGGLETIME_INTERVAL;
+  static unsigned long prevInvalidSatellitesTime = TOGGLETIME_INTERVAL;
+  static bool leftInitialization = false;
+  static bool creditToggle = true;
+  static bool InvalidSatellitesToggle = true;
+#ifndef _16x2
+  static unsigned long prevDateTime = TOGGLETIME_INTERVAL;
+  static unsigned long prevHeadingTime = TOGGLETIME_INTERVAL;
+  static bool dateTimeToggle = true;
+  static bool headingToggle = true;
+#endif
+#ifdef DEBUG
+  static unsigned long prevDebugTime = 0;
+#endif
+#ifdef DATA_VALID_OVERRIDE
+  const bool dataValidOverride = true; // Set true to override data valid for debugging
+#else
+  const bool dataValidOverride = false; // Set false not to override data valid
+#endif
+#ifdef BACKLIGHT_OVERRIDE
+  // Override LCD backlight switch
+  // Force LCD backlight on/off
+  lcd.setBacklight(BACKLIGHT_ONOFF);
+#else
+  // Turn LCD backlight on/off
+  lcd.setBacklight(digitalRead(BACKLIGHT_SW));
+#endif
+  unsigned long now = millis();
+
+  while (GPSModule.available()) // While there are characters to come from the GPS
+  {
+    bool b = gps.encode(GPSModule.read()); // This feeds the serial NMEA data into the GPS library one char at a time
+  }
+
+  // Get the GPS data valid flags
+  dataValid =
+    gps.location.isValid()   &&
+    gps.speed.isValid()      &&
+    gps.altitude.isValid()   &&
+    gps.course.isValid()     &&
+    gps.date.isValid()       &&
+    gps.time.isValid()       &&
+    gps.satellites.isValid();
+
+  // Check if the GPS data is valid or data valid override is set (for debugging)
+  if (dataValid || dataValidOverride) {
+#ifndef DATA_VALID_OVERRIDE
+    // Store the real GPS data
+    GPSData.satellites = gps.satellites.value();
+    GPSData.lat        = gps.location.lat();
+    GPSData.lon        = gps.location.lng();
+    GPSData.speed      = gps.speed.mph();
+    GPSData.altitude   = gps.altitude.feet();
+#ifndef _16x2
+    GPSData.heading    = gps.course.deg();
+    GPSData.year       = gps.date.year();
+    GPSData.month      = gps.date.month();
+    GPSData.day        = gps.date.day();
+    GPSData.hour       = gps.time.hour();
+    GPSData.minute     = gps.time.minute();
+    GPSData.second     = gps.time.second();
+#endif // #ifndef _16x2
+#else // #ifndef DATA_VALID_OVERRIDE
+    // Store the fake GPS data (for debugging)
+    GPSData.satellites = 0; // Invalid satellites
+    GPSData.lat        = 39.16d; // East coast
+    GPSData.lon        = -77.07d; //   "
+    GPSData.speed      = 55.0d;
+    GPSData.altitude   = 555.0d;
+#ifndef _16x2
+    GPSData.heading    = 60.0d; // ENE or NE (16 cardinal point or 8 cardinal point)
+    GPSData.year       = 2016;
+    GPSData.month      = 11; // Day before ST starts
+    GPSData.day        = 5;  //      "
+    GPSData.hour       = 23; // 7pm my local time
+    GPSData.minute     = 10;
+    GPSData.second     = 25;
+#endif // #ifndef _16x2
+#endif // #ifndef DATA_VALID_OVERRIDE
+    // Clear the screen once when leaving initialization
+    if (!leftInitialization) {
+      leftInitialization = true;
+      lcd.clear(); // Clear the LCD
+    }
+    // Display the latest info from the gps object which it derived from the data sent by the GPS unit
+    // Send data to the LCD
+#ifdef _16x2 //------------------------------------------------------
+    lcd.home (); // Go to 1st line
+    lcd.print("Lat: ");
+    lcd.print(GPSData.lat);
+    lcd.setCursor (11, 0);
+    lcd.print("SV:");
+    if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0)) {
+      pastSatellites = GPSData.satellites;
+      if (GPSData.satellites == 0) {
+        // Toggle invalid satellites indicator every TOGGLETIME_INTERVAL seconds
+        if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL / 4) {
+          prevInvalidSatellitesTime = now;
+          if (InvalidSatellitesToggle) {
+            InvalidSatellitesToggle = false;
+            lcd.print("XX");
+          }
+          else {
+            InvalidSatellitesToggle = true;
+            lcd.print("  ");
+          } // if (InvalidSatellitesToggle)
+        } // if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL)
+      } // if (GPSData.satellites == 0)
+      else if (GPSData.satellites <= 9) {
+        lcd.print(" "); // Blank leading char
+        lcd.print(GPSData.satellites);
+      }
+      else {
+        lcd.print(GPSData.satellites);
+      }
+    } // if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0))
+    lcd.setCursor (0, 1); // Go to 2nd line
+    lcd.print("Lon: ");
+    lcd.print(GPSData.lon);
+    if ((digitalRead(SPEED_ALTITUDE_SW))) {
+      lcd.setCursor (12, 1);
+      if (GPSData.speed < SPEED_CUTOUT) {
+        lcd.print("0  ");
+      }
+      else {
+        lcd.print((int)GPSData.speed);
+        lcd.print(" "); // Clear the extra char
+      }
+    }
+    else {
+      lcd.print("     "); // Clear the extra chars
+      if (GPSData.altitude <= 99.9) {
+        lcd.setCursor (14, 1);
+      }
+      else {
+        lcd.setCursor (13, 1);
+      }
+      lcd.print((int)GPSData.altitude); // Altitude
+      // Toggle credit every TOGGLETIME_INTERVAL seconds
+      if (now - prevCreditTime > (TOGGLETIME_INTERVAL / 2)) {
+        prevCreditTime = now;
+        if (creditToggle) { // Display credit
+          creditToggle = false;
+          lcd.print("     "); // Clear the extra chars
+          lcd.print(CREDIT); // Yours truly :-)
+        }
+        else {
+          creditToggle = true;
+          lcd.print("        "); // Clear the extra chars
+        }
+      } // if (now - prevCreditTime > TOGGLETIME_INTERVAL)
+    } // if ((digitalRead(SPEED_ALTITUDE_SW)))
+#else // 20x4 ----------------------------------------------------
+    lcd.home (); // Go to 1st line
+    lcd.print("Lat: ");
+    lcd.print(GPSData.lat);
+    lcd.setCursor (15, 0);
+    lcd.print("SV:");
+    if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0)) {
+      pastSatellites = GPSData.satellites;
+      if (GPSData.satellites == 0) {
+        // Toggle invalid satellites indicator every TOGGLETIME_INTERVAL seconds
+        if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL / 3) {
+          prevInvalidSatellitesTime = now;
+          if (InvalidSatellitesToggle) {
+            InvalidSatellitesToggle = false;
+            lcd.print("XX");
+          }
+          else {
+            InvalidSatellitesToggle = true;
+            lcd.print("  ");
+          } // if (InvalidSatellitesToggle)
+        } // if (now - prevInvalidSatellitesTime > TOGGLETIME_INTERVAL)
+      } // if (GPSData.satellites == 0)
+      else if (GPSData.satellites <= 9) {
+        lcd.print(" "); // Blank leading char
+        lcd.print(GPSData.satellites);
+      }
+      else {
+        lcd.print(GPSData.satellites);
+      }
+    } // if ((pastSatellites != GPSData.satellites) || (GPSData.satellites == 0))
+    lcd.setCursor (0, 1); // Go to 2nd line
+    lcd.print("Lon: ");
+    lcd.print(GPSData.lon);
+#ifndef CONVERT_TO_LOCAL
+    // Only display if time/date is selected
+    if (!(digitalRead(ALTITUDE_DATE_TIME_SW))) {
+      lcd.print("      "); // Clear the extra chars
+      uint8_t DOW = dayOfWeek(GPSData.year, GPSData.month, GPSData.day);
+      if (IsDST(GPSData.day, GPSData.month, DOW)) {
+        lcd.print("DST");
+      }
+      else {
+        lcd.print(" ST");
+      }
+    }
+    else {
+      lcd.print("         "); // Clear the extra chars
+    }
+#endif // #ifndef CONVERT_TO_LOCAL
+    lcd.setCursor (0, 2); // Go to 3rd line
+    lcd.print("Spd: ");
+    if (GPSData.speed < SPEED_CUTOUT) {
+      lcd.print("0  ");
+    }
+    else {
+      lcd.print((int)GPSData.speed);
+      lcd.print(" "); // Clear the extra chars
+    }
+    lcd.setCursor (12, 2);
+    lcd.print("Hdg: ");
+    if (GPSData.speed < SPEED_CUTOUT) {
+      lcd.print("0  ");
+    }
+    else {
+      // Toggle heading every TOGGLETIME_INTERVAL seconds
+      if (now - prevHeadingTime > TOGGLETIME_INTERVAL) {
+        prevHeadingTime = now;
+        if (headingToggle) { // Display cardinal heading
+          headingToggle = false;
+          lcd.print(cardinal(GPSData.heading));
+        }
+        else { // Display degrees heading
+          headingToggle = true;
+          lcd.print((int)GPSData.heading);
+          if (GPSData.heading <= 99.9) lcd.print(" "); // Clear the extra char
+        } // if (headingToggle)
+      } // if (now - prevHeadingTime > TOGGLETIME_INTERVAL)
+    } // if (GPSData.speed < SPEED_CUTOUT)
+    lcd.setCursor (0, 3); // Go to 4th line
+    if ((digitalRead(ALTITUDE_DATE_TIME_SW))) {
+      lcd.print("Alt: ");
+      lcd.print((int)GPSData.altitude);
+      // Toggle credit every TOGGLETIME_INTERVAL seconds
+      if (now - prevCreditTime > (TOGGLETIME_INTERVAL / 2)) {
+        prevCreditTime = now;
+        if (creditToggle) { // Display credit
+          creditToggle = false;
+          lcd.print("         "); // Clear the extra chars
+          lcd.print(CREDIT); // Yours truly :-)
+        }
+        else {
+          creditToggle = true;
+          lcd.print("            "); // Clear the extra chars
+        }
+      } // if (now - prevCreditTime > TOGGLETIME_INTERVAL)
+      prevDateTime = TOGGLETIME_INTERVAL;
+      dateTimeToggle = true; // Default first to display date
+    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
+    else {
+      // Toggle date/time every TOGGLETIME_INTERVAL seconds
+      if (now - prevDateTime > TOGGLETIME_INTERVAL) {
+        prevDateTime = now;
+        if (dateTimeToggle) {
+          // Display date
+          dateTimeToggle = false;
+          lcd.print("Date: ");
+          uint8_t hour = GPSData.hour;
+          uint8_t day  = GPSData.day;
+          uint8_t month = GPSData.month;
+          uint16_t year = GPSData.year;
+#ifdef CONVERT_TO_LOCAL
+          // Convert UTC date to local date
+          bool DST = convertToLocal (&hour, &year, &month,
+                                     &day, GPSData.lon, true); // true means date conversion
+#endif // #ifdef CONVERT_TO_LOCAL
+          if (month < 10) lcd.print("0");
+          lcd.print(month);
+          lcd.print("/");
+          if (day < 10) lcd.print("0");
+          lcd.print(day);
+          lcd.print("/");
+          lcd.print(year);
+          printDay (dayOfWeek (year, month, day));
+        } // if (dateTimeToggle)
+        else {
+          // Display time
+          dateTimeToggle = true;
+          lcd.print("Time: ");
+          uint8_t hour = GPSData.hour;
+          uint8_t day  = GPSData.day;
+          uint8_t month = GPSData.month;
+          uint16_t year = GPSData.year;
+#ifdef CONVERT_TO_LOCAL
+          // Convert UTC time to local time (no need to convert the date)
+          bool DST = convertToLocal (&hour, &year, &month,
+                                     &day, GPSData.lon, false); // false means no date conversion
+#else // #ifdef CONVERT_TO_LOCAL
+#ifdef DISPLAY_12_HOUR
+          if (hour == 0) { // 12 hour clocks don't display 0
+            hour = 12;
+          }
+#endif // #ifdef DISPLAY_12_HOUR
+#endif // #ifdef CONVERT_TO_LOCAL
+#ifdef DISPLAY_12_HOUR
+          char AMPM[] = "am";
+          if (hour >= 12) { // Convert to 12 hour format
+            if (hour > 12) hour -= 12;
+            strcpy (AMPM, "pm");
+          }
+#endif
+          if (hour < 10) lcd.print("0");
+          lcd.print(hour);
+          lcd.print(":");
+          if (GPSData.minute < 10) lcd.print("0");
+          lcd.print(GPSData.minute);
+          lcd.print(":");
+          if (GPSData.second < 10) lcd.print("0");
+          lcd.print(GPSData.second);
+#ifdef DISPLAY_12_HOUR
+          lcd.print(AMPM);
+#endif // #ifdef DISPLAY_12_HOUR
+#ifdef CONVERT_TO_LOCAL
+#ifdef DISPLAY_12_HOUR
+          (DST) ? lcd.print(" DST") : lcd.print("  ST");
+#else // #ifdef DISPLAY_12_HOUR
+          (DST) ? lcd.print("   DST") : lcd.print("    ST");
+#endif // #ifdef DISPLAY_12_HOUR
+#endif // #ifndef CONVERT_TO_LOCAL
+#ifndef CONVERT_TO_LOCAL
+#ifdef DISPLAY_12_HOUR
+          lcd.print(" UTC");
+#else // #ifdef DISPLAY_12_HOUR
+          lcd.print("   UTC");
+#endif // #ifdef DISPLAY_12_HOUR
+#endif // #ifndef CONVERT_TO_LOCAL
+        } // if (dateTimeToggle)
+      } // if (now - prevDateTime > TOGGLETIME_INTERVAL)
+    } // if ((digitalRead(ALTITUDE_DATE_TIME_SW)))
+#endif //------------------------------------------------------------
+  } // if (dataValid)
+  else {
+    // GPS data is not valid, so it must be initializing
+#ifdef _16x2 //------------------------------------------------------
+    // Display initialization screen once every INITIALIZATION_INTERVAL
+    if (now - prevInitializationTime > INITIALIZATION_INTERVAL) {
+      prevInitializationTime = now;
+      lcd.setCursor (6, 0); // Go to 1st line
+      lcd.print("GPS");
+      lcd.setCursor (11, 0);
+      lcd.print("v");
+      lcd.print(VERSION);
+      lcd.setCursor (2, 1); // Go to 2nd line
+      lcd.print("Initializing");
+      lcd.setCursor (15, 1);
+      if (++initializingCounter > 9) initializingCounter = 1; // Limit 1 - 9
+      lcd.print(initializingCounter);
+      leftInitialization = false;
+    }
+#else // 20x4 -------------------------------------------------------
+    // Display initialization screen once every INITIALIZATION_INTERVAL
+    if (now - prevInitializationTime > INITIALIZATION_INTERVAL) {
+      prevInitializationTime = now;
+      lcd.setCursor (8, 0); // Go to 1st line
+      lcd.print("GPS");
+      lcd.setCursor (14, 0);
+      lcd.print("v");
+      lcd.print(VERSION);
+      lcd.setCursor (4, 1); // Go to 2nd line
+      lcd.print("Initializing");
+      lcd.setCursor (6, 2); // Go to 3rd line
+      lcd.print("Data Not");
+      lcd.setCursor (7, 3); // Go to 4th line
+      lcd.print("Valid");
+      lcd.setCursor (19, 3);
+      if (++initializingCounter > 9) initializingCounter = 1; // Limit 1 - 9
+      lcd.print(initializingCounter);
+      leftInitialization = false;
+    }
+#endif //------------------------------------------------------------
+  } // GPS data is not valid
+#ifdef DEBUG
+  // Display debug info to the serial monitor (if DEBUG is enabled)
+  // Display debug data once every DEBUG_INTERVAL
+  if (now - prevDebugTime > DEBUG_INTERVAL) {
+    prevDebugTime = now;
+    displayDebugData();
+  }
+#endif // #ifdef DEBUG
+} // loop
+
+#ifndef _16x2
+/* Helper functions start here
+
+  Ripped off from Electrical Engineering Stack Exchange
+  http://electronics.stackexchange.com/questions/66285/how-to-calculate-day-of-the-week-for-rtc
+  ------------------------------------------------------------
+   Returns the number of days to the start of the specified year, taking leap
+   years into account, but not the shift from the Julian calendar to the
+   Gregorian calendar. Instead, it is as though the Gregorian calendar is
+   extrapolated back in time to a hypothetical "year zero".
+*/
+uint16_t leap (uint16_t year)
+{
+  return year * 365 + (year / 4) - (year / 100) + (year / 400);
+}
+/* Returns a number representing the number of days since March 1 in the
+   hypothetical year 0, not counting the change from the Julian calendar
+   to the Gregorian calendar that occurred in the 16th century. This
+   algorithm is loosely based on a function known as "Zeller's Congruence".
+   This number MOD 7 gives the day of week, where 0 = Monday and 6 = Sunday.
+*/
+uint16_t zeller (uint16_t year, uint8_t month, uint8_t day)
+{
+  year += ((month + 9) / 12) - 1;
+  month = (month + 9) % 12;
+  return leap (year) + month * 30 + ((6 * month + 5) / 10) + day + 1;
+}
+
+// Returns the day of week for a given date.
+uint8_t dayOfWeek (uint16_t year, uint8_t month, uint8_t day)
+{
+  return (zeller (year, month, day) % 7) + 1;
+}
+//----------------------------------------------------------
+
+// Print the day of the week on the LCD
+void printDay(uint8_t day)
+{
+  if (day == 7) day = 0;
+  switch (day)
+  {
+    case 0:  lcd.print(" Mon"); break;
+    case 1:  lcd.print(" Tue"); break;
+    case 2:  lcd.print(" Wed"); break;
+    case 3:  lcd.print(" Thu"); break;
+    case 4:  lcd.print(" Fri"); break;
+    case 5:  lcd.print(" Sat"); break;
+    case 6:  lcd.print(" Sun"); break;
+    default: lcd.print(" Err");
+  }
+}
+
+// Compute the cardinal points of the compass
+const char* cardinal(double course)
+{
+#ifdef _16CARDINAL
+  const char* directions[] = {"N  ", "NNE", "NE ", "ENE", "E  ", "ESE", "SE ", "SSE",
+                              "S  ", "SSW", "SW ", "WSW", "W  ", "WNW", "NW ", "NNW"
+                             };
+#else
+  const char* directions[] = {"N  ", "N  ", "NE ", "NE ", "E  ", "E  ", "SE ", "SE ",
+                              "S  ", "S  ", "SW ", "SW ", "W  ", "W  ", "NW ", "NW "
+                             };
+#endif // #ifdef _16CARDINAL
+  uint8_t direction = (uint8_t)((course + 11.25d) / 22.5d);
+  return directions[direction % 16];
+}
+
+/* Ripped off from Stackoverflow
+  http://stackoverflow.com/questions/5590429/calculating-daylight-saving-time-from-only-date
+
+  Check to see if it's Daylight Savings Time (DST)
+*/
+bool IsDST(uint8_t day, uint8_t month , uint8_t DOW)
+{
+  // Make Day of Week (DOW) match with what Stackoverflow suggests
+  // for DOW (Sunday = 0 to Saturday = 6)
+  switch (DOW)
+  {
+    case 6:  DOW = 0; break; // Sun
+    case 7:  DOW = 1; break; // Mon
+    case 1:  DOW = 2; break; // Tue
+    case 2:  DOW = 3; break; // Wed
+    case 3:  DOW = 4; break; // Thu
+    case 4:  DOW = 5; break; // Fri
+    case 5:  DOW = 6; break; // Sat
+    default: break;
+  }
+  // January, February, and December are out
+  if (month < 3 || month > 11) {
+    return false;
+  }
+  // April to October are in
+  if (month > 3 && month < 11) {
+    return true;
+  }
+  int previousSunday = (int)(day - DOW);
+  // In march, we are DST if our previous Sunday was on or after the 8th
+  if (month == 3) {
+    return previousSunday >= 8;
+  }
+  // In November we must be before the first Sunday to be DST
+  // That means the previous Sunday must be before the 1st
+  return previousSunday <= 0;
+}
+
+#ifdef CONVERT_TO_LOCAL
+/* Convert UTC time and date to local time and date
+   Difference between UTC time/date (at Greenwich) and local time/date is 15 minutes
+   per 1 degree of longitude. See the following:
+   http://www.edaboard.com/thread101516.html
+*/
+bool convertToLocal (uint8_t* hour, uint16_t* year, uint8_t* month,
+                     uint8_t* day, const double lon, bool convertDate) {
+
+  uint8_t DaysAMonth [] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+  // Get Day of Week (DOW)
+  uint8_t DOW = dayOfWeek(*year, *month, *day);
+  // Get Daylight Saving Time (DST) or Standard Time (ST)
+  bool DST = IsDST(*day, *month, DOW);
+  // Compute local time (hours)
+  int UTCOffset = (int)(lon / 15.0d); // UTC offset
+  if (UTCOffset < 0) {
+    // West of Greenwich, subtract
+    UTCOffset = abs(UTCOffset); // Make offset positive
+    if (DST) --UTCOffset; // Compensate for DST
+    if (*hour <= UTCOffset) *hour += 24;
+    *hour = *hour - UTCOffset; // Subtract offset
+  }
+  else {
+    // East of Greenwich, add
+    if (DST) ++UTCOffset; // Compensate for DST
+    if (*hour <= UTCOffset) *hour += 24;
+    *hour = *hour + UTCOffset; // Add offset
+  }
+  // Convert date if convertDate flag is set
+  // Portions of the following code (with some modifications) ripped off from Instructables
+  // http://www.instructables.com/id/GPS-time-UTC-to-local-time-conversion-using-Arduin/?ALLSTEPS
+  if (convertDate) {
+    if ((24 - *hour) <= UTCOffset) { // A new UTC day started
+      if (*year % 4 == 0) DaysAMonth[1] = 29; //leap year check (the simple method)
+      if (*hour < 24) {
+        *day -= 1;
+        if (*day < 1) {
+          if (*month == 1) {
+            *month = 12;
+            *year -= 1;
+          } // if (*month == 1)
+          else {
+            *month -= 1;
+          }
+          *day = DaysAMonth[*month - 1];
+        } // if (*day < 1)
+      } // if (*hour < 24)
+      else if (*hour >= 24) {
+        day += 1;
+        if (*day > DaysAMonth[*month - 1]) {
+          *day = 1;
+          *month += 1;
+          if (*month > 12) *year += 1;
+        } // if (*day > DaysAMonth[*month - 1])
+      } // if (*hour >= 24)
+    } // if ((24 - *hour) <= UTCOffset)
+  } // if (convertDate)
+  return (DST);
+}
+#endif // #ifdef CONVERT_TO_LOCAL
+#endif // #ifndef _16x2
+
+#ifdef DEBUG
+// Displays debug data to the serial monitor
+void displayDebugData() {
+  Serial.print("Version: ");
+  Serial.println(VERSION);
+  Serial.print("Satellite Count: ");
+  Serial.println(GPSData.satellites);
+  Serial.print("Latitude: ");
+  Serial.println(GPSData.lat, 6);
+  Serial.print("Longitude: ");
+  Serial.println(GPSData.lon, 6);
+  Serial.print("Speed MPH: ");
+  Serial.println(GPSData.speed);
+  Serial.print("Altitude Feet: ");
+  Serial.println(GPSData.altitude);
+#ifdef _16x2
+  Serial.print("Alt/SPD: ");
+  Serial.println((digitalRead(SPEED_ALTITUDE_SW)) ? "Speed" : "Altitude");
+#else
+  Serial.print("Altitude/Date: ");
+  Serial.println(!(digitalRead(ALTITUDE_DATE_TIME_SW)) ? "Date/Time" : "Altitude");
+#endif
+  Serial.println((digitalRead(BACKLIGHT_SW)) ? "Backlight On" : "Backlight Off");
+  Serial.print("Data valid: ");
+  Serial.println(dataValid);
+  uint8_t DOW = dayOfWeek(GPSData.year, GPSData.month, GPSData.day);
+  Serial.print("DST = ");
+  Serial.println(IsDST(GPSData.day, GPSData.month, DOW));
+  Serial.println("");
+}
+#endif


copied from due/due.ino, editing for different base hardware

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

--- arduino/leo/leo.ino
+++ arduino/leo/leo.ino
@@ -0,0 +1,116 @@
+Print &dbg(Serial);//on leonardo this is the USB, Serial1 is hardware port
+
+//use a macro to get variable name:
+#define Show(arg) dbg.print("\n" #arg ":"); dbg.print(arg)
+
+#include "pinclass.h"
+
+/** attached to the high side of an LED */
+//const OutputPin<LED_BUILTIN> lamp;//13, also a motor control line on motor shield
+const OutputPin<LED_BUILTIN_RX> RX;// 17
+const OutputPin<LED_BUILTIN_TX>TX; // 30
+
+
+
+
+#include "motorshield1.h"
+
+#include "quadrater.h" // quadrature tracker.
+Quadrater<4,5,3> tracker;
+
+#include "timerservice.h"
+//
+//#include "retriggerablemonostable.h"
+//
+//RetriggerableMonostable lamprey(red, Ticks(350));
+//RegisterTimer(lamprey);
+//void triggerPulse(){
+//  lamprey.trigger();
+//}
+
+#include "interruptPin.h"
+void b2irqhandler(){
+  RX = button2;
+  if(button2) {
+    //analogWrite(10,100);
+    M2 = 1 * (1 - button1);//go forward unless other button is pressed in which case stop
+  }
+  dbg.print("G");
+  dbg.print(millis());
+}
+
+const InterruptPin<b2irqhandler, button2.number, FALLING> b2irq;
+
+void b1irqhandler(){
+  TX = button1;
+  if(button1) {
+    //analogWrite(10,200);
+    M2 = -1 * (1 - button2);//see greenLight();
+  }
+  dbg.print("R");
+}
+
+const InterruptPin<b1irqhandler, button1.number, FALLING> b1irq;
+
+//example of acting on timing event within the timer isr:
+class Flasher: public CyclicTimer {
+  using CyclicTimer::CyclicTimer;
+  void onDone(void) override {
+    CyclicTimer::onDone();
+//    RX.toggle();
+  }
+
+} flashLamp(451,false);
+RegisterTimer(flashLamp);
+
+#include "softpwm.h"
+class SlowPWMdemo: public SoftPWM {
+public:
+  using SoftPWM::SoftPWM;
+  //it is a bad idea to do this much in an isr ...
+  virtual void onToggle(bool on){
+    if(!on) {
+      dbg.print("\nSoftPWM:");
+    } else {
+      dbg.print(" to ");
+    }
+    dbg.print(millis());
+  }
+
+} spwmdemo(250,750,false);
+
+RegisterTimer(spwmdemo);
+
+void setup(){
+  SerialUSB.begin(230400);//'native' usb port
+  Serial.begin(57600);//an actual uart, on DUE DMA is used so we should be able to push the baud rate quite high without choking the processor with interrupts.
+  //Pin structs take care of themselves, unless you need special modes outside arduino's libraries.
+  b2irq.attach(true);//we don't build in attach() to the constructor as in many cases the isr needs stuff that isn't initialized until setup() is run.
+  b1irq.attach(true);
+  M2 = 0;
+  M1 = 0;
+  tracker.connect();
+} /* setup */
+
+int lastlocation = 0;
+void loop(){
+//  __WFE();
+  if(changed(lastlocation,tracker.position())) {
+    //initially this printed sequential values, but eventually only every 6 or 7, then choked.Will try usbserial again, maybe it can keep up.
+    dbg.print('\n');
+    dbg.print(lastlocation);
+  }
+  if(lastlocation>500){
+    tracker.beginCruising();
+  }
+  if(Serial){
+    char c=Serial.read();
+    Serial.print(c);
+    switch(c){
+      case '<': M2=1; break;
+      case '>': M2=-1; break;
+      case 27: M2=0; break;
+      case '?': Serial.println(tracker.position()); break;
+    }
+  }
+}


Added example using Huzzah32 with new terminal Widget and Wifi.

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

--- examples/Huzzah32_Wifi_Client_TouchscreenGui/Huzzah32_Wifi_Client_TouchscreenGui.ino
+++ examples/Huzzah32_Wifi_Client_TouchscreenGui/Huzzah32_Wifi_Client_TouchscreenGui.ino
@@ -0,0 +1,95 @@
+/*
+ *  This sketch sends a message to a TCP server
+ *
+ */
+
+#include <WiFi.h>
+#include <WiFiMulti.h>
+#include <neotimer.h>
+#include <Canvas_STMPE610.h>
+#include <Terminal.h>
+
+Canvas_STMPE610 canvas = Canvas_STMPE610(TFT_PORTRAIT,BLACK);
+Terminal terminal = Terminal(240,70,TERMINAL_SCROLL_UP,1);
+
+Neotimer timer = Neotimer(1000);
+WiFiMulti WiFiMulti;
+
+void setup()
+{
+    Serial.begin(115200);
+    delay(10);
+    canvas.init();
+    terminal.setColors(BLACK,GREEN,WHITE);
+    canvas.add(&terminal,0,0);
+
+    // We start by connecting to a WiFi network
+    WiFiMulti.addAP("Linksys03507", "4antgxupkm");
+    WiFiMulti.addAP("Samsung Galaxy Note9_2618", "hvdl9798");
+    WiFiMulti.addAP("frulrom2319", "familiarullan2319");
+
+    terminal.print("Trying to connect to Wifi...");
+
+    while(WiFiMulti.run() != WL_CONNECTED) {
+        Serial.print(".");
+        delay(500);
+    }
+
+    char buffer[terminal.maxCharacters];
+
+    String ssid = WiFi.SSID();
+    ssid.toCharArray(buffer,ssid.length()+1);
+    terminal.print("Connected to");
+    terminal.print(buffer);
+
+    String ipAddress = WiFi.localIP().toString();
+    ipAddress.toCharArray(buffer,ipAddress.length()+1);
+    terminal.print("IP Address");
+    terminal.print(buffer);
+
+    Serial.println("");
+    Serial.println("WiFi connected");
+    Serial.println("IP address: ");
+    Serial.println(WiFi.localIP());
+    delay(500);
+}
+
+
+void loop()
+{
+
+/*
+    const uint16_t port = 80;
+    const char * host = "192.168.1.1"; // ip or dns
+
+
+
+    Serial.print("connecting to ");
+    Serial.println(host);
+
+    // Use WiFiClient class to create TCP connections
+    WiFiClient client;
+
+    if (!client.connect(host, port)) {
+        Serial.println("connection failed");
+        Serial.println("wait 5 sec...");
+        delay(5000);
+        return;
+    }
+
+    // This will send the request to the server
+    client.print("Send this data to server");
+
+    //read back one line from server
+    String line = client.readStringUntil('\r');
+    client.println(line);
+
+    Serial.println("closing connection");
+    client.stop();
+
+    Serial.println("wait 5 sec...");
+    delay(5000);
+*/
+}
+
+


Příklad z lekce 6

Příklad z lekce 6

error: pathspec 'lekce/lekce06/work/read-time/read-time.ino' did not match any file(s) known to git

--- lekce/lekce06/work/read-time/read-time.ino
+++ lekce/lekce06/work/read-time/read-time.ino
@@ -0,0 +1,40 @@
+#include <Wire.h>
+
+#define ADDR 0x68
+
+void write_reg(byte addr, byte data) {
+  Wire.beginTransmission(ADDR);
+  Wire.write(addr);
+  Wire.write(data);
+  Wire.endTransmission();
+}
+
+byte read_reg(byte addr) {
+  Wire.beginTransmission(ADDR);
+  Wire.write(addr);
+  Wire.endTransmission();
+
+  Wire.requestFrom(ADDR, (byte)1);
+  return Wire.read();
+}
+
+void setup() {
+  Wire.begin();
+  Serial.begin(9600);
+  write_reg(0,0);
+}
+
+void loop() {
+  byte s = read_reg(0);
+  byte m = read_reg(1);
+  byte h = read_reg(2);
+
+  Serial.print(h, HEX);
+  Serial.print(":");
+  Serial.print(m, HEX);
+  Serial.print(":");
+  Serial.println(s, HEX);
+
+
+  delay(1000);
+}


Added keypad example sketch

Added keypad example sketch

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

--- keypad/keypad.ino
+++ keypad/keypad.ino
@@ -0,0 +1,41 @@
+/*4x4 Matrix Keypad connected to Arduino
+This code prints the key pressed on the keypad to the serial port*/
+
+#include <Keypad.h>
+
+const byte numRows = 4; //number of rows on the keypad
+const byte numCols = 4; //number of columns on the keypad
+
+//keymap defines the key pressed according to the row and columns just as appears on the keypad
+char keymap[numRows][numCols] =
+{
+  {'1', '2', '3', 'A'},
+  {'4', '5', '6', 'B'},
+  {'7', '8', '9', 'C'},
+  {'*', '0', '#', 'D'}
+};
+
+//Code that shows the the keypad connections to the arduino terminals
+byte rowPins[numRows] = {9, 8, 7, 6}; //Rows 0 to 3
+byte colPins[numCols] = {5, 4, 3, 2}; //Columns 0 to 3
+
+//initializes an instance of the Keypad class
+Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
+
+void setup()
+{
+  Serial.begin(9600);
+}
+
+//If key is pressed, this key is stored in 'keypressed' variable
+//If key is not equal to 'NO_KEY', then this key is printed out
+//if count=17, then count is reset back to 0 (this means no key is pressed during the whole keypad scan process
+void loop()
+{
+  char keypressed = myKeypad.getKey();
+  if (keypressed != NO_KEY)
+  {
+    Serial.print(keypressed);
+  }
+}
+


Serial comm from RasPi to Ard-connected neopixels

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

--- Arduino/Mimic_Serial.ino
+++ Arduino/Mimic_Serial.ino
@@ -0,0 +1,367 @@
+#include <Adafruit_NeoPixel.h>
+#include <string.h>
+//Connect USB port to Pi USB Port
+//For serial debugging - connect to the RX1 and TX1 pins
+Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, 6, NEO_GRB + NEO_KHZ800);
+Adafruit_NeoPixel module_strip = Adafruit_NeoPixel(16, 7, NEO_GRB + NEO_KHZ800);
+const int ledRedPin = 13;
+const int ledBluePin = 52;
+const int ledGreenPin = 53;
+String test;
+
+double Beta1B = 0.0;
+double Beta2B = 0.0;
+double Beta3B = 0.0;
+double Beta4B = 0.0;
+double Beta1A = 0.0;
+double Beta2A = 0.0;
+double Beta3A = 0.0;
+double Beta4A = 0.0;
+double PSARJ = 0.0;
+double SSARJ = 0.0;
+double PTRRJ = 0.0;
+double STRRJ = 0.0;
+double AOS = 0.00;
+double V2A = 0.00;
+double V2B = 0.00;
+double V4A = 0.00;
+double V4B = 0.00;
+String module = "unset module";
+
+void setup()
+{
+  pinMode(ledRedPin, OUTPUT);
+  pinMode(ledBluePin, OUTPUT);
+  pinMode(ledGreenPin, OUTPUT);
+  Serial.begin(9600);
+  Serial1.begin(115200);
+  Serial1.setTimeout(50);
+  strip.begin();
+  module_strip.begin();
+  strip.show();
+  module_strip.show();
+  allSet_module(module_strip.Color(255,0,0),5);
+}
+
+void loop()
+{
+  digitalWrite(ledRedPin, LOW);
+  digitalWrite(ledGreenPin, LOW);
+  digitalWrite(ledBluePin, LOW);
+  Serial.println("-------");
+  if(Serial1.available())
+  {
+    checkSerial();
+  }
+  allSet_module(module_strip.Color(0,0,0),0);
+  //Serial.println(module);
+  if(module == "SM")
+  {
+    module_strip.setPixelColor(0, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("SM");
+  }
+  else if(module == "FGB")
+  {
+    module_strip.setPixelColor(1, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("FGB");
+  }
+  else if(module == "Node1")
+  {
+    module_strip.setPixelColor(2, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("Node1");
+  }
+  else if(module == "Node2")
+  {
+    module_strip.setPixelColor(3, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("Node2");
+  }
+  else if(module == "Node3")
+  {
+    module_strip.setPixelColor(4, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("Node3");
+  }
+  else if(module == "AL")
+  {
+    module_strip.setPixelColor(5, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("AL");
+  }
+  else if(module == "USL")
+  {
+    module_strip.setPixelColor(6, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("USL");
+  }
+  else if(module == "Col")
+  {
+    module_strip.setPixelColor(7, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("Col");
+  }
+  else if(module == "JEM")
+  {
+    module_strip.setPixelColor(8, strip.Color(255,255,255));
+    module_strip.show();
+    //Serial.println("JEM");
+  }
+  else
+  {
+    allSet_module(module_strip.Color(0,255,0),5);
+    module_strip.show();
+  }
+
+
+  if(V2A < 151.5)
+  {
+    strip.setPixelColor(0, strip.Color(255,0,0));
+    strip.setPixelColor(1, strip.Color(255,0,0));
+    strip.setPixelColor(2, strip.Color(255,0,0));
+    strip.setPixelColor(3, strip.Color(255,0,0));
+    strip.setPixelColor(4, strip.Color(255,0,0));
+    strip.setPixelColor(5, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V2A > 160)
+  {
+    strip.setPixelColor(0, strip.Color(255,255,255));
+    strip.setPixelColor(1, strip.Color(255,255,255));
+    strip.setPixelColor(2, strip.Color(255,255,255));
+    strip.setPixelColor(3, strip.Color(255,255,255));
+    strip.setPixelColor(4, strip.Color(255,255,255));
+    strip.setPixelColor(5, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(0, strip.Color(0,0,255));
+    strip.setPixelColor(1, strip.Color(0,0,255));
+    strip.setPixelColor(2, strip.Color(0,0,255));
+    strip.setPixelColor(3, strip.Color(0,0,255));
+    strip.setPixelColor(4, strip.Color(0,0,255));
+    strip.setPixelColor(5, strip.Color(0,0,255));
+    strip.show();
+  }
+
+  if(V4A < 151.5)
+  {
+    strip.setPixelColor(6, strip.Color(255,0,0));
+    strip.setPixelColor(7, strip.Color(255,0,0));
+    strip.setPixelColor(8, strip.Color(255,0,0));
+    strip.setPixelColor(9, strip.Color(255,0,0));
+    strip.setPixelColor(10, strip.Color(255,0,0));
+    strip.setPixelColor(11, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V4A > 160)
+  {
+    strip.setPixelColor(6, strip.Color(255,255,255));
+    strip.setPixelColor(7, strip.Color(255,255,255));
+    strip.setPixelColor(8, strip.Color(255,255,255));
+    strip.setPixelColor(9, strip.Color(255,255,255));
+    strip.setPixelColor(10, strip.Color(255,255,255));
+    strip.setPixelColor(11, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(6, strip.Color(0,0,255));
+    strip.setPixelColor(7, strip.Color(0,0,255));
+    strip.setPixelColor(8, strip.Color(0,0,255));
+    strip.setPixelColor(9, strip.Color(0,0,255));
+    strip.setPixelColor(10, strip.Color(0,0,255));
+    strip.setPixelColor(11, strip.Color(0,0,255));
+    strip.show();
+  }
+
+  if(V4B < 151.5)
+  {
+    strip.setPixelColor(12, strip.Color(255,0,0));
+    strip.setPixelColor(13, strip.Color(255,0,0));
+    strip.setPixelColor(14, strip.Color(255,0,0));
+    strip.setPixelColor(15, strip.Color(255,0,0));
+    strip.setPixelColor(16, strip.Color(255,0,0));
+    strip.setPixelColor(17, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V4B > 160)
+  {
+    strip.setPixelColor(12, strip.Color(255,255,255));
+    strip.setPixelColor(13, strip.Color(255,255,255));
+    strip.setPixelColor(14, strip.Color(255,255,255));
+    strip.setPixelColor(15, strip.Color(255,255,255));
+    strip.setPixelColor(16, strip.Color(255,255,255));
+    strip.setPixelColor(17, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(12, strip.Color(0,0,255));
+    strip.setPixelColor(13, strip.Color(0,0,255));
+    strip.setPixelColor(14, strip.Color(0,0,255));
+    strip.setPixelColor(15, strip.Color(0,0,255));
+    strip.setPixelColor(16, strip.Color(0,0,255));
+    strip.setPixelColor(17, strip.Color(0,0,255));
+    strip.show();
+  }
+
+  if(V2B < 151.5)
+  {
+    strip.setPixelColor(18, strip.Color(255,0,0));
+    strip.setPixelColor(19, strip.Color(255,0,0));
+    strip.setPixelColor(20, strip.Color(255,0,0));
+    strip.setPixelColor(21, strip.Color(255,0,0));
+    strip.setPixelColor(22, strip.Color(255,0,0));
+    strip.setPixelColor(23, strip.Color(255,0,0));
+    strip.show();
+  }
+  else if(V2B > 160)
+  {
+    strip.setPixelColor(18, strip.Color(255,255,255));
+    strip.setPixelColor(19, strip.Color(255,255,255));
+    strip.setPixelColor(20, strip.Color(255,255,255));
+    strip.setPixelColor(21, strip.Color(255,255,255));
+    strip.setPixelColor(22, strip.Color(255,255,255));
+    strip.setPixelColor(23, strip.Color(255,255,255));
+    strip.show();
+  }
+  else
+  {
+    strip.setPixelColor(18, strip.Color(0,0,255));
+    strip.setPixelColor(19, strip.Color(0,0,255));
+    strip.setPixelColor(20, strip.Color(0,0,255));
+    strip.setPixelColor(21, strip.Color(0,0,255));
+    strip.setPixelColor(22, strip.Color(0,0,255));
+    strip.setPixelColor(23, strip.Color(0,0,255));
+    strip.show();
+  }
+}
+void checkSerial()
+{
+  digitalWrite(ledBluePin, HIGH);
+  test = "";
+
+  while(Serial1.available())
+  {
+    test = Serial1.readString();
+  }
+  Serial.println(test);
+  char sz[test.length() + 1];
+  char copy[test.length() + 1];
+  strcpy(sz, test.c_str());
+  char *p = sz;
+  char *str;
+  int delimeter = 0;
+  String test2 = "";
+
+  while((str = strtok_r(p," ",&p))!=NULL)
+  {
+    test2 = String(str);
+    delimeter = test2.indexOf('=');
+    if(test2.substring(0,delimeter)=="PSARJ")
+    {
+      PSARJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="SSARJ")
+    {
+      SSARJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="PTRRJ")
+    {
+      PTRRJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="STRRJ")
+    {
+      STRRJ = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta1B")
+    {
+      Beta1B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta1A")
+    {
+      Beta1A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta2B")
+    {
+      Beta2B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta2A")
+    {
+      Beta2A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta3B")
+    {
+      Beta3B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta3A")
+    {
+      Beta3A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta4B")
+    {
+      Beta4B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Beta4A")
+    {
+      Beta4A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage2A")
+    {
+      V2A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage2B")
+    {
+      V2B = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage4A")
+    {
+      V4A = (test2.substring(delimeter+1)).toFloat();
+    }
+    else if(test2.substring(0,delimeter)=="Voltage4B")
+    {
+      V4B = (test2.substring(delimeter+1)).toFloat();
+    }
+    //module Selection
+    else if(test2.substring(0,delimeter)=="Module")
+    {
+      //Serial.println("----Module!------");
+      module = (test2.substring(delimeter+1));
+    }
+    else if(test2.substring(0,delimeter)=="AOS")
+    {
+      //Serial1.println(test2);
+      AOS = (test2.substring(delimeter+1)).toFloat();
+      //Serial1.println(AOS);
+      if(AOS == 1.00)
+      {
+        digitalWrite(ledGreenPin, HIGH);
+      }
+      else
+      {
+        digitalWrite(ledRedPin, HIGH);
+      }
+    }
+  }
+  Serial.println();
+}
+void allSet(uint32_t c, uint8_t wait) {
+  for(uint16_t i=0; i<strip.numPixels(); i++)
+  {
+    strip.setPixelColor(i, c);
+    strip.show();
+    delay(wait);
+  }
+}
+void allSet_module(uint32_t c, uint8_t wait) {
+  for(uint16_t i=0; i<module_strip.numPixels(); i++)
+  {
+    module_strip.setPixelColor(i, c);
+    module_strip.show();
+    delay(wait);
+  }
+}


Committing working temp readout; mostly example

--- tempsens.ino
+++ tempsens.ino
@@ -0,0 +1,185 @@
+#include <OneWire.h>
+
+#define LED 13
+#define TEMPPIN 2
+#define SERIAL_BAUD   9600
+
+void setup(void) {
+Serial.begin(SERIAL_BAUD);
+}
+
+void loop(void) {
+for (int i=9;i<13;i++){
+handleOWIO(6,i);
+Serial.println();
+}
+
+delay(1000);
+Blink(LED,3);
+}
+
+void handleOWIO(byte pin, byte resolution) {
+int owpin = pin;
+
+// Device identifier
+byte dsaddr[8];
+OneWire myds(TEMPPIN);
+getfirstdsadd(myds,dsaddr);
+
+Serial.print(F("dsaddress:"));
+int j;
+for (j=0;j<8;j++) {
+if (dsaddr[j] < 16) {
+Serial.print('0');
+}
+Serial.print(dsaddr[j], HEX);
+}
+// Data
+
+Serial.println(getdstemp(myds, dsaddr, resolution));
+
+} // run OW sequence
+
+void getfirstdsadd(OneWire myds, byte firstadd[]){
+byte i;
+byte present = 0;
+byte addr[8];
+float celsius, fahrenheit;
+
+int length = 8;
+
+//Serial.print("Looking for 1-Wire devices...\n\r");
+while(myds.search(addr)) {
+//Serial.print("\n\rFound \'1-Wire\' device with address:\n\r");
+for( i = 0; i < 8; i++) {
+firstadd[i]=addr[i];
+//Serial.print("0x");
+if (addr[i] < 16) {
+//Serial.print('0');
+}
+//Serial.print(addr[i], HEX);
+if (i < 7) {
+//Serial.print(", ");
+}
+}
+if ( OneWire::crc8( addr, 7) != addr[7]) {
+//Serial.print("CRC is not valid!\n");
+return;
+}
+// the first ROM byte indicates which chip
+
+//Serial.print("\n\raddress:");
+//Serial.print(addr[0]);
+
+return;
+}
+}
+
+float getdstemp(OneWire myds, byte addr[8], byte resolution) {
+byte present = 0;
+int i;
+byte data[12];
+byte type_s;
+float celsius;
+float fahrenheit;
+
+switch (addr[0]) {
+case 0x10:
+//Serial.println(F("  Chip = DS18S20"));  // or old DS1820
+type_s = 1;
+break;
+case 0x28:
+//Serial.println(F("  Chip = DS18B20"));
+type_s = 0;
+break;
+case 0x22:
+//Serial.println(F("  Chip = DS1822"));
+type_s = 0;
+break;
+default:
+Serial.println(F("Device is not a DS18x20 family device."));
+}
+
+// Get byte for desired resolution
+byte resbyte = 0x1F;
+if (resolution == 12){
+resbyte = 0x7F;
+}
+else if (resolution == 11) {
+resbyte = 0x5F;
+}
+else if (resolution == 10) {
+resbyte = 0x3F;
+}
+
+// Set configuration
+myds.reset();
+myds.select(addr);
+myds.write(0x4E);         // Write scratchpad
+myds.write(0);            // TL
+myds.write(0);            // TH
+myds.write(resbyte);         // Configuration Register
+
+myds.write(0x48);         // Copy Scratchpad
+
+myds.reset();
+myds.select(addr);
+
+long starttime = millis();
+myds.write(0x44,1);         // start conversion, with parasite power on at the end
+while (!myds.read()) {
+// do nothing
+}
+Serial.print("Conversion took: ");
+Serial.print(millis() - starttime);
+Serial.println(" ms");
+
+//delay(1000);     // maybe 750ms is enough, maybe not
+// we might do a ds.depower() here, but the reset will take care of it.
+
+present = myds.reset();
+myds.select(addr);
+myds.write(0xBE);         // Read Scratchpad
+
+//Serial.print("  Data = ");
+//Serial.print(present,HEX);
+Serial.println("Raw Scratchpad Data: ");
+for ( i = 0; i < 9; i++) {           // we need 9 bytes
+data[i] = myds.read();
+Serial.print(data[i], HEX);
+Serial.print(" ");
+}
+//Serial.print(" CRC=");
+//Serial.print(OneWire::crc8(data, 8), HEX);
+Serial.println();
+
+// convert the data to actual temperature
+
+unsigned int raw = (data[1] << 8) | data[0];
+if (type_s) {
+raw = raw << 3; // 9 bit resolution default
+if (data[7] == 0x10) {
+// count remain gives full 12 bit resolution
+raw = (raw & 0xFFF0) + 12 - data[6];
+} else {
+byte cfg = (data[4] & 0x60);
+if (cfg == 0x00) raw = raw << 3;  // 9 bit resolution, 93.75 ms
+else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms
+else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms
+// default is 12 bit resolution, 750 ms conversion time
+}
+}
+celsius = (float)raw / 16.0;
+fahrenheit = celsius * 1.8 + 32.0;
+Serial.print("Temp (C): ");
+//Serial.println(celsius);
+return celsius;
+}
+
+void Blink(byte PIN, int DELAY_MS)
+{
+pinMode(PIN, OUTPUT);
+digitalWrite(PIN,HIGH);
+delay(DELAY_MS);
+digitalWrite(PIN,LOW);
+}


initial commit

initial commit

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/simonlovgren/Arduino-Flight-TX.git/'


Create ramdemo.ino

Create ramdemo.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/kaaLabs15/mcp7940.git/'


Arduino game

Arduino game

--- game/game.ino
+++ game/game.ino
@@ -0,0 +1,58 @@
+const int ledCount = 10;
+
+int ledPins[] = {
+  2, 3, 4, 5, 6, 7,8,9,10,11 };
+
+
+void setup() {
+  for (int thisLed = 0; thisLed < ledCount; thisLed++) {
+    pinMode(ledPins[thisLed], OUTPUT);
+  }
+}
+
+void loop() {
+  int difficulty = analogRead(A0);
+  digitalWrite(2, HIGH);
+  delay(difficulty);
+  digitalWrite(2, LOW);
+  digitalWrite(3, HIGH);
+  delay(difficulty);
+  digitalWrite(3, LOW);
+  digitalWrite(4, HIGH);
+  delay(difficulty);
+  digitalWrite(4, LOW);
+  digitalWrite(5, HIGH);
+  delay(difficulty);
+  digitalWrite(5, LOW);
+  digitalWrite(6, HIGH);
+  delay(difficulty);
+  digitalWrite(6, LOW);
+  digitalWrite(7, HIGH);
+  delay(difficulty);
+  digitalWrite(7, LOW);
+  digitalWrite(8, HIGH);
+  delay(difficulty);
+  digitalWrite(8, LOW);
+  int pin = 8;
+  pin+-1;
+  if (digitalRead(10) == HIGH) {
+    digitalWrite(8, HIGH);
+    if (pin == 8) {
+      int theLed = 2;
+      Serial.write("You won!");
+      while (true) {
+        if (theLed == 8) {
+          theLed+-6;
+        }
+      digitalWrite(ledPins[theLed], HIGH);
+      delay(500);
+      digitalWrite(ledPins[theLed], LOW);
+      delay(500);
+      theLed++;
+      }
+    }
+  }
+  delay(difficulty);
+  pin++;
+}
+


PALETTED8 full-screen example

PALETTED8 full-screen example

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

--- examples/paletted.ino
+++ examples/paletted.ino
@@ -0,0 +1,40 @@
+#include <EEPROM.h>
+#include <SPI.h>
+#include <GD2.h>
+
+uint32_t addr_pal = 0xffc00UL;
+
+void setup()
+{
+  GD.begin(0);
+  GD.BitmapLayout(PALETTED8, GD.w, GD.h);
+  GD.BitmapSize(NEAREST, BORDER, BORDER, GD.w, GD.h);
+  GD.BitmapSource(0);
+  GD.Begin(BITMAPS);
+  GD.BlendFunc(ONE, ZERO);
+
+  GD.ColorMask(1, 0, 0, 0);
+  GD.PaletteSource(addr_pal + 2);
+  GD.Vertex2f(0, 0);
+
+  GD.ColorMask(0, 1, 0, 0);
+  GD.PaletteSource(addr_pal + 1);
+  GD.Vertex2f(0, 0);
+
+  GD.ColorMask(0, 0, 1, 0);
+  GD.PaletteSource(addr_pal + 0);
+  GD.Vertex2f(0, 0);
+  GD.swap();
+
+  // randomize the palette
+  for (int i = 0; i < 1024; i++)
+    GD.wr(addr_pal + i, GD.random());
+}
+
+void loop()
+{
+  // fill the whole screen with random bytes
+  for (int y = 0; y < GD.h; y++)
+    for (int x = 0; x < GD.w; x++)
+      GD.wr(800 * y + x, GD.random());
+}


Initial commit

Initial commit

LEDs pulse and cycle through colors every few pulses.

--- arduino/blinkytape_orb.ino
+++ arduino/blinkytape_orb.ino
@@ -0,0 +1,73 @@
+#include "FastLED.h"
+
+/* hardware */
+#define NUM_LEDS 12
+
+#define DATA_PIN 3
+
+/* visuals */
+#define PULSE_MAX_VAL 255
+#define PULSE_MIN_VAL 160
+#define PULSE_CYCLE 2000
+#define PULSE_DELAY PULSE_CYCLE / (PULSE_MAX_VAL - PULSE_MIN_VAL)
+
+#define CHANGE_MIN_VAL 64
+#define CHANGE_CYCLE 500
+#define CHANGE_DELAY CHANGE_CYCLE / (PULSE_MIN_VAL - CHANGE_MIN_VAL)
+
+/* demo mode */
+#define DEMO_PULSES 5
+
+/* state */
+CRGB leds[NUM_LEDS];
+uint8_t hue = HUE_RED;
+uint8_t demo_pulse_count = 0;
+
+void setup() {
+  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
+
+  for (uint8_t i = 0; i < NUM_LEDS; i++) {
+    leds[i] = CHSV(hue, 255, PULSE_MAX_VAL);
+  }
+}
+
+void loop() {
+  demo_pulse_count = (demo_pulse_count + 1) % DEMO_PULSES;
+
+  for (uint8_t v = PULSE_MAX_VAL; v > PULSE_MIN_VAL; v--) {
+    for (uint8_t i = 0; i < NUM_LEDS; i++) {
+      leds[i] = CHSV(hue, 255, v);
+    }
+    FastLED.show();
+    delay(PULSE_DELAY);
+  }
+
+  /* demo mode */
+  if (demo_pulse_count == 0) {
+    for (uint8_t v = PULSE_MIN_VAL; v > CHANGE_MIN_VAL; v--) {
+      for (uint8_t i = 0; i < NUM_LEDS; i++) {
+        leds[i] = CHSV(hue, 255, v);
+      }
+      FastLED.show();
+      delay(CHANGE_DELAY);
+    }
+
+    hue = (hue + 32) % 255;
+
+    for (uint8_t v = CHANGE_MIN_VAL; v < PULSE_MIN_VAL; v++) {
+      for (uint8_t i = 0; i < NUM_LEDS; i++) {
+        leds[i] = CHSV(hue, 255, v);
+      }
+      FastLED.show();
+      delay(CHANGE_DELAY);
+    }
+  }
+
+  for (uint8_t v = PULSE_MIN_VAL; v < PULSE_MAX_VAL; v++) {
+    for (uint8_t i = 0; i < NUM_LEDS; i++) {
+      leds[i] = CHSV(hue, 255, v);
+    }
+    FastLED.show();
+    delay(PULSE_DELAY);
+  }
+}


print a file to stdout

print a file to stdout

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

--- Arduino/read_files/read_files.ino
+++ Arduino/read_files/read_files.ino
@@ -0,0 +1,45 @@
+#include <SD.h>
+
+
+
+File myFile;
+
+void setup()
+{
+
+  Serial.begin(9600);
+  Serial.print("Initializing SD card...");
+  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
+  // Note that even if it's not used as the CS pin, the hardware SS pin
+  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
+  // or the SD library functions will not work.
+   pinMode(10, OUTPUT);
+
+  if (!SD.begin(10)) {
+    Serial.println("initialization failed!");
+    return;
+  }
+  Serial.println("initialization done.");
+
+
+  // open the file for reading:
+  myFile = SD.open("OUTPUT.txt");
+  if (myFile) {
+    Serial.println("OUTPUT.txt:");
+
+    // read from the file until there's nothing else in it:
+    while (myFile.available()) {
+      Serial.write(myFile.read());
+    }
+    // close the file:
+    myFile.close();
+  } else {
+    // if the file didn't open, print an error:
+    Serial.println("error opening test.txt");
+  }
+}
+
+void loop()
+{
+  // nothing happens after setup
+}


test where code resets on power loss

test where code resets on power loss

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


wrote a sketch to erase all cards

wrote a sketch to erase all cards

error: pathspec 'etc/erase-cards.ino' did not match any file(s) known to git

--- etc/erase-cards.ino
+++ etc/erase-cards.ino
@@ -0,0 +1,22 @@
+#include <Arduino.h>
+#include <EEPROM.h>
+
+void loop();
+void setup();
+
+void loop() {
+};
+
+void setup() {
+  pinMode(LED_BUILTIN, OUTPUT);
+  digitalWrite(LED_BUILTIN, LOW);
+
+  unsigned int index;
+  unsigned int length = EEPROM.length();
+
+  for (index = 0; index < length; index++) {
+    EEPROM.update(index, 0);
+  };
+
+  digitalWrite(LED_BUILTIN, HIGH);
+};


first test with 7 segments displayer and interruptor

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

--- _7segments_ino/_7segments_ino.ino
+++ _7segments_ino/_7segments_ino.ino
@@ -0,0 +1,88 @@
+/* On assigne chaque LED à une broche de l'arduino */
+const int A = 2;
+const int B = 3;
+const int C = 4;
+const int D = 5;
+const int E = 6;
+const int F = 7;
+const int G = 8;
+//notez que l'on ne gère pas l'affichage du point, mais vous pouvez le rajouter si cela vous chante
+
+const int button = 11;
+
+int buttonState;
+
+int i = 0;
+
+int incr = 1;
+
+int tab[10][7] = {
+   {LOW, LOW, LOW, LOW, LOW, LOW, HIGH}, // write 0
+   {HIGH, LOW, LOW, HIGH, HIGH, HIGH, HIGH}, // write 1
+   {LOW, LOW, HIGH, LOW, LOW, HIGH, LOW}, //write 2
+   {LOW, LOW, LOW, LOW, HIGH, HIGH, LOW}, //write 3
+   {HIGH, LOW, LOW, HIGH, HIGH, LOW, LOW}, //write 4
+   {LOW, HIGH, LOW, LOW, HIGH, LOW, LOW}, //write 5
+   {LOW, HIGH, LOW, LOW, LOW, LOW, LOW}, //write 6
+   {LOW, LOW, LOW, HIGH, HIGH, HIGH, HIGH}, //write 7
+   {LOW, LOW, LOW, LOW, LOW, LOW, LOW}, //write 8
+   {LOW, LOW, LOW, LOW, HIGH, LOW, LOW} //write 9
+};
+
+
+void print(int number){
+    digitalWrite(A, tab[number][0]);
+    digitalWrite(B, tab[number][1]);
+    digitalWrite(C, tab[number][2]);
+    digitalWrite(D, tab[number][3]);
+    digitalWrite(E, tab[number][4]);
+    digitalWrite(F, tab[number][5]);
+    digitalWrite(G, tab[number][6]);
+}
+
+void setup()
+{
+    Serial.begin(9600);
+
+    //définition des broches en sortie
+    pinMode(A, OUTPUT);
+    pinMode(B, OUTPUT);
+    pinMode(C, OUTPUT);
+    pinMode(D, OUTPUT);
+    pinMode(E, OUTPUT);
+    pinMode(F, OUTPUT);
+    pinMode(G, OUTPUT);
+
+    pinMode(button, INPUT);
+
+
+    //mise à l'état HAUT de ces sorties pour éteindre les LED de l'afficheur
+    digitalWrite(A, HIGH);
+    digitalWrite(B, HIGH);
+    digitalWrite(C, HIGH);
+    digitalWrite(D, HIGH);
+    digitalWrite(E, HIGH);
+    digitalWrite(F, HIGH);
+    digitalWrite(G, HIGH);
+
+    digitalWrite(button, HIGH);
+}
+
+void loop()
+{
+   buttonState = digitalRead(button);
+   if(buttonState == LOW){
+     incr = - incr;
+     Serial.println("pushed");
+   }
+
+   print(i);
+
+   i += incr;
+   if(i == 10 && incr == 1){
+     i = 0;
+   } else if (i == -1 && incr -1){
+     i = 9;
+   }
+   delay(500);
+}