Simultaneus code. Unknown functionality

Simultaneus code. Unknown functionality

// FLIP-FLAP
// Arduino code for Maker Faire Rome
// October 2014
// by John Rees

// Declare the display not calibrated
boolean calibrated = false;

// Declare array strings for the 4 units
String s0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
String s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
String s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
String s3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";

// Define pin numbers
int STEP_0 = 8;
int STEP_1 = 6;
int STEP_2 = 10;
int STEP_3 = 12;

int DIR_0 = 9;
int DIR_1 = 7;
int DIR_2 = 11;
int DIR_3 = 13;

//int limit = 10000;
//int counter = 0;

char serialdata[4];

void setup() {

  // Init Serial
  Serial.begin(9600);
  Keyboard.begin();
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // Init stepper pins
  pinMode(DIR_3, OUTPUT);
  pinMode(STEP_3, OUTPUT);
  digitalWrite(DIR_3, HIGH);
  digitalWrite(STEP_3, LOW);

  pinMode(DIR_2, OUTPUT);
  pinMode(STEP_2, OUTPUT);
  digitalWrite(DIR_2, HIGH);
  digitalWrite(STEP_2, LOW);

  pinMode(DIR_0, OUTPUT);
  pinMode(STEP_0, OUTPUT);
  digitalWrite(DIR_0, HIGH);
  digitalWrite(STEP_0, LOW);

  pinMode(DIR_1, OUTPUT);
  pinMode(STEP_1, OUTPUT);
  digitalWrite(DIR_1, HIGH);
  digitalWrite(STEP_1, LOW);

  // Display Message
  Serial.println("Flip-Flap Ready!");
  Serial.println("Enter the 4 characters that the flipflap is displaying:");

}

int p0;
int p1;
int p2;
int p3;

void loop() {

  if (Serial.available() > 0) {

    Serial.readBytesUntil(10, serialdata, 4);

    p0 = s0.indexOf(0);
    p1 = s1.indexOf(1);
    p2 = s2.indexOf(2);
    p3 = s3.indexOf(3);

    if(!calibrated) {
      s0 = s0.substring(p0) + s0.substring(0,p0);
      s1 = s1.substring(p1) + s1.substring(0,p1);
      s2 = s2.substring(p2) + s2.substring(0,p2);
      s3 = s3.substring(p2) + s3.substring(0,p3);
      calibrated = true;
    }
    else {

      p0 *= 480;
      p1 *= 480;
      p2 *= 480;
      p3 *= 480;

      // Obtaining max of p0,p1,p2,p3
      int maxp=max(p0,p1);
      maxp=max(maxp,p2);
      maxp=max(maxp,p3);

      // Put all steps in the same common loop
      for(int i = 0; i < maxp; i++) {

        if (i < p0) {
          digitalWrite(STEP_0, HIGH);}
        if (i < p1) {
          digitalWrite(STEP_1, HIGH);}
        if (i < p2) {
          digitalWrite(STEP_2, HIGH);}
        if (i < p3)  {
          digitalWrite(STEP_3, HIGH);}

        delayMicroseconds(100);

        if (i < p0) {
          digitalWrite(STEP_0, LOW);}
        if (i < p1) {
          digitalWrite(STEP_1, LOW);}
        if (i < p2) {
          digitalWrite(STEP_2, LOW);}
        if (i < p3)  {
          digitalWrite(STEP_3, LOW);}
      }

     // Shift strings
     s0 = s0.substring(p0) + s0.substring(0,p0);
     s1 = s1.substring(p1) + s1.substring(0,p1);
     s2 = s2.substring(p2) + s2.substring(0,p2);
     s3 = s3.substring(p3) + s3.substring(0,p3);
     Serial.println("Done!");

    }
  }

}

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


Create mega2560_Modbusmaster.ino

Create mega2560_Modbusmaster.ino

#include <SimpleModbusMaster.h>

#define baud 9600
#define timeout 1000
#define polling 200
#define retry_count 10

#define TxEnablePin 2

long randNumber;
#define TOTAL_NO_OF_REGISTERS 1

enum
{
  PACKET1,
  PACKET2,
  TOTAL_NO_OF_PACKETS
};

Packet packets[TOTAL_NO_OF_PACKETS];

unsigned int regs[TOTAL_NO_OF_REGISTERS];

void setup()
{

  modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0, 1, 0);
  modbus_construct(&packets[PACKET2], 1, PRESET_MULTIPLE_REGISTERS, 1, 1, 0);

  modbus_configure(&Serial3, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);

}

void loop()
{randNumber = random(10, 30);
  modbus_update();

  regs[0] = randNumber;

}

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


Untested Arduino receiver code.

Untested Arduino receiver code.

#include <TinyWireM.h>
#include <USI_TWI_Master.h>
#include <Wire.h>
#include <RFM69.h>
#include <SPI.h>
#include <stdlib.h>

volatile byte* Float1ArrayPtr;
double dataToSend;
unsigned long lastReceivedMillis = millis();
unsigned long lastSentMillis = millis();
char radiopacket[150];

// Settings for the Adafruit RFM69HCW radio
#define NETWORKID     81
#define NODEID        1
#define FREQUENCY     RF69_915MHZ
#define ENCRYPTKEY    "eq^YkQ3n7HvC#9c$"
#define IS_RFM69HCW   true

// Pins for the Adafruit RFM69HCW radio
#define RFM69_CS      10
#define RFM69_IRQ     2
#define RFM69_IRQN    0  // IRQ 0
#define RFM69_RST     9

#define LED           13

#define SERIAL_BAUD   9600

// Setup the radio library
RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN);

void setupRadio() {
  // Hard Reset the RFM module
  pinMode(RFM69_RST, OUTPUT);
  digitalWrite(RFM69_RST, HIGH);
  delay(100);
  digitalWrite(RFM69_RST, LOW);
  delay(100);
// Initialize radio
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
  if (IS_RFM69HCW) {
    radio.setHighPower();    // Only for RFM69HCW & HW!
  }
  radio.setPowerLevel(31); // power output ranges from 0 (5dBm) to 31 (20dBm)

  radio.encrypt(ENCRYPTKEY);

  pinMode(LED, OUTPUT);
  Serial.print("\nListening at ");
  Serial.print(FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(" MHz");
}

void setup() {
  Serial.begin(SERIAL_BAUD);
  Serial.println("Starting Arduino Metro weather station I2C master, radio receiver...");
  setupRadio();

 Wire.begin(7);
 Wire.onRequest(requestEvent);
 Wire.onReceive(receiveEvent);
  Serial.println("Setup complete");
}

void loop() {
  //check if something was received (could be an interrupt from the radio)
  if (radio.receiveDone())
  {
    //print message received to serial
    Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
    Serial.print((char*)radio.DATA);
    Serial.print("   [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");

    lastReceivedMillis = millis();

    //check if sender wanted an ACK
    if (radio.ACKRequested())
    {
      radio.sendACK();
      Serial.println(" - ACK sent");
    }
  }

  radio.receiveDone(); //put radio in RX mode
  Serial.flush(); //make sure all serial data is clocked out before sleeping the MCU
}

double isDataNew() {
  unsigned long difference = lastReceivedMillis -  lastSentMillis;
  if(difference > 0) {
    return 1;
  } else {
    return 0;
  }
}

void requestEvent(){
  // char frame[30];
 //sprintf(frame, "%8.2", dataToSend);

   //String data = String(dataToSend, DEC);
   //dataToSend = 123456.78;

  if(dataToSend == 3) {
    //String data = String(radiopacket);
    lastSentMillis = millis();
    Wire.write(radiopacket);
  } else {
   char temp1[10];
   dtostrf(dataToSend, 10, 2, temp1);
   String data = String(temp1);
   Wire.write(temp1);
  }

  //Wire.write(frame, 30);
  //Wire.write("abcd");
  //Serial.print("Sent: ");
  //Serial.println(data);
  //Serial.println("-----");
}

void receiveEvent(int howMany){
  int c;
  c = Wire.read(); // receive byte as a character
  //Serial.print("Got: ");
  //Serial.println(c);
  if(c == 1) { // Is there new data?
    dataToSend = isDataNew();
    //dataToSend = 1.2;
  } else if(c == 2) { // What is the data?
     // dataToSend = 3.4;
    dataToSend = 3;
  }
}

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


Fix typos and incorrect LED assignment

Fix typos and incorrect LED assignment

error: pathspec 'Sounds' did not match any file(s) known to git
error: pathspec 'and' did not match any file(s) known to git
error: pathspec 'Senses/analog_range/analog_range.ino' did not match any file(s) known to git


Initial commit for shu_timer

Initial commit for shu_timer

/*
  Shu Timer

  A Timer app with for Shu-chan to limit his TV/Gaming time.
  Runs on littleBits + Arduino.
 */

// consts
const int START_BTN = 0; // timer start button input at D0
const int STOP_BTN = A0; // timer stop button input at A0
const int RESET_BTN = A1; // timer reset button input at A1
const int BLINKER_LED = 1; // blinker LED output at D1
const int COUNTER_LED = 5; // counter 7-seg LED output at D5
const int CLOUDBIT = 9; // cloudBit output at D9

const int START_VAL = 20 * 60; // the unit amount for starting timer in seconds
const int MAX_VAL = 99 * 60; // max amount of timer in seconds

// states
int timerValue = 0;
unsigned long lastTick = 0;
boolean isStopped = false;
int startBtnPrev = LOW;
int stopBtnPrev = 0;
int timerValuePrev = 0;

// setup
void setup() {
  pinMode(BLINKER_LED, OUTPUT);
  pinMode(COUNTER_LED, OUTPUT);
  pinMode(CLOUDBIT, OUTPUT);
  analogWrite(CLOUDBIT, 0);
}

// main loop
void loop() {
  delay(100);
  ticking();
  checkResetButton();
  checkStartButton();
  checkStopButton();
  outputCloudBit();
  displayBlinker();
  displayCounter();
}

// decrease timerValue every one sec if timer is not stopped
void ticking() {
  if (lastTick == 0 || millis() - lastTick > 1000) {
    lastTick = millis();
    timerValuePrev = timerValue;
    if (timerValue > 0 && !isStopped) {
      timerValue--;
    }
  }
}

// if reset button is pressed, clear all the states
void checkResetButton() {
  if (digitalRead(RESET_BTN) == HIGH) {
    lastTick = 0;
    timerValue = 0;
    timerValuePrev = 0;
    isStopped = false;
  }
}

// if start button is pressed, increase timerValue by START_VAL
void checkStartButton() {
  boolean startBtn = digitalRead(START_BTN);
  if (startBtn == HIGH && startBtnPrev == LOW) {
    timerValue = min(timerValue + START_VAL, MAX_VAL);
  }
  startBtnPrev = startBtn;
}

// if stop button is pressed, flip isStopped flag
void checkStopButton() {
  int stopBtn = analogRead(STOP_BTN);
  if (stopBtn > 90 && stopBtnPrev == 0 && timerValue > 0) {
    isStopped = !isStopped;
  }
  stopBtnPrev = stopBtn;
}

// output to blinker LED
void displayBlinker() {

  // if timer is not working, turn off
  if (timerValue == 0) {
      digitalWrite(BLINKER_LED, LOW);
      return;
  }

  // if timer is stopped, turn on
  if (isStopped) {
      digitalWrite(BLINKER_LED, HIGH);
      return;
  }

  // if timer is ticking, blink it
  int blinkerValue = LOW;
  if(timerValue % 2 == 0) {
    blinkerValue = LOW;
  } else {
    blinkerValue = HIGH;
  }
  digitalWrite(BLINKER_LED, blinkerValue);
}

// output to counter 7seg LED
void displayCounter() {
  int counterValue = counterValue = map(timerValue, 0, 5999, 0, 255); // maps 6000 sec to 100 minutes on littleBits LED
  analogWrite(COUNTER_LED, counterValue);
}

// output to cloutBit when timer counting is finished
void outputCloudBit() {
  if (timerValue == 0 && timerValuePrev == 1) {
    analogWrite(CLOUDBIT, 255);
    delay(500);
    analogWrite(CLOUDBIT, 0);
  }
}

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


quad ultrasonic sensor code optimization

Diger/ultrasonic sensor (dörtlü) arduino/quad_ultrasonic_sensor/quad_ultrasonic_sensor.ino

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


PWM reader

PWM reader

#include <LiquidCrystal.h>

#define LED_PIN 13
#define READ_PIN 2
#define PWM_PIN 3

#define POT_PIN 0

volatile long timeSinceLast = 0;
volatile long period = 0;
volatile long pilseLength = 0;

ISR(INT0_vect) {
  int currentTime = TCNT1;
  if (digitalRead(READ_PIN) == HIGH) {
    timeSinceLast = currentTime;
    period = pilseLength + currentTime;
  } else {
    TCNT1 = 0;
    pilseLength = currentTime - timeSinceLast;
  }
}

int currState = LOW;
LiquidCrystal lcd(5, 6, 8, 9, 10, 11);

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  pinMode(READ_PIN, INPUT);
  pinMode(PWM_PIN, OUTPUT);

  lcd.begin(16, 2);
  lcd.print("hello, world!");
  Serial.begin(9600);
  TCCR1A = 0;    // set timer1 operation mode to normal
  //TIFR1 |= _BV(OCF1A);     // clear any pending interrupts;
  //TIMSK1 |=  _BV(OCIE1A) ; // enable the output compare interrupt

  EICRA |= (1 << ISC00); // ext.int. any logic change
  EIMSK |= (1 << INT0);  // enable INT0
  TCCR1B = 2; // set prescaler 8
  // change timer2 prescaler. Timer2 controls PWM no pin 3
  TCCR2B &= 0xF8;  // clear prescaler bits
  TCCR2B |= 5;     // set 1024 prescaler

  Serial.println(TCCR0B);
  Serial.println(TCCR1B);
  Serial.println(TCCR2B);
}

