add test2 for the DIJN series

add test2 for the DIJN series

/// @dir test2
/// Very simple demo sketch to transmit LDR light readings once a second
// 2013-02-16 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <JeeLib.h>

#define LDR 0 // the LDR will be connected to AIO1, i.e. analog 0

void setup () {
  // this is node 1 in net group 100 on the 868 MHz band
  rf12_initialize(1, RF12_868MHZ, 100);

  // need to enable the pull-up to get a voltage drop over the LDR
  pinMode(14+LDR, INPUT_PULLUP);
}

void loop () {
  // measure analog value and convert the 0..1023 result to 255..0
  byte value = 255 - analogRead(LDR) / 4;

  // actual packet send: broadcast to all, current counter, 1 byte long
  rf12_sendNow(0, &value, 1);

  // let one second pass before sending out another packet
  delay(1000);
}

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


Create Slave-Board.ino

Create Slave-Board.ino

String version = "0.1.3";
/*

 >      FIRMWARE ONLY FOR AN ARDUINO NANO !!    <
 > IF YOU USE ANOTHER ARDUINO, ADAPT THE PINOUT <

 ###################################################
  ______  ______     _     _ ______  _____ _______
 (____  \(____  \   | |   | |  ___ \(_____|_______)
  ____)  )____)  )__| |   | | |   | | | | | |
 |  __  (|  __  (___) |   | | |   | | | | | |
 | |__)  ) |__)  )  | |___| | |   | |_| |_| |_____
 |______/|______/    \______|_|   |_(_____)\______)
    A open source project for create you own BB-8!
 ###################################################

 https://github.com/Gruniek/BB-UNIT
 Made by Daniel M/Gruniek/MOUS

 Compatible only with an Arduino Nano and the specific PCB.
 PCB Link : https://github.com/Gruniek/BB-UNIT/tree/master/Head/Stabiliser/PCB

 --------------
 - Change log -
 --------------

 11/2016
 =========
 - FIX alls bug foe stabilisation
 - ADD BOOT, STAT, ROTATE command
 - ADD Z motor configuration and production
 - ADD BOOT mode, for initilize or reinizialize the Droid position

 10/2016
 ==========
 - Add PID for X and Y

 To do list
 ==========
 - Add Z rotation controller
 - Add Rx/Tx from the motherboard for change de coordinate of the head,
  rotate the head and report to the remote the status off all sensors/positiom.

  Big thanks for http://r2builders.fr/ !
  Initial project : http://r2builders.fr/forum/viewtopic.php?f=26&t=3928&hilit=BB8+par+MOUS

  ===============
  EXEMPLE COMMAND
  ===============
  < SET >
  'SET x87 y75 h3 \n'        // SET a new setpoint for x and y with 3degree of Hysteressis
  'SET x90 y90 i1 j0 k1 \n'  // SET an inversion of the sensor X Y and invert the direction of X

  	x = SETPOINT for X
	y = SETPOINT for Y
	m = MULTIPLIER FOR THE SPEED OF THE MOTOR X and Y
	i = INVERT the angle sensor ( X = Y and Y = X )
	j = INVERT the direction of X
	k = INVERT the direction of Y
	h = SET a new HYSTERESSIS

  < BOOT >
  'BOOT \n'  // LAUNCH TEST for X, Y and Z -> Return X and Y to initial SETPOINT (x90 y90 ) and Z to ZERO

  < RUN >
  'RUN \n'   // RUN the code in production mode (Recieved all data, X and Y runing for the SETPOINT poistion and Z folow the remote controll

  < STOP >
  'STOP \n'  // STOP the production mode. All motors are stopped.

  < ROTATE >
  'ROTATE d1 s100 \n'   // ROTATE Z motor on the RIGHT DIRECTION (d0 LEFT, d1 RIGHT) WITH the SPEED at 1000/100 = 10 step/sec = 18dec/sec

  < STAT >
  // It is all data SENDED to the MASTER-BOARD

*/

#include "Wire.h"
#include "MPU6050.h"

// MOTOR CONFIGURATION // YOU CAN TOUCH THIS

#define pinEnable        4      // Activation off all stepper

#define pinStepX         3      // PIN STEP FOR X
#define pinDirX          2      // PIN DIRECTION FOR X

#define pinStepY         6      // PIN STEP FOR Y
#define pinDirY          5      // PIN DIRECTION FOR Y

#define pinStepZ         8      // PIN STEP FOR Y
#define pinDirZ          7      // PIN DIRECTION FOR Y

#define Z_POSITION       9      // PIN FOR THE DIGITAL INPUT FOR THE HEAD POSITION

bool    invertX        = false; // INVERT THE X MOTOR DIRECTION
bool    invertY        = true;  // INVERT THE Y MOTOR DIRECTION
bool    invertXY       = false; // INVERT X Y AXIAL

int     minX           = 45;    // SET THE MIN INCLINAISON FOR X
int     maxX           = 135;   // SET THE MAX INCLINAISON FOR X
int     minY           = 45;    // SET THE MIN INCLINAISON FOR Y
int     maxY           = 135;   // SET THE MAX INCLINAISON FOR Y

int     etalonX        = 0;     // AJUSTEMENT FOR X
int     etalonY        = -6;    // AJUSTEMENT FOR Y

int     hysteresis     = 1;     // HYSTERESSIS FOR THE ANGLE CALCULATION

//=====================//
// NOW YOU CAN'T TOUCH //
//=====================//

// MPU6050
MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

// I2C
int adress         = 2;
int PING           = 13; // PIN
int PING_MASTER    = 12;
// VARIABLE
int x              = 0;
int y              = 0;
int vx             = 0;
int vy             = 0;

int speedX         = 0;
int speedY         = 0;
int speedZ         = 0;
int setpointX      = 90;
int setpointY      = 90;

int Zangle         = 0;

int multiplier     = 15;
int emergencyStop  = 11; // PIN
int eStop          = 12; // PIN
bool emgStop       = false;

bool runX          = false;
bool runY          = false;
bool runZ          = false;
bool directX       = false; // false = Gauche / true = droite
bool directY       = false; // false = Gauche / true = droite
bool directZ       = false; // false = Gauche / true = droite

bool xok           = false;
bool yok           = false;
bool zok           = false;

// PID
unsigned long previousMillisX = 0;
unsigned long previousMillisY = 0;
unsigned long previousMillisZ = 0;

long                    intX  = 0;
long                    intY  = 0;

unsigned long trigGyro = 100;
unsigned long trigSec  = 1000;
unsigned long trigG    = 0;
unsigned long trigS    = 0;

bool production = false;
bool LED_PING   = false;
bool BOOT = false;

bool ifPing    = false;
int tmpPing    = 0;
int tmpPing2   = 0;
int pingMaster = 0;

//=============================================================================//
//   SETUP
//=============================================================================//
void setup()
{
    pinMode( pinEnable   , OUTPUT );
    pinMode( pinDirX     , OUTPUT );
    pinMode( pinStepX    , OUTPUT );
    pinMode( pinDirY     , OUTPUT );
    pinMode( pinStepY    , OUTPUT );
    pinMode( PING        , OUTPUT );
    pinMode( PING_MASTER , INPUT  );
    pinMode( Z_POSITION  , INPUT  );

    Serial.begin(9600);

    Serial.println(" ");
    Serial.println("#######################################");
    Serial.println("#         Astromech Industrie         #");
    Serial.println("#                BB-UNIT              #");
    Serial.println("# https://github.com/Gruniek/BB-UNIT/ #");
    Serial.println("#######################################");
    Serial.println(" ");
    Serial.print("  BB-8 Version ");
    Serial.println(version);
    Serial.println("===================");
    Serial.println(" ");

    Serial.print("Initializing I2C devices...  I2C ADRESS :");
    Serial.print(adress);
    Wire.begin(adress);

    accelgyro.initialize();
    Serial.print("Connect to the MPU6050 : ");

    Serial.println(accelgyro.testConnection() ? "Connection successful" : "Connection failed");

    Serial.println("Booting successful !");
    Serial.println("====================");

}

