added firmware for rallyx_timer

added firmware for rallyx_timer

#include <TimerOne.h>
#include <Wire.h>
#include <EEPROM.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>

#define PIN_LED 13 // internal debug led
#define PIN_SQW 22
#define PIN_SCL 19
#define PIN_SDA 18
#define PIN_TS  0
#define PIN_TF  1
#define PIN_MTS 2
#define PIN_MTF 3

// all time is in milliseconds
#define DEFAULT_DEBOUNCE 10
#define DEFAULT_DEADTIME 10000

// increment this any time the rom format is changed or needs to be cleared
#define EEPROM_VERSION 0

typedef enum {
  ROM_OFFSET_VERSION=0,
  ROM_OFFSET_DEBOUNCE,
  ROM_OFFSET_DEADTIME,
  ROM_OFFSET_START
} rom_offset_t;

typedef enum {
  SOURCE_START = 0,
  SOURCE_FINISH,
  SOURCE_MANUAL_START,
  SOURCE_MANUAL_FINISH
} time_source_t;

typedef struct
{
  uint32_t  pin;
  bool      active;
  uint32_t  debounce_count;
  uint32_t  deadtime_count;
  uint32_t  time;
} trigger_state_t;

typedef struct
{
  uint32_t time;
  time_source_t source;
} time_event_t;

volatile uint32_t debounce = DEFAULT_DEBOUNCE; // max number of debounce cycles
volatile uint32_t deadtime = DEFAULT_DEADTIME; // deadtime before next trigger

volatile uint32_t ms_time = 0; // master millisecond time

volatile uint32_t trigger_count = 0;

volatile trigger_state_t start_trigger = {PIN_TS, false, 0, 0};
volatile trigger_state_t finish_trigger = {PIN_TF, false, 0, 0};
volatile trigger_state_t manual_start_trigger = {PIN_MTS, false, 0, 0};
volatile trigger_state_t manual_finish_trigger = {PIN_MTF, false, 0, 0};

bool update_trigger( volatile trigger_state_t * trigger )
{
  // triggers are active low
  // debounce_count follows pin state
  if( digitalRead(trigger->pin) )
  {
    trigger->debounce_count = trigger->debounce_count < debounce ? trigger->debounce_count + 1 : debounce;
  }
  else
  {
    trigger->debounce_count = trigger->debounce_count > 0 ? trigger->debounce_count - 1 : 0;
  }

  trigger->deadtime_count = trigger->deadtime_count > 0 ? trigger->deadtime_count - 1 : 0;

  if( trigger->active == false && trigger->debounce_count == 0 )
  {
    // falling debounced edge detected
    trigger->active = true;

    if( trigger->deadtime_count == 0 )
    {
      trigger->time = ms_time;
      trigger->deadtime_count = deadtime;
    }
    return true;
  }
  else if( trigger->active == true && trigger->debounce_count >= debounce )
  {
    // rising debounced edge detected
    trigger->active = false;
    return false;
  }
  else
  {
    // no change
    return false;
  }
}

void timer_tick(void)
{
  ms_time++;

  update_trigger(&start_trigger);
  update_trigger(&finish_trigger);
  update_trigger(&manual_start_trigger);
  update_trigger(&manual_finish_trigger);
}

uint32_t eeprom_read(uint32_t offset)
{
  uint32_t value;
  uint32_t addr = offset * 4;

  value = EEPROM.read(addr+0);
  value |= EEPROM.read(addr+1) << 8;
  value |= EEPROM.read(addr+2) << 16;
  value |= EEPROM.read(addr+3) << 24;

  return value;
}

void eeprom_write(uint32_t offset, uint32_t value)
{
  uint32_t addr = offset * 4;

  EEPROM.write(addr+0, value & 0xff);
  EEPROM.write(addr+1, (value >> 8) & 0xff);
  EEPROM.write(addr+2, (value >> 16) & 0xff);
  EEPROM.write(addr+3, (value >> 24) & 0xff);
}

void format_eeprom(void)
{
  eeprom_write(ROM_OFFSET_VERSION, EEPROM_VERSION);
  eeprom_write(ROM_OFFSET_DEBOUNCE, debounce);
  eeprom_write(ROM_OFFSET_DEADTIME, deadtime);
  eeprom_write(ROM_OFFSET_START, 0xff);
}

void print_time(uint32_t time)
{
  uint32_t ms = time % 1000;
  uint32_t s = (time / 1000) % 60;
  uint32_t m = (time / 60000) % 60;
  uint32_t h = time / 3600000;

  if( h < 10 )
    Serial.write('0');
  Serial.print(h);
  Serial.write(':');
  if( m < 10 )
    Serial.write('0');
  Serial.print(m);
  Serial.write(':');
  if( s < 10 )
    Serial.write('0');
  Serial.print(s);
  Serial.write('.');
  if( ms < 100 )
    Serial.write('0');
  if( ms < 10 )
    Serial.write('0');
  Serial.print(ms);
}

void setup(void)
{
  for( uint32_t pin = 0; pin < 34; pin++ )
  {
    switch(pin)
    {
      case PIN_LED:
        pinMode(pin, OUTPUT);
        break;
      default:
        pinMode(pin, INPUT_PULLUP);
        break;
    }
  }

  Serial.begin(0);

  if( eeprom_read(ROM_OFFSET_VERSION) != EEPROM_VERSION )
  {
    format_eeprom();
  }
  else // load eeprom settings
  {
    debounce = eeprom_read(ROM_OFFSET_DEBOUNCE);
    deadtime = eeprom_read(ROM_OFFSET_DEADTIME);
  }

  Timer1.initialize(1000);
  Timer1.attachInterrupt(timer_tick);
  Timer1.start();
}

void command_process(char * cmd, uint32_t value, bool val_ok )
{
  if( strcasecmp(cmd, "ping") == 0 )
  {
    Serial.print("P ");
    Serial.println(value);
  }
  else if( strcasecmp(cmd, "recall") == 0 )
  {
    //Serial.println("R M1 01:23:45.678 123345 123");
    Serial.println("E not implemented");
  }
  else if( strcasecmp(cmd, "clear") == 0 )
  {
    //Serial.println("C");
    Serial.println("E not implemented");
  }
  else if( strcasecmp(cmd, "debounce") == 0 )
  {
    if( val_ok )
    {
      debounce = value;
      eeprom_write(ROM_OFFSET_DEBOUNCE, debounce);
    }
    Serial.print("B ");
    Serial.println(debounce);
  }
  else if( strcasecmp(cmd, "deadtime") == 0 )
  {
    if( val_ok )
    {
      deadtime = value;
      eeprom_write(ROM_OFFSET_DEADTIME, deadtime);
    }
    Serial.print("D ");
    Serial.println(deadtime);
  }
  else
  {
    Serial.println("E bad command");
    Serial.print("E ");
    Serial.println(cmd);
  }
}

void command_update(void)
{
  static char buffer[256];
  static uint32_t count = 0;
  char c;
  char *cmd;
  char *param;
  char *endptr;
  uint32_t value;

  while( Serial.available() )
  {
    c = Serial.read();
    switch( c )
    {
      case '\r':
      case '\n':
        if( count > 0 )
        {
          // parse command
          // format: <cmd> <value>
          cmd = strtok(buffer, " ");
          param = strtok(NULL, " ");
          value = param != NULL ? strtoul(param, &endptr, 0) : 0;

          command_process(cmd, value, (param != NULL) && (*endptr == 0));

          // reset buffer
          count = 0;
          buffer[count] = 0;
        }
        break;
      case 8:  // delete/backspace
        if( count > 0 )
        {
          count--;
          buffer[count] = 0;
        }
        break;
      case '\t':
        // convert tabs to single space
        c = ' ';
        // fall through to ' '
      case ' ':
        // filter out leading and multiple whitespace
        if( count == 0 || buffer[count-1] == ' ')
        {
          break;
        }
        // fall through to default
      default:
        if( c >= 32 && count < (sizeof(buffer) - 1) )
        {
          buffer[count] = c;
          count++;
          buffer[count] = 0;
        }
        break;
    }
  }
}

void loop_wait(void)
{
  static uint32_t prev_time = 0;
  while( prev_time == ms_time );
  prev_time = ms_time;
}

void loop(void)
{
  digitalWrite(PIN_LED, HIGH);

  if( start_trigger.time )
  {
    Serial.print("T 1 ");
    print_time(start_trigger.time);
    Serial.write(' ');
    Serial.print(start_trigger.time);
    Serial.write(' ');
    Serial.println(trigger_count++);
    start_trigger.time = 0;
  }

  if( finish_trigger.time )
  {
    Serial.print("T 2 ");
    print_time(finish_trigger.time);
    Serial.write(' ');
    Serial.print(finish_trigger.time);
    Serial.write(' ');
    Serial.println(trigger_count++);
    finish_trigger.time = 0;
  }

  if( manual_start_trigger.time )
  {
    Serial.print("T M1 ");
    print_time(manual_start_trigger.time);
    Serial.write(' ');
    Serial.print(manual_start_trigger.time);
    Serial.write(' ');
    Serial.println(trigger_count++);
    manual_start_trigger.time = 0;
  }

  if( manual_finish_trigger.time )
  {
    Serial.print("T M2 ");
    print_time(manual_finish_trigger.time);
    Serial.write(' ');
    Serial.print(manual_finish_trigger.time);
    Serial.write(' ');
    Serial.println(trigger_count++);
    manual_finish_trigger.time = 0;
  }

  command_update();

  digitalWrite(PIN_LED, LOW);

  loop_wait();
}

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


add additional output variables to print in basic algorithm

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/KaichenWang/wireless-thermometer.git/'


Add Arduino sketch for testing individual strips

This program cycles through all patterns of fully lit R, G, and B lights
in a known pattern at a known rate, so we can test each strip as it is
made.