void loop()
{
  blink();

  byte potValue = analogRead(POT_PIN)/4;
  analogWrite(PWM_PIN, potValue);

  lcd.setCursor(0, 0);
  lcd.print("Pulse(ms): ");
  lcd.print(1000.0 / (double)(F_CPU / (pilseLength * 8)));
  lcd.setCursor(0, 1);
  lcd.print("Period(ms): ");
  lcd.print(1000.0 / (double)(F_CPU / (period * 8)));

  Serial.print("Pulse(ms): ");
  Serial.print(1000.0 / (double)(F_CPU / (pilseLength * 8)));
  Serial.print(" Period(ms): ");
  Serial.print(1000.0 / (double)(F_CPU / (period * 8)));
  Serial.print(" PotValue: ");
  Serial.println(potValue);
 //Serial.println(TCNT1);

 //char str[255];
 //sprintf(str, "qwe %i", 555);
 //Serial.println(str);

 delay(10);
}

void blink() {
   digitalWrite(LED_PIN, currState);
     if (currState == LOW)
      currState = HIGH;
    else
      currState = LOW;
}

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


Create load-cell-calibration.ino

Create load-cell-calibration.ino

Use this sketch to calculate the calibration parameter to output mass in human readable quantities

//////////////////////////////////////////
// Particle Photon load cell scale v1.0 //
//////////////////////////////////////////

// Justin Ashton
// (c) J. Ashton & Company, Inc., 2016
//
// Borrowed code from: https://github.com/juano2310/HX711ADC
//
// Hardware setup: Particle Photon, HX711 load cell amp from SparkFun, load cell strain gauge
//
// This sketch is designed to help you calibrate your load cell scale.
// Run this sketch and open a serial port for input/output. The first time you run this
// sketch, enter the number "1" to reset any existing calibration. Then type "2" to
// zero out the scale (tare). Place a known weight on the scale, then type "3" to measure
// and output the weight on the scale. The calibration parameter needed in .set_scale() is
// equal to the value output in step #3 divided by the mass of the known weight. Enter it
// inside the parentheses of the scale.set_scale() function under void setup().

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

char user_input;

//HX711ADC(byte dout, byte pd_sck, byte gain = 128);
HX711ADC scale(D3, D2); //D3 to DAT and D2 to CLK pin on SparkFun load cell amp board

void setup() {
  Serial.begin(9600);
  scale.set_scale(1610.f); // to calibrate scale, change this parameter and be sure to add ".f" after
  Serial.println("HX711ADC Calibration Sketch");
  Serial.println("Menu: Enter number");
  Serial.println("m. List menu.");
  Serial.println("1. Reset scale calibration.");
  Serial.println("2. Zero out scale.");
  Serial.println("3. Weigh scale.");
  Serial.println();

}

void loop() {

  while(Serial.available()){
      user_input = Serial.read(); //Read user input and trigger appropriate action
      switch (user_input){
          case '1':
          Serial.println("1. Reset scale calibration."); //uses function .set_scale to reset the calibration value
          scale.set_scale();
          Serial.println("Initialized");
          delay(250);
          break;

          case '2':
          Serial.println("2.Zero out scale."); //use function .tare to zero out scale
          scale.tare();
          Serial.println("Zeroed.");
          delay(250);
          break;

          case '3':
          Serial.println("3. Weigh scale."); // reads and outputs an average value of weight.
          Serial.println(scale.get_units(10));
          delay(250);
          break;

          case 'm':
          Serial.println("Menu: Enter number");
          Serial.println("m. List menu.");
          Serial.println("1. Reset scale calibration.");
          Serial.println("2. Zero out scale.");
          Serial.println("3. Weigh scale.");
          Serial.println();
          delay(250);
          break;

          default:
          Serial.println("Invalid option entered.");
          }

          }
}

error: pathspec 'firmware/load-cell-calibration.ino' did not match any file(s) known to git


Use strcmp instead of == (c# habits die hard)

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


add arduino program to read animation from SD and sending to 3D8

#include "SD.h"
#include "string.h"

Sd2Card card;
SdVolume volume;
const int chipSelect = 4;
File root;

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

	pinMode(10, OUTPUT); // change this to 53 on a mega

	bool sd_ok = SD.begin(9);

	if (!sd_ok)
	{
		Serial.println("failed.");
		return;
	}

	root = SD.open("/");
}

void sendAnimation(byte *data)
{
	Serial.write(0xf3);
	Serial.write(data[1]);

	Serial.write(0xf4);
	Serial.write(data[2]);

	Serial.write(0xf5);
	Serial.write(data[3]);

	Serial.write(0xf2);
	for (byte i = 8; i < 72; i++)
	{
		Serial.write(data[i]);
	}

	delayMicroseconds(makeWord(data[4], data[5]));
	delay(makeWord(data[6], data[7]));
}

void readAnimation(File & file)
{
	byte data[72];
	while (file.available())
	{
		file.read(data, 72);
//		for (byte i = 0; i < 72; i++)
//			Serial.write(data[i]);

		sendAnimation(data);
	}
}

void loop(void)
{
	File file = root.openNextFile();
	if (file)
	{
		char *p = file.name();
		char *p_dot = strchr(p, '.');

		if (p_dot != NULL && strcmp(p_dot, ".DAT") == 0)
		{
			readAnimation(file);
		}

		file.close();
	}
	else
		root.rewindDirectory();
}

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


add audio-menu and extra playmode

add audio-menu and extra playmode

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


Asservissement:  mise en forme code asservissement vitesse

error: pathspec 'Module' did not match any file(s) known to git
error: pathspec 'Moteur/Software/Asservissement/Asservissement' did not match any file(s) known to git
error: pathspec 'vitesse/src/application.ino' did not match any file(s) known to git


Change 128x64 life to use tiny screen

Change 128x64 life to use tiny screen

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


Stuff

Stuff

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


SoundBuzzer

SoundBuzzer

updated the last note!

error: pathspec 'Action' did not match any file(s) known to git
error: pathspec 'Modules/Piano' did not match any file(s) known to git
error: pathspec 'Synthesizer/PianoSynthesizerATtiny/PianoSynthesizerATtiny.ino' did not match any file(s) known to git


Change control topic to, well, "control"


Create palette_example2.ino

Create palette_example2.ino

//***************************************************************
// Gradient palette that can have colors or anchor points updated on the fly.
// This is based on some code from Mike Brown.
// https://plus.google.com/u/0/102054795236178256184/posts/UWbQBcmKDdU?cfem=1
//
// Randomly picks start and end colors.  Colors in middle remain
// constant, but for fun their anchor points are randomly picked.
//
// More info on gradient palettes here:
// https://github.com/FastLED/FastLED/wiki/Gradient-color-palettes
//
// Marc Miller, May 2017
//***************************************************************

#include "FastLED.h"
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif

#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define BRIGHTNESS  255

CRGBPalette256 currentPalette;
CHSV hsv;
CRGB rgb;

//---------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  delay(500);  // startup delay
  //FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);
}

//---------------------------------------------------------------
void loop () {
  EVERY_N_SECONDS(2){
    newGradientPalette();
  }
  FastLED.show();
  FastLED.delay(100);
}

//---------------------------------------------------------------
void newGradientPalette(){
  uint8_t xyz[16];  // Needs to be 4 times however many colors are being used.
                    // 3 colors = 12, 4 colors = 16, etc.

  hsv = CHSV(random8(), 255, 255);  // pick random hue
  hsv2rgb_rainbow( hsv, rgb);  // convert to R,G,B

  xyz[0] = 0;  // anchor of first color - must be zero
  xyz[1] = rgb.r;
  xyz[2] = rgb.g;
  xyz[3] = rgb.b;

  xyz[4] = random8(48,118);  // random anchor point for second color
  xyz[5] = 255;
  xyz[6] = 0;
  xyz[7] = 0;

  xyz[8] = random8(138,225);  // random anchor point for third color
  xyz[9] = 0,
  xyz[10] = 255;
  xyz[11] = 0;

  hsv = CHSV(random8(), 255, 255);  // pick random hue
  hsv2rgb_rainbow( hsv, rgb);  // convert to R,G,B

  xyz[12] = 255;  // anchor of last color - must be 255
  xyz[13] = rgb.r;
  xyz[14] = rgb.g;
  xyz[15] = rgb.b;

  currentPalette = xyz;

  for (int p = 0; p < NUM_LEDS; p++) {
    leds[p] = ColorFromPalette(currentPalette, p*255/(NUM_LEDS-1), BRIGHTNESS, NOBLEND);
  }

}

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


Initial add of serial menu/macro based led control program for Arduino

 /***********************************************************************
 *  Copyright (c) 2014 - Matthew Fatheree <greymattr@gmail.com>
 *  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES.  THE USER(S) ARE HEREBY NOTIFIED THAT USE OF THIS SOFTWARE MAY
 * MAY CAUSE LOSS OF DATA, DATA DESTRUCTION, HEALTH AND MENTAL PROBLEMS. IT
 * MAY CAUSE YOU TO START DRINKING, INCREASE YOUR STUPIDITY LEVEL, CLUB
 * BABY SEALS, AND OVERALL BECOME A BAD PERSON.
 *
 * PLEASE USE AT YOUR OWN RISK
 * ____    ________
 * \   \  /    ___/
 * |    \/     __|
 * |  |\__/|  |
 * /  \atthew \atheree
 ************************************************************************/

#include <stdarg.h>

#define	min(a,b)	  ((a) < (b) ? (a) : (b))
#define	max(a,b)	  ((a) > (b) ? (a) : (b))

#define SET_BIT(p,n)      ((p) |= (1 << (n)))
#define CLR_BIT(p,n)      ((p) &= (~(1) << (n)))
#define IS_BIT_SET(val, bit_no) (((val) >> (bit_no)) & 1)