//=============================================================================//
//   LOOP
//=============================================================================//
void loop()
{
    // GET MOTION
    //-------------------------------------------------------------------------//
    unsigned long currentG = millis(); // millis();

    if (currentG - trigG  >= trigGyro)
    {
    	trigG = currentG;

    	accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
		if(invertXY)
		{
			y = (((ax/180)+etalonX)+90);
  			x = (((ay/180)+etalonY)+90);
		}
		else
		{
			x = (((ax/180)+etalonX)+90);
  			y = (((ay/180)+etalonY)+90);
		}
    }

    // GET SERIAL DATA
    //-------------------------------------------------------------------------//

    char msg[30];
    if (Serial.available() > 0)
    {
    	Serial.readBytesUntil('\n', msg, sizeof msg);

    	if (strcmp(strtok(msg, " "), "SET") == 0)
    	{
        	Serial.println("UPDATE SETPOINT");
      		// trouvé le message
      		char *p;
      		while ((p = strtok(NULL, " ")) != NULL)
      		{
        		int val = atoi(p + 1);
        		switch (*p)
        		{
          			case 'x': setpointX  = val; break;
          			case 'y': setpointY  = val; break;
      	  			case 'm': multiplier = val; break;
      				case 'i': invertXY   = val; break;
      				case 'j': invertX    = val; break;
      				case 'k': invertX    = val; break;
      				case 'h': hysteresis = val; break;
        		}
      		}
    	}

    	if (strcmp(strtok(msg, " "), "RUN") == 0)
    	{
        	Serial.println("ROll BB-8 ROLL !");
      	    production = true;
      	    emgStop = false;
    	}

    	if (strcmp(strtok(msg, " "), "STOP") == 0)
    	{
    		Serial.println("STOP");
    	    production = false;
    	}

    	if (strcmp(strtok(msg, " "), "RESET") == 0)
    	{
    		Serial.println("RESET");
    	    production = false;
    	}

    	if (strcmp(strtok(msg, " "), "BOOT") == 0)
    	{

    	    BOOT = true;
    	    Serial.println("BOOTING UP...");
    	    delay(2000);
    	}

    	if (strcmp(strtok(msg, " "), "ROTATE") == 0) // ROTATE d1 s100  <-- Rotate Z right, 18c/sec
    	{
      		// trouvé le message
      		char *p;
      		while ((p = strtok(NULL, " ")) != NULL)
      		{
        		int val = atoi(p + 1);
        		switch (*p)
        		{
          			case 'd': directZ  = val; break;
          			case 's': speedZ   = val; break;
        		}
      		}
    	}

  }

   if(BOOT)
   {
   	    // SET X IN POSITION
   		if(x < 90) directX = false;
  		else directX = true;

  		if(invertX)
  		{
    		if(directX) directX = false;
    		else directX = true;
  		}
  		digitalWrite(pinDirX, directX); // dirX

  		if(x > (setpointX + hysteresis) || (x < setpointX - hysteresis ))
  		{
  	        digitalWrite(pinStepX, 1);
        	delayMicroseconds( 500 );
    	    digitalWrite(pinStepX, 0);
    	    delayMicroseconds( 500 );
  		}
  		else
  		{
  			if(!xok)
  			{
  				Serial.println("BOOT x1 ");
  				xok = true;
  				delay(2000);
  			}
  		}

  		// SET Y IN POSITION
   		if(y < 90) directY = false;
  		else directY = true;

  		if(invertY)
  		{
    		if(directY) directY = false;
    		else directY = true;
  		}
  		digitalWrite(pinDirY, directY); // dirX

  		if(x > (setpointY + hysteresis) || (y < setpointY - hysteresis ))
  		{
  	        digitalWrite(pinStepY, 1);
        	delayMicroseconds( 500 );
    	    digitalWrite(pinStepY, 0);
    	    delayMicroseconds( 500 );
  		}
  		else
  		{
  			if(!yok)
  			{
  				Serial.println("BOOT y1 ");
  				yok = true;
  				delay(2000);
  			}
  		}

  		// SET Z IN POSITION

  		if(!Z_POSITION)
  		{
  		  	digitalWrite(pinStepZ, 1);
        	delayMicroseconds( 500 );
    	    digitalWrite(pinStepZ, 0);
    	    delayMicroseconds( 500 );
  		}
  		else
  		{
  		  	if(!zok)
  			{
  				Serial.println("BOOT z1 ");
  				zok = true;
  				Zangle = 0;
  				delay(2000);
  			}
  		}

  		if( xok && yok && zok)
  		{
			Serial.println("STAT b1 ");
  			Serial.println("Booting UP OK!");
  			Serial.println("SEND 'RUN \n' for start the production");
  			BOOT = false;
  		}

   }

	// PRODUCTION CODE
    //-------------------------------------------------------------------------//
    if(production && !emgStop)  //-
    {

  		// X //

		// Direction
  		if(x < 90) directX = false;
  		else directX = true;

  		if(invertX)
  		{
    		if(directX) directX = false;
    		else directX = true;
  		}
  		digitalWrite(pinDirX, directX); // dirX

  		// Si ont doit demarer le moteur
  		if(x > (setpointX + hysteresis) || (x < setpointX - hysteresis ))
  		{
    		if(x > minX && x < maxX) runX = true;
    		else runX = false;
  		}
  		else runX = false;

  		// Calcul du PID X
  		if(x < 90) vx = (90 - x);
  		if(x == 0) vx = 0;
  		if(x > 90) vx = (x - 90);

  		speedX = 1000 / (vx);
  		speedX = speedX * multiplier; // DEL
  		if(speedX < 15) speedX = 15;

		// Mise en route du moteur
  		unsigned long currentX = millis();

    	if (currentX - previousMillisX >= speedX)
    	{
      		previousMillisX = currentX;

      		if(runX)
      		{
        		digitalWrite(pinStepX, 1);
        		delayMicroseconds( 500 );
        		digitalWrite(pinStepX, 0);
    	 		delayMicroseconds( 500 );
      		}
  		}

  		// Y //
  		// Direction
  		if(y < 90) directY = false;
  		else directY = true;
  		if(invertY)
  		{
    		if(directY) directY = false;
    		else directY = true;
  		}
  		digitalWrite(pinDirY, directY);

		// Si ont doit demarer le moteur
  		if(y > (setpointY + hysteresis) || (y < setpointY - hysteresis ))
  		{
    		if(y > minY && y < maxY) runY = true;
    		else runY = false;
  		}
  		else runY = false;

  		// Calcul du PID Y
  		if(y < 90) vy = (90 - y);
  		if(y == 0) vy = 0;
  		if(y > 90) vy = (y - 90);

  		speedY = 1000 / (vy);
  		speedY = speedY * multiplier; // DEL
  		if(speedY < 15) speedY = 15;

  		// Mise en route du moteur
  		unsigned long currentY = millis(); // millis();

    	if (currentY - previousMillisY >= speedY)
    	{
      		previousMillisY = currentY;

      		if(runY)
      		{
        		digitalWrite(pinStepY, 1);
        		delayMicroseconds( 500 );
        		digitalWrite(pinStepY, 0);
        		delayMicroseconds( 500 );
      		}
  		}

  		//--- Z
  		if(speedZ != 0)
  		{
  			unsigned long currentZ = millis();
  			if (currentZ - previousMillisZ >= speedZ)
    		{
      			previousMillisZ = currentZ;

    	 		digitalWrite(pinStepY, 1);
    	    	delayMicroseconds( 500 );
    	    	digitalWrite(pinStepY, 0);
    	    	delayMicroseconds( 500 );
    	    	if(directZ) Zangle++;
    	    	else Zangle--;
  			}
  		}
  		if(Zangle == 201) Zangle = 0;
  		if(Zangle == -1)  Zangle = 0;

  } //-

  // Check if the Master-Board are ALIVE

  if(digitalRead(PING_MASTER) && !ifPing)
  {
  	ifPing = true;
  	pingMaster++;
  }

  if(digitalRead(PING_MASTER) && ifPing) ifPing = false;

  	// SEND SERIAL DATA
    //-------------------------------------------------------------------------//
    unsigned long currentS = millis(); // millis();

    if (currentS - trigS  >= trigSec)
    {
    	trigS = currentS;

    	// PING
    	if(LED_PING) LED_PING = false;
    	else LED_PING = true;
    	digitalWrite(PING, LED_PING);

    	tmpPing2++;

    	if(pingMaster > tmpPing)
    	{
    		tmpPing = pingMaster;
    		tmpPing2 = 0;
    	}
    	if(tmpPing2 > 3) emgStop = true;

    	if(!accelgyro.testConnection());
    	{
    		production = false;
    		emgStop = true;
    		accelgyro.initialize();
    		if(accelgyro.testConnection())
    		{
    			production = true;
    		}
    	}

    	// SEND STATUT
    	Serial.print("STAT x");
    	Serial.print(x);
    	Serial.print(" y");
    	Serial.print(y);
    	Serial.print(" i");
    	Serial.print(invertXY);
    	Serial.print(" j");
    	Serial.print(invertX);
    	Serial.print(" k");
    	Serial.print(invertY);
    	Serial.print(" m");
    	Serial.print(multiplier);
    	Serial.print(" z");
    	Serial.print(Zangle);

    	Serial.println(" ");

    }
}

error: pathspec 'Firmware/Ball/Slave-Board/Slave-Board.ino' did not match any file(s) known to git


[Untested] Added outer wheel speed modifier

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


Create cpu.ino

Create cpu.ino

// A Cpu meter, Copyright Ioan Loosley

int meter  = 11;   // blue LED in Digital Pin 9 (PWM)
int old = 0;
int failcount = 1000;
void setup(){
  Serial.begin(9600);
  pinMode(meter,OUTPUT);  // tell arduino it's an output
  // test and set all the outputs to low
  digitalWrite(meter,LOW);
  Serial.setTimeout(300);
  for(int x = 255;x =< 0;x--){analogWrite(meter,x);delay(100); }
}

void loop(){
  int msg;

  msg = Serial.read();

  int x = int(msg);
  if(x == -1){
    return;
    }

  analogWrite(meter,x);old=x;Serial.println(x,HEX);
}

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


add serial io driving script

add serial io driving script

// Wheel encoder
const byte interrupt1Pin = 2;
int interrupt1Count = 0;
int previousInterrupt1Count = 0;

const byte interrupt2Pin = 3;
int interrupt2Count = 0;
int previousInterrupt2Count = 0;