// Program for testing a single strip of lights.
// Cycles through each possible combination of pure colors:
// #000000 #FF0000 #00FF00 #FFFF00 #0000FF #FF00FF #00FFFF #FFFFFF
// For each color, lights up lights one at a time with a slight delay between
// individual lights, then leaves the whole strip lit up for 2 seconds.

#include <FAB_LED.h>

const uint8_t numPixels = 20;

apa106<D, 6> LEDstrip;
rgb pixels[numPixels] = {};

void setup()
{
}

void loop()
{
  static int color;

  for (int i = 0; i < numPixels; ++i) {
    pixels[i].r = !!(color & 1) * 255;
    pixels[i].g = !!(color & 2) * 255;
    pixels[i].b = !!(color & 4) * 255;
    delay(100);
    LEDstrip.sendPixels(numPixels, pixels);
  }

  color = (color + 1) % 8;

  // Display the pixels on the LED strip.
  LEDstrip.sendPixels(numPixels, pixels);
  delay(2000);
}

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


Add ArbitraryCommands demo.

Add ArbitraryCommands demo.

/**
 * Copyright (C) 2014 James Sleeman
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @author James Sleeman, http://sparks.gogo.co.nz/
 * @license MIT License
 */

#include <Arduino.h>
#include <SoftwareSerial.h>
#include <ESP8266_Simple.h>

// These are the SSID and PASSWORD to connect to your Wifi Network
#define ESP8266_SSID  ""
#define ESP8266_PASS  ""

ESP8266_Simple wifi(8,9);

// See HelloWorld example for further comments.

void setup()
{
  Serial.begin(115200);
  Serial.println("ESP8266 Demo Sketch");

  wifi.begin(9600);
  wifi.setupAsWifiStation(ESP8266_SSID, ESP8266_PASS, &Serial);

  // A blank line just for debug formatting
  Serial.println();
}

void loop()
{

  // This example is just to show you how to issue an arbitrary command to
  // the esp8266 device.
  byte responseCode;
  char buffer[300];
  Serial.print("Getting Access Points: ");
  if((responseCode = wifi.sendCommand(F("AT+CWLAP"), buffer, sizeof(buffer))) == ESP8266_OK)
  {
    // The command worked, prnt the result
    Serial.println("OK");
    Serial.println(buffer);
  }
  else
  {
    // An error occurred, would you like to see what
    wifi.debugPrintError(responseCode, &Serial);

    // Or you can get it as a string if you prefer
    char bufferWithMinLength50Char[50];
    wifi.getErrorMessage(responseCode, bufferWithMinLength50Char);
  }

  Serial.println();
  delay(5000);
}

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


add servo control - angles loop

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/electronicplayground/ep-arduino.git/'


Client Listener

Client Listener

Client is always listening for network communication from master hub

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


Manually align the right curly braces.

Manually align the right curly braces.

Oh man... that looks beautiful.

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


add datalogger source

add datalogger source

#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SD.h>
#include <Wire.h>

byte mac[] = {
  0x98, 0x4F, 0xEE, 0x01, 0x5B, 0x00 };    // mac adress of galileo
IPAddress ip(10,2,95,6);                    // ip of galileo
unsigned int localPort = 5810;              // local port to listen on
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  // buffer to hold incoming packet,
EthernetUDP Udp;

const int DS1307 = 0x68;
const int redPin = 7;
const int grnPin = 6;
const int redPin2 = 9;
const int grnPin2 = 10;
const int a0Pin = 2;
const int a1Pin = 3;
const int a2Pin = 4;
const int shortOn = 250;
const int shortOff = 200;
const int longOff = 1000;
const int errorFlash = 500;
const int timeOut = 10000;

File dataFile;
char dataFileName[40];
byte second;
byte minute;
byte hour;
byte day;
byte year;
byte month;

// --------------------------------------------------
//   get the match number and increment
// --------------------------------------------------
int getMatchNum(void) {
  File matchFile;
  char matchNumFile[] = "matchNum.txt";
  int match = 0;

  if (!SD.exists(matchNumFile)) {
    matchFile = SD.open(matchNumFile, FILE_WRITE);
    if (matchFile) {
      matchFile.print(++match);
      matchFile.close();
    }
    else
      return (0);
  }
  else {
    matchFile = SD.open(matchNumFile, FILE_READ);
    if (matchFile) {
      char fileData = matchFile.read();
      while (fileData != -1) {
        match = match*10 + (fileData - '0');
        fileData = matchFile.read();
      }
      matchFile.close();

      SD.remove(matchNumFile);
      matchFile = SD.open(matchNumFile, FILE_WRITE);
      match += 1;
      matchFile.print(match);
      matchFile.close();
    }
    else
      return (0);
  }
  return (match);
}  // getMatchNum

// --------------------------------------------------
//   blink error lights
// --------------------------------------------------
void error() {
  while(1) {
    digitalWrite(redPin, LOW);
    delay(shortOff);
    digitalWrite(redPin, HIGH);
    delay(shortOff);
  }
}  // error

// --------------------------------------------------
//   setup function
// --------------------------------------------------
void setup() {
  int match;

  system("telnetd -l /bin/sh");   // open galileo for ethernet access
  Serial.begin(9600);
  Serial.println("begin");

  // set the date on the galileo using the RTC
  Wire.begin();
  readTime();
  sprintf(dataFileName, "date %02d%02d%02d%02d20%02d", month, day, hour, minute, year);
  system(dataFileName);

  // begin the UDP connections
  Ethernet.begin(mac,ip);  // robot
  //Ethernet.begin(mac);   // dhcp
  Udp.begin(localPort);

  // set the I/O pins
  pinMode(a0Pin, OUTPUT);     // A0
  pinMode(a1Pin, OUTPUT);     // A1
  pinMode(a2Pin, OUTPUT);     // A2
  pinMode(redPin, OUTPUT);    // red
  pinMode(grnPin, OUTPUT);    // green
  pinMode(redPin2, OUTPUT);   // red
  pinMode(grnPin2, OUTPUT);   // green
  digitalWrite(redPin, LOW);  // off
  digitalWrite(grnPin, LOW);  // off
}  //setup

// --------------------------------------------------
//   create data file and write headers
// --------------------------------------------------
int createDataFile(void) {
  //if (!(match = getMatchNum())) error();
  //sprintf(dataFileName, "%08d.csv", match);  // no clock
  readTime();
  sprintf(dataFileName,"%02d_%02d-%02d-%02d.csv", day, hour, minute, second);
  dataFile = SD.open(dataFileName, FILE_WRITE);
  dataFile.print("time;tempLeftDrive4;tempLeftDrive3;tempRightDrive1;tempRightDrive2;tempLift0;tempCompressor6;");
  dataFile.print("currentLift;currentMotor2;currentMotor3;currentMotor4;");
  dataFile.println("currentMotor5;voltageRobot;liftEncoder");  // write the header to the file
  dataFile.print("0;0;0;0;0;0;0;0;0;0;0;0;0;0");  // write all zeros for the first line
  dataFile.flush();
  return (0);
}  // createDataFile

// --------------------------------------------------
//   main loop
// --------------------------------------------------
void loop() {
  static int s = 0;
  static int ledState = 0;
  static unsigned long initialTime;
  static unsigned long writeTime;
  static unsigned long packetTime;
  static unsigned long grnTime = 0;
  static unsigned long redTime = 0;
  int packetSize;
  int i;
  static int adc[6] = {
    0,0,0,0,0,0  };
  static char chan = 0;
  float temp;
  static unsigned long muxTime = 0;
  char tempString[40];

  switch(s) {

  case 0:   //wait for first packet
    packetSize = Udp.parsePacket();
    if (packetSize) {
      if (!createDataFile()) {
        i = Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
        initialTime = millis();
        packetTime = initialTime;
        writeTime = 0;
        if (packetBuffer[0] != '#') {
          dataFile.print(";\r\n");
          dataFile.print(writeTime);
          sprintf(tempString, ";%d;%d;%d;%d;%d;%d;", adc[0], adc[1], adc[2], adc[3], adc[4], adc[5]);
          dataFile.print(tempString);
        }
        else
          dataFile.print(";");
        dataFile.write((uint8_t *)packetBuffer, i);
        dataFile.flush();
        redTime = initialTime + errorFlash;
        digitalWrite(redPin, HIGH);
        digitalWrite(redPin2, HIGH);
        s = 1;
      }
      else
        s = 7;
    } // if
    break;

  case 1:   // wait for packet
    packetSize = Udp.parsePacket();
    if (packetSize) {
      i = Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
      packetTime = millis();
      writeTime = packetTime - initialTime;
      if (packetBuffer[0] != '#') {
        dataFile.print(";\r\n");
        dataFile.print(writeTime);
        sprintf(tempString, ";%d;%d;%d;%d;%d;%d;", adc[0], adc[1], adc[2], adc[3], adc[4], adc[5]);
        dataFile.print(tempString);
      }
      else
        dataFile.print(";");
      dataFile.write((uint8_t *)packetBuffer, i);
      dataFile.flush();
      redTime = packetTime + errorFlash;
      digitalWrite(redPin, HIGH);
      digitalWrite(redPin2, HIGH);
    }
    if ((millis() - packetTime) > timeOut)
      s = 3;
    break;

  case 3:  // close
    dataFile.print("\r\n");
    dataFile.close();
    s = 0;
    break;

  case 7:   // error
    break;

  }  // switch s

  //led state machine

  switch(ledState) {
  case 0:
    if (millis() > redTime) {
      digitalWrite(redPin, LOW);
      digitalWrite(redPin2, LOW);
    }
    if ( millis() > grnTime) {
      digitalWrite(grnPin, HIGH);
      digitalWrite(grnPin2, HIGH);
      grnTime = millis() + shortOn;
      ledState = 1;
    }
    break;

  case 1:
    if (millis() > redTime) {
      digitalWrite(redPin, LOW);
      digitalWrite(redPin2, LOW);
    }
    if (millis() > grnTime) {
      digitalWrite(grnPin, LOW);
      digitalWrite(grnPin2, LOW);
      grnTime = millis() + shortOff;
      if (s == 0)
        ledState = 3;
      else
        ledState = 2;
    }
    break;

  case 2:
    if (millis() > redTime) {
      digitalWrite(redPin, LOW);
      digitalWrite(redPin2, LOW);
    }
    if ( millis() > grnTime) {
      digitalWrite(grnPin, HIGH);
      digitalWrite(grnPin2, HIGH);
      grnTime = millis() + shortOn;
      ledState = 3;
    }
    break;

  case 3:
    if (millis() > redTime) {
      digitalWrite(redPin, LOW);
      digitalWrite(redPin2, LOW);
    }
    if (millis() > grnTime) {
      digitalWrite(grnPin, LOW);
      digitalWrite(grnPin2, LOW);
      grnTime = millis() + longOff;
      if (s == 7)
        ledState = 4;
      else
        ledState = 0;
    }
    break;

  case 4:
    if (millis() > grnTime) {
      grnTime = millis() + shortOff;
      digitalWrite(grnPin, HIGH);
      digitalWrite(grnPin2, HIGH);
      digitalWrite(redPin, LOW);
      digitalWrite(redPin2, LOW);
      ledState = 5;
    }
    break;

  case 5:
    if (millis() > grnTime) {
      grnTime = millis() + shortOff;
      digitalWrite(grnPin, LOW);
      digitalWrite(grnPin2, LOW);
      digitalWrite(redPin, HIGH);
      digitalWrite(redPin2, HIGH);
      if (s == 7)
        ledState = 4;
      else
        ledState = 3;
    }
    break;
  }  // led switch

  if (millis() > muxTime) {
    temp = (float)analogRead(0) * 0.488;
    adc[chan] = (int)temp;
    //Serial.println(adc[chan]);
    if (++chan > 5) chan = 0;
    mux(chan);
    muxTime = millis() + 50;
  }
}  // loop