#define INTENSE_MIN        0
#define INTENSE_MAX        255

//#define FADE_STEPS         8
#define FADE_STEPS         16
//#define FADE_STEPS         32

#define SL_VERSION         "v0.1.1"

#define BORDER             "\n--------------------\n"
#define LED_CHOICE         "Which LED would you like to"
#define FREQ_CHOICE        "How quickly would you like it to"
#define REPEAT_CHOICE      "How many times should it"
#define INTENSE_CHOICE     "How bright"
#define MODE_SEL_ERR       "mode select error\n"
#define PARAM_ERR          "parameter error\n"

#define HIGH_VAL_STR       "High Value"
#define MID_VAL_STR        "Mid Value"
#define LOW_VAL_STR        "Low Value"

#define CONTROL_SETTINGS   "Control Settings"
#define START_INTS         "Start Intensity"
#define END_INTS           "End Intensity"
#define TXT_MACRO          "\n\n macro = "

#define MAX_MACRO_LEN      128
#define SMALL_BUFF         8

#define LED1_FLAG          1
#define LED2_FLAG          2
#define LED3_FLAG          4
#define LED4_FLAG          8
#define LED5_FLAG          16
#define LED6_FLAG          32
#define LED7_FLAG          64
#define LED8_FLAG          128
#define LED9_FLAG          256
#define LED10_FLAG         512
#define LED11_FLAG         1024
#define LED12_FLAG         2048
#define LED13_FLAG         4096

//macro modes
#define MODE_BLINK         1
#define MODE_PULSE         2
#define MODE_FADE          3
#define MODE_WAIT          4
#define MODE_SET           5

#define MAX_LEDS           13
#define ALL_LEDS           8191
#define NONE_LEDS          0

#define POWER_SAVE

int HighVal = INTENSE_MAX;
int MidVal = INTENSE_MAX / 2;
int LowVal = INTENSE_MIN;
int UserLed = 10;
int UserVal = INTENSE_MAX;
int UserFreq = 1000;
int UserRepeat = 1;
int UserState1 = LowVal;
int UserState2 = HighVal;
char Uinput[ MAX_MACRO_LEN ];

void setup()
{
  int x = 0;

  for( x=0; x<=MAX_LEDS; x++ ) {
    pinMode( UserLed,OUTPUT );    // Configure the onboard LED for output
    analogWrite( UserLed,0 );  // default to LED off
  }
  Serial.begin( 57600 );
  while( !Serial ) {
    delay( 500 );
  }
  delay( 1000 ); // because Arduino,... am I right?...

}

void p( char *fmt, ... )
{
  char buf[MAX_MACRO_LEN]; // resulting string limited to 128 chars
  va_list args;
  va_start ( args, fmt );
  memset( buf, 0, sizeof( buf ) );
  vsnprintf( buf, MAX_MACRO_LEN, fmt, args );
  va_end ( args );
  Serial.print( buf );
}

void display_menu()
{
  delay( 500 );
  p( "\n\n    LED %s %s\n", CONTROL_SETTINGS, SL_VERSION );
  p( " I. Intensity %s\n", CONTROL_SETTINGS );
  p( " F. Fade  %s\n", CONTROL_SETTINGS );
  p( " P. Pulse %s\n", CONTROL_SETTINGS );
  p( " B. Blink %s\n", CONTROL_SETTINGS );
  p( " C. Clear all LEDS off\n" );
#if 0
  p( " M. Macro %s\n", CONTROL_SETTINGS );
#endif
  p( "%s", BORDER);
  p( " > " );
}

void loop()
{
  char *selection;
  int a = 0;
  int ok;

  display_menu();
  selection = get_user_input();
  memset( Uinput, 0, sizeof( Uinput ) );
  for( a=0; a<( MAX_MACRO_LEN-1 ); a++ ) {
    Uinput[a] = ( char ) *( selection + a );
    if( Uinput[a] == '\0' ) {
      break;
    }
  }
  switch ( Uinput[0] ) {
  case 'I':
  case 'i':
    IntensityControls();
    break;
  case 'F':
  case 'f':
    FadeControls();
    break;
  case 'P':
  case 'p':
    PulseControls();
    break;
  case 'B':
  case 'b':
    BlinkControls();
    break;
  case 'C':
  case 'c':
    p( "\n All LEDS OFF\n\n" );
    a = 8191;
    p("%s c\n", TXT_MACRO);
    set_leds( a, 0 );
    break;
  case '*':
    SayHello();
    break;
#if 1
  case 't':
    // put test functions here
    unrecognized();
    break;
  case 'M':
  case 'm':
    //unrecognized();
    parse_macro( ( char * )( Uinput + 1 ) );
    break;
#endif
  default:
    unrecognized();
    break;
  }

}

void set_leds( int leds, int brightness )
{
  int x;
  //p("\nset led(s) %d at %d\n", leds, brightness);
  for( x=1; x<=MAX_LEDS; x++ ) {
    if( IS_BIT_SET( leds, x ) ) {
      analogWrite( x,brightness );
    }
  }
}

void leds_off( int leds )
{
  set_leds( leds,0 );
}

void leds_on( int leds )
{
  set_leds( leds,255 );
}

void blink_leds( int leds, int brightness, int freq, int repeat )
{
  int i = 0, x = 0;
  int led;

  set_leds( leds, 0 );
  //p( "\n blink led(s) %d at %d/%dms %d times\n", leds, brightness, freq, repeat );
  for( i=0; i<repeat; i++ ) {
    set_leds( leds, brightness );
    delay( freq / 2 );
    set_leds( leds, 0 );
    delay( freq/2 );
  }
}

void blink_led( int led, int b, int f, int r )
{
  int ls = 0;
  SET_BIT( ls, led );
  blink_leds( ls, b, f, r );
}

void fade_leds( int leds, int from, int to, int freq, int repeat )
{
  int total_time = freq;
  int steps = FADE_STEPS;
  int total_range = ( ( max( from,to ) ) - min( from,to ) );
  int step_value =  ( total_range / steps );
  int sleep_value = ( total_time / steps );
  int i, y;
  int curval;
  int led = 0;

  //p( "\n fade led(s) %d from %d to %d/%dms %d times\n", leds, from, to, freq, repeat );
  for( i=0; i<repeat; i++ ) {
    curval = from;
    for ( y=0; y<=steps; y++ ) {
      if( curval < 0 ) {
        curval = 0;
      }
      set_leds( leds, curval );
      if( curval > to ) {
        curval = curval - step_value;
      } else {
        curval = curval + step_value;
      }
      delay( sleep_value );
    }
  }
  set_leds( leds, to );
}

void fade_led( int leds, int from, int to, int freq, int repeat )
{
  int ls = 0;
  SET_BIT( ls, leds );
  fade_leds( ls, from, to, freq, repeat );
}

void pulse_leds( int leds, int from, int to, int freq, int repeat )
{
  int i;
  int new_freq = freq / 2;
  for( i=0; i<repeat; i++ ) {
    fade_leds( leds, from, to, new_freq, 1 );
    fade_leds( leds, to, from, new_freq, 1 );
  }

}

void pulse_led( int led, int from, int to, int freq, int repeat )
{
  int ls = 0;
  SET_BIT( ls, led );
  pulse_leds( ls, from, to, freq, repeat );
}

void SayHello()
{
  p( "%s", BORDER );
  p( "\n Hey Matt... greymattr want a beer?... You're awesome!...\n" );
  p( "%s", BORDER );
}

char *get_user_input()
{
  int i=0;
  char b = 0;
  char commandbuffer[MAX_MACRO_LEN];

  memset( commandbuffer, 0, sizeof( commandbuffer ) );
  while( i < ( sizeof( commandbuffer )-1 ) ) {
    if( Serial.available() ) {
      b = Serial.read();
      if( b != 0x08 ){
        commandbuffer[i++] = b;
      } else {
        commandbuffer[i] = '\0';
        i--;
      }
      if( ( b == 0x0a ) || ( b== 0x0d ) ) {
        break;
      } else {
        Serial.write( b );
      }
    }
  }
  if( i<2 ) {
    return "\0";
  }
  commandbuffer[i]='\0';
  //p("\ncmd buffer = %s\n", commandbuffer);
  return commandbuffer;
}

int get_user_int( int orig )
{
  char *arg = '\0';
  int val = 0;
  arg = get_user_input();
  if( *arg != '\0' ) {
    val=atoi( arg );
    if( ( val >= INTENSE_MIN ) && ( val <= INTENSE_MAX ) ) {
      return val;
    } else {
      return orig;
    }
  }
  return orig;
}

int get_user_intlarge( int orig )
{
  char *arg = '\0';
  int val = 0;
  arg = get_user_input();
  if( *arg != '\0' ) {
    val=atoi( arg );
    if( ( val >= 0 ) && ( val <= 0xFFFF ) ) {
      return val;
    } else {
      return orig;
    }
  }
  return orig;
}

void BlinkControls()
{
  int aNumber;
  char resp;
  char *arg = '\0';
  int ok;
  int val;

  Serial.flush();
  p( "\n\nBlink %s\n", CONTROL_SETTINGS );
  p( "%s blink [ %d ]?: ", LED_CHOICE, UserLed );
  while( !Serial.available() ) {
    ;
  }
  UserLed = get_user_int( UserLed );
  p( "\n%s blink [ %dms ]?: ", FREQ_CHOICE, UserFreq );
  while( !Serial.available() ) {
    ;
  }
  UserFreq = get_user_intlarge( UserFreq );
  p( "\n%s (1-255) [ %d ]?: ", INTENSE_CHOICE, UserVal );
  while( !Serial.available() ) {
    ;
  }
  UserVal = get_user_int( UserVal );
  p( "\n%s should it blink [ %d ]?: ", REPEAT_CHOICE, UserRepeat );
  while( !Serial.available() ) {
    ;
  }
  UserRepeat = get_user_int( UserRepeat );
  p("%s ml(%d)b(%d,%d,%d)\n", TXT_MACRO,UserLed, UserVal, UserFreq, UserRepeat);
  blink_led( UserLed, UserVal, UserFreq, UserRepeat );
}

void IntensityControls()
{
  char *arg = NULL;
  int val = 0;
  int ok;

  Serial.flush();
  p( "\n\nIntensity %s ( 1 - 255 )\n", CONTROL_SETTINGS );
  p( "%s [ %d ]?: ",HIGH_VAL_STR, HighVal );
  while( !Serial.available() ) {
    ;
  }
  HighVal = get_user_int( HighVal );
  p( "\n %s [ %d ]?: ",MID_VAL_STR, MidVal );
  while( !Serial.available() ) {
    ;
  }
  MidVal = get_user_int( MidVal );
  p( "\n %s [ %d ]?: ",LOW_VAL_STR, LowVal );
  while( !Serial.available() ) {
    ;
  }
  LowVal = get_user_int( LowVal );
  p( "%s", BORDER );
  p( "%s=%d, %s=%d, %s=%d\n",HIGH_VAL_STR,HighVal,MID_VAL_STR, MidVal,LOW_VAL_STR, LowVal );
  p( "%s", BORDER );
  p( "\n%s set [ %d ]?: ", LED_CHOICE, UserLed );
  while( !Serial.available() ) {
    ;
  }
  UserLed = get_user_int( UserLed );
  p( "\n%s [ %d ]?: ", INTENSE_CHOICE, UserVal );
  while( !Serial.available() ) {
    ;
  }
  UserVal = get_user_intlarge( UserVal );
  p( "%s", BORDER );
  p( "\nLED %d set to %d\n", UserLed, UserVal );
  p("%s ml(%d)i(%d)\n", TXT_MACRO,UserLed, UserVal);
  analogWrite( UserLed, UserVal );
  p( "%s", BORDER );
}

