Added simple danger-avoiding example.

Added simple danger-avoiding example.

#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);
}

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


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

#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;
  }
}

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


Added current Arduino control file

Added current Arduino control file

#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;
    }
  }
}

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


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

/*
 * 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++;
  }
}

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


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

/*
   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);
}

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


Add accelerometer orientation example

Add accelerometer orientation example

/*
   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;
  }
}

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


Added Arduino code

Added Arduino code

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);
}

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


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

/*
 * 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);
}

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


v1.0  Initial release

v1.0  Initial release

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

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


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

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;
    }
  }
}

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


Added example using Huzzah32 with new terminal Widget and Wifi.

/*
 *  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);
*/
}

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


Příklad z lekce 6

Příklad z lekce 6

#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);
}

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


Added keypad example sketch

Added keypad example sketch

/*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);
  }
}

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


Serial comm from RasPi to Ard-connected neopixels

#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);
  }
}

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


Committing working temp readout; mostly example

#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

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

#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());
}

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


Initial commit

Initial commit

LEDs pulse and cycle through colors every few pulses.

#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

#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
}

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


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

#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);
};

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


first test with 7 segments displayer and interruptor

/* 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);
}

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


Create FLC_DOOR_V1.ino

Create FLC_DOOR_V1.ino

/*
Garage Door Opener, v1, 04/21/2015
by Sesh Kanury

Anyone is free to use this software as long as credit is given to the author
and it is only used for means of a good nature.

Eat my shorts.
*/

#define DOOR_BUTTONS 3;

int Up_Pin = D0;
int Down_Pin = D1;
int Stop_Pin = D2;
int Upper_Limit_Pin = D4;
int Lower_Limit_Pin = D5;

int last_Upper_Limit_state;
int last_Lower_Limit_state;

unsigned long last_publish = 0;
unsigned long publish_interval = 60000;
unsigned long last_change_publish = 0;
unsigned long change_publish_interval = 750;

int pinArraySize = 22;

struct structEEPROM {
    double crc;           //cycle redundancy check - if memory is not intact, set all to defaults
    int adminPin;
    int pinArray[22];
};

union {
    structEEPROM settings;
    char eeArray[sizeof(structEEPROM)];
} EEPROMData;

//declare spark function
int get_web_message(String command);

/************************************ stamdard SETUP ************************************/
void setup() {
    Serial.begin(9600);

    //register spark function
    Spark.function("from_web", get_web_message);
    Spark.variable("pinArray", EEPROMData.settings.pinArray, INT);

    pinMode(Up_Pin, OUTPUT);
    pinMode(Down_Pin, OUTPUT);
    pinMode(Stop_Pin, OUTPUT);
    pinMode(Upper_Limit_Pin, INPUT);
    pinMode(Lower_Limit_Pin, INPUT);

    digitalWrite(Up_Pin, LOW);
    digitalWrite(Down_Pin, LOW);
    digitalWrite(Stop_Pin, LOW);

    readEEPROM();
    //EEPROMData.settings.adminPin = 99999;
    if(EEPROMData.settings.crc != 1234.56){
        setDefaultEEPROM();
    }
    consolidate_access_pins();
    writeEEPROM();
}
/****************************************************************************************/

/************************************ standard LOOP *************************************/
void loop() {
    unsigned long now = millis();

    if(now-last_change_publish > change_publish_interval){
        last_change_publish = now;
        if(check_for_limit_switch_change()) publish_door_state();
    }

    if(now-last_publish > publish_interval){
        last_publish = now;
        publish_door_state();
    }
}
/****************************************************************************************/

/****************************** Detect Limit Switch Change ******************************/
int check_for_limit_switch_change(){
    int upper_state = digitalRead(Upper_Limit_Pin);
    int lower_state = digitalRead(Lower_Limit_Pin);
    int result = 0;

    if(upper_state != last_Upper_Limit_state || lower_state != last_Lower_Limit_state) result = 1;

    last_Upper_Limit_state = upper_state;
    last_Lower_Limit_state = lower_state;

    return result;
}
/****************************************************************************************/