// --------------------------------------------------
//   switch the mux channels
// --------------------------------------------------
void mux(char chan) {
  switch(chan) {
  case 0:   // sensor 0
    digitalWrite(a0Pin, LOW);
    digitalWrite(a1Pin, LOW);
    digitalWrite(a2Pin, LOW);
    break;

  case 1:   // sensor 1
    digitalWrite(a0Pin, HIGH);
    digitalWrite(a1Pin, LOW);
    digitalWrite(a2Pin, LOW);
    break;

  case 2:   // sensor 2
    digitalWrite(a0Pin, LOW);
    digitalWrite(a1Pin, HIGH);
    digitalWrite(a2Pin, LOW);
    break;

  case 3:   // sensor 3
    digitalWrite(a0Pin, HIGH);
    digitalWrite(a1Pin, HIGH);
    digitalWrite(a2Pin, LOW);
    break;

  case 4:   // sensor 4
    digitalWrite(a0Pin, LOW);
    digitalWrite(a1Pin, LOW);
    digitalWrite(a2Pin, HIGH);
    break;

  case 5:
    digitalWrite(a0Pin, HIGH);
    digitalWrite(a1Pin, LOW);
    digitalWrite(a2Pin, HIGH);
    break;
  }

}

// --------------------------------------------------
//   convert byte to decimal
// --------------------------------------------------
byte bcdToDec(byte val) {
  return ((val / 16 * 10) + (val % 16));
}

// --------------------------------------------------
//   print the time from the RTC
// --------------------------------------------------
void printTime() {
  char buffer[3];
  const char* AMPM = 0;
  readTime();
  Serial.print("20");
  Serial.print(year);
  Serial.print("-");
  Serial.print(month);
  Serial.print("-");
  Serial.print(day);

  Serial.print(" ");
  if (hour > 12) {
    hour -= 12;
    AMPM = " PM";
  }
  else AMPM = " AM";
  Serial.print(hour);
  Serial.print(":");
  sprintf(buffer, "%02d", minute);
  Serial.print(buffer);
  Serial.println(AMPM);
}

// --------------------------------------------------
//   read the time from the RTC
// --------------------------------------------------
void readTime() {
  Wire.beginTransmission(DS1307);
  Wire.write(byte(0));
  Wire.endTransmission();
  Wire.requestFrom(DS1307, 7);
  second = bcdToDec(Wire.read());
  minute = bcdToDec(Wire.read());
  hour = bcdToDec(Wire.read());
  Wire.read();
  day = bcdToDec(Wire.read());
  month = bcdToDec(Wire.read());
  year = bcdToDec(Wire.read());

}

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


Adding a program to print the inertial sensor values.

// OSRVR latency-testing hardware firmware source code.
// Author: Russell Taylor working for Sensics.com through ReliaSolve.com
// LICENSE: Apache License 2.0.

// This code is based on the "Accelerometer_Gyro_Shield_test" example from
// Robogaia industries that ships along with their 6-axis Gyro/Accelerometer
// shield.  That source is available from Robogaia.com.

// This code also uses information from the Blink example modified by Scott
// Fitzgerald that came with the Arduino.
// This code uses information from the AnalogReadSerial example that
// came with the Arduino.

//some other examples for MPU6000 code
//http://arduino.cc/en/Tutorial/BarometricPressureSensor
//http://code.google.com/p/ardu-imu/downloads/detail?name=ArduIMU_1.9.zip&can=2&q=

/*
 Circuit:
 MPU6000 sensor attached to the SPI communications circuit using pins  10 - 13:
 NOTE: Pin 13 is also the pin that controls the on-board LED, so it cannot be
       used for LED indication when SPI communication is happening.
 CSB: pin 10
 MOSI: pin 11
 MISO: pin 12
 SCK: pin 13
 */

// the sensor communicates using SPI, so include the library:
#include <SPI.h>

//MPU 6000 register addresses
const int ACCEL_XOUT_H = 0x3B;    //59  R ACCEL_XOUT[15:8]
const int ACCEL_XOUT_L = 0x3C;    //60  R ACCEL_XOUT[7:0]
const int ACCEL_YOUT_H = 0x3D;    //61  R ACCEL_YOUT[15:8]
const int ACCEL_YOUT_L = 0x3E;    //62  R ACCEL_YOUT[7:0]
const int ACCEL_ZOUT_H = 0x3F;    //63  R ACCEL_ZOUT[15:8]
const int ACCEL_ZOUT_L = 0x40;    //64  R ACCEL_ZOUT[7:0]
const int TEMP_OUT_H   = 0x41;    //65  R TEMP_OUT[15:8]
const int TEMP_OUT_L   = 0x42;    //66  R TEMP_OUT[7:0]
const int GYRO_XOUT_H  = 0x43;    //67  R GYRO_XOUT[15:8]
const int GYRO_XOUT_L  = 0x44;    //68  R GYRO_XOUT[7:0]
const int GYRO_YOUT_H  = 0x45;    //69  R GYRO_YOUT[15:8]
const int GYRO_YOUT_L  = 0x46;    //70  R GYRO_YOUT[7:0]
const int GYRO_ZOUT_H  = 0x47;    //71  R GYRO_ZOUT[15:8]
const int GYRO_ZOUT_L  = 0x48;    //72  RGYRO_ZOUT[7:0]

const int READ_FLAG =0x80;   //128 has to be added to the address register

// MPU 6000 registers
#define MPUREG_WHOAMI 0x75 //
#define	MPUREG_SMPLRT_DIV 0x19 //
#define MPUREG_CONFIG 0x1A //
#define MPUREG_GYRO_CONFIG 0x1B
#define MPUREG_ACCEL_CONFIG 0x1C
#define MPUREG_INT_PIN_CFG 0x37
#define	MPUREG_INT_ENABLE 0x38
#define MPUREG_ACCEL_XOUT_H 0x3B //
#define MPUREG_ACCEL_XOUT_L 0x3C //
#define MPUREG_ACCEL_YOUT_H 0x3D //
#define MPUREG_ACCEL_YOUT_L 0x3E //
#define MPUREG_ACCEL_ZOUT_H 0x3F //
#define MPUREG_ACCEL_ZOUT_L 0x40 //
#define MPUREG_TEMP_OUT_H 0x41//
#define MPUREG_TEMP_OUT_L 0x42//
#define MPUREG_GYRO_XOUT_H 0x43 //
#define	MPUREG_GYRO_XOUT_L 0x44 //
#define MPUREG_GYRO_YOUT_H 0x45 //
#define	MPUREG_GYRO_YOUT_L 0x46 //
#define MPUREG_GYRO_ZOUT_H 0x47 //
#define	MPUREG_GYRO_ZOUT_L 0x48 //
#define MPUREG_USER_CTRL 0x6A //
#define	MPUREG_PWR_MGMT_1 0x6B //
#define	MPUREG_PWR_MGMT_2 0x6C //

// Configuration bits  MPU 6000
#define BIT_SLEEP 0x40
#define BIT_H_RESET 0x80
#define BITS_CLKSEL 0x07
#define MPU_CLK_SEL_PLLGYROX 0x01
#define MPU_CLK_SEL_PLLGYROZ 0x03
#define MPU_EXT_SYNC_GYROX 0x02
#define BITS_FS_250DPS              0x00
#define BITS_FS_500DPS              0x08
#define BITS_FS_1000DPS             0x10
#define BITS_FS_2000DPS             0x18
#define BITS_FS_2G                  0x00
#define BITS_FS_4G                  0x08
#define BITS_FS_8G                  0x10
#define BITS_FS_16G                 0x18
#define BITS_FS_MASK                0x18
#define BITS_DLPF_CFG_256HZ_NOLPF2  0x00
#define BITS_DLPF_CFG_188HZ         0x01
#define BITS_DLPF_CFG_98HZ          0x02
#define BITS_DLPF_CFG_42HZ          0x03
#define BITS_DLPF_CFG_20HZ          0x04
#define BITS_DLPF_CFG_10HZ          0x05
#define BITS_DLPF_CFG_5HZ           0x06
#define BITS_DLPF_CFG_2100HZ_NOLPF  0x07
#define BITS_DLPF_CFG_MASK          0x07
#define	BIT_INT_ANYRD_2CLEAR	    0x10
#define	BIT_RAW_RDY_EN		    0x01
#define	BIT_I2C_IF_DIS              0x10