int previousMillis1 = 0;
int previousMillis2 = 0;

const int stepsPerRevelation = 20;
const int distanceInMMPerRevelation = 220;

// Motor
const uint8_t motorPin1_1 = A3;
const uint8_t motorPin1_2 = A2;
const uint8_t motorEnablePin1 = 5;
bool motorDirectionIsForward1 = true;

const uint8_t motorPin2_1 = A5;
const uint8_t motorPin2_2 = A4;
const uint8_t motorEnablePin2 = 6;
bool motorDirectionIsForward2 = true;

void setup() {
    //Wheel encoder
    pinMode(interrupt1Pin, INPUT);
    pinMode(interrupt2Pin, INPUT);
    attachInterrupt(digitalPinToInterrupt(interrupt1Pin), EncoderRotationCount1, RISING);
    attachInterrupt(digitalPinToInterrupt(interrupt2Pin), EncoderRotationCount2, RISING);

    // Motor
    pinMode(motorPin1_1, OUTPUT);
    pinMode(motorPin1_2, OUTPUT);

    pinMode(motorPin2_1, OUTPUT);
    pinMode(motorPin2_2, OUTPUT);

    Serial.begin(230400);
}

void SendWheelData()
{
    Serial.print("Wheel");
    Serial.print("|");
    Serial.print(millis());
    Serial.print("|");
    SendSerialDataHelper(1);
    Serial.print("|");
    SendSerialDataHelper(2);
    Serial.println("");
}

void SendSerialDataHelper(int id)
{
    int interruptCount = 0;
    int interruptCountDelta = 0;
    int timeDelta = 0;
    if(id == 1)
    {
        interruptCountDelta = interrupt1Count - previousInterrupt1Count;
        timeDelta = millis() - previousMillis1;
        previousMillis1 = millis();
        interruptCount = interrupt1Count;
        previousInterrupt1Count = interrupt1Count;
    }
    if(id == 2)
    {
        interruptCountDelta = interrupt2Count - previousInterrupt2Count;
        timeDelta = millis() - previousMillis2;
        previousMillis2 = millis();
        interruptCount = interrupt2Count;
        previousInterrupt2Count = interrupt2Count;
    }

    Serial.print(id);
    Serial.print("|");
    Serial.print(timeDelta);
    Serial.print("|");
    Serial.print(interruptCount);
    Serial.print("|");
    Serial.print(interruptCountDelta);
}

void EncoderRotationCount1() {
    if(motorDirectionIsForward1)
    {
        interrupt1Count++;
    }
    else
    {
        interrupt1Count--;
    }
}

void EncoderRotationCount2() {
    if(motorDirectionIsForward2)
    {
        interrupt2Count++;
    }
    else
    {
        interrupt2Count--;
    }
}

void SetMotor(int id, int speed)
{
    if(id == 1)
    {
        motorDirectionIsForward1 = (speed >= 0);
        SetMotorWorker(motorPin1_1, motorPin1_2, motorEnablePin1, speed);
    }

    if(id == 2)
    {
        motorDirectionIsForward2 = (speed >= 0);
        SetMotorWorker(motorPin2_1, motorPin2_2, motorEnablePin2, speed);
    }
}