void intensity_menu()
{
  p( "\n a. %s ( %d )\n", HIGH_VAL_STR, HighVal );
  p( " b.  %s ( %d )\n", MID_VAL_STR, MidVal );
  p( " c.  %s ( %d )\n", LOW_VAL_STR, LowVal );
}

void FadeControls()
{
  char *arg = '\0';
  int state1 = UserState1;
  int state2 = UserState2;

  Serial.flush();
  p( "\n\nFade %s\n", CONTROL_SETTINGS );
  p( "%s fade [ %d ]?: ", LED_CHOICE, UserLed );
  while( !Serial.available() ) {
    ;
  }
  UserLed = get_user_int( UserLed );
  intensity_menu();
  p( "%s [ %d ]?: ", START_INTS, UserState1 );
  while( !Serial.available() ) {
    ;
  }
  arg = get_user_input();
  switch( *arg ) {
  case 'A':
  case 'a':
    UserState1 = HighVal;
    break;
  case 'B':
  case 'b':
    UserState1 = MidVal;
    break;
  case 'C':
  case 'c':
    UserState1 = LowVal;
    break;
  default:
    state1 = atoi( arg );
    if( ( state1 > 255 ) || ( state1 < 0 ) ) {
      state1=UserState1;
    } else {
      state1 = UserState1;
    }
    break;
  }
  intensity_menu();
  p( "%s [ %d ]?: ",END_INTS, UserState2 );
  while( !Serial.available() ) {
    ;
  }
  arg = get_user_input();
  switch( *arg ) {
  case 'A':
  case 'a':
    state2 = HighVal;
    break;
  case 'B':
  case 'b':
    state2 = MidVal;
    break;
  case 'c':
  case 'C':
    state2 = LowVal;
    break;
  default:
    state2 = atoi( arg );
    if( ( state2 > 255 ) || ( state2 < 0 ) ) {
      state2=UserState2;
    } else {
      state2 = UserState2;
    }
    break;
  }
  UserState2 = state2;
  p( "\n%s fade [ %d ]?: ", FREQ_CHOICE, UserFreq );
  while( !Serial.available() ) {
    ;
  }
  UserFreq = get_user_intlarge( UserFreq );
  p( "\n%s fade [ %d ]?: ", REPEAT_CHOICE, UserRepeat );
  while( !Serial.available() ) {
    ;
  }
  UserRepeat = get_user_int( UserRepeat );
  p("%s ml(%d)f(%d,%d,%d,%d)\n", TXT_MACRO,UserLed, UserState1, UserState2, UserFreq, UserRepeat);
  fade_led( UserLed, UserState1, UserState2, UserFreq, UserRepeat );
}

void PulseControls()
{
  char *arg = '\0';
  int sel = 0;
  int state1, state2;
  int ok;

  Serial.flush();
  p( "\n\nPulse %s\n", CONTROL_SETTINGS );
  p( "%s Pulse [ %d ]?: ",LED_CHOICE, UserLed );
  while( !Serial.available() ) {
    ;
  }
  UserLed = get_user_int( UserLed );
  intensity_menu();
  p( "%s [ %d ]?: ", START_INTS, UserState1 );
  while( !Serial.available() ) {
    ;
  }
  arg = get_user_input();
  switch( arg[0] ) {
  case 'a':
  case 'A':
    state1 = HighVal;
    break;
  case 'b':
  case 'B':
    state1 = MidVal;
    break;
  case 'c':
  case 'C':
    state1 = LowVal;
    break;
  default:
    state1 = atoi( arg );
    if( ( state1 > 255 ) || ( state1 < 0 ) ) {
      state1=UserState1;
    } else {
      state1 = UserState1;
    }
    break;
  }
  UserState1 = state1;
  p( "\n%s %d\n", START_INTS, UserState1 );
  intensity_menu();
  p( "%s [ %d ]?: ",END_INTS, UserState2 );
  while( !Serial.available() ) {
    ;
  }
  arg = get_user_input();
  switch( arg[0] ) {
  case 'a':
  case 'A':
    state2 = HighVal;
    break;
  case 'b':
  case 'B':
    state2 = MidVal;
    break;
  case 'c':
  case 'C':
    state2 = LowVal;
    break;
  default:
    state2 = atoi( arg );
    if( ( state2 > 255 ) || ( state2 < 0 ) ) {
      state2=UserState2;
    } else {
      state2 = UserState2;
    }
    break;
  }
  UserState2 = state2;
  p( "\n%s pulse [ %d ]?: ", FREQ_CHOICE, UserFreq );
  while( !Serial.available() ) {
    ;
  }
  UserFreq=get_user_intlarge( UserFreq );
  p( "\n%s pulse [ %d ]?: ", REPEAT_CHOICE, UserRepeat );
  while( !Serial.available() ) {
    ;
  }
  UserRepeat=get_user_int( UserRepeat );
  p("%s ml(%d)p(%d,%d,%d,%d)\n", TXT_MACRO,UserLed, UserState1, UserState2, UserFreq, UserRepeat);
  pulse_led( UserLed, UserState1, UserState2, UserFreq, UserRepeat );
}

int parse_macro( char *macro )
{
  int ok = 0;
  long int leds = 0;
  char *ch;
  char buf[ SMALL_BUFF ];
  int val1 = -1;
  int val2 = -1;
  int freq = -1;
  int repeat = -1;
  int wait = -1;
  int state = 0;
  int i, x;
  int scratch = 0;
  int mode = 0;

  set_leds( ALL_LEDS, 0 );
  p( "\nRun Macro [ %s ]\n", macro-1 );
  for( i=0; i<( MAX_MACRO_LEN - 1 ); i++ ) {
    ch = ( char * )( macro + i );
    switch( *ch ) {
    case 'l':
    case 'L':
      leds = 0;
      if( *( ch + 1 ) == '(' ) {
        i++;  // skip char
        memset( buf, 0, sizeof( buf ) );
        for( x=0; x<sizeof( buf ); x++ ) {
          i++;
          ch = ( char * )( macro + i );
          switch( *ch ) {
          case ',':
          case ')':
            scratch = atoi( buf );
            //p("got led #%d\n", scratch);
            SET_BIT( leds, scratch );
            if( *ch == ')' ) {
              for( x=0; x<MAX_LEDS; x++ ) {
                if( IS_BIT_SET( leds, x ) ) {
                  p( "+ LED #%d\n", x );
                }
              }
              x = sizeof( buf ); // stop here
            } else {
              memset( buf, 0, sizeof( buf ) );
              x = -1;
            }
            break;
          default:
            buf[x] = *ch;
            //p("buf[%d] = %c\n", x, *ch);
            break;
          }
        }
      } else {
        p( "LED err: %s", PARAM_ERR );
        ok = -1;
      }
      //leds = 0;
      val1 = -1;
      val2 = -1;
      freq = -1;
      wait = - 1;
      repeat = -1;
      mode = 0;
      break;
    case 'b':
    case 'B':
      i++;
      if( mode == 0 ) {
        p("\nBlink\n");
        mode = MODE_BLINK;
      } else {
        p( "%s",MODE_SEL_ERR );
      }
      for( x=0; x<sizeof( buf ); x++ ) {
        i++;
        ch = ( char * )( macro + i );
        switch( *ch ) {
        case ',':
        case ')':
          scratch = atoi( buf );
          //p("got led #%d\n", scratch);
          if( val1 == -1 ) {
            p( "got %s %d\n", END_INTS, scratch );
            val1 = scratch;
            x = -1;
          } else {
            if( freq == -1 ) {
              p( "got frequency %d\n", scratch );
              freq = scratch;
              x = -1;
            } else {
              if( repeat == -1 ) {
                p( "got repeat %d\n", scratch );
                repeat = scratch;
                blink_leds( leds, val1, freq, repeat );
                x = sizeof( buf );
              } else {
                p( "Blink set %s", PARAM_ERR );
              }
            }
          }
          memset( buf, 0, sizeof( buf ) );
          break;
        default:
          buf[x] = *ch;
          //p("buf[%d] = %c\n", x, *ch);
          break;
        }
      }
      //leds = 0;
      val1 = -1;
      val2 = -1;
      freq = -1;
      wait = - 1;
      repeat = -1;
      mode = 0;
      break;
    case 'f':
    case 'F':
    case 'p':
    case 'P':
      i++;
      if( mode == 0 ) {
        if( ( *ch == 'f' ) || ( *ch == 'F' ) ) {
          mode = MODE_FADE;
          p( "\nFade\n" );
        } else {
          mode = MODE_PULSE;
          p( "\nPulse\n" );
        }
      } else {
        p( "%s",MODE_SEL_ERR );
      }
      for( x=0; x<sizeof( buf ); x++ ) {
        i++;
        ch = ( char * )( macro + i );
        switch( *ch ) {
        case ',':
        case ')':
          scratch = atoi( buf );
          //p("got led #%d\n", scratch);
          if( val1 == -1 ) {
            p( "got %s %d\n",START_INTS, scratch );
            val1 = scratch;
            x = -1;
          } else {
            if ( val2 == -1 ) {
              p( "got %s %d\n",END_INTS, scratch );
              val2 = scratch;
              x = -1;
            } else {
              if( freq == -1 ) {
                p( "got frequency %d\n", scratch );
                freq = scratch;
                x = -1;
              } else {
                if( repeat == -1 ) {
                  p( "got repeat %d\n", scratch );
                  repeat = scratch;
                  if( mode == MODE_FADE ) {
                    fade_leds( leds, val1, val2, freq, repeat );
                  } else {
                    pulse_leds( leds, val1, val2, freq, repeat );
                  }
                  x = sizeof( buf );
                } else {
                  p( "set %s", PARAM_ERR );
                }
              }
            }
          }
          memset( buf, 0, sizeof( buf ) );
          break;
        default:
          buf[x] = *ch;
          //p("buf[%d] = %c\n", x, *ch);
          break;
        }
      }
      //leds = 0;
      val1 = -1;
      val2 = -1;
      freq = -1;
      wait = - 1;
      repeat = -1;
      mode = 0;
      break;
    case 'i':
    case 'I':
      if( mode == 0 ) {
        mode = MODE_SET;
        p( "\nIntensity\n" );
      } else {
        p( "%s",MODE_SEL_ERR );
      }
      i++;
      mode = MODE_SET;
      memset( buf,0, sizeof( buf ) );
      for( x=0; x<sizeof( buf ); x++ ) {
        i++;
        ch = ( char * )( macro + i );
        switch( *ch ) {
        case ')':
          if( freq == -1 ) {
            scratch = atoi( buf );
            p( "got %s %d\n", END_INTS, scratch );
            val1 = scratch;
            set_leds( leds, val1 );
            x = sizeof( buf );
          } else {
            p( "intensity %s", PARAM_ERR );
          }
          break;
        default:
          buf[x] = *ch;
          break;
        }
      }
      //leds = 0;
      val1 = -1;
      val2 = -1;
      freq = -1;
      wait = - 1;
      repeat = -1;
      mode = 0;
      break;
    case 'w':
    case 'W':
      if( ( mode == 0 ) &&  ( *( ch+1 ) == '(' ) ) {
        i++;
        p( "\nWait\n" );
        mode = MODE_WAIT;
        memset( buf,0, sizeof( buf ) );
        for( x=0; x<sizeof( buf ); x++ ) {
          i++;
          ch = ( char * )( macro + i );
          switch( *ch ) {
          case ')':
            if( freq == -1 ) {
              scratch = atoi( buf );
              p( "got freq %d\n", scratch );
              freq = scratch;
              delay( freq );
              x = sizeof( buf );
            } else {
              p( "Wait set %s", PARAM_ERR );
            }
            break;
          default:
            buf[x] = *ch;
            break;
          }
        }
      } else {
        p( "%s",MODE_SEL_ERR );
      }
      //leds = 0;
      val1 = -1;
      val2 = -1;
      freq = -1;
      wait = - 1;
      repeat = -1;
      mode = 0;
      break;
    case 'c':
    case 'C':
      i++;
      p( "Clear\n" );
      set_leds( ALL_LEDS, 0 );
      //leds = 0;
      val1 = -1;
      val2 = -1;
      freq = -1;
      wait = - 1;
      repeat = -1;
      mode = 0;
      break;
    }
  }// end of loop through macro
  //p("led = %d\n", leds );
  return ok;
}