#undef VERBOSE
#undef VERBOSE2

// pins used for the connection with the sensor
// the other you need are controlled by the SPI library):
const int chipSelectPin = 10;

//*****************************************************
void setup()
//*****************************************************
{
  Serial.begin(9600);
  Serial.print("OSVR_latency_hardware_firmware print_intertial v01.00.00\n");

  MPU6000_Init();
  delay(100);
}

//*****************************************************
void loop()
//*****************************************************
{
  int accX, accY, accZ;
  int gyroX, gyroY, gyroZ;
  accX = getXAccelerometerCounts();
  accY = getYAccelerometerCounts();
  accZ = getZAccelerometerCounts();
  gyroX = getXGyroCounts();
  gyroY = getYGyroCounts();
  gyroZ = getZGyroCounts();

  Serial.print("Acc XYZ, Gyro XYZ "); Serial.print(accX);
  Serial.print(" "); Serial.print(accY);
  Serial.print(" "); Serial.print(accZ);
  Serial.print(", "); Serial.print(gyroX);
  Serial.print(" "); Serial.print(gyroY);
  Serial.print(" "); Serial.print(gyroZ);
  Serial.print("\n");
  delay(500);
}

//*****************************************************
int getXAccelerometerCounts(void)
//*****************************************************
{
    int tempData_HI,tempData_LO;
     //Read the  data
    tempData_HI = readRegister(ACCEL_XOUT_H);
    tempData_LO = readRegister(ACCEL_XOUT_L );

    return ((tempData_HI << 8) | tempData_LO);

}//end func

//*****************************************************
int getYAccelerometerCounts(void)
//*****************************************************
{
    int tempData_HI,tempData_LO;

    tempData_HI = readRegister(ACCEL_YOUT_H);
    tempData_LO = readRegister(ACCEL_YOUT_L );

    return ((tempData_HI << 8) + tempData_LO);
}//end func

//*****************************************************
int getZAccelerometerCounts(void)
//*****************************************************
{
    int tempData_HI,tempData_LO;

    tempData_HI = readRegister(ACCEL_ZOUT_H );
    tempData_LO = readRegister(ACCEL_ZOUT_L );

    return ((tempData_HI << 8) + tempData_LO);

}//end func

//*****************************************************
int getXGyroCounts(void)
//*****************************************************
{
     int tempData_HI,tempData_LO;

     tempData_HI = readRegister(GYRO_XOUT_H );
     tempData_LO = readRegister(GYRO_XOUT_L );

     return ((tempData_HI << 8) + tempData_LO);
}//end func

//*****************************************************
int getYGyroCounts(void)
//*****************************************************
{
     int tempData_HI,tempData_LO;

     tempData_HI = readRegister(GYRO_YOUT_H);
     tempData_LO = readRegister(GYRO_YOUT_L );

     return ((tempData_HI << 8) + tempData_LO);
}//end func

//*****************************************************
int getZGyroCounts(void)
//*****************************************************
{
     int tempData_HI,tempData_LO;

     tempData_HI = readRegister(GYRO_ZOUT_H);
     tempData_LO = readRegister(GYRO_ZOUT_L);

     return ((tempData_HI << 8) + tempData_LO);
}//end func

//Read from register
//*****************************************************
unsigned int readRegister(byte thisRegister)
//*****************************************************
{
  unsigned int result = 0;   // result to return
  byte addr = thisRegister + 0x80;
 // Serial.print(thisRegister, BIN);
 // byte dataToSend = thisRegister ;
  //Serial.println(thisRegister, BIN);
  // take the chip select low to select the device:
  digitalWrite(chipSelectPin, LOW);
  // send the device the register you want to read:
  SPI.transfer(addr);
  // send a value of 0 to read the first byte returned:
  result = SPI.transfer(0x00);
  // take the chip select high to de-select:
  digitalWrite(chipSelectPin, HIGH);
  // return the result:
  return(result);
}

//Write to register
//*****************************************************
void writeRegister(byte thisRegister, byte thisValue)
//*****************************************************
{
  thisRegister = thisRegister ;
  // now combine the register address and the command into one byte:
  byte dataToSend = thisRegister;

  // take the chip select low to select the device:
  digitalWrite(chipSelectPin, LOW);

  SPI.transfer(dataToSend); //Send register location
  SPI.transfer(thisValue);  //Send value to record into register

  // take the chip select high to de-select:
  digitalWrite(chipSelectPin, HIGH);
}//

// MPU6000 Initialization and configuration
//*************************************************
void MPU6000_Init(void)
//*************************************************
{
    // MPU6000 chip select setup
    pinMode(chipSelectPin, OUTPUT);
    digitalWrite(chipSelectPin, HIGH);

    // SPI initialization
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV16);      // SPI at 1Mhz (on 16Mhz clock)
    delay(10);

    // Chip reset
    writeRegister(MPUREG_PWR_MGMT_1, BIT_H_RESET);
    delay(100);

    // Wake up device and select GyroZ clock (better performance)
    writeRegister(MPUREG_PWR_MGMT_1, MPU_CLK_SEL_PLLGYROZ);
    delay(1);

    // Disable I2C bus (recommended on datasheet)
    writeRegister(MPUREG_USER_CTRL, BIT_I2C_IF_DIS);
    delay(1);

    // Set the sampling rate.  We do this by setting the divisor on the rate,
    // which has a base update rate of 1kHz.  The number we use here is added
    // to 1 and then used as a divisor: Rate = 1Khz / (value + 1).  So a value
    // of 0 is 1 kHz, a value of 4 is 200Hz, and a value of 19 is 50Hz.
    // We want to sample as rapidly as possible, so that we have the minimum
    // latency between motion and its detection.  Even at 1kHz, we're going to
    // have some fraction of a second of latency on our reads.
    writeRegister(MPUREG_SMPLRT_DIV,0);
    delay(1);

    // Set the filter pass frequency on the low-pass filter to the maximum
    // (no filter, corresponding to a 2.1Khz cutoff).
    writeRegister(MPUREG_CONFIG, BITS_DLPF_CFG_2100HZ_NOLPF);
    delay(1);

    // Set the measurement scale on the gyros and the accelerometers.
    // From the data sheet: For precision tracking of both fast and slow
    // motions, the parts feature a user-programmable gyroscope full-scale range
    // of ±250, ±500, ±1000, and ±2000°/sec (dps) and a user-programmable accelerometer
    // full-scale range of ±2g, ±4g, ±8g, and ±16g.
    // We set the sensitivity to match the example app, which got good full-scale results.
    writeRegister(MPUREG_GYRO_CONFIG,BITS_FS_2000DPS);
    delay(1);
    writeRegister(MPUREG_ACCEL_CONFIG,BITS_FS_4G);
    delay(1);

    // Oscillator set
    writeRegister(MPUREG_PWR_MGMT_1,MPU_CLK_SEL_PLLGYROZ);
    delay(1);
}

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


add arduino program to control Hbridge from potentiometer reading

// constants won't change. Used here to
// set pin numbers:
const int HbridgeEnablePin =  13;
const int HbridgeLogicPin1 = 4;
const int HbridgeLogicPin2 = 5;
int sensorValue = 0;        // value read from the potentiometer
// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to

void setup()
{
  // set the digital pin as output:
  pinMode(HbridgeEnablePin, OUTPUT);
  pinMode(HbridgeLogicPin1, OUTPUT);
  pinMode(HbridgeLogicPin2, OUTPUT);
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);

}