void SetMotorWorker(int pin1, int pin2, int enablePin, int speed)
{
    analogWrite(enablePin, abs(speed));

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

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

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

void loop() {
    SendWheelData()

    delay(200);
}

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


Create loopFunctions.ino

Create loopFunctions.ino

SENS readSensors() {
  SENS temp;

  temp.pressure = 3024;
  temp.temp = 18.3;
  temp.volt = 10.8;
  temp.gyr.ax = 0;
  temp.gyr.ay = 0;
  temp.gyr.az = 0;
  temp.gyr.compass = 0;

  temp = mpuLoop(temp); // read orientation

  return  temp;
}

ACT communicate(SENS sens) {
  ACT temp;
  if (Serial.available() > 0) {
    //Receive data
    String incoming = Serial.readString();

    // Send data back
    String sending = createString(sens);
    Serial.println(sending);
  }

  return  temp;
}

ACT communicateProto(SENS sens) {
  ACT temp;
  if (Serial.available() > 0) {
    //Receive data
    String incoming = Serial.readString();
  }

  // Send data back
  String sendString = createString(sens);
  Serial.println(sendString);

  return  temp;
}

String createString(SENS sens) {
  String str = "SENSORS,";
  str += "press:";
  str += sens.pressure;
  str += ",temp:";
  str += sens.temp;
  str += ",volt:";
  str += sens.volt;
  str += ",roll:";
  str += sens.gyr.roll;
  str += ",yaw:";
  str += sens.gyr.yaw;
  str += ",pitch:";
  str += sens.gyr.pitch;
  str += ",ax:";
  str += sens.gyr.ax;
  str += ",ay:";
  str += sens.gyr.ay;
  str += ",az:";
  str += sens.gyr.az;
  str += ",compass:";
  str += sens.gyr.compass;

  return str;
}

void moveActuator(ACT act) {

}

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


finished with switch case break

finished with switch case break

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


The most basic of them all with a ton of copy/paste

/*
"What hath God wrought" in morse code
A · —
D — · ·
G — — ·
H · · · ·
O . space .
R · space · ·
T —
U · · —
W · — —
*/

// defining ledPin on pin no.13
const int ledPin = 13;

// Duration of blinks and pauses
int dah = 300;
int dit = 70;
int space = 50;
int letterSpace = 100;
int wordSpace = 600;

// setting pin 13 as output
void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {

// Word WHAT ---------------------------------------------------------------

  // letter "W" = .--
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  // letter space
  delay(letterSpace);

  // letter H = ....
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  // letter space
  delay(letterSpace);

 // letter A = .-
    digitalWrite(ledPin, HIGH);
    delay(dit);
    digitalWrite(ledPin, LOW);
    delay(space);

    digitalWrite(ledPin, HIGH);
    delay(dah);
    digitalWrite(ledPin, LOW);
    delay(space);

  // letter space
  delay(letterSpace);

  // letter T = -
  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  // word HATH --------------------------------------------------------------
  delay(wordSpace);

  // letter H = ....
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  // letter space
  delay(letterSpace);

  // letter A = .-
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  // letter space
  delay(letterSpace);

  // letter T = -
  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  // letter space
  delay(letterSpace);

  // letter H = ....
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  // word GOD --------------------------------------------------------------
  delay(wordSpace);

  // letter G = --.
  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

// letter space
  delay(letterSpace);

  // letter O = . .
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

// letter space
  delay(letterSpace);

  // letter D = -..
  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  // word WROUGHT --------------------------------------------------------------
  delay(wordSpace);

  // letter "W" = .--
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  // letter space
  delay(letterSpace);

  // letter R = . ..
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

// letter space
  delay(letterSpace);

  // letter O = . .
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

// letter space
  delay(letterSpace);

  // letter U = ..-
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

// letter space
  delay(letterSpace);

  // letter G = --.
  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

// letter space
  delay(letterSpace);

  // letter H = ....
  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

  digitalWrite(ledPin, HIGH);
  delay(dit);
  digitalWrite(ledPin, LOW);
  delay(space);

// letter space
  delay(letterSpace);

  // letter T = -
  digitalWrite(ledPin, HIGH);
  delay(dah);
  digitalWrite(ledPin, LOW);
  delay(space);

// pause before repeat
delay(wordSpace);
delay(wordSpace);
delay(wordSpace);

  }

error: pathspec 'people/twobeers83/Week4/Arduino/MorseBasic/TZ_Assignment4Basic/TZ_Assignment4Basic.ino' did not match any file(s) known to git


added

added

void setup() {

    // Setup computer to Teensy serial
    Serial.begin(115200);

    delay(5000);

    // Setup Teensy to ESP8266 serial
    Serial1.begin(115200);

}

void loop() {

    // Send bytes from ESP8266 -> Teensy to Computer
    if ( Serial1.available() ) {
        Serial.write( Serial1.read() );
    }

    // Send bytes from Computer -> Teensy back to ESP8266
    if ( Serial.available() ) {
        Serial1.write( Serial.read() );
    }

}

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


Adds WebFileBrowserExample

Adds WebFileBrowserExample

Change-Id: I4fcc621777095138bb481a1821fb9c8740192c36
GitOrigin-RevId: f5d9b5c77c8ff4d828a367ca6e5aa3135c7a4456

/*
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <coralmicro_SD.h>

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <memory>
#include <vector>

#include "Arduino.h"
#include "libs/base/filesystem.h"
#include "libs/base/http_server.h"
#include "libs/base/led.h"
#include "libs/base/strings.h"
#include "libs/base/utils.h"
#include "third_party/freertos_kernel/include/FreeRTOS.h"
#include "third_party/freertos_kernel/include/task.h"

// Hosts an HTTP server on the Dev Board Micro, allowing connected clients
// to browse files with a web browser, and push/pull files to the board with
// curl commands.
using namespace coralmicro;
namespace {
constexpr char kUrlPrefix[] = "/fs/";

void RemoveDuplicateChar(std::string& s, char ch) {
  s.erase(std::unique(s.begin(), s.end(),
                      [ch](char a, char b) { return a == ch && b == ch; }),
          s.end());
}

std::string GetPath(const char* uri) {
  static constexpr char kIndexShtml[] = "index.shtml";
  std::string path(uri);
  RemoveDuplicateChar(path, '/');

  if (StrEndsWith(path, kIndexShtml))
    return path.substr(0, path.size() - StrLen(kIndexShtml));
  return path;
}

bool DirHtml(SDFile dir, const char* dirname, std::vector<uint8_t>* html) {
  StrAppend(html, "<!DOCTYPE html>\r\n");
  StrAppend(html, "\r\n");
  StrAppend(html, "\r\n");
  StrAppend(html,
            "<meta http-equiv=\"Content-Type\" content=\"text/html; "
            "charset=utf-8\">\r\n");
  StrAppend(html, "<title>Directory listing for %s</title>\r\n", dirname);
  StrAppend(html, "\r\n");
  StrAppend(html, "\r\n");
  StrAppend(html, "
Directory listing for %s
\r\n", dirname);
  StrAppend(html, "
\r\n");
  StrAppend(html, "
\r\n");
  if (!SD.exists(dir.name())) return false;
  while (true) {
    SDFile entry = dir.openNextFile();
    if (!entry) {
      break;
    }
    if (!entry.isDirectory()) {
      StrAppend(html, "
\r\n");
      StrAppend(html, "🗎	\r\n");
      StrAppend(html, "%s	\r\n", kUrlPrefix,
                dirname + 1, entry.name(), entry.name());
      StrAppend(html, "%d	", entry.size());
      StrAppend(html, "
\r\n");
    } else {
      if (std::strcmp(entry.name(), ".") == 0) continue;
      StrAppend(html, "
\r\n");
      StrAppend(html, "📁	\r\n");
      StrAppend(html, "%s/	\r\n", kUrlPrefix,
                dirname + 1, entry.name(), entry.name());
      StrAppend(html, "	\r\n");
      StrAppend(html, "
\r\n");
    }
    entry.close();
  }
  StrAppend(html, "
\r\n");
  StrAppend(html, "
\r\n");
  StrAppend(html, "\r\n");
  StrAppend(html, "\r\n");
  return true;
}

HttpServer::Content UriHandler(const char* uri) {
  if (!StrStartsWith(uri, kUrlPrefix)) return {};
  auto path = GetPath(uri + StrLen(kUrlPrefix) - 1);
  assert(!path.empty() && path.front() == '/');

  Serial.print("GET ");
  Serial.print(uri);
  Serial.print(" => ");
  Serial.println(path.c_str());

  if (SD.exists(path.c_str())) {
    SDFile file = SD.open(path.c_str());
    if (!file.isDirectory()) {
      file.close();
      return path;
    } else {
      // Make sure directory path has '/' at the end.
      if (path.back() != '/') path.push_back('/');

      std::vector<uint8_t> html;
      html.reserve(1024);
      if (!DirHtml(file, path.c_str(), &html)) {
        file.close();
        return {};
      }
      file.close();
      return html;
    }
  }
  return {};
}

class FileHttpServer : public HttpServer {
 public:
  err_t PostBegin(void* connection, const char* uri, const char* http_request,
                  u16_t http_request_len, int content_len, char* response_uri,
                  u16_t response_uri_len, u8_t* post_auto_wnd) override {
    (void)http_request;
    (void)http_request_len;
    (void)response_uri;
    (void)response_uri_len;
    (void)post_auto_wnd;

    if (!StrStartsWith(uri, kUrlPrefix)) return ERR_ARG;
    auto path = GetPath(uri + StrLen(kUrlPrefix) - 1);
    assert(!path.empty() && path.front() == '/');

    if (path.back() == '/') return ERR_ARG;
    assert(path.size() > 1);

    Serial.print("POST ");
    Serial.print(uri);
    Serial.print(" (");
    Serial.print(content_len);
    Serial.print(" bytes) => ");
    Serial.println(path.c_str());

    auto dirname = LfsDirname(path.c_str());
    if (!SD.mkdir(dirname.c_str())) return ERR_ARG;

    SD.remove(path.c_str());
    SDFile file = SD.open(path.c_str(), FILE_WRITE);
    if (!file) return ERR_ARG;

    files_[connection] = {std::move(file), std::move(dirname)};
    return ERR_OK;
  }

  err_t PostReceiveData(void* connection, struct pbuf* p) override {
    SDFile file = files_[connection].file;
    struct pbuf* cp = p;
    while (cp) {
      if (file.write(reinterpret_cast<uint8_t const*>(cp->payload), cp->len) !=
          cp->len)
        return ERR_ARG;
      cp = p->next;
    }
    pbuf_free(p);
    return ERR_OK;
  }

  void PostFinished(void* connection, char* response_uri,
                    u16_t response_uri_len) override {
    auto& entry = files_[connection];
    entry.file.close();
    snprintf(response_uri, response_uri_len, "%s%s", kUrlPrefix,
             entry.dirname.c_str() + 1);
    files_.erase(connection);
  }

 private:
  struct Entry {
    SDFile file;
    std::string dirname;
  };
  std::map<void*, Entry> files_;  // connection-to-entry map
};

FileHttpServer http_server;
}  // namespace

void setup() {
  Serial.begin(115200);
  // Turn on Status LED to show the board is on.
  pinMode(PIN_LED_STATUS, OUTPUT);
  digitalWrite(PIN_LED_STATUS, HIGH);
  Serial.println("Arduino Web File Browser Example!");

  SD.begin();

  http_server.AddUriHandler(UriHandler);
  UseHttpServer(&http_server);

  std::string ip;
  if (GetUsbIpAddress(&ip)) {
    Serial.print("BROWSE:   http://");
    Serial.print(ip.c_str());
    Serial.println(kUrlPrefix);
    Serial.print("UPLOAD:   curl -X POST http://");
    Serial.print(ip.c_str());
    Serial.print(kUrlPrefix);
    Serial.println("file --data-binary @file");
    Serial.print("DOWNLOAD: curl -O http://");
    Serial.print(ip.c_str());
    Serial.print(kUrlPrefix);
    Serial.println("file");
  }
}

void loop() { delay(1000); }

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


adding cap sensor example

adding cap sensor example

// CapSense.pde
// Paul Badger 2007

// Fun with capacitive sensing and some machine code - for the Arduino (or Wiring Boards).
// Note that the machine code is based on Arduino Board and will probably require some changes for Wiring Board
// This works with a high value (1-10M) resistor between an output pin and an input pin.
// When the output pin changes it changes the state of the input pin in a time constant determined by R * C
// where R is the resistor and C is the capacitance of the pin plus any capacitance present at the sensor.
// It is possible when using this setup to see some variation in capacitance when one's hand is 3 to 4 inches from the sensors
// Try experimenting with larger sensors. Lower values of R will probably yield higher reliability.
// Use 1 M resistor (or less maybe) for absolute touch to activate.
// With a 10 M resistor the sensor will start to respond 1-2 inches away

// Setup
// Connect a 10M resistor between pins 8 and 9 on the Arduino Board
// Connect a small piece of alluminum or copper foil to a short wire and also connect it to pin 9

// When using this in an installation or device it's going to be important to use shielded cable if the wire between the sensor is
// more than a few inches long, or it runs by anything that is not supposed to be sensed.
// Calibration is also probably going to be an issue.
// Instead of "hard wiring" threshold values - store the "non touched" values in a variable on startup - and then compare.
// If your sensed object is many feet from the Arduino Board you're probably going to be better off using the Quantum cap sensors.

// Machine code and Port stuff from a forum post by ARP  http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1169088394/0#0

int  i;
unsigned int x, y;
float accum, fout, fval = .07;    // these are variables for a simple low-pass (smoothing) filter - fval of 1 = no filter - .001 = max filter

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

  DDRB=B101;     // DDR is the pin direction register - governs inputs and outputs- 1's are outputs
  // Arduino pin 8 output, pin 9 input, pin 10 output for "guard pin"
  //  preceding line is equivalent to three lines below
  //  pinMode(8, OUTPUT);     // output pin
  //  pinMode(9, INPUT);      // input pin
  //  pinMode(10, OUTPUT);    // guard pin
  digitalWrite(10, LOW);  //could also be HIGH - don't use this pin for changing output though
}

void loop() {
  y = 0;        // clear out variables
  x = 0;

  for (i=0; i < 4 ; i++ ){       // do it four times to build up an average - not really neccessary but takes out some jitter

    // LOW-to-HIGH transition
    PORTB = PORTB | 1;                    // Same as line below -  shows programmer chops but doesn't really buy any more speed
    // digitalWrite(8, HIGH);
    // output pin is PortB0 (Arduino smiley-cool, sensor pin is PortB1 (Arduinio 9)

    while ((PINB & B10) != B10 ) {        // while the sense pin is not high
      //  while (digitalRead(9) != 1)     // same as above port manipulation above - only 20 times slower!
      x++;
    }
    delay(1);

    //  HIGH-to-LOW transition
    PORTB = PORTB & 0xFE;                // Same as line below - these shows programmer chops but doesn't really buy any more speed
    //digitalWrite(8, LOW);
    while((PINB & B10) != 0 ){            // while pin is not low  -- same as below only 20 times faster
      // while(digitalRead(9) != 0 )      // same as above port manipulation - only 20 times slower!
      y++;
    }

    delay(1);
  }

  fout =  (fval * (float)x) + ((1-fval) * accum);  // Easy smoothing filter "fval" determines amount of new data in fout
  accum = fout;

  Serial.print((long)x, DEC);    // raw data - Low to High
  Serial.print( "   ");
  Serial.print((long)y, DEC);    // raw data - High to Low
  Serial.print( "   ");
  Serial.println( (long)fout, DEC); // Smoothed Low to High
}

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


Create palette_basic_setup.ino

Create palette_basic_setup.ino

//***************************************************************
// Basic palette example using one of FastLED's palettes.
//
// FastLED includes these pre-defined palettes:
//   RainbowColors_p, RainbowStripeColors_p, OceanColors_p,
//   CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p
//
// Marc Miller,  March 2019
//***************************************************************

#include "FastLED.h"
#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
#define COLOR_ORDER GRB
#define BRIGHTNESS 100
CRGB leds[NUM_LEDS];

uint8_t startIndex;
uint8_t colorIndex;

//---------------------------------------------------------------
void setup() {
  Serial.begin(115200);  // Allows serial monitor output (check baud rate)
  delay(1500);  // startup delay
  FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(BRIGHTNESS);
}

//---------------------------------------------------------------
void loop() {
  colorIndex = startIndex;
  for( int i = 0; i < NUM_LEDS; i++) {
    //ColorFromPalette( paletteName, colorIndex[0-255], brightness[0-255], blendType[NOBLEND or LINEARBLEND])
    leds[i] = ColorFromPalette( RainbowColors_p, colorIndex, 255, LINEARBLEND);
    colorIndex = colorIndex + 10;  //how fast to advance through palette
  }

  FastLED.show();
  FastLED.delay(10);
  startIndex = startIndex + 1;  //how fast to move the palette down the strip
}

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


Sharp dust sensor sample code

Sharp dust sensor sample code

#define DUST_PIN 0
int dustVal = 0;

#define LED_POWER 2
int delayTime = 280;
int delayTime2 = 40;
float offTime = 9680;
void setup()
{
	Serial.begin(9600);
	pinMode(LED_POWER, OUTPUT);
	pinMode(4, OUTPUT);
}

void loop()
{
	// ledPower is any digital pin on the arduino connected to Pin 3 on the sensor
	digitalWrite(LED_POWER, LOW); // power on the LED
	delay(delayTime);
	dustVal = analogRead(DUST_PIN); // read the dust value via pin 5 on the sensor
	delay(delayTime2);
	digitalWrite(LED_POWER, HIGH); // turn the LED off
	delay(offTime);

	delay(200);
	Serial.print("Dust value: ");
	Serial.println(dustVal);
}

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


arduino serial

arduino serial

void setup(){
  Serial.begin( 9600 );
  pinMode( 13 , 1 );
}
void loop(){

  if( Serial.available() ){
   char valor = (char) Serial.read();
   if( valor == '0' ){
   		digitalWrite( 2 , 1 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 1 );
   		digitalWrite( 6 , 1 );
                digitalWrite( 7 , 1 );
   		digitalWrite( 8 , 0 );
   }
   if( valor == '1' ){
   		digitalWrite( 2 , 0 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 0 );
   		digitalWrite( 6 , 0 );
                digitalWrite( 7 , 0 );
   		digitalWrite( 8 , 0 );
   }
      if( valor == '2' ){
   		digitalWrite( 2 , 1 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 0 );
                digitalWrite( 5 , 1 );
   		digitalWrite( 6 , 1 );
                digitalWrite( 7 , 0 );
   		digitalWrite( 8 , 1 );
      }
      if( valor == '3' ){
   		digitalWrite( 2 , 1 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 1 );
   		digitalWrite( 6 , 0 );
                digitalWrite( 7 , 0 );
   		digitalWrite( 8 , 1 );
      }
      if( valor == '4' ){
   		digitalWrite( 2 , 0 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 0 );
   		digitalWrite( 6 , 0 );
                digitalWrite( 7 , 1 );
   		digitalWrite( 8 , 1 );
      }
      if( valor == '5' ){
   		digitalWrite( 2 , 1 );
                digitalWrite( 3 , 0 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 1 );
   		digitalWrite( 6 , 0 );
                digitalWrite( 7 , 1 );
   		digitalWrite( 8 , 1 );
      }
      if( valor == '6' ){
   		digitalWrite( 2 , 0 );
                digitalWrite( 3 , 0 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 1 );
   		digitalWrite( 6 , 1 );
                digitalWrite( 7 , 1 );
   		digitalWrite( 8 , 1 );
      }
      if( valor == '7' ){
   		digitalWrite( 2 , 1 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 0 );
   		digitalWrite( 6 , 0 );
                digitalWrite( 7 , 0 );
   		digitalWrite( 8 , 0 );
      }
      if( valor == '8' ){
   		digitalWrite( 2 , 1 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 1 );
   		digitalWrite( 6 , 1 );
                digitalWrite( 7 , 1 );
   		digitalWrite( 8 , 1 );
      }
      if( valor == '9' ){
   		digitalWrite( 2 , 1 );
                digitalWrite( 3 , 1 );
   		digitalWrite( 4 , 1 );
                digitalWrite( 5 , 0 );
   		digitalWrite( 6 , 0 );
                digitalWrite( 7 , 1 );
   		digitalWrite( 8 , 1 );
 }
  }
  }

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


update

update

/*
The MIT License (MIT)

Copyright (c) 2016 Field Science Robotics

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

#include <Arduino.h>
#include <cc430f5137.h>
#include "HardwareSerial.h"
#include "cc430f5137.h"
#include "wiring.h"
#include "Flag.h"
#include "regtable.h"
#include "product.h"
#include "swap.h"

Flag flag;
int pin_map[] = {16, 17, 0, 1, 2, 3, 4, 5, 6, 7};
int pin_map_len = sizeof(pin_map) / sizeof(int);

void setup() {
  WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer

  swap.init();
  swap.getRegister(REGI_PRODUCTCODE)->getData();

  initialise_flags(); //initalise flags

  _BIS_SR(LPM0_bits + GIE); //LPM0_bits
}

void initialise_flags()
{
  for(int i = 0; i < pin_map_len; i++)
  {
    int servo_pin = pin_map[i];
    flag.attach(servo_pin);
    flag.raise(3.0);
  }
}

void loop(){}

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


Removed debug garbage

Removed debug garbage

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


Added RFduino source

Added RFduino source

#include <RFduinoBLE.h>

#define DISCONNECTED 0
#define CONNECTED 1

#define CMD_TOGGLE 'T'

int switchMs = 500;

int GPIO2 = 2;
int _rssi = 0;
int state = DISCONNECTED;

char buffer[256];
int buflen = 0;

bool toggle = false;

void setup()
{
  state = DISCONNECTED;
  buflen = 0;

  // output for Garage switch
  pinMode(GPIO2, OUTPUT);
  digitalWrite(GPIO2, LOW);

  RFduinoBLE.deviceName = "GarageDuino";
  RFduinoBLE.advertisementInterval = 1000;
  RFduinoBLE.txPowerLevel = +4; //limit range

//  Serial.begin(9600);
//  Serial.println("GarageDuino started");

  // start the BLE stack
  RFduinoBLE.begin();
}

void loop()
{
// switch to lower power mode
//  RFduino_ULPDelay(SECONDS(1));
//  Serial.println("Post ULPDelay");

  while(RFduinoBLE.radioActive)
    ;

  if( toggle )
    toggleDoor();
}

void RFduinoBLE_onConnect()
{
  state = CONNECTED;
}

void RFduinoBLE_onDisconnect()
{
  state = DISCONNECTED;
}

void RFduinoBLE_onAdvertisement(bool start)
{
}

void RFduinoBLE_onRSSI(int rssi)
{
  _rssi = rssi;
}

void RFduinoBLE_onReceive(char *data, int len)
{
  if( len > 0 && data[0] == CMD_TOGGLE )
     toggle = true;
}

void displayBuffer()
{
  RFduinoBLE.sendInt(buflen);
  for( int i = 0; i < buflen; ++i )
  {
    RFduinoBLE.sendByte(state == CONNECTED ? 0x01 : 0x00);
  }
}

void toggleDoor()
{
    toggle = false;

    digitalWrite(GPIO2, LOW);
    delay(50);
    digitalWrite(GPIO2, HIGH);
    delay(switchMs);
    digitalWrite(GPIO2, LOW);
}

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


Added example sketch

Added example sketch

/*
This a simple serial port thermometer application using the Thermocouple Nanoshield.

 Copyright (c) 2013 Circuitar
 This software is released under the MIT license. See the attached LICENSE file for details.
 */
#include <SPI.h>
#include "Nanoshield_Thermocouple.h"

Nanoshield_Thermocouple thermocouple;

void setup()
{
  Serial.begin(115200);
  Serial.println("-------------------------------");
  Serial.println(" Nanoshield Serial Thermometer");
  Serial.println("-------------------------------");
  Serial.println("");

  // Initialize thermocouple
  thermocouple.begin();
}

void loop()
{
  // Read thermocouple data
  thermocouple.read();

  // Print temperature in the serial port, checking for errors
  if (thermocouple.isShortedToVcc()) {
    Serial.println("Shorted to VCC");
  }
  else if (thermocouple.isShortedToGnd()) {
    Serial.println("Shorted to GND");
  }
  else if (thermocouple.isOpen()) {
    Serial.println("Open circuit");
  }
  else {
    Serial.print(thermocouple.getExternal());
    Serial.print(", ");
    Serial.println(thermocouple.getInternal());
  }

  // Wait for next second
  delay(1000);
}

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


added Hello world

added Hello world

/*
  Blink Hello World
 */

// Pin 13 has the LED on Teensy 3.0
int led = 13;
int dit = 200;
int dah = 800;
int space = 300;
int letterspace = 800-space;

void setup() {
  pinMode(led, OUTPUT);
}

void loop() {
//h dit dit dit dit
  for(int counter = 0; counter < 4; counter++){
    digitalWrite(led, HIGH);
    delay(dit);
    digitalWrite(led, LOW);
    delay(space);
  }
  delay(letterspace);
//e dit
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  delay(letterspace);
//l dit dah dit dit
  for(int counter = 0; counter < 2; counter++){
    digitalWrite(led, HIGH);
    delay(dit);
    digitalWrite(led, LOW);
    delay(space);
    digitalWrite(led, HIGH);
    delay(dah);
    digitalWrite(led, LOW);
    delay(space);
    digitalWrite(led, HIGH);
    delay(dit);
    digitalWrite(led, LOW);
    delay(space);
    digitalWrite(led, HIGH);
    delay(dit);
    digitalWrite(led, LOW);
    delay(space);
    delay(letterspace);
  }
//o dah dah dah
  for(int counter = 0; counter < 3; counter++){
    digitalWrite(led, HIGH);
    delay(dah);
    digitalWrite(led, LOW);
    delay(space);
  }
  delay(letterspace);
//w dit dah dah
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dah);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dah);
  digitalWrite(led, LOW);
  delay(space);
  delay(letterspace);