void unrecognized()
{
  p( "\nError!\n" );
}

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


Restored arduino file

Restored arduino file

int led = 0;

char incomingByte = 0;
char message[4];
int index = 0;

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

void readMessage() {
  while(Serial.available() > 0) {
    incomingByte = Serial.read();
    message[index++] = incomingByte;
    message[index] = '\0';
  }
}

void cleanMessage() {
  message[(index = 0)] = '\0';
}

void loop() {
  readMessage();
  if(strcmp(message,"REQ")  == 0) {
    Serial.println(analogRead(A0));
  } else if (strcmp(message,"ON")  == 0) {
    digitalWrite(led, HIGH);
    Serial.println("OK");
  } else if (strcmp(message,"OFF")  == 0) {
    digitalWrite(led, LOW);
    Serial.println("OK");
  } else if(message[0] != '\0') {
    Serial.println("NOK");
  }
  cleanMessage();
}

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


Program to accept slope and intercept and return data mapped to 1023

/*
VernierDetermineSlopeIntercept (v 2015.02)
Reads a Vernier analog (BTA) Sensor connected to pin A0 of the Arduino.
This sketch displays the time and digital readout from the sensor
readings on the Serial Monitor.
As written, the readings will be displayed every half second.
Change the variable TimeBetweenReadings to change the rate.

 See www.vernier.com/arduino for more information.
*/
/*
////////////////////////////////////////
The data from this sketch will allow you to determine the slope and
intercept of the sensor - assuming a linear relationship. Once this
is determined another sketch called "VernierAnalog Sensor" can be used
to read values of the sensor.
//See www.vernier.com/products/sensors.
*/
int TimeBetweenReadings = 500; // in ms
float Count;
float Voltage;
float SensorReading;
int ReadingNumber=0;
float Time;
/////////////////////////////////////////

void setup()
{
  Serial.begin(9600); //initialize serial communication at 9600 baud
  Serial.println("Vernier Format Special");
  Serial.println("Readings taken using Ardunio to determine slope and intercept");
  Serial.println("Data Set");
  Serial.print("Time");//long name
  Serial.print("\t"); //tab character
  Serial.print("(s)");//units
  Serial.print("\t");
  Serial.print("Count");
  Serial.print("\t");
  Serial.print("Voltage");
  Serial.print("\t");
  Serial.println("(V)");
}
void loop()
{

//the print below does the division first to avoid overflows
  Serial.print("\t");
  Serial.print(ReadingNumber/1000.0*TimeBetweenReadings);
  Serial.print("\t");
  Count = analogRead(A0);
  Voltage = Count / 1023 * 5.0;// convert from count to raw voltage
  Serial.print (Count);
  Serial.print ("\t");
  Serial.println (Voltage);
  delay(TimeBetweenReadings);// delay in between reads for stability
  ReadingNumber++;
}

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


Fixed bug where skyprobe test would hang.

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


added arduino source code

added arduino source code

#include <AFMotor.h>

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

int motorSpeed = 200;

String command = "";

void setup()
{
  Serial.begin(9600);
  Serial.print("Ready\n");
}

void loop()
{
  char character;

  while(Serial.available()) {
    character = Serial.read();
    command.concat(character);
  }

  if (command != "") {
    String result = handleCommand(command);
    Serial.print(result + "\n");
    command = "";
  }

  delay(250);
}

String handleCommand(String command) {
  String result;

  if(command == "check battery status") {
    result = checkBatteryStatus();
  } else if(command == "forward") {
    result = forward();
  } else if(command == "backward") {
    result = backward();
  } else if(command == "left") {
    result = left();
  } else if(command == "right") {
    result = right();
  } else if(command == "stop") {
    result = halt();
  } else {
    result = "unknown command: " + command;
  }

  return result;
}

String forward()
{
  turnMotorsOn();

  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);

  return "ok";
}

String backward()
{
  turnMotorsOn();

  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);

  return "ok";
}

String halt()
{
  turnMotorsOff();

  return "ok";
}

String left()
{
  turnMotorsOn();

  motor1.run(FORWARD);
  motor2.run(BACKWARD);
  motor3.run(FORWARD);
  motor4.run(BACKWARD);

  delay(250);

  turnMotorsOff();

  return "ok";
}

String right()
{
  turnMotorsOn();

  motor1.run(BACKWARD);
  motor2.run(FORWARD);
  motor3.run(BACKWARD);
  motor4.run(FORWARD);

  delay(250);

  turnMotorsOff();

  return "ok";
}

String checkBatteryStatus()
{
  return "battery status is " + String(random(0, 1));
}

void turnMotorsOff()
{
  motor1.setSpeed(0);
  motor2.setSpeed(0);
  motor3.setSpeed(0);
  motor4.setSpeed(0);
}

void turnMotorsOn()
{
  motor1.setSpeed(motorSpeed);
  motor2.setSpeed(motorSpeed);
  motor3.setSpeed(motorSpeed);
  motor4.setSpeed(motorSpeed);
}

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


that is a sceleton of the movement control

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/trinamic/T-Bone.git/'


Basic Arduino Sketch setup and initialising the project

/*
  Pin Settings
*/
const int DS_pin = 8;
const int STCP_pin = 9;
const int SHCP_pin = 10;

const int MR_pin = 7;

/*
  Init the System
*/
void setup(){
  // initialize serial:
  Serial.begin(9600);

  pinMode(DS_pin, OUTPUT);
  pinMode(STCP_pin, OUTPUT);
  pinMode(SHCP_pin, OUTPUT);
  pinMode(MR_pin, OUTPUT);

  writeShift();
}

/*
  Stores the Values of the registers
*/
boolean shiftRegValues[32];

/*
  Writes the content of the shift register value array out.
*/
void writeShift(){
  Serial.println("-->writeShift");
  Serial.print("-->");

  digitalWrite(SHCP_pin, LOW);

  for(int i = 31; i >= 0; i--){
    Serial.print(shiftRegValues[i]);

    digitalWrite(STCP_pin, LOW);
    digitalWrite(DS_pin, shiftRegValues[i]);
    digitalWrite(STCP_pin, HIGH);
  }

  Serial.println("");

  digitalWrite(SHCP_pin, HIGH);
}

/*
  Main LOOP
*/
void loop(){
  // Reset the shift registers
  digitalWrite(MR_pin, LOW);
  digitalWrite(MR_pin, HIGH);

  // DO some magic

  writeShift();
  delay(500);

}

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


Switch to hardware MIDI

Switch to hardware MIDI

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


Add code to read temperature and light to display on a LCD

/*
 * Read temperature and light and display on the LCD
 *
 * For: Arduino Uno R3
 *
 * Parts:
 * 1x LCD (16x2 characters)
 * 1x 10 kΩ variable resistor
 * 1x 10 KΩ resistor
 * 1x 220 Ω resitor
 * 1x Photocell
 * 1x TMP36 temperature sensor
 */
#include <LiquidCrystal.h>

int temperaturePin = 0;
int lightPin = 1;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // Set columns and rows to use
  lcd.begin(16, 2);
  // Start on the first row
  lcd.print("Temp :      C");
}

void loop() {
  int temperatureReading = analogRead(temperaturePin);
  float temperatureInVolts = (temperatureReading / 1024.0) * 5.0;
  float temperatureInCelcius = (temperatureInVolts - 0.5) * 100;
  // Jump 6 columns
  lcd.setCursor(6, 0);
  lcd.print(temperatureInCelcius);

  int lightReading = analogRead(lightPin);
  // Jump to the next row
  lcd.setCursor(0, 1);
  lcd.print("Light:           ");
  lcd.setCursor(6, 1);
  lcd.print(lightReading);
  delay(1000);
}

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


add code arduino

add code arduino

#include <Servo.h>

int octetReception=0;
long nombreReception=0;

const int posMin=500;
const int posMax=2300;

const int brocheServo1=10;
const int brocheServo2=9;

Servo servo1;
Servo servo2;

int angleServo1=0;
int angleServo2=0;

void setup() {
  Serial.begin(115200);
  servo1.attach(brocheServo1, posMin, posMax);
  servo2.attach(brocheServo2, posMin, posMax);
}

void loop() {
  while (Serial.available()>0) {
    octetReception=Serial.read();
    if (octetReception==10 || octetReception==44) {
      Serial.print ("Nombre recu = ");
      Serial.println (nombreReception);
      if (octetReception==44){
        angleServo1=nombreReception;
      }
      else{
        angleServo2=nombreReception;
      }
      servo2.write(angleServo2);
      servo1.write(angleServo1);
      nombreReception=0;
      delay(10);
      break;
    }
    else {
      octetReception=octetReception-48;
      if ((octetReception>=0)&&(octetReception<=9))
      nombreReception = (nombreReception*10)+octetReception;
      else Serial.println("La chaine n'est pas un nombre valide !");
      delay(1);
    }
  }
}

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


Enable ROS Subscriber to allow rpi control of LIDAR servo

Needs work... That is, it needs the requisite libraries installed and it needs to actually be tested because it probably won't work :frowning:

LIDAR Data Extraction/LidarCommands/Currently Used/lidar_servo_driver/lidar_servo_driver.ino

error: pathspec 'LIDAR' did not match any file(s) known to git
error: pathspec 'Data' did not match any file(s) known to git
error: pathspec 'Extraction/LidarCommands/Currently' did not match any file(s) known to git
error: pathspec 'Used/lidar_servo_driver/lidar_servo_driver.ino' did not match any file(s) known to git


Added arduino stuff

Added arduino stuff

#define STEP 6
#define DIR 5
#define DISABLE 7

#define ROT_PER_SEC 2.5
#define STEP_PER_ROT 100
#define USEC_PER_STEP_2 (1000000UL/(ROT_PER_SEC * STEP_PER_ROT * 2))

static inline void step() {
  digitalWrite(STEP, 1);
  delayMicroseconds(USEC_PER_STEP_2);
  digitalWrite(STEP, 0);
  delayMicroseconds(USEC_PER_STEP_2);
}

static inline void steps(int8_t n) {
  if(n < 0) {
    n = -n;
    digitalWrite(DIR, 1);
  } else {
    digitalWrite(DIR, 0);
  }

  while(n--) {
    step();
  }
}

void setup() {
  Serial.begin(9600);
  pinMode(STEP, OUTPUT);
  pinMode(DIR, OUTPUT);
  pinMode(DISABLE, OUTPUT);

  digitalWrite(DISABLE, 1);

  Serial.write("Ready.\r\n");
}

int r = 0;

void loop() {
  if(Serial.available()) {
    int c = Serial.read();
    if(c == '.') {
      r = 0;
      step();
    }
    if(c >= '0' && c <= '9') {
      r = r * 10 + c - '0';
    }
    if(c == '\r') {
      while(r > 0) {
        digitalWrite(DISABLE, 0);
        delay(50);
        steps(STEP_PER_ROT*5/8);
        delay(10);
        steps(-STEP_PER_ROT/2);
        delay(10);
        steps(STEP_PER_ROT/8);
        delay(10);
        steps(-STEP_PER_ROT/2-STEP_PER_ROT/8);
        delay(50);
        steps(STEP_PER_ROT-STEP_PER_ROT*5/8);
        delay(100);

        steps(-STEP_PER_ROT*3/8);
        delay(50);
        steps(STEP_PER_ROT);
        delay(50);
        steps(-STEP_PER_ROT+STEP_PER_ROT*3/8);

        r--;
      }
      delay(500);
      digitalWrite(DISABLE, 1);
      r = 0;
    }

    if(c != '\n') {
      Serial.write(c);
      if(c == '\r') {
        Serial.write('\n');
      }
    }
  }
}

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