void loop()
{
  digitalWrite(HbridgeEnablePin, HIGH);
  double minTime_ms = 30;//Minimal time to have motor starting at maximum voltage
  // read the analog in value:
  double sensorValueMin = 255;//0
  double sensorValueMax = 767;//1023
  double deadBand = 0.05; // Should not be zero
  sensorValue = analogRead(analogInPin);
  double alphaSigned = 2*((sensorValue-sensorValueMin)/(sensorValueMax - sensorValueMin)-0.5);
  double alpha = max(fabs(alphaSigned), deadBand);
  alpha = min(alpha, 1);
  if (alphaSigned>fabs(deadBand))
  {
    digitalWrite(HbridgeLogicPin1, HIGH);
    digitalWrite(HbridgeLogicPin2, LOW);
  }
  else
  {
    if (alphaSigned<-fabs(deadBand))
    {
      digitalWrite(HbridgeLogicPin1, LOW);
      digitalWrite(HbridgeLogicPin2, HIGH);
    }
    else
    {
      digitalWrite(HbridgeLogicPin1, LOW);
      digitalWrite(HbridgeLogicPin2, LOW);
    }
  }
  delay(minTime_ms);

  sensorValue = analogRead(analogInPin);
  alphaSigned = 2*((sensorValue-sensorValueMin)/(sensorValueMax - sensorValueMin)-0.5);
  alpha = max(fabs(alphaSigned), deadBand);
  alpha = min(alpha, 1);
    if (alphaSigned>fabs(deadBand))
  {
    digitalWrite(HbridgeLogicPin1, HIGH);
    digitalWrite(HbridgeLogicPin2, LOW);
  }
  else
  {
    if (alphaSigned<-fabs(deadBand))
    {
      digitalWrite(HbridgeLogicPin1, LOW);
      digitalWrite(HbridgeLogicPin2, HIGH);
    }
    else
    {
      digitalWrite(HbridgeLogicPin1, LOW);
      digitalWrite(HbridgeLogicPin2, LOW);
    }
  }
  double initialTime = millis();
  double elapsedTime_ms = millis() - initialTime;
  while (elapsedTime_ms < minTime_ms/alpha*(1-alpha)-minTime_ms)
  {
    digitalWrite(HbridgeEnablePin, LOW);
    delay(minTime_ms);
    sensorValue = analogRead(analogInPin);
    Serial.print("sensorValue = " );
    Serial.println(sensorValue);
    alphaSigned = 2*((sensorValue-sensorValueMin)/(sensorValueMax - sensorValueMin)-0.5);
    Serial.print("alphaSigned = " );
    Serial.println(alphaSigned);
    alpha = max(fabs(alphaSigned), deadBand);
    alpha = min(alpha, 1);
      if (alphaSigned>fabs(deadBand))
  {
    digitalWrite(HbridgeLogicPin1, HIGH);
    digitalWrite(HbridgeLogicPin2, LOW);
  }
  else
  {
    if (alphaSigned<-fabs(deadBand))
    {
      digitalWrite(HbridgeLogicPin1, LOW);
      digitalWrite(HbridgeLogicPin2, HIGH);
    }
    else
    {
      digitalWrite(HbridgeLogicPin1, LOW);
      digitalWrite(HbridgeLogicPin2, LOW);
    }
  }
    Serial.print("alpha = " );
    Serial.println(alpha);
    elapsedTime_ms = millis() - initialTime;
    Serial.print("elapsedTime_ms = " );
    Serial.println(elapsedTime_ms);
  }
  digitalWrite(HbridgeEnablePin, LOW);
  delay(fabs(minTime_ms/alpha*(1-alpha)- elapsedTime_ms));

  // print the results to the serial monitor:
  Serial.print("alphaManual = " );
  Serial.print(alphaSigned);
  Serial.print("\t alphaUsed = ");
  Serial.println(alphaSigned);
}


Added Arduino file for Sigfox DHT module

/*
 * This programme reads the temperature (Celsius), relative humidity, and light (0-1000) and sends it to Sigfox every 10 minutes
 */

#include <Wire.h>
#include <arduinoUART.h>
#include <arduinoUtils.h>
#include <arduinoSigfox.h>

#include <DHT.h>
#define DHTTYPE DHT22
#define LEDONBOARD 13
#define DHTPIN  2
#define LEDREAD 3
#define LEDACK 4
#define LEDERROR 5
DHT dht(DHTPIN, DHTTYPE, 11); // 11 works fine for ESP8266

float humidity, temperature;
int light;
int secondsdelay = 600;

// define union-type variables for the temperature and humidity that we can use when sending data to Sigfox
union
{
  uint8_t  values[4];
  float    temperature;
} temperature_union;

union
{
  uint8_t  values[4];
  float    humidity;
} humidity_union;

//////////////////////////////////////////////
uint8_t socket = SOCKET0;     //Asign to UART0
//////////////////////////////////////////////

uint8_t error;

void getReadings() {
    humidity = dht.readHumidity();
    temperature = dht.readTemperature();
    if (isnan(humidity) || isnan(temperature)) {
      humidity = 0;
      temperature = 0;
    }

    temperature_union.temperature = temperature;
    humidity_union.humidity = humidity;
    light = analogRead(0);
}

void setup()
{
  pinMode(LEDONBOARD, OUTPUT);
  digitalWrite(LEDONBOARD, LOW);
  pinMode(LEDREAD, OUTPUT);
  pinMode(LEDACK, OUTPUT);
  pinMode(LEDERROR, OUTPUT);
  blinkn (3,LEDREAD);
  blinkn (3,LEDACK);
  blinkn (3,LEDERROR);
  // Set up sensors
  dht.begin();
  delay (200);
  getReadings();
}

void blinkn (int i, int pin ) {
  int j;
  for (j=0; j < i; j++) {
    digitalWrite(pin, HIGH);
    delay (100);
    digitalWrite(pin, LOW);
    delay (100);
  }
}

void loop()
{
  error = Sigfox.ON(socket);
  if( error != 0 ) {
    blinkn (3,LEDONBOARD);
  } else {
    blinkn (3,LEDREAD);
    getReadings();

    /*
     * Old message structure (using 2 byte integers instead of 4 byte float values
     *
    int16_t temperatureb2 = (int16_t)(temperature * 100);
    int16_t humidityb2 = (int16_t)(humidity * 100);
    int16_t lightb2 = (int16_t)(light);
    byte data[6];
    data[0] = temperatureb2 >> 8;
    data[1] = temperatureb2 & 0xFF;
    data[2] = humidityb2 >> 8;
    data[3] = humidityb2 & 0xFF;
    data[4] = lightb2 >> 8;
    data[5] = lightb2 & 0xFF;*/

    int16_t lightb2 = (int16_t)(light);
    byte data[10];

    data[0] = temperature_union.values[3]; // big-endian
    data[1] = temperature_union.values[2];
    data[2] = temperature_union.values[1];
    data[3] = temperature_union.values[0];

    data[4] = humidity_union.values[3]; // big-endian
    data[5] = humidity_union.values[2];
    data[6] = humidity_union.values[1];
    data[7] = humidity_union.values[0];

    data[8] = lightb2 >> 8;
    data[9] = lightb2 & 0xFF;

    error = Sigfox.sendACK(data, sizeof(data));
    if( error == 0 ) {
      blinkn (3,LEDACK);
    } else {
      blinkn (3,LEDERROR);
    }
  }
  blinkn (6,LEDONBOARD);
  delay(600000);
}

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


Simplifying

Simplifying

Dimming didn't make a lot of sense. 32 leds make a lot of light for something that
just needs to glow. So I just turned the brightness down to 30
which seems to be a good value for a nighttime bedroom.

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


Evothings Arduino CC3000 Wifi Module

Evothings Arduino CC3000 Wifi Module

This is an example of how to use CC3000 with Evothings

/*
Arduino CC3000 Wifi Module
Created January 15, 2016
Klaus Camilleri

This example is a mix of both an example written by Adafruit team & Wifi example written by Mikael Kindborg, Evothings AB

TCP socket server that accept commands for basic scripting
of the Arduino board.
This example is written for a network using WPA encryption.
For WEP or WPA, change the Wifi.begin() call accordingly.
The API consists of the requests listed below.
Requests and responses end with a new line.
The input parameter n is a pin number ranging from 2 to 9.
The response is always a 4-character string with a
hex encoded number ranging from 0 to FFFF.
Possible response string values:
H (result from digital read)
L (result from digital read)
0 to 1023 - Analog value (result from analog read)
Set pin mode to OUTPUT for pin n: On
Response: None
Example: O5
Note: O is upper case letter o, not digit zero (0).
Set pin mode to INPUT for pin n: In
Response: None
Example: I5
Write LOW to pin n: Ln
Response: None
Example: L5
Write HIGH to pin n: Hn
Response: None
Example: H5
READ pin n: Rn
Response: "H" (HIGH) or "L" (LOW)
Example: R5 -> H
ANALOG read pin n: An
Response: int value as string (range "0" to "1023")
Example: A5 -> 42
*/

#include <Adafruit_CC3000.h>
#include <SPI.h>

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11

Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed

#define WLAN_SSID       "wifi"   // cannot be longer than 32 characters!
#define WLAN_PASS       "password"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define LISTEN_PORT           3300      // What TCP port to listen on for connections.

#define BUFFER_SIZE           120

#define TIMEOUT_MS            500    // Amount of time in milliseconds to wait for
                                     // an incoming request to finish.  Don't set this
                                     // too high or your server could be slow to respond.

Adafruit_CC3000_Server httpServer(LISTEN_PORT);
uint8_t buffer[BUFFER_SIZE+1];
int bufindex = 0;

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

  // Initialise the module
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }

  Serial.print(F("\nAttempting to connect to ")); Serial.println(WLAN_SSID);
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }

  Serial.println(F("Connected!"));

  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100);
  }

  // Start listening for connections
  httpServer.begin();

  Serial.println(F("Listening for connections..."));
}

void loop(void)
{
  // Try to get a client which is connected.
  Adafruit_CC3000_ClientRef client = httpServer.available();
  if (client) {
    Serial.println(F("Client connected."));

    Serial.println("Client connected");

    String request = readRequest(&client);
    executeRequest(&client, &request);

    // Close the connection.
    //client.stop();

    Serial.println("Client disonnected");
  }
}

String readRequest(Adafruit_CC3000_ClientRef* client)
{
  String request = "";

  // Loop while the client is connected.
  while (client->connected())
  {
    // Read available bytes.
    while (client->available())
    {
      // Read a byte.
      char c = client->read();

      // Print the value (for debugging).
      Serial.write(c);

      // Exit loop if end of line.
      if ('\n' == c)
      {
        return request;
      }

      // Add byte to request line.
      request += c;
    }
  }
  return request;
}

void executeRequest(Adafruit_CC3000_ClientRef* client, String* request)
{
  char command = readCommand(request);
  int n = readParam(request);
  if ('O' == command)
  {
    pinMode(n, OUTPUT);
  }
  else if ('I' == command)
  {
    pinMode(n, INPUT);
  }
  else if ('L' == command)
  {
    digitalWrite(n, LOW);
  }
  else if ('H' == command)
  {
    digitalWrite(n, HIGH);
  }
  else if ('R' == command)
  {
    sendResponse(client, String(digitalRead(n)));
  }
  else if ('A' == command)
  {
    sendResponse(client, String(analogRead(n)));
  }
}

// Read the command from the request string.
char readCommand(String* request)
{
  String commandString = request->substring(0, 1);
  return commandString.charAt(0);
}