/************************************ publish to web ************************************/
void publish_door_state(){
    String message = update_door_state();
    Spark.publish("doorState", message);

    Serial.println(message);
}
/****************************************************************************************/

/********************************** update door state ***********************************/
String update_door_state(){
    int upper_state = digitalRead(Upper_Limit_Pin);
    int lower_state = digitalRead(Lower_Limit_Pin);

    if(!upper_state && !lower_state) return "{\"state\":\"Half\"}";
    if(upper_state && !lower_state) return "{\"state\":\"Open\"}";
    if(!upper_state && lower_state) return "{\"state\":\"Closed\"}";
    if(upper_state && lower_state) return "{\"state\":\"Error\"}";

    return "{\"state\":\"Debug\"}";
}
/****************************************************************************************/

/************************************** do web com **************************************/
//All pin numbers must be 5 digits
//This expects a string beginning with a pin number to identify the user.
//The next character should be a character representing the action, as follows:
//<pin>O = open the door
//<pin>C = close the door
//<pin>S = stop the door
//<adminPin>D<pin> = delete <pin> from users
//<adminPin>A<pin> = add <pin> to users
//<adminPin>L<pin> = list all pins
//<adminPin>N<pin> = change admin pin to <pin>
int get_web_message(String command){
    Serial.print("Command:   ");Serial.println(command);
    //declared in the order they are in String command
    char command_pin[5];
    char command_character;
    char command_new_pin[5];

    int pin;
    int new_pin;

    unsigned int k;
    for(k=0; k<sizeof(command_pin); k++){
        command_pin[k] = 0;
        command_new_pin[k] = 0;
    }

    //parse and convert the recieved user pin to and int
    for(k=0; k<sizeof(command_pin); k++) command_pin[k] = command[k];
    pin = atoi(command_pin);
    Serial.print("ATOI pin:   "); Serial.println(pin);
    //parse the recieved command character
    command_character = command[5];
    Serial.print("command_character:   ");Serial.println(command_character);
    //0=wrong pin or no pin
    //1=user pin
    //2=admin pin
    int validation = validate_pin(pin);
    Serial.print("Validation:   "); Serial.println(validation);
    switch(validate_pin(pin)){
        case 0:
            break;
        case 1:
            Serial.println("USER");
            control_door(command_character);
            break;
        case 2:
            //Serial.println("ADMIN");
            //parse and convert the recieved NEW user pin to and int if it exists
            //otherwise abort
            if(sizeof(command) > (sizeof(command_pin)+1)){
                for(k=0; k<sizeof(command_new_pin); k++) command_new_pin[k] = command[k+6];
                new_pin = atoi(command_new_pin);
                Serial.print("new_pin:   "); Serial.println(new_pin);
            }else return -1;
            manage_access(command_character, new_pin);
            break;
        default:
            break;
    }

    unsigned long now = millis();
    if(now-last_publish > 1000){
        last_publish = now;
        publish_door_state();
    }

    writeEEPROM();

    return 0;
}
/****************************************************************************************/

/*********************************** control the door ***********************************/
void control_door(char command){
    Serial.print("control_door:   "); Serial.println(command);
    switch(command){
                case 'O':
                    Serial.println("opening");
                    digitalWrite(Up_Pin, HIGH);
                    delay(500);                     //slow things down so it looks like a human pushed the button.
                    digitalWrite(Up_Pin, LOW);
                    break;
                case 'C':
                    Serial.println("closing");
                    digitalWrite(Down_Pin, HIGH);
                    delay(500);                     //slow things down so it looks like a human pushed the button.
                    digitalWrite(Down_Pin, LOW);
                    break;
                case 'S':
                    Serial.println("stopping");
                    digitalWrite(Stop_Pin, HIGH);
                    delay(500);                     //slow things down so it looks like a human pushed the button.
                    digitalWrite(Stop_Pin, LOW);
                    break;
                default:
                    Serial.println("nothing");
                    break;
            }
}
/****************************************************************************************/