arduino: adding the arduino code

arduino: adding the arduino code

int redPin = 9;
int greenPin = 10;
int bluePin = 11;

void setup()
{
  Serial.begin(9600);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void setColor(String& color) {
  long number = strtol( &color[0], NULL, 16);

  long r = number >> 16;
  long g = number >> 8 & 0xFF;
  long b = number & 0xFF;

  // ---------------------------------
  // PNP transistors controls the values
  // 0v (base pin) => 5v (emitter pin);
  // 5v (base pin) => 0v (emitter pin);
  // so i need to patch the values (or to use NPN transistors)

  r = 255 - r;
  g = 255 - g;
  b = 255 - b;
  // ---------------------------------

  analogWrite(redPin, r);
  analogWrite(greenPin, g);
  analogWrite(bluePin, b);
}

void loop()
{
  if (Serial.available()) {
    delay(100);
    while (Serial.available() > 0) {
      String color = Serial.readString();
      setColor(color);
    }
  }
}

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


Refactor / code cleanup

Refactor / code cleanup

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


Initial commit

Initial commit

Arduino sketch for the joystick

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

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 accelgyro;
//MPU6050 accelgyro(0x69); // <-- use for AD0 high

int16_t ax, ay, az;
int16_t gx, gy, gz;
int jx, jy;

// uncomment "OUTPUT_READABLE_ACCELGYRO" if you want to see a tab-separated
// list of the accel X/Y/Z and then gyro X/Y/Z values in decimal. Easy to read,
// not so easy to parse, and slow(er) over UART.
#define OUTPUT_READABLE_ACCELGYRO

// uncomment "OUTPUT_BINARY_ACCELGYRO" to send all 6 axes of data as 16-bit
// binary, one right after the other. This is very fast (as fast as possible
// without compression or data loss), and easy to parse, but impossible to read
// for a human.
//#define OUTPUT_BINARY_ACCELGYRO

#define LED_PIN 13
#define BUTTON_PIN 2

bool blinkState = false;
int buttonState = LOW;

int JOYSTICK_PIN_X = A0;
int JOYSTICK_PIN_Y = A1;

void setup() {
    // join I2C bus (I2Cdev library doesn't do this automatically)
    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(38400);

    // initialize device
    Serial.println("Initializing I2C devices...");
    accelgyro.initialize();

    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

    // use the code below to change accel/gyro offset values

    Serial.println("Updating internal sensor offsets...");
    // 2426;681;92;-40;22;-42
    Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76
    Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359
    Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688
    Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0
    Serial.print("\n");
    accelgyro.setXAccelOffset(-1923);
    accelgyro.setYAccelOffset(-662);
    accelgyro.setZAccelOffset(1835);
    accelgyro.setXGyroOffset(46);
    accelgyro.setYGyroOffset(-11);
    accelgyro.setZGyroOffset(44);
    Serial.print(accelgyro.getXAccelOffset()); Serial.print("\t"); // -76
    Serial.print(accelgyro.getYAccelOffset()); Serial.print("\t"); // -2359
    Serial.print(accelgyro.getZAccelOffset()); Serial.print("\t"); // 1688
    Serial.print(accelgyro.getXGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getYGyroOffset()); Serial.print("\t"); // 0
    Serial.print(accelgyro.getZGyroOffset()); Serial.print("\t"); // 0
    Serial.print("\n");

    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
    pinMode(BUTTON_PIN, INPUT);
}

void loop() {
    delay(100); // delay read for 100 ms

	if(Serial)
	{
		// read raw accel/gyro measurements from device
		accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

		// these methods (and a few others) are also available
		//accelgyro.getAcceleration(&ax, &ay, &az);
		//accelgyro.getRotation(&gx, &gy, &gz);

		// convert the raw accelerometer data into a range from -1 to 1 for Unity to consume
		float pax = 1.0 * (ax / 20000.0);
		float pay = 1.0 * (ay / 20000.0);
		float paz = 1.0 * (az / 20000.0);

		// capture joystick input from the analog
		jx = analogRead(JOYSTICK_PIN_X);
		jy = analogRead(JOYSTICK_PIN_Y);

		//convert the raw analog joystick data into a range from -1 to 1 for Unity to consume
		float pjx = ConvertRawValue(jx);
		float pjy = ConvertRawValue(jy);

		bool buttonState = digitalRead(BUTTON_PIN);
		digitalWrite(LED_PIN, buttonState);

    #ifdef OUTPUT_READABLE_ACCELGYRO
        // display tab-separated accel/gyro x/y/z values
        Serial.print("a;");
        Serial.print(pax); Serial.print(";");
        Serial.print(pay); Serial.print(";");
        Serial.print(paz); Serial.print(";");
        Serial.print(gx); Serial.print(";");
        Serial.print(gy); Serial.print(";");
        Serial.println(gz);
        Serial.print("j;");
        Serial.print(pjx); Serial.print(";");
        Serial.print(pjy); Serial.println();
        Serial.print("b;"); Serial.print(buttonState); Serial.println();
    #endif

    #ifdef OUTPUT_BINARY_ACCELGYRO
        //Serial.write((uint8_t)(ax >> 8)); Serial.write((uint8_t)(ax & 0xFF));
        //Serial.write((uint8_t)(ay >> 8)); Serial.write((uint8_t)(ay & 0xFF));
        //Serial.write((uint8_t)(az >> 8)); Serial.write((uint8_t)(az & 0xFF));
        //Serial.write((uint8_t)(gx >> 8)); Serial.write((uint8_t)(gx & 0xFF));
        //Serial.write((uint8_t)(gy >> 8)); Serial.write((uint8_t)(gy & 0xFF));
        //Serial.write((uint8_t)(gz >> 8)); Serial.write((uint8_t)(gz & 0xFF));
    #endif

    }
	else
	{
		Serial.flush();
	}

    // blink LED to indicate activity
    //blinkState = !blinkState;
    //digitalWrite(LED_PIN, buttonState);
}

float ConvertRawValue(float rawValue)
{
    if (rawValue < 512 && rawValue > 0)
    {
        return -1.0 - (-1.0 * (rawValue / 512));
    }
    else if (rawValue > 512 && rawValue < 1024)
    {
        return 1.0 - (1.0 * ((1024 - rawValue) / 512));
    }
    else if (rawValue == 0)
    {
        return -1.0;
    }
    else if (rawValue == 1024)
    {
        return 1.0;
    }
}

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


Added arduino sketch, waiting for special input to activate LED.

    int led = 13; // LED connected to digital pin 13
    int recv = 0; // byte received on the serial port

    void setup() {
      // initialize onboard LED (led) and serial port
      pinMode(led, OUTPUT);
      Serial.begin(9600);
    }

    void loop()
    {
      // if serial port is available, read incoming bytes
      if (Serial.available() > 0) {
        recv = Serial.read();

        // if 'x' (decimal 120) is received, turn LED on
        // anything other than 120 is received, turn LED off
        if (recv == 120){
          digitalWrite(led, HIGH);
        } else {
          digitalWrite(led, LOW);
        }

        // confirm values received in serial monitor window
        Serial.print("--Arduino received: ");
        Serial.println(recv);
      }
    }

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


Create SerialHello.ino

Create SerialHello.ino

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

void loop() {
  delay(1000);
  Serial.println("Hello World!");
}

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


Valor do vot

Valor do vot

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/ciandt-dev/garage-kelvin-celsius.git/'


Loop program implemented

Loop program implemented

Irrigation Loop implemented

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


support for RevE board

support for RevE board

Flipping the display and changing of pinouts for switch

/*
 * OLED, nav button, neopixels
 *
 * For ESP32-WROOM board (OLED, battery, full pin breakout) and custom PCB
 * Don't forget to turn the device on, or it won't show up in the port list
 * If UART disappears from port list, change board to UNO and attach an UNO
 *
 * Board:   Wemos Wifi&Bluetooth Battery
 * Flash:   80Mhz
 * Upload:  921600
 * Port:    cu.SLAB_USBtoUART
 * Prog:    AVRISPmkII
 *
 * ESP pins to watch out for:
 * 4,5          OLED
 * 0,2,5,12,15  Strapping pins (boot-related)
 * 34,35        Input-only
 *
 */

//this is inside the required library U8g2
#include <U8x8lib.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// OLED
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ 4, /* data=*/ 5, /* reset=*/U8X8_PIN_NONE );

// Neopixels
#define PIN       17
#define NUMPIXELS 10
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
//int delayval = 500;

const int led = 16;
//int navBtn = 0;

// Nav button
const int buttonPin1 = 18;   // right
const int buttonPin2 = 16;   // select
const int buttonPin3 = 23;   // up
const int buttonPin4 = 19;   // down
const int buttonPin5 = 14;   // left

// https://github.com/Serpent999/ESP32_Touch_LED/blob/master/Touch_LED/Touch_LED.ino
int buff(int pin){
  int out = (25 - touchRead(pin));             //  adjust touch sensitivity here
  if (out > 0 ){
    return (out + 2);
  }else{
    return 0;
  }
}

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  u8x8.begin();
  u8x8.setFont(u8x8_font_pxplusibmcga_r);
  //u8x8.setFlipMode(1);        //remove if screen is flipped

  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT);
  pinMode(buttonPin5, INPUT);

  strip.begin();              // This initializes the NeoPixel library
  strip.show();               // Begin with all LEDs turned off
  strip.setBrightness(5);     // These goddamn things are bright

}

void loop(){

  pollMenu();

/*
  digitalWrite(led,LOW);  //onboard LED is on when pulled LOW
  delay(100);
  digitalWrite(led,HIGH);
*/

  //delay(3000);

}

void pollMenu(){

  // LOW is button pressed
  u8x8.setFont(u8x8_font_victoriamedium8_u);

  // Center button
  if(digitalRead(buttonPin2) == 0){
    u8x8.drawString(0,0,"X BUTTON");
    chase(strip.Color(0, 255, 0));
  }else{
    u8x8.drawString(0,0,"  BUTTON");
  }

  // Upper right
  if(digitalRead(buttonPin1) == 0){
    u8x8.drawString(0,1,"X RIGHT");
    chase(strip.Color(255, 0, 0));
  }else{
    u8x8.drawString(0,1,"  RIGHT");
  }

  // Upper left
  if(digitalRead(buttonPin3) == 0){
    u8x8.drawString(0,2,"X UP");
    chase(strip.Color(0, 0, 255));
  }else{
    u8x8.drawString(0,2,"  UP");
  }

  // Lower right
  if(digitalRead(buttonPin4) == 0){
    u8x8.drawString(0,3,"X DOWN");
    chase(strip.Color(255, 0, 255));
  }else{
    u8x8.drawString(0,3,"  DOWN");
  }

  // Lower left
  if(digitalRead(buttonPin5) == 0){
    u8x8.drawString(0,4,"X LEFT");
    chase(strip.Color(255, 255, 255));
  }else{
    u8x8.drawString(0,4,"  LEFT");
  }
  //String touchData = String(buff(T9));
  //Serial.println(touchData);
  u8x8.setCursor(0, 5);
  u8x8.print("  TOUCH " + String(buff(T9)));
}

static void chase(uint32_t c) {
  for(uint16_t i=0; i<strip.numPixels()+4; i++) {
      strip.setPixelColor(i  , c); // Draw new pixel
      strip.setPixelColor(i-4, 0); // Erase pixel a few steps back
      strip.show();
      delay(25);
  }
}

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


detect water function

detect water function

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


Changed backlight setting

Changed backlight setting

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


Focussing on Rollups logic

Focussing on Rollups logic

include an interrupt to confirm the opening of the greenhouse.