//o dah dah dah
  for(int counter = 0; counter < 3; counter++){
    digitalWrite(led, HIGH);
    delay(dah);
    digitalWrite(led, LOW);
    delay(space);
  }
  delay(letterspace);
//r dit dah dit
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dah);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  delay(letterspace);
//l dit dah dit dit
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dah);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  delay(letterspace);
//d dah dit dit
  digitalWrite(led, HIGH);
  delay(dah);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  digitalWrite(led, HIGH);
  delay(dit);
  digitalWrite(led, LOW);
  delay(space);
  delay(letterspace);
}

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


Create Database on SD Card

Create Database on SD Card

Create Database with structure:
Id   |   Username   |   Apartment   |   CardID   |   CardStatus

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/TheGum/Arduino-Elevator-Chip-System.git/'


Update Distance1 to use pulseIn and simpler maths

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


Renamed Arduino_files to arduino to conform to package standards

/*
 * Rosserial sensor value publisher
 * Publishes the value of the sensors to ros
 * Sensor types: Sharp 041SK, Sharp GP2D12. Sharp 2Y0A02 and HC-SR04 (Ultrasonic)
 *
 * Usage:
 * Run roscore
 * Type in terminal: rosrun rosserial_python serial_node.py /dev/ttyACM#
 * where # is the number of the serial port the Arduino is attached to
 * Call the topic with: rostopic echo sensors
 */