// Read the parameter from the request string.
int readParam(String* request)
{
	// This handles a hex digit 0 to F (0 to 15).
	char buffer[2];
	buffer[0] = request->charAt(1);
	buffer[1] = 0;
	return (int) strtol(buffer, NULL, 16);
}

void sendResponse(Adafruit_CC3000_ClientRef* client, String response)
{
  // Send response to client.
  client->println(response);

  // Debug print.
  Serial.println("sendResponse:");
  Serial.println(response);
}

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


Arduino code updated light_sensor() and distance_sensor()

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


Create environment-monitor.ino

Create environment-monitor.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/olayenca/Environment-Monitor.git/'


oled test sketch added

oled test sketch added

    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

    Adafruit_SSD1306 display = Adafruit_SSD1306();

    #ifdef ARDUINO_SAMD_ZERO
    #define Serial SerialUSB
    #endif

    #if defined(ESP8266)
      #define BUTTON_A 0
      #define BUTTON_B 16
      #define BUTTON_C 2
      #define LED      0
    #elif defined(ARDUINO_STM32F2_FEATHER)
      #define BUTTON_A PA15
      #define BUTTON_B PC7
      #define BUTTON_C PC5
      #define LED PB5
    #else
      #define BUTTON_A 9
      #define BUTTON_B 6
      #define BUTTON_C 5
      #define LED      13
    #endif

    #if (SSD1306_LCDHEIGHT != 32)
    #error("Height incorrect, please fix Adafruit_SSD1306.h!");
    #endif

    void setup() {
    #if !defined(ESP8266)
      while (!Serial) delay(1);
    #endif

      Serial.begin(9600);

      Serial.println("OLED test");
      // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
      display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
      // init done
      Serial.println("OLED begun");

      // Show image buffer on the display hardware.
      // Since the buffer is intialized with an Adafruit splashscreen
      // internally, this will display the splashscreen.
      display.display();
      delay(1000);

      // Clear the buffer.
      display.clearDisplay();
      display.display();

      Serial.println("IO test");

      pinMode(BUTTON_A, INPUT_PULLUP);
      pinMode(BUTTON_B, INPUT_PULLUP);
      pinMode(BUTTON_C, INPUT_PULLUP);

      // text display tests
      display.setTextSize(1);
      display.setTextColor(WHITE);
      display.setCursor(0,0);
      display.println("abcdefghijklmnopqrstu");
      display.println("ABCDEFGHIJKLMNOPQRSTU");
      display.println("123456789012345678901");
      display.println("/-\|/-\|/-\|/-\|/-\|/");
    }

    void loop() {
//      if (! digitalRead(BUTTON_A)) display.print("A");
//      if (! digitalRead(BUTTON_B)) display.print("B");
//      if (! digitalRead(BUTTON_C)) display.print("C");
      if (! digitalRead(BUTTON_A)) {
        Serial.print("A");
        display.clearDisplay();
        display.setCursor(0,0);
        display.println("A-A-A");
      }
      if (! digitalRead(BUTTON_B)) {
        Serial.print("B");
        display.clearDisplay();
        display.setCursor(0,0);
        display.println("B-B-B");
      }
      if (! digitalRead(BUTTON_C)) {
        Serial.print("C");
        display.clearDisplay();
        display.setCursor(0,0);
        display.println("C-C-C");
      }

      delay(10);
      yield();
      display.display();
    }

error: pathspec 'oled_test/oled_test.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

  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 uint8_t 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 unsigned long prevHdopTime = TOGGLETIME_INTERVAL;
  static bool dateTimeToggle = true;
  static bool headingToggle = true;
  static bool hdopToggle = true;