#include <OneWire.h>
#include <DallasTemperature.h>

#define Open 1
#define Close 0

#define ONE_WIRE_BUS 2
#define ROLLUP1_OPEN  12//relais on/off - moteur1
#define ROLLUP1_CLOSE  11 //relais gauche/droite - moteur1
#define FAN  8 //relais ventilation forcée
#define CHAUFFAGE1 7 //relais fournaise1
#define CHAUFFAGE2 6 // relais fournaise2

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

const int ON = HIGH;
const int OFF = LOW;

byte opened = 100;
byte openTarget = 0;

boolean heating1 = false;                     //fournaise 1 éteinte par défaut
boolean heating2 = false;                     //fournaise 2 éteinte par défaut
boolean fan = false;                          //VENTilation forcée éteinte par défaut
float greenhouseTemperature = 20.0;               //température par défaut : 20C (ajusté après un cycle)

int TEMP_CIBLE = 20;          //température cible par défaut : 20C (ajustée après un cycle))
//temp cible pour équipement chauffage/refroidissement
int TEMP_ROLLUP1 = TEMP_CIBLE+1;
int TEMP_ROLLUP2 = TEMP_CIBLE+2;
int TEMP_ROLLUP3 = TEMP_CIBLE+3;
int TEMP_ROLLUP4 = TEMP_CIBLE+4;
int TEMP_VENTILATION = TEMP_CIBLE+5;
int TEMP_FOURNAISE1 = TEMP_CIBLE-2;
int TEMP_FOURNAISE2 = TEMP_CIBLE-4;

byte HYST_ROLLUP = 2;           //hysteresis rollup
byte HYST_VENT = 2;             //hysteresis ventilation
byte HYST_FOURNAISE1 = 2;       //hysteresis fournaise 1
byte HYST_FOURNAISE2 = 2;       //hysteresis fournaise 2

long OPENING_TIME;       //temps de rotation des moteurs pour ouvrir d'un quart de tour(en mili-secondes)
long CLOSING_TIME;       //temps de rotation des moteurs pour fermer d'un quart de tour(en mili-secondes)
long PAUSE_TIME;         //temps d'arrêt entre chaque ouverture/fermeture(en mili-secondes)
//incréments d'ouverture(nombre d'incréments d'ouverture = PCT_OPEN/NB_OF_STEPS_IN_ANIMATION = 25/5 = 5 incréments d'ouverture)
const int PCT_OPEN = 25;
const int NB_OF_STEPS_IN_ANIMATION = 5; //doit être un divisible de PCT_OPEN
//Autres variables
const int SLEEPTIME = 900; //temps de pause entre chaque exécution du programme(en mili-secondes)

volatile byte rollupState = LOW;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  sensors.begin();

  pinMode(ROLLUP1_OPEN, OUTPUT);
  digitalWrite(ROLLUP1_OPEN, LOW);
  pinMode(ROLLUP1_CLOSE, OUTPUT);
  digitalWrite(ROLLUP1_CLOSE, LOW);
  pinMode(CHAUFFAGE1, OUTPUT);
  digitalWrite(CHAUFFAGE1, LOW);
  pinMode(CHAUFFAGE2, OUTPUT);
  digitalWrite(CHAUFFAGE2, LOW);
  pinMode(FAN, OUTPUT);
  digitalWrite(FAN, LOW);
  attachInterrupt(digitalPinToInterrupt(2), confirmOpening, CHANGE);

  //Remise à niveau des rollup
  Reset();
}

void loop() {
  // put your main code here, to run repeatedly:
  //--------------DS18B20--------------------
  sensors.requestTemperatures();
  greenhouseTemperature = sensors.getTempCByIndex(0);
  //--------------Relais--------------------

  //Programme d'ouverture/fermeture des rollups à 4 paliers
  if ((opened = 0)&&(greenhouseTemperature > TEMP_ROLLUP1)){
    openTarget = 25;
    openSides();
  }
  else if ((opened = 1)&&(greenhouseTemperature > TEMP_ROLLUP2)){
    openTarget = 50;
    openSides();
  }
  else if ((opened = 2)&&(greenhouseTemperature > TEMP_ROLLUP3)){
    openTarget = 75;
    openSides();
  }
  else if ((opened = 3)&&(greenhouseTemperature > TEMP_ROLLUP4)){
    openTarget = 100;
    openSides();
  }
  else if ((opened = 4)&&(greenhouseTemperature < (TEMP_ROLLUP4 - HYST_ROLLUP))) {
    openTarget = 75;
    closeSides();
  }
  else if ((opened = 3)&&(greenhouseTemperature < (TEMP_ROLLUP3 - HYST_ROLLUP))) {
    openTarget = 50;
    closeSides();
  }
  else if ((opened = 2)&&(greenhouseTemperature < (TEMP_ROLLUP2 - HYST_ROLLUP))) {
    openTarget = 25;
    closeSides();
  }
  else if ((opened = 1)&&(greenhouseTemperature < (TEMP_ROLLUP1 - HYST_ROLLUP))) {
    openTarget = 0;
    closeSides();
  }

  //Programme fournaise1
  if (greenhouseTemperature < TEMP_FOURNAISE1) {
    setHeater1(ON);
  }
  else if (greenhouseTemperature > (TEMP_FOURNAISE1 + HYST_FOURNAISE1)) {
    setHeater1(OFF);
  }
  //Programme fournaise2
  if (greenhouseTemperature < TEMP_FOURNAISE2) {
    setHeater2(ON);
  }
  else if (greenhouseTemperature > (TEMP_FOURNAISE2 + HYST_FOURNAISE2)) {
    setHeater2(OFF);
  }
  //Programme ventilation forcée
  if ((greenhouseTemperature > TEMP_VENTILATION)&&(rollupState == HIGH)) {
    setFan(ON);
  } else if ((greenhouseTemperature < (TEMP_VENTILATION - HYST_VENT))||(rollupState == LOW)) {
    setFan(OFF);
  }
}

void Reset(){
    Serial.println(F("Resetting position"));
  for (int i = 0; i < 5; i++) {
    closeSides();
  }
  Serial.println(F("Resetting done"));
}

//Affichage du % d'ouverture des rollup
void setOpenedStatus(int pctIncrease) {
  opened += pctIncrease;
  if (opened < 0) {
    opened = 0;
  } else if (opened > 100) {
    opened = 100;
  }
  Serial.print(F("    "));
  Serial.println(opened);
}

//Exécution de la séquence d'ouverture/fermeture
void animate(int movement, int action) {
  for (int i = 0; i < NB_OF_STEPS_IN_ANIMATION; i++) {
    if (action == Open){
      delay(OPENING_TIME / NB_OF_STEPS_IN_ANIMATION);}
    else if (action == Close){
      delay(CLOSING_TIME / NB_OF_STEPS_IN_ANIMATION);}
    setOpenedStatus(movement * PCT_OPEN / NB_OF_STEPS_IN_ANIMATION);
  }
}

//Programme d'ouverture des rollup
void openSides() {
  if (opened < 100) {
    Serial.println(F(""));
    Serial.println(F("  Opening"));
    digitalWrite(ROLLUP1_OPEN, ON);
    //digitalWrite(ROLLUP2_OPEN, ON);
    animate(1, Open);
    digitalWrite(ROLLUP1_OPEN, OFF);
    //digitalWrite(ROLLUP2_OPEN, OFF);
    Serial.println(F("  Done opening"));
    delay(PAUSE_TIME);
  }
}

//Programme de fermeture des rollups
void closeSides() {
  if (opened > 0) {
    Serial.println(F(""));
    Serial.println(F("  Closing"));
    //digitalWrite(ROLLUP2_CLOSE, ON);
    animate(-1, Close);
    digitalWrite(ROLLUP1_CLOSE, OFF);
    //digitalWrite(ROLLUP2_CLOSE, OFF);
    Serial.println(F("  Done closing"));
    delay(PAUSE_TIME);
  }
}

//État de la première fournaise
void setHeater1(int heaterCommand1) {
  if ((heaterCommand1 == ON) && (heating1 == false)) {
    Serial.println(F(""));
    Serial.println(F("  Start heating1"));
    heating1 = true;
    digitalWrite(CHAUFFAGE1, ON);
  } else if ((heaterCommand1 == OFF) && (heating1 == true)) {
    Serial.println(F(""));
    Serial.println(F("  Stop heating1"));
    heating1 = false;
    digitalWrite(CHAUFFAGE1, OFF);
  }
}

//État de la deuxième fournaise
void setHeater2(int heaterCommand2) {
  if ((heaterCommand2 == ON) && (heating2 == false)) {
    Serial.println(F(""));
    Serial.println(F("  Start heating2"));
    heating2 = true;
    digitalWrite(CHAUFFAGE2, ON);
  } else if ((heaterCommand2 == OFF) && (heating2 == true)) {
    Serial.println(F(""));
    Serial.println(F("  Stop heating2"));
    heating2 = false;
    digitalWrite(CHAUFFAGE2, OFF);
  }
}

//État de la ventilation
void setFan(int fanCommand) {
  if ((fanCommand == ON) && (fan == false)) {
    Serial.println(F(""));
    Serial.println(F("  Start fan"));
    fan = true;
    digitalWrite(FAN, ON);
  } else if ((fanCommand == OFF) && (fan == true)) {
    Serial.println(F(""));
    Serial.println(F("  Stop fan"));
    fan = false;
    digitalWrite(FAN, OFF);
  }
}

void confirmOpening() {
  rollupState =! rollupState;
}

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


Add RC car firmware

Add RC car firmware

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/embeddedemily/ember-agaricglow.git/'


relocated arduino code for impact & pulloff testing: MC wants separate tools for each test instead of a single program

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


update

update

/*
Penélope
Adriana Marmorek

By: Andrés Luján y Karo Ladino
*/

#include <SPI.h>
#include <Ethernet.h>
#include <SoftwareSerial.h>
#include <ArduinoJson.h>

SoftwareSerial Thermal(5, 6);
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "lovefrompenelope.herokuapp.com";    // name address for Google (using DNS)

int heatTime = 80;
int heatInterval = 255;
char printDensity = 15;
char printBreakTime = 15;
//int 3,5,8
int zero=0;
boolean connected = false;

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  pinMode(3, OUTPUT); //Twitter
    pinMode(9, OUTPUT); // Printing
      pinMode(8, OUTPUT); //Shredder

  // Open serial communications and wait for port to open:
  Serial.begin(57600);
  Thermal.begin(19200); // to write to our new printer
  initInternet();
  initPrinter();

}

void initInternet() {
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    connected = true;
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
    Thermal.println("I can't find you love");
    connected = false;
    Thermal.write(10);
    Thermal.write(10);
    Thermal.write(10);
  }
}