#include <ros.h>
#include <aidu_vision/DistanceSensors.h>
#include <math.h>

ros::NodeHandle  nh;

aidu_vision::DistanceSensors distance;
ros::Publisher sensor_publisher("sensors", &distance);

// Analog infrared defines
int sensorpin_ir_41 = 0; // analog pin used to connect the sharp 041SK
int sensorpin_ir_12 = 1; // analog pin used to connect the sharp GP2D12
int sensorpin_ir_02 = 2; // analog pin used to connect the sharp 2Y0A02
int sensorpin_ir_022= 3;

// Ultrasonic defines
#define echoPin_clean 7
#define trigPin_clean 8
#define echoPin_duct 12
#define trigPin_duct 13

void setup()
{
  nh.initNode();
  nh.advertise(sensor_publisher);

  pinMode(trigPin_clean, OUTPUT);
  pinMode(echoPin_clean, INPUT);
  pinMode(trigPin_duct, OUTPUT);
  pinMode(echoPin_duct, INPUT);
}

void loop()
{

  // HC-SR04 ultrasonic clean
  // Range: 2 to 400 cm
  // Value: 20 to 4000 (mm)
  // Attached to digital 7 (echo, blue) and digital 8 (Trig, red)
  distance.Frontright = ultrasonic(trigPin_clean, echoPin_clean);

  // HC-SR04 ultrasonic duct
  // Range: 2 to 400 cm
  // Value: 20 to 4000 (mm)
  // Attached to digital 12 (Echo, blue) and digital 13 (Trigger, red)
  distance.Frontleft = ultrasonic(trigPin_duct, echoPin_duct);

  // Publisher
  sensor_publisher.publish( &distance );
  nh.spinOnce();
  delay(50);
}

/**
 * Measures distance from an ultrasonic sensor
 */
float ultrasonic(int triggerPin, int echoPin) {
  float duration[5], distance;
  for(int i = 0; i < 4; i++){
    digitalWrite(triggerPin, LOW);
    delayMicroseconds(2);

    digitalWrite(triggerPin, HIGH);
    delayMicroseconds(10);

    digitalWrite(triggerPin, LOW);
    duration[i] = pulseIn(echoPin, HIGH);
    delayMicroseconds(60000);
  }
  duration[4] = (((duration[0] + duration[1] + duration[2] + duration[3])/4));
  distance = (duration[4] / 5.82 ) - 0.2979052982*(duration[4] / 5.82 ) + 4.0456059645;
  distance = distance + 0.1*distance - 10;
  return distance;
}

// Sharp 041SK
// Range: 3 to 30 cm
// Value: 30 to 300 (mm)
// Attached to analog input 0
//double sensor_value_ir_41 = analogRead(sensorpin_ir_41);
//int dis_ir_41 = 27205.2633 * pow(sensor_value_ir_41, -1.0183);
//distance.Back = dis_ir_41;

// Sharp GP2D12
// Range: 10 to 80 cm
// Value: 100 to 800 (mm)
// Attached to analog input 1
//  double sensor_value_ir_12 = analogRead(sensorpin_ir_12);
//  int dis_ir_12 = 38161.1739 * pow(sensor_value_ir_12, -0.9298) - 2936752.6632 * pow(sensor_value_ir_12,-2.2758995196);
//  distance.Frontmiddle = dis_ir_12;

//  // Sharp 2Y0A02
//  // Range: 20 to 150 cm
//  // Value: 200 to 1500 (mm)
//  // Attached to analog input 2
// double sensor_value_ir_02[5];
// for (int i=0;i<4;i++){
//   sensor_value_ir_02[i]= analogRead(sensorpin_ir_02);
//   delayMicroseconds(50000);
// }
// sensor_value_ir_02[4]=(sensor_value_ir_02[0]+sensor_value_ir_02[1]+sensor_value_ir_02[2]+sensor_value_ir_02[3])/4;
// int dis_ir_02 = 100356.1342 * pow(sensor_value_ir_02[4], -0.97711388);
// int dir_ir_02 = dir_ir_02 + 0.11999*dir_ir_02 /*- 18.91585*/;
// distance.Left = dis_ir_02;
//
//
//    // Sharp 2Y0A02
//  // Range: 20 to 150 cm
//  // Value: 200 to 1500 (mm)
//  // Attached to analog input 3
// double sensor_value_ir_022[5];
// for (int i=0;i<4;i++){
//   sensor_value_ir_022[i]= analogRead(sensorpin_ir_022);
//   delayMicroseconds(50000);
// }
// sensor_value_ir_022[4]=(sensor_value_ir_022[0]+sensor_value_ir_022[1]+sensor_value_ir_022[2]+sensor_value_ir_022[3])/4;
// int dis_ir_022 = 100356.1342 * pow(sensor_value_ir_022[4], -0.97711388);
// int dir_ir_022 = dir_ir_022 + 0.11999*dir_ir_022 /*- 18.91585*/;
// distance.Right = dis_ir_022;
//

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


better mouse code for right hand

better mouse code for right hand

#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
#include <Mouse.h>

//right hand optimized!

#define LPF_ALPHA .2//alpha value for the LP Filter
//#define numMPUMeasures 6;
#define button1 4 //will map left click to opponance with pointer finger
#define button2 5 //will map right click to opponance with middle finger

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz;
int vx, vy;

int buttonState1 = 0;
int buttonState2 = 0;

float MPUState_gyroZ;
float MPUState_gyroY;

void setup() {

  Serial.begin(9600);
  Wire.begin();
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  mpu.initialize();
  if (!mpu.testConnection()) { while (1); }

//MPU offsets
   //mpu.setXGyroOffset(-200);
    //mpu.setYGyroOffset(76);
    //mpu.setZGyroOffset(-85);
    mpu.setZAccelOffset(1788);
}

void loop() {
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); //accelerometer then gyroscope data

//  vx = (gx+15)/150;
//  vy = -(gz-100)/150;

  Serial.print("gx = ");
  Serial.print(gx);
   Serial.print(" | gy = ");
  Serial.print(gy);
  Serial.print(" | gz = ");
  Serial.print(gz);

  Serial.print("        | X = ");
  Serial.print(vx);
  Serial.print(" | Y = ");
  Serial.println(vy);