#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() &&
    gps.hdop.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.hdop       = gps.hdop.value();
    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 points or 8 cardinal points)
    GPSData.hdop       = 150;
    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((int16_t)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((int16_t)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
    }
#else // #ifndef CONVERT_TO_LOCAL
#ifdef DISPLAY_HDOP_ERROR
    // Display Horizontal Dilution of Precision (Hdop) with the format X.X
    // It comes in from the GPS module as XXX
    // If you care how Hdop is computed (I don't :-(), see the following:
    // http://www2.unb.ca/gge/Resources/gpsworld.may99.pdf
    uint32_t hdopInteger = GPSData.hdop / 100;
    uint32_t hdopFarction = (GPSData.hdop - (hdopInteger * 100)) / 10;
    lcd.print(" Hdop:");
    if (hdopInteger < 10) {
      lcd.print(hdopInteger); // Integer part
      lcd.print(".");
      lcd.print(hdopFarction); // Fraction part
    }
    else {
      // Hdop value too large for my LCD, so cross it out
      // Toggle Hdop indicator every TOGGLETIME_INTERVAL seconds
      if (now - prevHdopTime > TOGGLETIME_INTERVAL / 3) {
        prevHdopTime = now;
        if (hdopToggle) {
          hdopToggle = false;
          lcd.print("XXX");
        }
        else {
          hdopToggle = true;
          lcd.print("   ");
        } // if (hdopToggle)
      } // if (now - prevHdopTime > TOGGLETIME_INTERVAL)
    } // if (hdopInteger < 10)
#else // #ifdef DISPLAY_HDOP_ERROR
    // Display horizontal position error in feet
    uint32_t hdopInteger = GPSData.hdop / 100;
    uint32_t hdopFarction = (GPSData.hdop - (hdopInteger * 100)) / 10;
    float hError = (float)hdopInteger + ((float)hdopFarction) / 10.0f;
    hError *= GPS_RECEIVER_ERROR; // Error in meters
    hError *= METERS_TO_FEET; // Error in feet
    lcd.print(" Err: ");
    if (hError < 100.0f) {
      lcd.print((uint8_t)hError);
      if (hError < 10.0f) {
        lcd.print("f ");
      }
      else {
        lcd.print("f");
      }
    }
    else {
      // horizontal position error value too large for my LCD, so cross it out
      // Toggle Hdop indicator every TOGGLETIME_INTERVAL seconds
      if (now - prevHdopTime > TOGGLETIME_INTERVAL / 3) {
        prevHdopTime = now;
        if (hdopToggle) {
          hdopToggle = false;
          lcd.print("XXX");
        }
        else {
          hdopToggle = true;
          lcd.print("   ");
        } // if (hdopToggle)
      } // if (now - prevHdopTime > TOGGLETIME_INTERVAL)
    } // if (hError < 100.0f)
#endif // #ifdef DISPLAY_HDOP_ERROR
#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((int16_t)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((int16_t)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((int16_t)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
} // 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;
  }
  int8_t previousSunday = (int8_t)(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)
  int8_t UTCOffset = (int8_t)(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

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


First pass at ReadAnalog demo

First pass at ReadAnalog demo

/*************************************************
 *  ReadAnalog.ino                               *
 *  Example from the ArTICL library              *
 *           Created by Christopher Mitchell,    *
 *           2011-2014, all rights reserved.     *
 *                                               *
 *  This demo reads the Arduino's six analog     *
 *  pins whenever the calculator requests a      *
 *  list, and returns the results as a six-      *
 *  element list with values between 0 and 1023. *
 *************************************************/

#include "CBL2.h"
#include "TIVar.h"

CBL2* cbl;
int lineRed = 7;
int lineWhite = 6;

#define MAXDATALEN 255
uint8_t header[16];
uint8_t data[MAXDATALEN];

void setup() {
  Serial.begin(9600);
  cbl = new CBL2(lineRed, lineWhite);
  cbl->resetLines();
  cbl->setVerbosity(true, &Serial);			// Comment this in for mesage information
  cbl->setupCallbacks(header, data, MAXDATALEN,
                      onGetAsCBL2, onSendAsCBL2);
}

void loop() {
  int rval;
  rval = cbl->eventLoopTick();
  if (rval && rval != ERR_READ_TIMEOUT) {
    Serial.print("Failed to run eventLoopTick: code ");
    Serial.println(rval);
  }
}

int onGetAsCBL2(uint8_t type, int datalen) {
  Serial.print("Got variable of type ");
  Serial.print(type);
  Serial.println(" from calculator.");
  return 0;
}

int onSendAsCBL2(uint8_t type, int* datalen) {
  Serial.print("Got request for variable of type ");
  Serial.print(type);
  Serial.println(" from calculator.");

  if (type != 0x01)
    return -1;

  // Compose the VAR header
  *datalen = 2 + 9 * 6;
  header[0] = *datalen;			// Two bytes for the element count, 6 9-byte reals
  header[1] = 0;
  header[2] = 0x04;
  header[3] = 0x01;
  header[4] = 0x41;				// See http://www.cemetech.net/forum/viewtopic.php?p=224739#224739
  header[5] = 0x00;

  // Compose the body of the variable
  data[0] = 6;
  data[1] = 0;
  for(int i = 0; i < 6; i++) {
	float value = analogRead(i);
	TIVar::floatToReal8x(value, &data[2 + 9 * i]);
  }
  for(int i = 0; i < *datalen; i++) {
    Serial.print(data[i], HEX);
	Serial.print(" ");
  }
  Serial.println("]]");

  return 0;
}

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


updata

updata

/*
 * WaterAlarm.ino
 * Example sketch for Grove Water Sensor
 *
 * Copyright (c) 2013 seeed technology inc.
 * Website    : www.seeed.cc
 * Author     : Frankie.Chu
 * Create Time: Jan 18,2013
 * Change Log :
 *
 * The MIT License (MIT)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

/*macro definition of water sensor and the buzzer*/
#define WATER_SENSOR 2
#define BUZZER 3
void setup()
{
	pins_init();
}
void loop()
{
	if(isExposedToWater())
		soundAlarm();
}
void pins_init()
{
	pinMode(WATER_SENSOR, INPUT);
	pinMode(BUZZER, OUTPUT);
}
/************************************************************************/
/*Function: When the sensor is exposed to the water, the buzzer sounds	*/
/*			for 2 seonds.												*/
void soundAlarm()
{
	for(uint8_t i = 0;i < 20;i ++)
	{
		digitalWrite(BUZZER, HIGH);
		delay(50);
		digitalWrite(BUZZER, LOW);
		delay(50);
	}
}
/************************************************************************/
/*Function: Determine whether the sensor is exposed to the water		*/
/*Parameter:-void           											*/
/*Return:	-boolean,if it is exposed to the water,it will return ture. */
boolean isExposedToWater()
{
	if(digitalRead(WATER_SENSOR) == LOW)
		return true;
	else return false;
}

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


Create blink_test.ino

Create blink_test.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/pylonman/simple_gpio_class.git/'


Temperatuur, Altimeter

Temperatuur, Altimeter

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


testing

testing

// tiny-vumeter.ino

#include <Arduino.h>
#include <stdlib.h>

#define PIN_LED 13
#define PIN_PWM 1

void setup()
{
    Serial.begin(115200);
    Serial.println("Starting...");
    pinMode(PIN_LED, OUTPUT);
    digitalWrite(PIN_LED, LOW);
    pinMode(PIN_PWM, OUTPUT);
    analogWrite(PIN_PWM, 0);
    Serial.println("Setup complete.");
}

void loop()
{
    int i = 0;
    int up = 1;
    while (1)
    {
        analogWrite(PIN_PWM, i);
        if (up)
        {
            // counting up
            if (i == 255)
            {
                up = 0;
            }
            else
            {
                ++i;
            }
        }
        else
        {
            // counting down
            if (i == 0)
            {
                up = 1;
            }
            else
            {
                --i;
            }
        }
        delay(5);
    }
}
// EOF

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


Removed Useless Code

Removed Useless Code

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


Updated Snow Crash

Updated Snow Crash

/* Snow Crash: TcDS

based mostly off blinkwithoutdelay:
 created 2005
 by David A. Mellis
 modified 8 Feb 2010
 by Paul Stoffregen

 This example code is in the public domain.
 */

// constants won't change. Used here to
// set pin numbers:
const int ledPin =  11;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval =20;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop()
{

   int sensorValue = analogRead(A0);
   Serial.println(sensorValue);

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

error: pathspec 'Mod/E-Stim/TCDS__BASIC_POTENTIOMETER/TCDS__BASIC_POTENTIOMETER.ino' did not match any file(s) known to git


Working script for output leds

Working script for output leds

// @author Jukka Dahlbom
// @created 30.12.2014

// Adapted from Wire Master Writer sample code
// by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates running multiple leds in sequence on MCP23017
// I2C port expander.

#include <Wire.h>

int ADDRESS = 0x20; // Default address for MCP23017
int IODIRA = 0x00;
int GPIOA = 0x12; // IOCON.BANK bit resets to 0, so using that mode.

void setup()
{
  delay(1000);
  Serial.begin(9600);
  Wire.begin(); // join i2c bus (address optional for master)
  Wire.beginTransmission(ADDRESS);
  Wire.write(IODIRA);         // IODIRA register
  Wire.write(0x00);        // Set bank A to output
  Wire.endTransmission();    // stop transmitting
}

void loop()
{
  setOutput(computeUpdatedState());
  delay(300);
}

int computeUpdatedState() {
  static int phase = 0;
  int pin6 = 0x00, pin7 = 0x00, pin8 = 0x00;
  if (phase > 0 && phase < 4) {
    pin6 = 0x20;
  }
  if (phase > 1 && phase < 5) {
    pin7 = 0x40;
  }
  if (phase > 2 && phase < 6) {
    pin8 = 0x80;
  }
  phase = ++phase % 6;
  return pin6 + pin7 + pin8;
}

void setOutput(int value) {
  Wire.beginTransmission(ADDRESS);
  Wire.write(GPIOA);        // select GPIOA register
  Wire.write(value);  // Set all output HIGH in bank A
  Wire.endTransmission();    // stop transmitting
}

error: pathspec 'testing-output-23017/testing-output-23017.ino' did not match any file(s) known to git


Test DVD stepper motor

Test DVD stepper motor

#include <AFMotor.h>
#include <Servo.h>

#define START_X  10
#define START_Y  9
#define SERVO_PIN 2

AF_Stepper motorX(48, 1);
AF_Stepper motorY(48, 2);
Servo penServo;

void goTo(int newX, int newY);
void penUp();
void penDown();

int posX, posY;

void setup() {
  penServo.attach(SERVO_PIN);  // attaches the servo on pin 9 to the servo object
  penUp();
  Serial.begin(115200);
  pinMode(START_X, INPUT);
  pinMode(START_Y, INPUT);
  motorX.setSpeed(160);  // 10 rpm
  motorY.setSpeed(100);  // 10 rpm

  // Move to the start position
  while(digitalRead(START_X))
  {
    motorX.step(1, BACKWARD, INTERLEAVE);
    delay(5);
  }
  while(digitalRead(START_Y))
  {
    motorY.step(1, BACKWARD, INTERLEAVE);
    delay(5);
  }
  motorX.step(5, FORWARD, INTERLEAVE);
  motorY.step(5, FORWARD, INTERLEAVE);
  posX = 0;
  posY = 0;
}

void loop()
{
  for (int i = 0; i <75; i+=5)
  {
    goTo(i, i);
    penDown();
    goTo(150 - i, i);
    goTo(150 - i, 150 - i);
    goTo(i, 150 - i);
    goTo(i, i);
    penUp();
  }

  penUp();
  while(1);

  return;

  int r = 70;
  goTo(75 + r, 75);
  delay(200);

  char buf[20];

  float phi = 0;
  for (float phi = 0; phi < 3.1415926 * 2; phi+= 3.1415 / 10.01)
  {
    int x = 75.0 + cos(phi) * r;
    int y = 75.0 + sin(phi) * r;

    sprintf(buf, "%d\t%d", x, y);
    Serial.println(buf);
    goTo(x, y);
  }
  penUp();
  while(1);
}

void goTo(int newX, int newY)
{
  newX <<= 1;
  newY <<= 1;
  if (newX > posX)
  {
    motorX.step(newX - posX, FORWARD, INTERLEAVE);
  }
  else if (newX < posX)
  {
    motorX.step(posX - newX, BACKWARD, INTERLEAVE);
  }
  posX = newX;

  if (newY > posY)
  {
    motorY.step(newY - posY, FORWARD, INTERLEAVE);
  }
  else if (newY < posY)
  {
    motorY.step(posY - newY, BACKWARD, INTERLEAVE);
  }
  posY = newY;
//  motorX.release();
//  motorY.release();
}

void penUp()
{
  penServo.write(100);
  delay(600);
}

void penDown()
{
  penServo.write(60);
  delay(600);
}

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


Delete Arduino_Uno(not RFID).ino

Delete Arduino_Uno(not RFID).ino

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


added arduino code

added arduino code

#include <ClickButton.h> // https://code.google.com/p/clickbutton/
#include <Encoder.h>

Encoder encoder(2, 3);
ClickButton rec_button(4, LOW, CLICKBTN_PULLUP);
int button_state = 0;

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

  rec_button.debounceTime   = 20;   // Debounce timer in ms
  rec_button.multiclickTime = 250;  // Time limit for multi clicks
  rec_button.longClickTime  = 2500; // time until "held-down clicks" register
}

long pos  = -999;
long last_value = 0;
long act_value = 0;

int distance = 7; // how many ticks until keypress is fired, 7 seemed to result in ~8 keys per round

void loop() {

  long newPos = encoder.read();
  if(newPos > pos)     { act_value += 1; }
  else if(newPos < pos){ act_value -= 1; }
  if (newPos != pos)   { pos = newPos;   }

  if(act_value - last_value >= distance){ // clockwise
    Keyboard.press(KEY_RIGHT_ARROW);
    Keyboard.release(KEY_RIGHT_ARROW);
    last_value = act_value;
  } else if(act_value - last_value <= -1 * distance){ // counter clockwise
    Keyboard.press(KEY_LEFT_ARROW);
    Keyboard.release(KEY_LEFT_ARROW);
    last_value = act_value;
  }

  rec_button.Update();
  button_state = rec_button.clicks;

  if(button_state == 1){ // single click
    Keyboard.press('r');
    Keyboard.release('r');
  }else if(button_state == 2){ // double click
    Keyboard.press('p');
    Keyboard.release('p');
  }else if(button_state == -1){ // long press
    Keyboard.press(KEY_ESC);
    Keyboard.release(KEY_ESC);
  }
}

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


Added IrcClientExample for TM4C129 Connected LaunchPad

/* IRC Example
 * Simple IRC client which connects gracefully, joins #energia and says a simple Hello
 * before quitting and indefinitely sleeping.
 *
 * Written in March 2014 by Eric Brundick for the Energia project.
 *
 * Requires the Ethernet library, tested with TI Tiva Connected LaunchPad
 *   based on the TM4C1294NCPDT microcontroller.
 *
 * Released as Public Domain.  Do with it as you wish.
 */

#include <Ethernet.h>
#include <IPAddress.h>
#include <string.h>

byte ourMac[] = { 0x52, 0x54, 0xFF, 0xFF, 0xFF, 0x01 };
EthernetClient client;

const char *ircserver_name = "chat.freenode.net";

//#define IRC_USE_IP_NOT_DNS
//IPAddress ircserver(62,231,75,133);
// ^ Required for connecting through an SSH tunnel for getting around a firewall
// Comment out #define IRC_USE_IP_NOT_DNS to use the ircserver_name DNS to connect.

#define IRCSERVER_PORT 6667

const char *irc_nick = "MyTivaLP";
const char *irc_user = "tm4c129";
const char *irc_user_description = "Energia Warrior";
const char *irc_channel = "#energia";

void dispatch_composite_message(uint8_t, int);
void process_inbound_message(uint8_t, int);

void setup()
{
  IPAddress ip;

  Serial.setBufferSize(2048, 64);  /* New Energia 12 feature; specifying large TX buffer to avoid locking
                                    * up the sketch for any reason when spitting debugging messages
                                    * over the ICDI backchannel UART.
                                    */
  Serial.begin(115200);

  // Wait for USR_SW1 to be pressed before continuing (10ms resolution polling the button)...
  pinMode(USR_SW1, INPUT_PULLUP);
  uint32_t lastmillis = millis();
  while (digitalRead(USR_SW1)) {
    if ( (millis() - lastmillis) > 1000 ) {
      Serial.println("Waiting for USR_SW1 press to begin...");
      lastmillis = millis();
    }
    delay(10);
  }

  // Initialize network.
  Serial.println("\n\nDHCP IRC Client Example");
  Serial.print("DHCP init: ");
  if (!Ethernet.begin(ourMac)) {
    Serial.println("Failed to configure Ethernet using DHCP.  Halting.");
    while(1)
      delay(1000);
  }
  Serial.print("done; IP=");
  ip = Ethernet.localIP();
  ip.printTo(Serial);
  Serial.println("\n");
}

volatile boolean is_connected = false;
volatile int prot_stage = 0;  // State machine status.
volatile boolean prot_stage_latched = false;
/* ^ Determines if the current event stage has been carried out, in which
 * case we're waiting for some reply or some other event to proceed to
 * the next event stage.
 */

// IRC protocol event stages
#define PROT_STAGE_WAITINIT 0
#define PROT_STAGE_NICK 1
#define PROT_STAGE_USER 2
#define PROT_STAGE_JOIN 3
#define PROT_STAGE_SAYHELLO 4
#define PROT_STAGE_QUIT 5
#define PROT_STAGE_DONE 6

void loop()
{
  uint8_t buf[2049];
  int len;

  // Main loop
  if (!is_connected || !client.connected()) {
    Serial.print("Connecting to: ");
    Serial.println(ircserver_name);
#ifdef IRC_USE_IP_NOT_DNS
    if (client.connect(ircserver, IRCSERVER_PORT)) {
#else
    if (client.connect(ircserver_name, IRCSERVER_PORT)) {
#endif
      Serial.println("connected\n");
      is_connected = true;
      prot_stage = PROT_STAGE_WAITINIT;  /* Connected; wait for server to send some welcome data
                                          * before logging in & registering nickname, etc.
                                          */
    } else {
      is_connected = false;
      Serial.println("Failed; pausing 5 seconds before retrying");
      delay(5000);
    }
  } else {
    // Process incoming data first
    if (client.available()) {
      if ((len = client.read(buf, 2048)) > 0) {
        buf[len] = '\0';
        Serial.print("Inbound msg: ");
        Serial.write(buf, len);
        Serial.println();
        dispatch_composite_message(buf, len);
        // TODO: Use a ring-buffer with this code as the producer and
        //   dispatch_composite_message as the consumer.
      }
    }

    // Check protocol event stage and perform outbound messages
    switch (prot_stage) {
      case PROT_STAGE_NICK:
        if (!prot_stage_latched) {
          Serial.println("Registering NICK-\n");
          // Compose NICK command
          client.print("NICK ");
          client.print(irc_nick);
          client.print("\r\n");
          prot_stage++;  // No reply needed to advance to next step
        }
        break;

      case PROT_STAGE_USER:
        if (!prot_stage_latched) {
          Serial.println("Registering USER-\n");
          client.print("USER ");
          client.print(irc_nick);
          client.print(" ");
          client.print(irc_user);
          client.print(" ");
          client.print(ircserver_name);
          client.print(" :");
          client.print(irc_user_description);
          client.print("\r\n");
          prot_stage_latched = true;
          // Must wait for RPY_ENDOFMOTD before proceeding.
          // This is found & processed in process_inbound_message() below.
        }
        break;

      case PROT_STAGE_JOIN:
        if (!prot_stage_latched) {
          Serial.print("Joining "); Serial.print(irc_channel); Serial.println("-");
          client.print("JOIN ");
          client.print(irc_channel);
          client.print("\r\n");
          prot_stage_latched = true;
          // Must wait for RPY_TOPIC before proceeding.
          // This is found & processed in process_inbound_message() below.
        }
        break;

      case PROT_STAGE_SAYHELLO:
        if (!prot_stage_latched) {
          Serial.print("Writing to "); Serial.print(irc_channel); Serial.println("-");
          client.print("PRIVMSG ");
          client.print(irc_channel);
          client.print(" :");
          client.println("Hi everyone!  I am a TI TM4C129 LaunchPad connecting to IRC and sending you a brief message.");
          prot_stage++;  // No reply needed to proceed with the next step
        }
        break;

      case PROT_STAGE_QUIT:
        if (!prot_stage_latched) {
          Serial.println("Issuing QUIT-\n");
          client.print("QUIT :Bye for now!\r\n");
          prot_stage++;
        }
        break;

      case PROT_STAGE_DONE:
        Serial.println("Done.");
        // IRC server should close connection; we don't bother doing it ourselves here.
        while (1)
          delay(1000);
        break;
    }  /* switch(prot_stage) */
  }  /* if (is_connected) */
} /* loop() */

/* Process a packet into a sequence of \r\n-terminated lines; Note this should be replaced
 * with a ring-buffer design, as data which flows across multiple packets will not be
 * processed correctly; the last request will be truncated and the beginning of the next
 * request will be handled improperly.
 */
void dispatch_composite_message(uint8_t *buf, int len)
{
  uint8_t *bufptr = buf;
  uint8_t *nl = (uint8_t *)strstr((char *)bufptr, "\r\n");
  int sublen = 0;

  while (nl != NULL) {
    sublen = (int) (nl - bufptr);
    process_inbound_message(bufptr, sublen);
    bufptr += sublen + 2;
    if ( (bufptr - buf) >= len )
      return;

    nl = (uint8_t *)strstr((char *)bufptr, "\r\n");
  }
}

/* Process individual line. */
void process_inbound_message(uint8_t *buf, int sublen)
{
  uint8_t *arg1, *arg2;
  int len;

  // Process inbound message
  buf[sublen] = '\0';

  arg1 = (uint8_t *)strstr((char *)buf, " ");
  if (arg1 == NULL)
    return;
  *arg1 = '\0';
  arg1++;
  int i=0;
  while (arg1[i] != ' ' && arg1[i] != '\0')
    i++;
  arg1[i] = '\0';
  if ( (arg1 + i - buf) >= sublen )
    arg2 = NULL;
  else
    arg2 = arg1 + i + 1;

  Serial.print("Reply ARG: "); Serial.println((char *)arg1);

  // WAITINIT waits for any sort of reply from the IRC server indicating it has connected
  if (prot_stage == PROT_STAGE_WAITINIT) {
    prot_stage++;
    prot_stage_latched = false;
    return;
  }

  // Perform PING reply
  if (!strcmp((char *)buf, "PING")) {
    Serial.print("Received PING "); Serial.print((char *)arg1); Serial.println("; sending PONG");
    client.print("PONG ");
    if (arg1[0] == ':')
      client.print((char *)(arg1+1));
    else
      client.print((char *)arg1);
    client.print("\r\n");
  }

  // RPY_ENDOFMOTD to advance past USER
  if (prot_stage == PROT_STAGE_USER && !strcmp((char *)arg1, "376")) {
    prot_stage++;
    prot_stage_latched = false;
  }

  // RPY_TOPIC to advance past JOIN
  if (prot_stage == PROT_STAGE_JOIN && !strcmp((char *)arg1, "332")) {
    prot_stage++;
    prot_stage_latched = false;
  }

  // TODO: Add more stuff!  Process more replies.
}

error: pathspec 'hardware/lm4f/libraries/Ethernet/examples/IrcClientExample/IrcClientExample.ino' did not match any file(s) known to git


FINISHED IK

FINISHED IK

// code for BoilerMake 2015
// Steven Macenski
// making a 2D write plotter using arduino
// standard 2 link robotics conventions apply and use forward and inverse kinematic solutions to the classical problem
#include <math.h>
#include <Servo.h>

double l1 = 25; //cm
double l2 = 14; //cm

double theta1 = 34;
double theta2 = 128;

double x = -14;
double y = -0;

Servo link1;
Servo link2;

void setup() {
  Serial.begin(9600);
  link1.attach(9);
  link2.attach(10);
}

void loop() {

  //reading in values from serial
    while (Serial.available())  {
      x = -Serial.parsefloat();
      y = -Serial.parsefloat();
    }

    // inverse kinematics
 theta2 = atan2(-sqrt(1-((x*x + y*y - l1*l1 - l2*l2)/(2*l1*l2))), (x*x + y*y - l1*l1 - l2*l2)/(2*l1*l2));
 theta1 = atan2(y,x) - atan2(l2*sin(theta2), l1 + l2*cos(theta2));

//converting to degrees for writing
theta2 = theta2*(57296/1000);
theta1 = theta1*(57296/1000);

theta2 = (int)theta2;
theta1 = (int)theta1;

if (theta1 < 0 && theta1 >-180){
  theta1 = theta1 + 180;
}
if (theta1 < -180 && theta1 > -270) {
  theta1 = theta1 + 270;
}
if (theta1 < -270 && theta1 > -360) {
  theta1 = theta1 + 360;
}

if (theta2 < 0 && theta2 >-180){
  theta2 = theta2 + 180;
}
if (theta2 < -180 && theta2 > -270) {
  theta2 = theta2 + 270;
}
if (theta2 < -270 && theta2 > -360) {
  theta2 = theta2 + 360;
}
Serial.print(theta1);Serial.print(' ');Serial.println(theta2);

//writing to links
link1.write(theta1);
link2.write(theta2);

}

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