/************************************* validate pin *************************************/
int validate_pin(int pin){
    Serial.print("validate_pin:   ");Serial.println(pin);
    Serial.print("Admin PIN:   "); Serial.println(EEPROMData.settings.adminPin);
    //unsigned int k = 0;
    int search_result = -1;
    //Serial.print("adminPin:   ");Serial.println(EEPROMData.settings.adminPin);

    if(pin == EEPROMData.settings.adminPin) return 2;
        else search_result = search_for_matching_pin(pin);
    if(search_result >= 0) return 1;
        else return 0;
}
/****************************************************************************************/

/******************************* Admin Access Management ********************************/
void manage_access(char command, int new_pin){
    Serial.println(command);
    Serial.println(new_pin);

    int search_result;
    int k = 0;
    char publish_pin[63];
    for(k=0;k<sizeof(publish_pin);k++) publish_pin[k] = 0;

    switch(command){
            case 'D':
                search_result = search_for_matching_pin(new_pin);
                if(search_result != -1){
                    EEPROMData.settings.pinArray[search_result] = 0;
                    consolidate_access_pins();
                }
                break;
            case 'A':
                search_result = search_for_matching_pin(0);
                if(new_pin != 0 &&  search_for_matching_pin(new_pin) == -1 && search_result != -1)
                    EEPROMData.settings.pinArray[search_result] = new_pin;
                break;
            case 'L':
                for(k=0;k<pinArraySize;k++){
                    sprintf(publish_pin, "{\"pin\":\"%i\"}", EEPROMData.settings.pinArray[k]);
                    Spark.publish("pin_list", publish_pin);
                    Serial.print(EEPROMData.settings.pinArray[k]); Serial.print("   "); Serial.println(publish_pin);
                }
                break;
            case 'N':
                if(new_pin > 9999 || new_pin < 100000)
                    EEPROMData.settings.adminPin = new_pin;
                break;
            case 'Z':
                setDefaultEEPROM();
                break;

        }
}
/****************************************************************************************/

/*********************************** search for PINs ************************************/
int search_for_matching_pin(int pin){
    int k;
    for(k=0; k<pinArraySize;k++){
        if(pin == EEPROMData.settings.pinArray[k]) return k;
    }
    return -1;
}
/****************************************************************************************/

/*********************************** consolidate pins ***********************************/
//this puts all the pins in the array in the first cells available
//then fills the rest of the array with zeros
void consolidate_access_pins(){
    unsigned int k = 0;
    int index_counter = 0;
    int temp_array[pinArraySize];
    for(k=0;k<pinArraySize;k++) temp_array[k] = EEPROMData.settings.pinArray[k];

    //store the non-zero numbers in sequence from index 0
    for(k=0; k<pinArraySize;k++){
        if(temp_array[k]>9999 && temp_array[k]<100000){
            EEPROMData.settings.pinArray[index_counter] = temp_array[k];
            index_counter++;
        }
    }
    //handle array over-count reference
    if(index_counter < pinArraySize)
        //fill the remaining cells with zeros
        for(k=index_counter; k<pinArraySize; k++){
            EEPROMData.settings.pinArray[k] = 0;
        }
}
/****************************************************************************************/

/*********************************** EEPROM functions ***********************************/
void readEEPROM(){
    for(unsigned int i=0; i<sizeof(structEEPROM); i++){
        EEPROMData.eeArray[i] = EEPROM.read(i);
    }
}

void writeEEPROM(){
    for(unsigned int i=0; i<sizeof(structEEPROM); i++){
        EEPROM.write(i, EEPROMData.eeArray[i]);
    }
}

void setDefaultEEPROM(){
    EEPROMData.settings.crc = 1234.56;
    unsigned int k=0;
    for(k=0;k<pinArraySize;k++) EEPROMData.settings.pinArray[k] = 0;
    EEPROMData.settings.adminPin = 11111;

    writeEEPROM();
}
/****************************************************************************************/

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