//
//
//  Serial.print("ax = ");
//  Serial.print(ax);
//   Serial.print(" | ay = ");
//  Serial.print(ay);
//  Serial.print(" | az = ");
//  Serial.println(az);

  //moveMouseAVG(2);

//for LP filter, comment out if going unfiltered
  vy = int(readMPU_gyroY_LPF(gy));
  vx = int(readMPU_gyroZ_LPF(gz)); //happy with this function

  Mouse.move(vx, vy);

  buttonState1 = digitalRead(button1);
  buttonState2 = digitalRead(button2);

//uncomment when you're ready to deal with random clicking or have grounded the wires for pins 4 + 5
// if (buttonState1 == HIGH) {
//    Mouse.press(MOUSE_LEFT);
//    delay(100);
//    Mouse.release(MOUSE_LEFT);
//    delay(200);
//  }
//  else if(buttonState2 == HIGH) {
//    Mouse.press(MOUSE_RIGHT);
//    delay(100);
//    Mouse.release(MOUSE_RIGHT);
//    delay(200);
//  }
  delay(200);
}

void moveMouseAVG(int numSamples){ //simple average filter for gyro data (not moving avg)
  int gxsum = 0;
  //int gysum = 0;
  int gzsum = 0;
  for(int i =0; i<numSamples; i++){
    gxsum += mpu.getRotationX();
    //gysum += mpu.getRotationY();
    gzsum += mpu.getRotationZ();
    delay(20);
  }
    float newX = (gxsum/numSamples+150)/200;
    float newY = -(gzsum/numSamples-100)/200; //get y value from gz samples

  Mouse.move(newX, newY);

}

float readMPU_gyroY_LPF(int inputReading){
 float updateVal = float(inputReading);
  MPUState_gyroY = updateVal*LPF_ALPHA + MPUState_gyroY*(1-LPF_ALPHA);
  return -(MPUState_gyroY-50)/100;
}

float readMPU_gyroZ_LPF(int inputReading){
 float updateVal = float(inputReading);
  MPUState_gyroZ = updateVal*LPF_ALPHA + MPUState_gyroZ*(1-LPF_ALPHA);
  //rightHandRAmplify(); //something that amplifies pos x values because it's much harder to turn the right hand to the right (and vice versa)
  return (MPUState_gyroZ+50)/100;
}

void rightHandRAmplify(){
  float rawVal = (MPUState_gyroZ+50)/100;
  if(rawVal > 0){
    rawVal = rawVal*5;
  }
  MPUState_gyroZ = rawVal*300;
}

//int readAxis(int gyroAxis){
//  MPUState =
//}

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


Fixed Arduino Sketch & Modified Basic HTTP Authentication

error: pathspec 'Devices/Generic' did not match any file(s) known to git
error: pathspec 'HTTP' did not match any file(s) known to git
error: pathspec 'Device/ArduinoSample.ino' did not match any file(s) known to git


MTM_MODULE

//MTM_MODULE.ino

int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
    digitalWrite(led, HIGH);  // turn the LED on (HIGH is the voltage level)
    delay(100);               // wait for a second
    digitalWrite(led, LOW);   // turn the LED off by making the voltage LOW
    delay(100);               // wait for a second
}

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


iwork inital version

iwork inital version

// This #include statement was automatically added by the Particle IDE.
#include <clickButton.h>

#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"

//PIN PHOTON => PIN OLED
#define OLED_MOSI   D0 //=>D1
#define OLED_CLK    D1 //=>D0
#define OLED_DC     D2 //=>DC
#define OLED_CS     D3 //=>CS
#define OLED_RESET  D4 //=>RST
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

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

// Icons
// Created by http://javl.github.io/image2cpp/
const unsigned char clockIcon [] PROGMEM = {
    0x3c, 0x4a, 0x89, 0x89, 0xb1, 0x81, 0x42, 0x3c
};

const unsigned char loginIcon [] PROGMEM = {
	0x3f, 0x01, 0x11, 0xf9, 0xf9, 0x11, 0x01, 0x3f
};

const unsigned char logoutIcon [] PROGMEM = {
    0x3f, 0x01, 0x21, 0x7d, 0x7d, 0x21, 0x01, 0x3f
};
const unsigned char tempIcon [] PROGMEM = {
    0x1c, 0x22, 0x2a, 0x2a, 0x2a, 0x5d, 0x5d, 0x3e
};
// WIFI Icons 1 = LOW, 4=FULL
const unsigned char wifiIcon1 [] PROGMEM = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18
};
const unsigned char wifiIcon2 [] PROGMEM = {
    0x00, 0x00, 0x00, 0x00, 0x18, 0x24, 0x18, 0x18
};
const unsigned char wifiIcon3 [] PROGMEM = {
    0x00, 0x00, 0x3c, 0x42, 0x18, 0x24, 0x18, 0x18
};
const unsigned char wifiIcon4 [] PROGMEM = {
    0x7e, 0x81, 0x3c, 0x42, 0x18, 0x24, 0x18, 0x18
};
const unsigned char noWifiIcon [] PROGMEM = {
    0xff, 0xc3, 0x3c, 0x5a, 0x18, 0x24, 0x5a, 0x99
};

const unsigned char lampIcon [] PROGMEM = {
	0x00, 0x08, 0x1e, 0x2c, 0x48, 0x20, 0x10, 0x78
};

const unsigned char lampIcon24 [] PROGMEM = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x27, 0x80, 0x00,
	0x77, 0xf0, 0x00, 0x77, 0xf8, 0x00, 0xc7, 0xfc, 0x01, 0x8f, 0xf8, 0x03, 0x0f, 0xe0, 0x06, 0x0f,
	0x90, 0x38, 0x04, 0x60, 0x38, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x06, 0x00, 0x00, 0x03, 0x00, 0x00,
	0x01, 0x80, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x70, 0x00, 0x00, 0x78, 0x00, 0x00, 0x7c, 0x00, 0x01,
	0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

// Constants
#define ENTER_ADDR 0
#define EXIT_ADDR 4

// PIN LED-Button Constants
#define BTN_LOGIN   D5
#define BTN_LOGOUT  D6
#define BTN_MODE    D7
#define LED_LOGIN   A0
#define LED_LOGOUT  A1
#define LED_MODE    A2

// Debounce Stuff
#define T_TIMEOUT 100 // milliseconds

ClickButton loginButton(BTN_LOGIN, LOW, CLICKBTN_PULLUP);
ClickButton logoutButton(BTN_LOGOUT, LOW, CLICKBTN_PULLUP);
ClickButton modeButton(BTN_MODE, LOW, CLICKBTN_PULLUP);

void blinkModeLED()
{
    Serial.println("Blink LED");
    toggleModeLED();
}

Timer blinkModeLEDtimer(1000, blinkModeLED);

// VARIABLES
int enteredTime = 0;
int exitedTime = 0;
String enteredTimeStr;
String exitedTimeStr;

#define WEATHER_UPDATE_INTERVAL 3600 // 3600sec = 1h
#define Rostock_City_ID "2844588"
int lastWeatherUpdate = 0;
double tempHRO;

// For debugging
String dataStr;

// IFTTT EVENT HANDLER
void onWorkHandler(const char *event, const char *data) {
    dataStr = String(data).trim().toLowerCase();
    if (dataStr.equals("entered")) {
        setEnteredTime(Time.now());
    } else if (dataStr.equals("exited")) {
        setExitedTime(Time.now());
    }
}

// WEATHER HANDLER
void receiveWeather(const char *event, const char *data) {
    // Convert String to double
    tempHRO = atof(data);
}

int mode = 0;

// STARTUP(WiFi.selectAntenna(ANT_AUTO));
STARTUP(WiFi.selectAntenna(ANT_INTERNAL));

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

    // Load data from EEPROM
    setEnteredTime(loadEEPROM(ENTER_ADDR));
    setExitedTime(loadEEPROM(EXIT_ADDR));

    // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
    display.begin(SSD1306_SWITCHCAPVCC);
    // init done

    display.display(); // show splashscreen
    delay(1000);
    display.clearDisplay();   // clears the screen and buffer

    // Time.zone(+2);
    Time.zone(+1);

    Particle.subscribe("on_work", onWorkHandler);
    Particle.subscribe("hook-response/weather/", receiveWeather, MY_DEVICES);

    Particle.variable("enteredTime", enteredTimeStr);
    Particle.variable("exitedTime", exitedTimeStr);
    Particle.variable("eventStr", dataStr);

    // PIN MODES
    pinMode(BTN_MODE, INPUT_PULLUP);
    // Setup button timers (all in milliseconds / ms)
    // (These are default if not set, but changeable for convenience)
    modeButton.debounceTime   = 30;   // Debounce timer in ms
    modeButton.longClickTime  = 1000; // time until "held-down clicks" register

    pinMode(LED_LOGIN, OUTPUT);
    pinMode(LED_LOGOUT, OUTPUT);
    pinMode(LED_MODE, OUTPUT);

    setModeLED(true);
}