void initPrinter()
{
 //Modify the print speed and heat
 Thermal.write(27);
 Thermal.write(55);
 Thermal.write(7); //Default 64 dots = 8*('7'+1)
 Thermal.write(heatTime); //Default 80 or 800us
 Thermal.write(heatInterval); //Default 2 or 20us
 //Modify the print density and timeout
 Thermal.write(18);
 Thermal.write(35);
 int printSetting = (printDensity<<4) | printBreakTime;
 Thermal.write(printSetting); //Combination of printDensity and printBreakTime
 Serial.println("Printer ready");
 Thermal.println("Where are you, love?");
 Thermal.println("Adriana Marmorek");
 Thermal.write(10);
 Thermal.write(10);
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  // Make a HTTP request:

  if (connected) {
   digitalWrite(3, HIGH);
   delay(1000);
   digitalWrite(3, LOW);
   delay(1000);
   digitalWrite(3, HIGH);
   delay(1000);
   digitalWrite(3, LOW);

    client.println("GET / HTTP/1.1");
    client.println("Content-Type: application/json;charset=utf-8");
    client.println("Host: lovefrompenelope.herokuapp.com");
    client.println("Connection: keep-alive");
    client.println();
    String tweet = ""; ///-
    boolean read = false; ///-
    while (client.available()) {
      char c = client.read();
      if (c == '{') {
        read = true;
      }
//    else if (c == '}') {
//      read = false;
//    }
      if (read == true) {
        tweet += c;
      }
    }
// tweet += "}";
  Serial.println(tweet);
  Serial.println(tweet.length());
    //char json[300];
  //tweet.toCharArray(json, 300);
  StaticJsonBuffer<400> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(tweet);
  const char* name = root["name"];
  const char* user = root["user"];
  const char* text = root["text"];
  const char* date = root["date"];

  String header = "";
  Serial.println(name);
  Serial.println(user);
  Serial.println(text);
  Serial.println(date);

   // Name and date
   Thermal.println(name);
   Thermal.write(27);
   Thermal.write(45);
   Thermal.write(1);
   Thermal.println(date);

   // User and text
   Thermal.write(27);
   Thermal.write(45);
   Thermal.write(zero);
   Thermal.println(user); //31 caracteres,
   Thermal.println(text); //31 caracteres,
   Thermal.write(10);
   Thermal.write(10);
   Thermal.write(10);
   digitalWrite(9, HIGH);
   delay(1000);
   digitalWrite(9, LOW);

//Shredder
  delay(5000);
   digitalWrite(8, HIGH);
   delay(2000);
   digitalWrite(8, LOW);
//Waiting
  delay(45000);

    if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    initInternet();
   }
  } else {
    initInternet();
  }

}

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


+ clap detection

+ clap detection

//Anor Batista Esteves Neto
//  08/01/2015
//  Attiny send IR Remote Key with button or clap
// clap detection based on example from Manoj Kunthu (http://imanoj-tech.blogspot.com.br/2013/02/arduino-clapper.html)

#include <attiny85_IR.h>

// defining pins
#define buttonPin  4    // attiny physical pin 3, button with pull down resistor
#define ledPin     0      // attiny physical pin 5 , normal led for visual feedback of when we are sending an ir command
#define micPin    3   // Analog Pin 3 = attiny physical pin 2

//defining constants
#define TRIGGER 60 //point above average that is considered a clap
#define CLAPS_TO_ACTIVATE 2 //The number of claps detected before output is toggled
#define CLAP_TIME 4000 // Time between claps

IRsend irsend; // IR led on physical pin 6 (D1) , the IR output will be always on attiny physical pin 6

// Variables that will change:
int buttonState = HIGH;             // the current reading from the input pin
int lastButtonState = HIGH;   // the previous reading from the input pin
// the following variables are long's because the time, measured in miliseconds,
// will quickly overflow an int
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

//variable to store the value read from the mic
int micValue = 0;

//CLAP STATE CONSTANTS
const int FINAL_DETECTED = 0, LOST_CONTINUITY = 1, CLAP_NOT_DETECTED = 2;

int SIZE = 3;
int buffer[3];
int loopIteration = 0;
int average = 0;
int total = 0;

void setup() {
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin,HIGH); //activating internal pull-up on button pin
  pinMode(ledPin,OUTPUT);
  digitalWrite(ledPin,LOW);
}

void loop() {
  check_button();
  check_claps();
 }

//Check the button, if pressed send ir command.
void check_button( void ){
    // read the state of the switch into a local variable:
    int reading = digitalRead(buttonPin);

    // check to see if you just pressed the button
    // (i.e. the input went from LOW to HIGH),  and you've waited
    // long enough since the last press to ignore any noise:

    // If the switch changed, due to noise or pressing:
    if (reading != lastButtonState) {
      // reset the debouncing timer
      lastDebounceTime = millis();
    }

    if ((millis() - lastDebounceTime) > debounceDelay) {
      // whatever the reading is at, it's been there for longer
      // than the debounce delay, so take it as the actual current state:
      // if the button state has changed:
      if (reading != buttonState)  buttonState = reading;
      if (buttonState == LOW) send_ir();
    }
    // save the reading.  Next time through the loop,
    // it'll be the lastButtonState:
    lastButtonState = reading;
}

// Send ir command to toggle the fan light
void send_ir(){
    irsend.sendNEC(150468615, 32); // ir code for my fan light
    digitalWrite(ledPin,HIGH); // just a visual feedback
    delay(200);
    digitalWrite(ledPin,LOW);
}

//read the mic value and store it in a global variable
void read_mic(void){
  micValue = analogRead(micPin);
}

/**
* Purpose:  A clap is detected when the sensor value is greater than the average plus
*     an offset.  The offset might need to be fine tuned for different sound sensors.
*/
boolean clap_detected()
{
    return micValue > average + TRIGGER;
}

void check_claps(){
    int clapState = detect_claps(CLAPS_TO_ACTIVATE);

    if(clapState == FINAL_DETECTED)
    {
      // indicate_clap(1);//turn off any clap indicating lights
       send_ir();
    }
    else if(clapState == LOST_CONTINUITY)
    {
      // indicate_clap(0);//turn off any clap indicating lights
    }
}

int detect_claps(int numClaps)
{
  int clapNum = numClaps;

  //Base Case - if clapNum is 0, then all claps have been accounted.
  if(clapNum == 0)
  {
    return FINAL_DETECTED;
  }

  //Read from mic and update ambient noise levels.
  read_mic();

  total = (total - buffer[loopIteration]) + micValue;
  average = (total/SIZE);
  buffer[loopIteration] = micValue;

  loopIteration = (loopIteration+1)%SIZE;

  if(clap_detected())
  {
    delay(50);
    for(int i = 0; i < CLAP_TIME; i++)
    {
      int clapState = detect_claps(clapNum - 1);

      if(clapState == FINAL_DETECTED || clapState == LOST_CONTINUITY)
      {
         return clapState;
      }
    }
    return LOST_CONTINUITY;
  }
  return CLAP_NOT_DETECTED;
}

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


Removed old include from removed driver

Removed old include from removed driver

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


Reduce font size

Reduce font size

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


Fixes for lights

Fixes for lights

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/WestwoodRobotics/BEST-2015.git/'


Create AHRS_euler_ekf.ino

Create AHRS_euler_ekf.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/mcprakash/ardunav.git/'


Added demo code for arduino due board.

Added demo code for arduino due board.

#define C_LOGGER_ADDR  (0x400E1000)
#define PY_LOGGER_ADDR (0x400E1200)
#define RS_LOGGER_ADDR (0x400E1400)

void setup()
{
  Serial.begin(9600);
  Serial.println("start");
}

void say_hello_logger(int addr, const char * msg)
{
    int cnt = 0;
    while (cnt < strlen(msg))
    {
        *(int*)addr = msg[cnt++];
    }
    *(int*)addr = '\n';
}

void loop()
{
  while (1)
  {
    Serial.println("-------------------LOOP START-------------------");

    say_hello_logger(C_LOGGER_ADDR, "Hello C logger!");
    say_hello_logger(PY_LOGGER_ADDR, "Hello PY logger!");
    say_hello_logger(RS_LOGGER_ADDR, "Hello RUST logger!");

    Serial.println("===================loop end===================");
  }
}

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


some minor tweaks

some minor tweaks

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/trinamic/T-Bone.git/'


Add Super Nintendo Entertainment System (SNES) Controller/Gamepad to USB

/* Super Nintendo Entertainment System (SNES) Controller/Gamepad to USB
 * Auth: John Milner / jfrmilner
 *
 * Version
 * 1.0
 *
 * Date
 * July 2016
 *
 * Hardware
 * ATmega32u4 based Arduino (Arduino Leonardo/Micro)
 * Super Nintendo Entertainment System Controller
 *
 * Software
 * Arduino IDE 1.6.8
 * Arduino Joystick Library 1.0.1 - https://github.com/MHeironimus/ArduinoJoystickLibrary
 *
 * Works with..
 * OS (plug and play): Windows 10 / Linux RetroPie 3.8.1
 * Snes9x (SNES Emulator) - http://www.snes9x.com/ / https://tcrf.net/SNES_Test_Program
 *
 * Pinout - http://pinoutsguide.com/Game/snescontroller_pinout.shtml
 *
 * 7 pin SNES proprietary female connector view:
 *  -----------------\
 * | 1 2 3 4 | 5 6 7 |
 *  -----------------/
 * pin 1: +5v
 * pin 2: Data Clock
 * pin 3: Data Latch
 * pin 4: Serial Data
 * pin 5: No Connection
 * pin 6: No Connection
 * pin 7: Ground
 *
 */

#include <Joystick.h>

// Controller Buttons
#define SNES_B       1      //000000000001
#define SNES_Y       2      //000000000010
#define SNES_SELECT  4      //000000000100
#define SNES_START   8      //000000001000
#define SNES_UP      16     //000000010000
#define SNES_DOWN    32     //000000100000
#define SNES_LEFT    64     //000001000000
#define SNES_RIGHT   128    //000010000000
#define SNES_A       256    //000100000000
#define SNES_X       512    //001000000000
#define SNES_L       1024   //010000000000
#define SNES_R       2048   //100000000000

const int PIN_CLOCK = 6;
const int PIN_LATCH = 7;
const int PIN_DATA = 12;

void setup(){
  Joystick.begin(false);

  pinMode(PIN_CLOCK, OUTPUT);
  digitalWrite(PIN_CLOCK, HIGH);
  pinMode(PIN_LATCH, OUTPUT);
  digitalWrite(PIN_LATCH, LOW);
  pinMode(PIN_DATA, INPUT_PULLUP);
}

void loop(){
  uint16_t state = 0;
    // 12us latch
    digitalWrite(PIN_LATCH, HIGH);
    delayMicroseconds(12);
    digitalWrite(PIN_LATCH, LOW);
    delayMicroseconds(6);
    // Retrieve 4021s sixteen bits of data
    for(int i = 0; i < 16; i++){
        digitalWrite(PIN_CLOCK, LOW);
        delayMicroseconds(6);
        state |= digitalRead(PIN_DATA) << i;
        digitalWrite(PIN_CLOCK, HIGH);
        delayMicroseconds(6);
    }

  // buttons
  SNES_B & ~state ? Joystick.pressButton(0) : Joystick.releaseButton(0);
  SNES_Y & ~state ? Joystick.pressButton(1) : Joystick.releaseButton(1);
  SNES_SELECT & ~state ? Joystick.pressButton(2) : Joystick.releaseButton(2);
  SNES_START & ~state ? Joystick.pressButton(3) : Joystick.releaseButton(3);
  SNES_A & ~state ? Joystick.pressButton(4) : Joystick.releaseButton(4);
  SNES_X & ~state ? Joystick.pressButton(5) : Joystick.releaseButton(5);
  SNES_L & ~state ? Joystick.pressButton(6) : Joystick.releaseButton(6);
  SNES_R & ~state ? Joystick.pressButton(7) : Joystick.releaseButton(7);

  // 360° Hat Switch 0
  Joystick.setHatSwitch(0, -1); // release
  if (SNES_UP & ~state) Joystick.setHatSwitch(0, 0);
  if (SNES_RIGHT & ~state) Joystick.setHatSwitch(0, 90);
  if (SNES_DOWN & ~state) Joystick.setHatSwitch(0, 180);
  if (SNES_LEFT & ~state) Joystick.setHatSwitch(0, 270);
  if (SNES_UP & ~state && SNES_RIGHT & ~state) Joystick.setHatSwitch(0, 45);
  if (SNES_DOWN & ~state && SNES_RIGHT & ~state) Joystick.setHatSwitch(0, 135);
  if (SNES_DOWN & ~state && SNES_LEFT & ~state) Joystick.setHatSwitch(0, 225);
  if (SNES_UP & ~state && SNES_LEFT & ~state) Joystick.setHatSwitch(0, 315);

  Joystick.sendState();
  delay(25);
}

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