int page = 0;
// PAINT STUFF IN LOOP
void loop() {
    // Update button state
    loginButton.Update();
    logoutButton.Update();
    modeButton.Update();

    // Save click codes in LEDfunction, as click codes are reset at next Update()
    int function = 0;
    if(modeButton.clicks != 0) function = modeButton.clicks;

    if(function == 1) {
        Serial.println("SINGLE click");
        if (mode == 0) {
            Serial.println("Change Page");
            // Normaler Modus > Seite weiterschalten
            page = (page + 1) % 4;
        }
    }
    if(function == -1) {
        Serial.println("SINGLE LONG click");
        if (mode == 0) {
            Serial.println("Edit Mode");
            mode = 1;
            blinkModeLEDtimer.start();
        } else if (mode == 1) {
            Serial.println("Normal Mode");
            mode = 0;
            blinkModeLEDtimer.stop();
            setModeLED(true);
        }
    }

    // Load weather data
    if ((lastWeatherUpdate + WEATHER_UPDATE_INTERVAL) < Time.now()) {
        Particle.publish("weather", Rostock_City_ID, PRIVATE);
        lastWeatherUpdate = Time.now();
    }

    display.clearDisplay();   // clears the screen and buffer

    updateLoginLED();
    updateLogoutLED();
    updateModeLED();

    if (page == 0) {
        printTime();
        printWifiState();
        printWorkStarted();
        printWorkDuration();
        printExitTime();
        printTemperature();
    }

    display.display();
}

void updateLoginLED() {
    digitalWrite(LED_LOGIN, enteredTime <= exitedTime);
}

void updateLogoutLED() {
    digitalWrite(LED_LOGOUT, enteredTime > exitedTime);
}

void updateModeLED() {
    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setTextWrap(false);
    display.setCursor(60,56);

    display.print(page);
}

void printWorkStarted() {
    display.drawBitmap(0, 0, loginIcon, 8, 8, WHITE);

    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setTextWrap(false);

    display.setCursor(10,0);

    // Not initialized
    if (enteredTime == 0 && exitedTime == 0) {
        display.print("--:--");
        return;
    }

    if (enteredTime < exitedTime) {
        display.print("--:--");
    } else {
        display.print(Time.format(enteredTime, "%H:%M"));
    }
}

void printTime() {
    display.drawBitmap(88, 0, clockIcon, 8, 8, WHITE);

    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setTextWrap(false);

    display.setCursor(98,0);

    if (Time.now() % 2 == 0) {
        display.print(Time.format(Time.now(), "%H:%M"));
    } else {
        display.print(Time.format(Time.now(), "%H %M"));
    }
}

void printWifiState() {
    if (!WiFi.ready()) {
        display.drawBitmap(60, 0, noWifiIcon, 8, 8, WHITE);
        return;
    }

    // Signal strength
    int sig = WiFi.RSSI();
    if (sig < -95) {
        // Bad signal
        display.drawBitmap(60, 0, wifiIcon1, 8, 8, WHITE);
    } else if (-95 <= sig && sig < -63) {
        display.drawBitmap(60, 0, wifiIcon2, 8, 8, WHITE);
    } else if (-63 <= sig && sig < -31) {
        display.drawBitmap(60, 0, wifiIcon3, 8, 8, WHITE);
    } else if (-31 <= sig && sig < 0) {
        // Good signal
        display.drawBitmap(60, 0, wifiIcon4, 8, 8, WHITE);
    } else if (sig > 0) {
        // Error
        display.drawBitmap(60, 0, noWifiIcon, 8, 8, WHITE);
    }
}

void printWorkDuration() {
    display.drawBitmap(0, 20, lampIcon24, 24, 24, WHITE);

    display.setTextSize(3);
    display.setTextColor(WHITE);
    display.setTextWrap(false);

    display.setCursor(30,23);

    // Not initialized
    if (enteredTime == 0 && exitedTime == 0) {
        display.print("--:--");
        return;
    }

    if (enteredTime < exitedTime) {
        display.print("--:--");
    } else {
        int timeNow = Time.now();
        int timeDiff = timeNow - enteredTime;
        int minutes = timeDiff / 60;

        // Hours
        display.print(String::format("%02d", minutes / 60));

        if (timeNow % 2 == 0) {
            display.print(":");
        } else {
            display.print(" ");
        }

        // Minutes
        display.print(String::format("%02d", minutes % 60));
    }
}

void printExitTime() {
    display.drawBitmap(0, 56, logoutIcon, 8, 8, WHITE);

    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setTextWrap(false);

    display.setCursor(10, 56);

    if (exitedTime == 0) {
        display.print("--:--");
    } else {
        display.print(Time.format(exitedTime, "%H:%M"));
    }
}

void printTemperature() {
    display.drawBitmap(88, 56, tempIcon, 8, 8, WHITE);

    display.setTextSize(1);
    display.setTextColor(WHITE);
    display.setTextWrap(false);

    display.setCursor(98, 56);

    if (lastWeatherUpdate == 0) {
        display.print("-.-");
    } else {
        // display.print(String::format("%+5.1f", tempHRO));
        display.print(String::format("%+3.0f%cC", tempHRO, char(247)));
        //display.print(tempHRO);
    }
}

/*
* HELPER METHODS
*/
void toggleModeLED() {
    digitalWrite(LED_MODE, !digitalRead(LED_MODE));
}

void setModeLED(bool isOn) {
    digitalWrite(LED_MODE, isOn);
}

int loadEEPROM(int address) {
    int tmpVal;
    EEPROM.get(address, tmpVal);
    return tmpVal;
}

void setEnteredTime(long timeInSeconds) {
    if (timeInSeconds > 1483228800 && timeInSeconds < 4102444800) {
        enteredTime = timeInSeconds;
        EEPROM.put(ENTER_ADDR, enteredTime);
    }
    enteredTimeStr = Time.format(enteredTime, TIME_FORMAT_DEFAULT);
}

void setExitedTime(long timeInSeconds) {
    if (timeInSeconds > 1483228800 && timeInSeconds < 4102444800) {
        exitedTime = timeInSeconds;
        EEPROM.put(EXIT_ADDR, exitedTime);
    }
    exitedTimeStr = Time.format(exitedTime, TIME_FORMAT_DEFAULT);
}

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


Arduino用のサンプルを追加

Arduino用のサンプルを追加

byte c = 0;

void setup(){
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}

void loop(){
  while (Serial.available()){
    c = (int)Serial.read();
    //Serial.flush();
    switch(c){
      case 48://0
        digitalWrite(13,LOW);
        break;
      case 49://1
        digitalWrite(13,HIGH);
        break;
    }
  }
}

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


Initial commit of code

Initial commit of code

#include "Arduino.h"
#include "ESP8266.h"
// If SOFTWARSERIAL or DebugSerial is applied,
// requires declaration of SortwareSerial.h
#include "SoftwareSerial.h"
SoftwareSerial	DebugSerial(8, 9);

#define SSID	"WARPSTAR-9FD487-G"
#define PWD		"BC5457B5C4E0A"

void setup() {
	char	*ipAddress, ap[31];

	DebugSerial.begin(9600);
	DebugSerial.println(F("Setup"));
	if (WiFi.reset(WIFI_RESET_HARD))
		DebugSerial.println(F("reset Complete"));
	else {
		DebugSerial.println(F("reset fail"));
		while (1);
	}
	if (WiFi.begin(9600)) {
		if (WiFi.setup(WIFI_CONN_CLIENT, WIFI_PRO_TCP, WIFI_MUX_SINGLE) != WIFI_ERR_OK) {
			DebugSerial.println(F("setup fail"));
			while (1);
		}
	} else {
		DebugSerial.println(F("begin fail"));
		while (1);
	}
	if (WiFi.join(SSID, PWD) == WIFI_ERR_OK) {
		ipAddress = WiFi.ip(WIFI_MODE_STA);
		DebugSerial.print(F("\n\rIP address:"));
		DebugSerial.print(ipAddress);
		DebugSerial.print(':');
		if (WiFi.isConnect(ap))
			DebugSerial.println(ap);
		else
			DebugSerial.println(F("not found"));
	} else {
		DebugSerial.println(F("connect fail"));
		while (1);
	}
}

void loop() {
	if (WiFi.connect((char *)"www.google.co.jp", 80) == WIFI_ERR_CONNECT) {
		DebugSerial.println(F("Send Start"));
		if (WiFi.send((const uint8_t *)"GET / HTTP/1.1\r\n\r\n") == WIFI_ERR_OK) {
			int16_t	c;
			uint16_t len = WiFi.listen(10000UL);
			DebugSerial.print(F("\nRCV:"));
			DebugSerial.print(len);
			DebugSerial.print(F("-->"));
			while (len)
				if ((c = WiFi.read()) > 0) {
					DebugSerial.write((char)c);
					len--;
				}
			DebugSerial.println(F("<--RCV"));
		} else {
			DebugSerial.println(F("Send fail"));
		}
		WiFi.close();
	} else {
		DebugSerial.println(F("TCP connect fail"));
	}
	WiFi.disconnect();
	while (1);
}

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


Blink test

Blink test

// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6  has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0

#define LED 13
#define PULSE 200

void setup()
{
    // initialize the digital pin as an output.
    pinMode(LED, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop()
{
    digitalWrite(LED, HIGH);
    delay(PULSE);
    digitalWrite(LED, LOW);
    delay(PULSE);
}

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