Add example of outputting an analog read value

/*
  AnalogReadEasyctrl
  Reads an analog input on pin 0.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

 This example code is based on the Arduino example AnalogReadSerial
 */

#include "easyctrl.h"

Monitored<int> sensorValue("sensorValue");

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);
  Easyctrl.begin("AnalogReadEasyctrl", Serial);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  sensorValue = analogRead(A0);

  // Let easyctrl run
  Easyctrl.update();

  delay(1);        // delay in between reads for stability
}

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


Add example code for Kelvinator A/C control.

#include <IRKelvinator.h>

IRKelvinatorAC kelvir(D1);  // IR led controlled by Pin D1.

void printState() {
  // Display the settings.
  Serial.println("Kelvinator A/C remote is in the following state:");
  Serial.printf("  Basic\n  Power: %d,  Mode: %d, Temp: %dC, Fan Speed: %d\n",
                kelvir.getPower(), kelvir.getMode(), kelvir.getTemp(),
                kelvir.getFan());
  Serial.printf("  Options\n  X-Fan: %d,  Light: %d, Ion Filter: %d\n",
                kelvir.getXFan(), kelvir.getLight(), kelvir.getIonFilter());
  Serial.printf("  Swing (V): %d, Swing (H): %d, Turbo: %d, Quiet: %d\n",
                kelvir.getSwingVertical(), kelvir.getSwingHorizontal(),
                kelvir.getTurbo(), kelvir.getQuiet());
  // Display the encoded IR sequence.
  unsigned char* ir_code = kelvir.getRaw();
  Serial.print("IR Code: 0x");
  for (int i = 0; i < KELVINATOR_STATE_LENGTH; i++)
    Serial.printf("%02X", ir_code[i]);
  Serial.println();
}

void setup(){
  kelvir.begin();
  Serial.begin(115200);
  delay(200);

  // Set up what we want to send. See IRKelvinator.cpp for all the options.
  // Most things default to off.
  Serial.println("Default state of the remote.");
  printState();
  Serial.println("Setting desired state for A/C.");
  kelvir.on();
  kelvir.setFan(1);
  kelvir.setMode(KELVINATOR_COOL);
  kelvir.setTemp(26);
  kelvir.setSwingVertical(false);
  kelvir.setSwingHorizontal(true);
  kelvir.setXFan(true);
  kelvir.setIonFilter(false);
  kelvir.setLight(true);
}

void loop() {
  // Now send the IR signal.
  Serial.println("Sending IR command to A/C ...");
  kelvir.send();
  printState();
  delay(5000);
}

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


Fix comment

Fix comment

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/FrankBoesing/TeensyTransfer.git/'


unfortunate signedness

unfortunate signedness

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


Added non blocking one wire test

Added non blocking one wire test

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

#define ONE_WIRE_BUS 4

OneWire oneWire(ONE_WIRE_BUS);

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

DeviceAddress tempDeviceAddress;

int  resolution = 12;
unsigned long lastTempRequest = 0;
int  delayInMillis = 0;
float temperature = 0.0;
int  idle = 0;

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

  sensors.begin();
  sensors.getAddress(tempDeviceAddress, 0);
  sensors.setResolution(tempDeviceAddress, resolution);

  sensors.setWaitForConversion(false);
  sensors.requestTemperatures();
  delayInMillis = 750 / (1 << (12 - resolution));
  lastTempRequest = millis();

  pinMode(13, OUTPUT);
}

void loop(void)
{

  if (millis() - lastTempRequest >= delayInMillis) // waited long enough??
  {
    digitalWrite(13, LOW);
    Serial.print(" Temperature: ");
    temperature = sensors.getTempCByIndex(0);
    Serial.println(temperature, resolution - 8);
    Serial.print("  Resolution: ");
    Serial.println(resolution);
    Serial.print("Idle counter: ");
    Serial.println(idle);
    Serial.println();

    idle = 0;

    resolution++;
    if (resolution > 12) resolution = 9;

    sensors.setResolution(tempDeviceAddress, resolution);
    sensors.requestTemperatures();
    delayInMillis = 750 / (1 << (12 - resolution));
    lastTempRequest = millis();
  }

  digitalWrite(13, HIGH);
  // we can do usefull things here
  // for the demo we just count the idle time in millis
  delay(1);
  idle++;
}

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


Fixed percentage rounding.

Fixed percentage rounding.

static inline __attribute__((always_inline)) void threeDigitPercentage( char *buffer, const uint8_t &bufferSize, const float &percentage, const bool &addPercentSign )
{
  if ( percentage < 0.005 )
  {
    snprintf( buffer, bufferSize, addPercentSign ? "  0%%  " : "  0  " );
  }
  else if ( percentage > 99.9 )
  {
    snprintf( buffer, bufferSize, addPercentSign ? " 100%% " : " 100 " );
  }
  else if ( percentage < 10 )
  {
    snprintf( buffer,  bufferSize , addPercentSign ? " %1.2f%% " : " %1.2f ", percentage );
  }
  else
  {
    snprintf( buffer,  bufferSize , addPercentSign ? " %2.1f%% " : " %2.1f ", percentage );
  }
}

static inline __attribute__((always_inline)) void threeDigitPercentage( char *buffer, const uint8_t &bufferSize, const float &percentage, const bool &addPercentSign )
{
  if ( percentage < 0.005 )
  {
    snprintf( buffer, bufferSize, addPercentSign ? "  0%%  " : "  0  " );
  }
  else if ( percentage == 100 )
  {
    snprintf( buffer, bufferSize, addPercentSign ? " 100%% " : " 100 " );
  }
  else if ( percentage < 10 )
  {
    snprintf( buffer,  bufferSize , addPercentSign ? " %1.2f%% " : " %1.2f ", percentage );
  }
  else
  {
    snprintf( buffer,  bufferSize , addPercentSign ? " %2.1f%% " : " %2.1f ", percentage );
  }
}


Add validation of DS18B20 temperature calculation.

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

#include "Cosa/Trace.hh"
#include "Cosa/IOStream/Driver/UART.hh"
#include "Cosa/Watchdog.hh"

void setup()
{
  uart.begin(9600);
  trace.begin(&uart, PSTR("CosaDS18B20calc: started"));
}

int32_t iscale(int16_t temp)
{
  bool negative = false;
  if (temp < 0) {
    temp = -temp;
    negative = true;
  }
  int32_t res = (temp >> 4) * 1000L + (625 * (temp & 0xf));
  return (negative ? -res : res);
}

float32_t fscale(int16_t temp)
{
  return (temp * 0.0625);
}

#define CHECK(c,t) trace << PSTR(#c "=") << fscale(t) << endl

void loop()
{
  CHECK(+125, 0x07D0);
  CHECK(+85, 0x0550);
  CHECK(+25.0625, 0x0191);
  CHECK(+10.125, 0x00A2);
  CHECK(+0.5, 0x0008);
  CHECK(0, 0x0000);
  CHECK(-0.5, 0xFFF8);
  CHECK(-10.125, 0xFF5E);
  CHECK(-25.0625, 0xFE6F);
  CHECK(-55, 0xFC90);
  ASSERT(true == false);
}

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


set DS1307 time directly using wire protocol

#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <AWS.h>

// DS1307RTC instance created in DS1307 lib
// DS1307RTC RTC = DS1307RTC();
// DS1307RTC constructor calls Wire.begin()

#define DS1307_CTRL_ID 0x68

aws_error_t aws_code ;

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

  aws_code = init_rtc();
  for(int i = 0 ; i < 200 ; i++) {
      delayMicroseconds(1000);
  }

  // set DS1307 RTC as time provider
  // sync interval is default 5 minutes
  if(aws_code == AWS_RTC_ERROR_NONE) {
      setSyncProvider(RTC.get);
      if(timeStatus()!= timeSet) {
          // wait a bit
          for(int i = 0 ; i < 4000 ; i++) {
              delayMicroseconds(1000);
          }
      }

      // try again
      if(timeStatus()!= timeSet) {
          aws_code = AWS_RTC_SYNC_ERROR ;
      }
  }

}

void loop() {

    if(aws_code == AWS_RTC_ERROR_NONE ) {
        Serial.print(hour());
        Serial.print(" ");
        Serial.print(minute());
        Serial.print(" ");
        Serial.println(second());
    } else {
        Serial.print("error in RTC setup");
        Serial.println(aws_code);

    }

    delay(1000);
}

uint8_t dec2bcd(uint8_t num)
{
  return ((num/10 * 16) + (num % 10));
}

aws_error_t init_rtc() {

    aws_error_t code ;
    byte second =      00; //0-59
    byte minute =      19; //0-59
    byte hour =        21; //0-23
    byte weekDay =     4; //1-7
    byte monthDay =    27; //1-31
    byte month =       10; //1-12
    byte year  =       13; //0-99

    Wire.beginTransmission(DS1307_CTRL_ID);
    Wire.write((uint8_t)0x00);

    Wire.write(dec2bcd(second));
    Wire.write(dec2bcd(minute));
    Wire.write(dec2bcd(hour));
    Wire.write(dec2bcd(weekDay));
    Wire.write(dec2bcd(monthDay));
    Wire.write(dec2bcd(month));
    Wire.write(dec2bcd(year));

    Wire.write((uint8_t)0x00);

    if(Wire.endTransmission() != 0) {
        code = AWS_RTC_WRITE_ERROR ;
    } else {
        code = AWS_RTC_ERROR_NONE;
    }

    return code;

}

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


Initial commit. Still haven't even gone through it after a mass copy from 'just-get-it-working'.

/**
 *  move
 *  move.ino
 *  Positions robot in cylindrical coordinates.
 *
 * @author:    Tyler Lucas
 * Student ID: 3305203
 * Date:       Aug 9, 2017
 * Version     0.1
 */

#include <Servo.h>  // servo library

Servo servo_turret, servo_boom, servo_pincher, servo_main;
Servo servos[4] = { servo_turret, servo_boom, servo_pincher, servo_main };
const int angles[4] = { 90, 65, 90, 60 };   // initial angles

void setup()
{
  attach_servos();
  initialize();

  Serial.begin(9600);
}

void loop()
{
  Serial.println();

  Serial.print("Servo #");
  int servo_num = -1;
  while ( servo_num < 0 || servo_num > 3 )
  {
    while ( Serial.available() == 0 ) { }
    servo_num = Serial.parseInt();
    if ( servo_num < 0 || servo_num > 3 )
      Serial.print("\n Umm.. nope. Try again.\nServo #");
  }
  Serial.println( servo_num );

  Serial.print("Angle: ");
  while ( Serial.available() == 0 ) { }
  int angle = Serial.parseInt();
  Serial.println( angle );

  angle = constrain_servo_angle(servo_num, angle);

  Serial.print("Setting servo #");
  Serial.print( servo_num );
  Serial.print(" to ");
  Serial.print( angle );
  Serial.println(" degrees.");

  go_to(servo_num, angle);

  Serial.print("Servo #");
  Serial.print( servo_num );
  Serial.print(" set to ");
  Serial.print( angles[servo_num] );
  Serial.println(" degrees.");
}

int constrain_servo_angle(int servo_number, int input_angle)
{
  switch ( servo_number )
  {
  case 0: return constrain(input_angle, 0, 180);
  case 1:
    if (angles[3] < 60)
      return constrain(input_angle, formulaZ(angles[3]), formulaA(angles[3]));
    else if (angles[3] >= 60 && angles[3] < 70)
      return constrain(input_angle, formulaY(angles[3]), formulaB(angles[3]));
    else if (angles[3] >= 70 && angles[3] < 80)
      return constrain(input_angle, formulaY(angles[3]), formulaC(angles[3]));
    else if (angles[3] >= 80 && angles[3] < 100)
      return constrain(input_angle, formulaX(angles[3]), formulaC(angles[3]));
    else if (angles[3] >= 100 && angles[3] < 110)
      return constrain(input_angle, formulaX(angles[3]), formulaD(angles[3]));
    else if (angles[3] >= 110 && angles[3] < 120)
      return constrain(input_angle, formulaW(angles[3]), formulaE(angles[3]));
    else if (angles[3] >= 120 && angles[3] < 140)
      return constrain(input_angle, formulaV(angles[3]), formulaE(angles[3]));
    else if (angles[3] >= 140)
      return constrain(input_angle, formulaU(angles[3]), formulaE(angles[3]));
    else
      return -1;
  case 2: return constrain(input_angle, 65, 140);
  case 3: return constrain(input_angle, 60, 140);
  default: return -1;
  }
}

int formulaA(int angle) { return 140; }
int formulaB(int angle) { return 140 + (angle - 60) * (135-140)/(70-60); }
int formulaC(int angle) { return 135; }
int formulaD(int angle) { return 135 + (angle - 100) * (130-135)/(110-100); }
int formulaE(int angle) { return 130; }
int formulaZ(int angle) { return 65; }
int formulaY(int angle) { return 65 + (angle - 60) * (54-65)/(80-60); }
int formulaX(int angle) { return 54 + (angle - 80) * (20-54)/(110-80); }
int formulaW(int angle) { return 20 + (angle - 110) * (25-20)/(120-110); }
int formulaV(int angle) { return 25 + (angle - 120) * (18-25)/(140-120); }
int formulaU(int angle) { return 18; }

int constrain_servo_angle_conservatively(int servo_number, int input_angle)
{
  switch ( servo_number )
  {
  case 0: return constrain(input_angle, 15, 165);
  case 1: return constrain(input_angle, 65, 130);
  case 2: return constrain(input_angle, 65, 140);
  case 3: return constrain(input_angle, 60, 140);
  default: return -1;
  }
}

/*
 * Increments towards the intended angle, keeping other angles in valid ranges.
 */
void go_towards(int servo_number, int angle)
{
  angle = constrain_servo_angle(servo_number, angle);

  int diff = angle - angles[servo_number];
  int dir;
  if (diff == 0)
    dir = 0;
  else
    dir = diff / abs(diff);

  angles[servo_number] += dir;
  servo[servo_number].write( angles[servo_number] );

  if ( servo_number == 3)
  {
    angles[(servo_number + 2) % 4] = constrain_servo_angle((servo_number + 2) % 4, angles[(servo_number + 2) % 4]);
    servo[(servo_number + 2) % 4].write( angles[(servo_number + 2) % 4] );
  }

//  if ( angles[servo_number] % 15 == 0 )
//    Serial.print(angles[servo_number]);
}

void go_to(int servo_number, int angle)
{
  int min_delay_time = 10, max_delay_time = 100, delay_time = max_delay_time;

  int previous_angle;
  do {
    previous_angle = angles[servo_number];

    delay(delay_time);

    go_towards(servo_number, angle);

    if ( abs(angle - angles[servo_number]) > 15 && delay_time > min_delay_time )
      delay_time -= min_delay_time;
    else if ( abs(angle - angles[servo_number]) <= 15 && delay_time < max_delay_time)
      delay_time += min_delay_time;
  } while ( previous_angle - angles[servo_number] != 0 );
}

void initialize()
{
  int angles[4] = { 90, 65, 90, 60 };

  for (int i=0; i<4; i++)
    servos[i].write( angles[i] );
}

void detach_servos()
{
  for (int i=0; i<4; i++)
    servos[i].detach();
}

void attach_servos()
{
  servo_turret.attach( 9 );   // swivel
  servo_boom.attach( 6 );   // boom
  servo_pincher.attach( 5 );   // pincher
  servo_main.attach( 3 );   // main arm
}

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


Enables second neopixel strip.

Enables second neopixel strip.

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/bassjansson/vera.git/'


Delete original_led_sketch.ino

Delete original_led_sketch.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/nolanpatrick/spi_leds_862.git/'


First test with just a single red led running through the lines

#include "FastLED.h"
// Define number of leds
#define NUM_LEDS 110
// Define the array of leds
CRGB leds[NUM_LEDS];
// Arduino pin used for Data
#define PIN 6

void setup() {
  FastLED.addLeds<NEOPIXEL, PIN>(leds, NUM_LEDS);
}

void loop() {
  // one led at a time
    for(int i= 0; i < NUM_LEDS; i++)
    {
      // clear all values in array and set to 0
      memset(leds, 0, NUM_LEDS * 3);
      leds[i].r = 64;
      leds[i].g = 0;
      leds[i].b = 0;
      FastLED.show();
      delay(250);
    }
}

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


Ajout d'un script arduino

Ajout d'un script arduino

#include <LiquidCrystal_I2C.h>

#include <Wire.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <Servo.h>

//Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 180;
int LOW_POSITION =  180;
int HIGH_POSITION =  0;

void setup()
{
  Serial.begin(9600);
  lcd.init(); // initialize the lcd
  lcd.backlight();
  lcd.print((char) 0x5C);
 // lcd.print("Setup Arduino"); // Print a message to the LCD.
  //myservo.attach(9);
  //myservo.write(LOW_POSITION);

}

void loop()
{
  if (Serial.available())  {
    delay(100);
    lcd.setCursor(0,0);
    lcd.print(Serial.readString());
    Serial.write("DONE");
  }

}

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


add serial control

add serial 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/dave-ausbone/TJU-SST.git/'


minor edit

minor edit

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/nisald/robot_program.git/'


TODO-632: WIP

TODO-632: WIP

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/Denzo77/OTRadioLink.git/'


Bumped version for testing.

Bumped version for testing.

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/FirstBuild/pizzaduino.git/'


some minor changes

some minor changes

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


Adding example that clears the EEPROM

Adding example that clears the EEPROM

/*
  Clear the entire EEPROM
  -----------------------
  Example using the EEPROM Manager library to erase the entire EEPROM
  By Jac Goudsmit
  Distributed under the BSD (3-clause) license.
  http://github.com/jacgoudsmit/EEPROM_mgr

*/

#include <arduino.h>
#include <stdlib.h>
#include <EEPROM_mgr.h>

// The highest usable EEPROM address is #defined in the Arduino header files
// as E2END. The value depends on the microcontroller that's used. For
// example, the AVR328 has 1KB of EEPROM, the AVR168 has 512 bytes.
// The following line declares a type that takes up the entire size of the
// EEPROM.
typedef char entire_eeprom[E2END + 1];

// Create an item that uses the entire EEPROM
EEPROM_item<entire_eeprom> everything;

void setup()
{
  // Fill the item with 0xFF to clear the EEPROM
  // We can't use the assignment operator here so we use the Data operator
  // to get a pointer to the internal data of the item, fill the data with
  // bytes containing value 255, and then store the item to the EEPROM.
  memset(everything.Data(), 255, sizeof(entire_eeprom));
  everything.Store();
}

void loop()
{
}

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


a working test bed

a working test bed


Fixed a few try-catch errors

Fixed a few try-catch errors

error: pathspec 'Version' did not match any file(s) known to git
error: pathspec '1.2/No_bell/email.ino' did not match any file(s) known to git


arduino

arduino

#include <Wire.h>
#include <Adafruit_BMP085.h>

Adafruit_BMP085 bmp;

#include "DHT.h"

#define DHTPIN 12     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN, DHTTYPE);

int incomingByte = 0;   // for incoming serial data

void setup() {
        Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
        dht.begin();
        bmp.begin();
}

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                if (incomingByte == 116) { // Temperatur
                  int t1 = dht.readTemperature()*10;
                  int t2 = bmp.readTemperature()*10;
                  int t = (t1 + t2)/2;
                  Serial.print(t/10);
                  Serial.print(".");
                  Serial.print(t % 10);
                  Serial.print("\n");
                }

                if (incomingByte == 104) { // Luftfeuchte
                  Serial.print(dht.readHumidity());
                  Serial.print("\n");
                }

                if (incomingByte == 112) { // Druck
                  Serial.print(bmp.readPressure());
                  Serial.print("\n");
                }

        }
}

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


Windmill_test :facepunch:

Windmill_test :facepunch:

Arduino project to test all I/O devices

/**************************Windmill_Test***************************/
/*****************System Integrated course form ******************/
/*Faculdade Ciências e Tecnologias from New University of Lisbon*/
/*********Authors: João Miguel Duarte Barata Oliveira **********/
/***************************    &   ***************************/
/************* Pedro Miguel dos Santos Martins ***************/
/************************************************************/

//PINS
const int buttonPin=2;
const int buttonPin1=3;
const int ledPin=4;
const int potPin=A0;

//Variables
int buttonState=0;
int buttonState1=0;
int sensorValue;

void init_pinMode(){
  pinMode(buttonPin,INPUT);
  pinMode(buttonPin1,INPUT);
  pinMode(ledPin,OUTPUT);
}

void setup(){
  init_pinMode();
}

void loop(){
  buttonState=digitalRead(buttonPin);
  buttonState1=digitalRead(buttonPin1);
  sensorValue=analogRead(potPin);

  if(buttonState == HIGH){
    digitalWrite(ledPin,HIGH);
    delay(100);
    digitalWrite(ledPin,LOW);
  }

  if(buttonState1 == HIGH){
    for(int i=0;i<=10;i++){
      digitalWrite(ledPin,HIGH);
      delay(sensorValue);
      digitalWrite(ledPin,LOW);
    }
  }
}

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


example for buzzer on RevE

example for buzzer on RevE

int freq = 2000;
int channel = 0;
int resolution = 8;

void setup() {

  Serial.begin(115200);
  ledcSetup(channel, freq, resolution);
  ledcAttachPin(15, channel);

}

void loop() {

  ledcWriteTone(channel, 2000);

  for (int dutyCycle = 0; dutyCycle <= 255; dutyCycle=dutyCycle+10){

    Serial.println(dutyCycle);

    ledcWrite(channel, dutyCycle);
    delay(1000);
  }

  ledcWrite(channel, 125);

  for (int freq = 255; freq < 10000; freq = freq + 250){

     Serial.println(freq);

     ledcWriteTone(channel, freq);
     delay(1000);
  }

}

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


Few Changes on Motor Test

Few Changes on Motor Test

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


First working version

First working version

#include "debug.h"
#include <OneWire.h>
#include <LiquidCrystal.h>
#include "Button.h"
#include "Relay.h"
#include "Sensor.h"
#include "Config.h"

//############ HW CONFIG
// pin connected to temperature sensor DS18S20
const byte TEMPS_1 = 7;

// Relays
const byte REL_1 = 8;

// Buttons
const byte BTN_DOWN = A1;
const byte BTN_UP = A2;
const byte BTN_ENTER = A6;
const byte BTN_EXIT = A7;

// LCD display pins
const byte LCD_RS = 12;
const byte LCD_E = 11;
const byte LCD_D4 = 5;
const byte LCD_D5 = 4;
const byte LCD_D6 = 3;
const byte LCD_D7 = 2;

float tempDelta = 0.1;
float eps = 0.5;      //
bool cooling = true;  // switch between heating and cooling

// LCD display
LiquidCrystal *lcd;

// Temperature sensors
TempSensor *temps1;

Button *btnDown;
Button *btnUp;

// Relays
Relay *relay1;      // relay 1

//
bool modeSetTemp = false;
unsigned long modeSetTempEnd = 0;

bool blinkPhase = true;
int blinkOff = 500;
int blinkOn = 500;
unsigned long blinkStateEnd = millis();
float temp1 = 0;
float oldtemp1 = 0;

ConfigEE cfg;

void setup(void) {
  Serial.begin(115200);
  lcd = new LiquidCrystal(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
  temps1 = new TempSensor(TEMPS_1);
  btnDown = new Button(BTN_DOWN);
  btnUp = new Button(BTN_UP);
  relay1 = new Relay(REL_1);
  lcd->begin(16, 2);

  if (!cfg.read()){
    dpln("Failed to load configuration");
    cfg.setDefaults();
    cfg.write();
  }

  cfg.print();
}

void loop(void) {
  temp1 = temps1->getTemp();

  if (temp1 != oldtemp1){
    dp("Temp=");
    dpln(temp1);
    oldtemp1 = temp1;
  }

  if (millis() > blinkStateEnd){
    if (blinkPhase){
      blinkStateEnd = millis()+blinkOff;
    } else
      blinkStateEnd = millis()+blinkOn;
    blinkPhase = !blinkPhase;
  }

  lcd->setCursor(0, 0);
  if (cfg.data.cooling)
    lcd->print("Cool to: ");
  else
    lcd->print("Heat to: ");

  lcd->setCursor(9, 0);
  if (modeSetTemp && !blinkPhase)
    lcd->print("     ");
  else
    lcd->print(cfg.data.temp);

  lcd->setCursor(14, 0);
  lcd->print(char(223));
  lcd->print("C");

  lcd->setCursor(3, 1);
  lcd->print("Temp: ");
  lcd->print(temp1);
  lcd->print(char(223));
  lcd->print("C");

  if (cfg.data.cooling) {
    if (cfg.data.temp+cfg.data.eps < temp1) { // current temperature is outside higher limit
      //dpln("Cooling - relay ON");
      relay1->on();
    } else {
      //dpln("Cooling - relay OFF");
      relay1->off();
    }
  }

  bool b1 = btnDown->check(LOW);
  bool b2 = btnUp->check(LOW);

  if (!modeSetTemp){
    if (!b1 && !b2){
      dpln("SetTemp START");
      modeSetTemp = true;
      modeSetTempEnd = millis()+10000;
    }
  } else {
    if (millis() > modeSetTempEnd){
      modeSetTemp = false;
      dpln("SetTemp END");
      cfg.write();
    }

    if (btnDown->isDown()) {
      cfg.data.temp -= tempDelta;
      modeSetTempEnd = millis()+3000;
      dp("-");
    }

    if (btnUp->isDown()) {
      cfg.data.temp += tempDelta;
      modeSetTempEnd = millis()+3000;
      dp("+");
    }

  }

    delay(100);

}

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


Fixes bug where example sketch only reads one time

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/kennethlimcp/Adafruit_L3GD20.git/'


Master

Master

#define NUM_MODULES 2
#define DATA_SIZE   4

byte modules[NUM_MODULES]={0,1};

int error();
int send(byte addr, byte data[], int n);
int init();

void setup() {
    delay(100);
    if(!init())
        Serial.println("Initialization Failed");
}

void loop() {

}

int init() {
    //Check connected
    for(int i=0; i<NUM_MODULES; i++) {
        if(!send(modules[i], 0, 1))
            return error();
    }

}

int send(byte addr, byte data[], int n) {
    if(!Wire.isEnabled())
        Wire.begin();
    Wire.beginTransmission(addr);
    Wire.write(data, n);
    if(Wire.endTransmission())
        return error();
    return 0;
}

int error() {
    return -1;
}

int zero() {

}

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


Fix CI

Fix CI

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/DanNixon/Alice.git/'


Changed delay

Changed delay

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


is this just logging?

is this just logging?

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


refactors.

refactors.

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/nverdicchio/soa-2017-bicicleta-inteligente.git/'


Functional

Functional

#include "Laser.h"

// Instantiate strip
CRGB leds[NUM_LEDS];

// Instantiate pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

const int iterationCount = 2000;
const int SCENE_COOLDOWN = 0;
const int SCENE_IDLE = 1;
const int SCENE_CHARGING = 2;
const int SCENE_CHARGED = 3;
const int SCENE_FIRING = 4;
const int SCENE_PRETTYLIGHTS = 5;

long laserTimer;

const int CHARGE_PIXELS = 20; //number of pixels in bottom of tube near coil

const int minBrightness = 8;

int sceneBrightness = 1;
int r = 32;
int g = 32;
int b = 32;

// AMPLITUDE = brightness amplitude for standy
byte amplitude = 10;

// FREQUENCY = laser charge frequencyrightness amplitude for standy
byte frequency = 10; //todo unused

// PERIOD: Standby frequency period
byte period = 4; //todo unused

// VOLUME: Sound volume. Range  0 - 30
byte volume = 15;

// BRIGHTNESS: Pixel Brightness
byte brightness = 128;

// Fire: Fire laser flag
byte fire = 1;

// PRETTYLIGHTS: Pretty lights flag
byte prettylights = 0;

int sceneState = SCENE_IDLE; // start with idle scene
uint64_t count = 0;
long sceneStartMillis = 0;

void setupLaser(){
    pixels.begin(); // Initializes NeoPixel Library
    Serial.println("NeoPixel array started");
    setScene(SCENE_COOLDOWN);
}

void fireLaser(void){

  // if we are in idle state: fire; otherwise, do nothing
  if (sceneState == SCENE_IDLE){
    setScene(SCENE_CHARGING);
  }

}
void Laser(void)
{
//todo laser energy charging model
}

void keepOnLasing(void)
{
//  if (millis() > laserTimer + 1000 / FRAMES_PER_SECOND)
//  {
//    laserTimer = millis();
//    Laser(); //update model state (based on time)
//    for (int i = 0; i < NUM_LEDS; i++)
//    {
//      pixels.setPixelColor(i, pixels.Color(leds[i].r, leds[i].g, leds[i].b));
//    }
//
//    pixels.setBrightness(sceneBrightness);// set pixel brightness
//    pixels.show(); //send updated pixel color to hardware
//
//  }
}

//////////////////////////////////////
//////////////////////////////////////
// IDLE SCENCE
//////////////////////////////////////
void sceneIdle() {
    // idle loop when nothing else is happening
  count++;

  if (count % iterationCount == 0) {
    Serial.println("-- idle");
  }

  if (sceneBrightness < 1) { pixels.setBrightness(1); sceneBrightness = 1; }

  int iteration = count % iterationCount;
  int lbrightness = (sceneBrightness < 72 ? sceneBrightness++ : map(iteration, 0, iterationCount, -72, 72));
  int r = 0;
  int g = 0; // abs(lbrightness);
  int b = abs(lbrightness);; // 64;
  for (int i = 0; i < NUM_LEDS; i++) {
    pixels.setPixelColor(i, pixels.Color(r, g, b));
    delay(0);
  }

  pixels.show(); //send updated pixel color to hardware

}

void sceneCharging() {
  // charging up animation

  long sceneEnd = sceneStartMillis + SCENE_CHARGING_LEN_MS;
  count++;
  laserTimer = millis();
  if (laserTimer > sceneEnd) {
    Serial.println("Finished charging");
    // if we've been charging for 5 sec, we're charged
    //setScene(SCENE_CHARGED); //skip charged SCENE FOR NOW
    setScene(SCENE_FIRING);
    return;
  }
  //int intensity = count % NUM_LEDS;

  if (sceneBrightness < 32) { pixels.setBrightness(32); sceneBrightness = 32; }

  int sceneBrightness = map(laserTimer, sceneStartMillis, sceneEnd, 200, 0);
  for (int i = 0; i < NUM_LEDS; i++) {
    int localr = map(laserTimer, sceneStartMillis, sceneEnd, r, 0);
    int localg = map(laserTimer, sceneStartMillis, sceneEnd, g, 0);
    b = sceneBrightness;
    pixels.setPixelColor(i, pixels.Color(localr, localg, b));
    delay(0);
  }

//add progress-bar style charge-up
  int chargeLevel = map(laserTimer, sceneStartMillis, sceneEnd, 1, CHARGE_PIXELS);
  for (int i = 0; i < chargeLevel; i++) {
    pixels.setPixelColor(i, pixels.Color(0,0,255));
    delay(0);
  }
// add increasing number of random flashes
  for (int i=0; i < chargeLevel; i++){
    pixels.setPixelColor(random(chargeLevel,NUM_LEDS),pixels.Color(sceneBrightness,sceneBrightness,sceneBrightness));
    delay(0);
  }

  //pixels.setBrightness(brightness);// set pixel brightness
  pixels.show(); //send updated pixel color to hardware

}

//////////////////////////////////////
//////////////////////////////////////
// Charged SCENE
//////////////////////////////////////

void sceneCharged() {
  // charged loop
  count++;
  laserTimer= millis();
  if (laserTimer > sceneStartMillis + SCENE_CHARGED_LEN_MS) {
    // if we've been charged for 2 sec, fire
    Serial.println("Ready to fire");
    setScene(SCENE_FIRING);
    return;
  }

  r = 0; g = 0; b = 255;
  for (int i = 0; i < CHARGE_PIXELS; i++) {
    pixels.setPixelColor(i, pixels.Color(r, g, b));
    delay(0);
  }
  for (int i = CHARGE_PIXELS; i < NUM_LEDS; i++) {
    pixels.setPixelColor(i, pixels.Color(0, 0, 0));
    delay(0);
  }

  pixels.show(); //send updated pixel color to hardware
}

//////////////////////////////////////
//////////////////////////////////////
// FIRING SCENE
//////////////////////////////////////

void sceneFiring() {
  // firing animation
  count++;
  laserTimer = millis();
  long sceneEnd = sceneStartMillis + SCENE_FIRING_LEN_MS;
  if (laserTimer > sceneEnd) {
    // if we're finished firing go back to idle
    Serial.println("Finished firing, cooling down");
    sceneBrightness = 1;
    setScene(SCENE_COOLDOWN);
    return;
  }

  for (int i = 0; i < NUM_LEDS; i++) {
    int currentLED = count % NUM_LEDS;
    if (i >= currentLED + 3 || i <= currentLED - 3) {
      r = 0; g = 0; b = map(laserTimer, sceneStartMillis, sceneEnd, 255, 0);
     } else {
      r = 0; g = 0; b = 0;
    }
    pixels.setPixelColor(i, pixels.Color(r, g, b));
    delay(0);
  }

  pixels.show(); //send updated pixel color to hardware
}

void sceneCooldown(){
  count ++;
  laserTimer = millis();
    if (laserTimer > sceneStartMillis + SCENE_COOLDOWN_LEN_MS) {
    // if we've been charged for 2 sec, fire
    Serial.println("Cooled down");
    setScene(SCENE_IDLE);
    return;
  }
    for (int i = 0; i < NUM_LEDS; i++) {
      pixels.setPixelColor(i, pixels.Color(0, 0, 0));
      delay(0);
  }

  pixels.show();
}

void setScene(int sceneNum) {
    count = 0; //reset counter
    if (sceneNum < SCENE_COOLDOWN || sceneNum > SCENE_PRETTYLIGHTS) {
      Serial.println("Invalid scene, setting Idle scene");
      sceneNum = SCENE_IDLE; // return to idle if we're looping around
    }
    Serial.print("Setting scene to ");
    Serial.println(sceneNum);

    switch (sceneNum) {
      case SCENE_CHARGING:
        // fire the sound file for charging scene
        playSoundFile(SCENE_CHARGING_INDEX + 1);
        break;
      case SCENE_CHARGED:
        // fire the sound file for charged scene
        playSoundFile(SCENE_CHARGED_INDEX + 1);
        break;
      case SCENE_FIRING:
        // fire the sound file for the firing scene
        playSoundFile(SCENE_FIRING_INDEX + 1);
        break;
      case SCENE_COOLDOWN:
       //playSoundFile(SCENCE_COOLDOWN_INDEX +1);
       break;
    }

    sceneState = sceneNum;
    sceneStartMillis = millis();
}

void doScene() {
  // animates the current scene
  // simple state machine
  switch (sceneState) {
    case SCENE_IDLE: // idle
      sceneIdle();
      break;
    case SCENE_CHARGING: // charging
      sceneCharging();
      break;
    case SCENE_CHARGED:
      sceneCharged();
      break;
    case SCENE_FIRING:
      sceneFiring();
      break;
    case SCENE_COOLDOWN:
      sceneCooldown();
      break;
    case SCENE_PRETTYLIGHTS:
      scenePrettyLights();
      break;
  }
}

void prettyLights(){
  Serial.println("Activating Pretty Lights Mode");
  setScene(SCENE_PRETTYLIGHTS);
}

void scenePrettyLights() {
  rainbowCycle(20);
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< pixels.numPixels(); i++) {
      pixels.setPixelColor(i, Wheel(((i * 256 / pixels.numPixels()) + j) & 255));
    }
    pixels.show();
    //delay(wait);
  }
}

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

#include "Laser.h"

// Instantiate strip
CRGB leds[NUM_LEDS];

// Instantiate pixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);

const int iterationCount = 2000;
const int SCENE_COOLDOWN = 0;
const int SCENE_IDLE = 1;
const int SCENE_CHARGING = 2;
const int SCENE_CHARGED = 3;
const int SCENE_FIRING = 4;
const int SCENE_PRETTYLIGHTS = 5;

long laserTimer;

const int CHARGE_PIXELS = 20; //number of pixels in bottom of tube near coil

const int minBrightness = 8;

int sceneBrightness = 1;
int r = 32;
int g = 32;
int b = 32;

// AMPLITUDE = brightness amplitude for standy
byte amplitude = 10;

// FREQUENCY = laser charge frequencyrightness amplitude for standy
byte frequency = 10; //todo unused

// PERIOD: Standby frequency period
byte period = 4; //todo unused

// VOLUME: Sound volume. Range  0 - 30
byte volume = 15;

// BRIGHTNESS: Pixel Brightness
byte brightness = 128;

// Fire: Fire laser flag
byte fire = 1;

// PRETTYLIGHTS: Pretty lights flag
byte prettylights = 0;

int sceneState = SCENE_IDLE; // start with idle scene
uint64_t count = 0;
long sceneStartMillis = 0;

void setupLaser(){
    pixels.begin(); // Initializes NeoPixel Library
    Serial.println("NeoPixel array started");
    setScene(SCENE_COOLDOWN);
}

void fireLaser(void){

  // if we are in idle state: fire; otherwise, do nothing
  if (sceneState == SCENE_IDLE){
    setScene(SCENE_CHARGING);
  }

}
void Laser(void)
{
//todo laser energy charging model
}

void keepOnLasing(void)
{
//  if (millis() > laserTimer + 1000 / FRAMES_PER_SECOND)
//  {
//    laserTimer = millis();
//    Laser(); //update model state (based on time)
//    for (int i = 0; i < NUM_LEDS; i++)
//    {
//      pixels.setPixelColor(i, pixels.Color(leds[i].r, leds[i].g, leds[i].b));
//    }
//
//    pixels.setBrightness(sceneBrightness);// set pixel brightness
//    pixels.show(); //send updated pixel color to hardware
//
//  }
}

//////////////////////////////////////
//////////////////////////////////////
// IDLE SCENCE
//////////////////////////////////////
void sceneIdle() {
    // idle loop when nothing else is happening
  count++;

  if (count % iterationCount == 0) {
    Serial.println("-- idle");
  }

  if (sceneBrightness < 1) { pixels.setBrightness(1); sceneBrightness = 1; }

  int iteration = count % iterationCount;
  int lbrightness = (sceneBrightness < 72 ? sceneBrightness++ : map(iteration, 0, iterationCount, -72, 72));
  int r = 0;
  int g = 0; // abs(lbrightness);
  int b = abs(lbrightness);; // 64;
  for (int i = 0; i < NUM_LEDS; i++) {
    pixels.setPixelColor(i, pixels.Color(r, g, b));
    delay(0);
  }

  pixels.show(); //send updated pixel color to hardware

}

void sceneCharging() {
  // charging up animation

  long sceneEnd = sceneStartMillis + SCENE_CHARGING_LEN_MS;
  count++;
  laserTimer = millis();
  if (laserTimer > sceneEnd) {
    Serial.println("Finished charging");
    // if we've been charging for 5 sec, we're charged
    //setScene(SCENE_CHARGED); //skip charged SCENE FOR NOW
    setScene(SCENE_FIRING);
    return;
  }
  //int intensity = count % NUM_LEDS;

  if (sceneBrightness < 32) { pixels.setBrightness(32); sceneBrightness = 32; }

  int sceneBrightness = map(laserTimer, sceneStartMillis, sceneEnd, 200, 0);
  for (int i = 0; i < NUM_LEDS; i++) {
    int localr = map(laserTimer, sceneStartMillis, sceneEnd, r, 0);
    int localg = map(laserTimer, sceneStartMillis, sceneEnd, g, 0);
    b = sceneBrightness;
    pixels.setPixelColor(i, pixels.Color(localr, localg, b));
    delay(0);
  }

//add progress-bar style charge-up
  int chargeLevel = map(laserTimer, sceneStartMillis, sceneEnd, 1, CHARGE_PIXELS);
  for (int i = 0; i < chargeLevel; i++) {
    pixels.setPixelColor(i, pixels.Color(0,0,255));
    delay(0);
  }
// add increasing number of random flashes
  for (int i=0; i < chargeLevel; i++){
    pixels.setPixelColor(random(chargeLevel,NUM_LEDS),pixels.Color(sceneBrightness,sceneBrightness,sceneBrightness));
    delay(0);
  }

  //pixels.setBrightness(brightness);// set pixel brightness
  pixels.show(); //send updated pixel color to hardware

}

//////////////////////////////////////
//////////////////////////////////////
// Charged SCENE
//////////////////////////////////////

void sceneCharged() {
  // charged loop
  count++;
  laserTimer= millis();
  if (laserTimer > sceneStartMillis + SCENE_CHARGED_LEN_MS) {
    // if we've been charged for 2 sec, fire
    Serial.println("Ready to fire");
    setScene(SCENE_FIRING);
    return;
  }

  r = 0; g = 0; b = 255;
  for (int i = 0; i < CHARGE_PIXELS; i++) {
    pixels.setPixelColor(i, pixels.Color(r, g, b));
    delay(0);
  }
  for (int i = CHARGE_PIXELS; i < NUM_LEDS; i++) {
    pixels.setPixelColor(i, pixels.Color(0, 0, 0));
    delay(0);
  }

  pixels.show(); //send updated pixel color to hardware
}

//////////////////////////////////////
//////////////////////////////////////
// FIRING SCENE
//////////////////////////////////////

void sceneFiring() {
  // firing animation
  count++;
  laserTimer = millis();
  long sceneEnd = sceneStartMillis + SCENE_FIRING_LEN_MS;
  if (laserTimer > sceneEnd) {
    // if we're finished firing go back to idle
    Serial.println("Finished firing, cooling down");
    sceneBrightness = 1;
    setScene(SCENE_COOLDOWN);
    return;
  }

  for (int i = 0; i < NUM_LEDS; i++) {
    int currentLED = count % NUM_LEDS;
    if (i >= currentLED + 5 || i <= currentLED - 5) {
      r = 0; g = 0; b = map(laserTimer, sceneStartMillis, sceneEnd, 255, 0);
     } else {
      r = 0; g = 0; b = 0;
    }
    pixels.setPixelColor(i, pixels.Color(r, g, b));
    delay(0);
  }

  pixels.show(); //send updated pixel color to hardware
}

void sceneCooldown(){
  count ++;
  laserTimer = millis();
    if (laserTimer > sceneStartMillis + SCENE_COOLDOWN_LEN_MS) {
    // if we've been charged for 2 sec, fire
    Serial.println("Cooled down");
    setScene(SCENE_IDLE);
    return;
  }
    for (int i = 0; i < NUM_LEDS; i++) {
      pixels.setPixelColor(i, pixels.Color(0, 0, 0));
      delay(0);
  }

  pixels.show();
}

void setScene(int sceneNum) {
    count = 0; //reset counter
    if (sceneNum < SCENE_COOLDOWN || sceneNum > SCENE_PRETTYLIGHTS) {
      Serial.println("Invalid scene, setting Idle scene");
      sceneNum = SCENE_IDLE; // return to idle if we're looping around
    }
    Serial.print("Setting scene to ");
    Serial.println(sceneNum);

    switch (sceneNum) {
      case SCENE_CHARGING:
        // fire the sound file for charging scene
        playSoundFile(SCENE_CHARGING_INDEX + 1);
        break;
      case SCENE_CHARGED:
        // fire the sound file for charged scene
        playSoundFile(SCENE_CHARGED_INDEX + 1);
        break;
      case SCENE_FIRING:
        // fire the sound file for the firing scene
        playSoundFile(SCENE_FIRING_INDEX + 1);
        break;
      case SCENE_COOLDOWN:
       //playSoundFile(SCENCE_COOLDOWN_INDEX +1);
       break;
    }

    sceneState = sceneNum;
    sceneStartMillis = millis();
}

void doScene() {
  // animates the current scene
  // simple state machine
  switch (sceneState) {
    case SCENE_IDLE: // idle
      sceneIdle();
      break;
    case SCENE_CHARGING: // charging
      sceneCharging();
      break;
    case SCENE_CHARGED:
      sceneCharged();
      break;
    case SCENE_FIRING:
      sceneFiring();
      break;
    case SCENE_COOLDOWN:
      sceneCooldown();
      break;
    case SCENE_PRETTYLIGHTS:
      scenePrettyLights();
      break;
  }
}

void prettyLights(){
  Serial.println("Activating Pretty Lights Mode");
  setScene(SCENE_PRETTYLIGHTS);
}

void scenePrettyLights() {
  rainbowCycle(20);
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< pixels.numPixels(); i++) {
      pixels.setPixelColor(i, Wheel(((i * 256 / pixels.numPixels()) + j) & 255));
    }
    pixels.show();
    //delay(wait);
  }
}

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


Update ArduCAM_Shield_V2_MT9D111_Camera_JPEG.ino

// ArduCAM demo (C)2020 Lee
// web: http://www.ArduCAM.com
// This program is a demo of how to use most of the functions of the library with a supported camera modules.
// This demo can only work on ARDUCAM_SHIELD_V2 platform.
// This demo will run the MT9D111 with JPEG mode, it is compatible with autofocus and non-autofocus.
// The demo sketch will do the following tasks:
// 1. Set the sensor to JPEG output mode.
// 2. Capture and buffer the image to FIFO.
// 3. Store the image to Micro SD/TF card with JPEG format.
// This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM shield V2
// and use Arduino IDE 1.8.9 compiler or above.

#include <UTFT_SPI.h>
#include <SD.h>
#include <Wire.h>
#include <ArduCAM.h>
#include <SPI.h>
#if defined(__arm__)
#include <itoa.h>
#endif

#define SD_CS 9
#define JPEGIMAGEOFFSET 625

  //  w1 = 0x0140;  320
  //  h1 = 0x00f0;  240
  //  w2 = 0x0320;  800
  //  h2 = 0x0258;  600
  //  w2 = 0x0640;  1600
  //  h2 = 0x04B0;  1200

int jpeg = 1;
unsigned long jpeg_length = 0;
// Set the offset to adjust the error data at the end of the image.
int16_t OFFSET = 50;
//set resolution
const uint16_t width = 1600;
const uint16_t height = 1200;
// set pin 10 as the slave select for the ArduCAM shiel:
const int slaveSelectPin = 10;

const char JPEG_header[625] PROGMEM =
{
  0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01,
  0x00, 0x01, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03,
  0x03, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x05, 0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x09, 0x07,
  0x07, 0x05, 0x08, 0x0b, 0x0a, 0x0b, 0x0b, 0x0b, 0x0a, 0x0b, 0x0a, 0x0c, 0x0e, 0x11, 0x0f, 0x0c,
  0x0d, 0x10, 0x0d, 0x0a, 0x0b, 0x0f, 0x14, 0x0f, 0x10, 0x12, 0x12, 0x13, 0x14, 0x13, 0x0c, 0x0e,
  0x15, 0x17, 0x15, 0x13, 0x17, 0x11, 0x13, 0x13, 0x13, 0x01, 0x03, 0x03, 0x03, 0x05, 0x04, 0x05,
  0x09, 0x05, 0x05, 0x09, 0x13, 0x0c, 0x0b, 0x0c, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
  0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
  0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
  0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x04,
  0x80, 0x06, 0x40, 0x03, 0x00, 0x21, 0x00, 0x01, 0x11, 0x01, 0x02, 0x11, 0x01, 0xff, 0xc4, 0x00,
  0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4,
  0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00,
  0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13,
  0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15,
  0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25,
  0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
  0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
  0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86,
  0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4,
  0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2,
  0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
  0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
  0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01,
  0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
  0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04,
  0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11,
  0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08,
  0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a,
  0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35,
  0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55,
  0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75,
  0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93,
  0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
  0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
  0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
  0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xdd, 0x00,
  0x04, 0x00, 0x20, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x01, 0x11, 0x02, 0x11, 0x00, 0x3f,
  0x00
};

const uint16_t patch_addr_0400[206] PROGMEM = {
  0x0400,
  0x00cc,
  0xce06, 0x10ed, 0x0230, 0xec00, 0xce06, 0x10ed, 0x00ce, 0x0610,
  0xec04, 0xc300, 0x01ed, 0x04ce, 0x1070, 0xc603, 0xe70f, 0xc611,
  0xe740, 0xc680, 0xe742, 0xc603, 0xe701, 0xc6fe, 0xe74c, 0xc600,
  0xe71a, 0xe71b, 0xe710, 0xe712, 0xc680, 0xe711, 0xc680, 0xe713,
  0xc601, 0xe744, 0xc6fe, 0xe746, 0x39ce, 0x0620, 0xed02, 0x30ec,
  0x00ce, 0x0620, 0xed00, 0xce06, 0x20e6, 0x05cb, 0x01c4, 0x7fe7,
  0x05ce, 0x0720, 0x3a18, 0xce06, 0x2018, 0xe603, 0xe700, 0x3c34,
  0xce01, 0x0de6, 0x03e7, 0x04ce, 0x0620, 0xe603, 0xce01, 0x0de7,
  0x03ce, 0x1070, 0xc602, 0xe703, 0xc6ff, 0xe746, 0xc601, 0xe745,
  0x18ce, 0x010d, 0x18e6, 0x034f, 0xc300, 0x0105, 0xed10, 0x18e6,
  0x034f, 0x1830, 0x18ed, 0x01cc, 0x0101, 0x18a3, 0x0105, 0xed12,
  0xc600, 0xe745, 0xc6fe, 0xe746, 0xc602, 0xe703, 0x4fcc, 0x0050,   // 50 is time needed for lens setling
  0xbd9b, 0x1118, 0xce01, 0x0d18, 0xe605, 0xca02, 0x18e7, 0x0530,
  0xc603, 0x3a35, 0x39ce, 0x0630, 0xed02, 0x30ec, 0x00ce, 0x0630,
  0xed00, 0xce06, 0x30ec, 0x08c3, 0x0001, 0xed08, 0x39ce, 0x0640,
  0xed02, 0x30ec, 0x00ce, 0x0640, 0xed00, 0xcc06, 0x40ec, 0x08c3,
  0x0001, 0xed08, 0xbd9c, 0x43c1, 0x0126, 0x1218, 0xce01, 0x0d18,
  0xe605, 0xf400, 0xfd18, 0xe705, 0xce06, 0x40e7, 0x04ce, 0x0640,
  0xe704, 0x18ce, 0x010d, 0x18e6, 0x0539, 0x3c3c, 0x3c3c, 0x34cc,
  0x02c4, 0x30ed, 0x06fe, 0x1050, 0xec0c, 0xfd02, 0xc0fe, 0x02c0,
  0xec00, 0xfd02, 0xc230, 0x6f08, 0xe608, 0x4f05, 0xf302, 0xc28f,
  0xec00, 0x30ed, 0x00e6, 0x084f, 0x05e3, 0x0618, 0x8fec, 0x0018,
  0xed00, 0x6c08, 0xe608, 0xc104, 0x25de, 0x30ee, 0x06cc, 0x0400,
  0xed00, 0x30ee, 0x06cc, 0x0449, 0xed02, 0x30ee, 0x06cc, 0x04d5,
  0xed04, 0x30ee, 0x06cc, 0x04ed, 0xed06, 0xcc02, 0xc4fe, 0x010d,
  0xed00, 0x30c6, 0x093a, 0x3539
};

ArduCAM myCAM(MT9D111_B, slaveSelectPin);
UTFT myGLCD(slaveSelectPin);

void AF_refocus() {
  Serial.println("af_refocus");
  myCAM.wrSensorReg8_16(0xF0, 0x01);
  myCAM.wrSensorReg8_16(0xC6, 0xA102);
  myCAM.wrSensorReg8_16(0xC8, 0x31);
  myCAM.wrSensorReg8_16(0xC6, 0xA504);
  myCAM.wrSensorReg8_16(0xC8, 0x01);
}

void AF_mode() {
  uint16_t value, v;

  myCAM.wrSensorReg8_16( 0xF0, 0x02);
  myCAM.rdSensorReg8_16(0x4C, &v);
  v |= 0x000B;
  myCAM.wrSensorReg8_16(0x4C, v);
  myCAM.rdSensorReg8_16(0x56, &v);
  v |= 0x000B;
  myCAM.wrSensorReg8_16(0x56, v);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA102);
  myCAM.rdSensorReg8_16( 0xC8, &value);
  value |= 0x0010;                        // enable AF driver
  myCAM.wrSensorReg8_16( 0xC6, 0xA102);
  myCAM.wrSensorReg8_16( 0xC8, value);
  myCAM.wrSensorReg8_16( 0xC6, 0xA102);
  myCAM.rdSensorReg8_16( 0xC8, &value);

  if (jpeg == 1 )  {
    value = 0x01;
    myCAM.wrSensorReg8_16( 0xC6, 0xA12C);
    myCAM.wrSensorReg8_16( 0xC8, value);

    refresh();

    value = 0x00;
    myCAM.wrSensorReg8_16( 0xC6, 0xA12C);
    myCAM.wrSensorReg8_16( 0xC8, value);

    value = 0x01;
    myCAM.wrSensorReg8_16( 0xC6, 0xA13A);
    myCAM.wrSensorReg8_16( 0xC8, value);

    myCAM.wrSensorReg8_16( 0xC6, 0xA504);
    myCAM.wrSensorReg8_16( 0xC8, 0X00);

    //    myCAM.wrSensorReg8_16( 0xC6, 0xA505);
    //    myCAM.wrSensorReg8_16( 0xC8, 0x80);

    //    myCAM.wrSensorReg8_16( 0xC6, 0xA502);
    //    myCAM.wrSensorReg8_16( 0xC8, 0x17);
    //    myCAM.wrSensorReg8_16( 0xC6, 0xA503);
    //    myCAM.wrSensorReg8_16( 0xC8, 0x11);
  }
  else {
    value = 0x01;
    myCAM.wrSensorReg8_16( 0xC6, 0xA12C);
    myCAM.wrSensorReg8_16( 0xC8, value);

    //    myCAM.wrSensorReg8_16( 0xC6, 0xA504);
    //    myCAM.wrSensorReg8_16( 0xC8, 0X00);

    //    myCAM.wrSensorReg8_16( 0xC6, 0xA505);
    //    myCAM.wrSensorReg8_16( 0xC8, 0x80);

    //    myCAM.wrSensorReg8_16( 0xC6, 0xA502);
    //    myCAM.wrSensorReg8_16( 0xC8, 0x17);
    //    myCAM.wrSensorReg8_16( 0xC6, 0xA503);
    //    myCAM.wrSensorReg8_16( 0xC8, 0x11);

    refresh();
    refreshMode();
  }
}

void load_patch_segment()
{
  uint16_t  start, size, data, offreg;
  uint16_t  pdata;
  int offset;

  //start = patch[0];   // start MCU_ADDRESS
  start = pgm_read_word(&patch_addr_0400[0]);
  //size = patch[1];    // data size
  size = pgm_read_word(&patch_addr_0400[1]);
  pdata = 2;     // data pointer
  offset = 0;         // MCU_DATA_0,7

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  while (size > 0)
  {
    if (offset == 0)
    {
      //mi2010soc_reg_write(0x1C6, start);  // write MCU_ADDRESS
      myCAM.wrSensorReg8_16( 0xC6, start);
      //printk(KERN_INFO "REG=1, 0xC6, 0x%04X t// MCU_ADDRESSn", start);
    }
    //data = *pdata++;
    data = pgm_read_word(&patch_addr_0400[pdata++]);
    //offreg = 0x1C8 + offset;
    //mi2010soc_reg_write(offreg, data);  // write MCU_ADDRESS

    //addr = 0x2003;
    //myCAM.wrSensorReg8_16( 0xC6, addr);
    myCAM.wrSensorReg8_16( 0xC8 + offset, data);
    //printk(KERN_INFO "REG=1, 0x%02X, 0x%04X t// MCU_DATA_%dn", offreg&0xff, data, offset);
    start += 2;
    size--;
    offset++;
    if (offset == 8)
      offset = 0;
  }
  return;
}

void call_vmt(uint16_t base) {
  uint16_t value, addr, v;

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  addr = 0x2003;
  value = base;
  myCAM.wrSensorReg8_16( 0xC6, addr);
  myCAM.wrSensorReg8_16( 0xC8, value);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  addr = 0xA002;
  value = 0x0001;
  myCAM.wrSensorReg8_16( 0xC6, addr);
  myCAM.wrSensorReg8_16( 0xC8, value);

  addr = 0xA002;
  myCAM.wrSensorReg8_16(0xC6, addr);
  myCAM.rdSensorReg8_16(0xC8, &v);
  while ( v != 0) {
    addr = 0xA002;
    myCAM.wrSensorReg8_16(0xC6, addr);
    myCAM.rdSensorReg8_16(0xC8, &v);
  }
}

void call_init(uint16_t base) {
  uint16_t value, v, addr;

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  addr = 0x2003;
  value = base;
  myCAM.wrSensorReg8_16( 0xC6, addr);
  myCAM.wrSensorReg8_16( 0xC8, value);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  addr = 0xA002;
  value = 0x0001;
  myCAM.wrSensorReg8_16( 0xC6, addr);
  myCAM.wrSensorReg8_16( 0xC8, value);

  addr = 0xA002;
  myCAM.wrSensorReg8_16(0xC6, addr);
  myCAM.rdSensorReg8_16(0xC8, &v);
  while ( v != 0) {
    addr = 0xA002;
    myCAM.wrSensorReg8_16(0xC6, addr);
    myCAM.rdSensorReg8_16(0xC8, &v);
  }
}

void resetCAM() {
  uint16_t state;
  Serial.println("reset CAM");

  myCAM.wrSensorReg8_16( 0xF0, 0x00);
  myCAM.wrSensorReg8_16( 0x65, 0xA000);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC3, 0x0501);

  myCAM.wrSensorReg8_16( 0xF0, 0x00);
  myCAM.wrSensorReg8_16( 0x0D, 0x0021);
  myCAM.wrSensorReg8_16( 0x0D, 0x0000);

  delayMicroseconds(10000);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA104);
  myCAM.rdSensorReg8_16( 0xC8, &state);

  Serial.print("mod.state : ");
  Serial.println(state);

  delayMicroseconds(200000);
  myCAM.wrSensorReg8_16( 0xF0, 0x00);
  myCAM.wrSensorReg8_16( 0x65, 0xA000);
  myCAM.wrSensorReg8_16( 0x66, 0x1001);
  myCAM.wrSensorReg8_16( 0x67, 0x0503);

  delayMicroseconds(15000);

  myCAM.wrSensorReg8_16( 0xF0, 0x00);
  myCAM.wrSensorReg8_16( 0x65, 0x2000);

  delayMicroseconds(15000);

  if (state != 3)
  {
    myCAM.wrSensorReg8_16( 0xF0, 0x01);
    myCAM.wrSensorReg8_16( 0xC6, 0xA103);
    myCAM.wrSensorReg8_16( 0xC8, 0X0001);
    // Waiting state to standby mode
    unsigned int count = 500000;
    while (state != 3 && count > 0) {
      myCAM.wrSensorReg8_16( 0xF0, 0x01);
      myCAM.wrSensorReg8_16( 0xC6, 0xA104);
      myCAM.rdSensorReg8_16( 0xC8, &state);
      count--;
    }
    Serial.print("mod.state : ");
    Serial.println(state);
    Serial.print("mod.state : ");
    Serial.println(500000 - count);
  }
  Serial.print("mod.state : ");
  Serial.println(state);

  //  myCAM.wrSensorReg8_16( 0xF0, 0x01);      //clear possible testpattern setting
  //  myCAM.wrSensorReg8_16( 0x48, 0x0000);
  //  refresh();
}

void refresh()
{
  uint16_t cmd;
  int i;
  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA103);
  myCAM.wrSensorReg8_16( 0xC8, 0X05);
  myCAM.wrSensorReg8_16( 0xC6, 0xA103);
  myCAM.rdSensorReg8_16( 0xC8, &cmd);
  while (( cmd != 0) && (i < 65535))
  {
    myCAM.wrSensorReg8_16( 0xC6, 0xA103);
    myCAM.rdSensorReg8_16( 0xC8, &cmd);
    i++;
  }
  if ( i == 65535)
    Serial.println("refresh time out");
}

void refreshMode()
{
  uint16_t cmd;
  int i;
  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA103);
  myCAM.wrSensorReg8_16( 0xC8, 0X06);
  while (( cmd != 0) && (i < 65535))
  {
    myCAM.wrSensorReg8_16( 0xC6, 0xA103);
    myCAM.rdSensorReg8_16( 0xC8, &cmd);
    i++;
  }
  if ( i == 65535)
    Serial.println("refreshMode time out");
}

void setSizes(uint16_t w1, uint16_t h1, uint16_t w2, uint16_t h2 ) {
  //  uint16_t w1,h1;
  //  uint16_t w2,h2;

  //  w1 = 0x0140;  320
  //  h1 = 0x00f0;  240
  //  w2 = 0x0320;  800
  //  h2 = 0x0258;  600
  //  w2 = 0x0640;  1600
  //  h2 = 0x04B0;  1200
  //msg("setSizes");

  // A context

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2703);
  myCAM.wrSensorReg8_16( 0xC8, w1);
  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2705);
  myCAM.wrSensorReg8_16( 0xC8, h1);

  // B context

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2707);
  myCAM.wrSensorReg8_16( 0xC8, w2);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2709);
  myCAM.wrSensorReg8_16( 0xC8, h2);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2779);
  myCAM.wrSensorReg8_16( 0xC8, w2);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x277B);
  myCAM.wrSensorReg8_16( 0xC8, h2);

  refreshMode();
  refresh();
}

void setFormats() {
  Serial.println("setFormat");

  // A context
  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA77D);
  myCAM.wrSensorReg8_16( 0xC8, 0X00020);

  // B context

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA77E);
  myCAM.wrSensorReg8_16( 0xC8, 0X0000);

  // Refresh Sequencer

  //  refreshMode();
  //  refresh();

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA103);
  myCAM.wrSensorReg8_16( 0xC8, 0X0006);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA103);
  myCAM.wrSensorReg8_16( 0xC8, 0X0005);

}

void doCapture(unsigned short restart_int) {

  Serial.println("doCapture");

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0x48, 0X0000);
  myCAM.wrSensorReg8_16( 0x49, 0X0000);
  myCAM.wrSensorReg8_16( 0x4A, 0X007f);
  myCAM.wrSensorReg8_16( 0x4B, 0X0000);

  myCAM.wrSensorReg8_16( 0xF0, 0x02);
  myCAM.wrSensorReg8_16( 0x00, 0X0001);
  //
  //  myCAM.wrSensorReg8_16( 0xF0, 0x01);      // set format B
  //  myCAM.wrSensorReg8_16( 0xC6, 0xA77E);
  //  myCAM.wrSensorReg8_16( 0xC8, 0X0000);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);      // switch to JPEG settings
  myCAM.wrSensorReg8_16( 0xC6, 0x270B);
  myCAM.wrSensorReg8_16( 0xC8, 0X0010);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2772);
  myCAM.wrSensorReg8_16( 0xC8, 0X0067);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2774);
  myCAM.wrSensorReg8_16( 0xC8, 0X0406);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA776);
  myCAM.wrSensorReg8_16( 0xC8, 0X0002);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2908);
  myCAM.wrSensorReg8_16( 0xC8, restart_int);  // set restart interval

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA907);
  myCAM.wrSensorReg8_16( 0xC8, 0X0010);     // enable scaled quantization

  refreshMode();
  refresh();

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA120);
  myCAM.wrSensorReg8_16( 0xC8, 0X0002);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA103);
  myCAM.wrSensorReg8_16( 0xC8, 0X0002);

}

void mirror() {
  uint16_t value;

  Serial.println("Mirror");

  myCAM.wrSensorReg8_16( 0xF0, 0x00);
  myCAM.rdSensorReg8_16( 0x20, &value);
  value |= 0x0001;
  myCAM.wrSensorReg8_16( 0x20, value);

  refresh();
}

void toggleTestpattern() {
  uint16_t value;

  Serial.println("Toggle testpattern");

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.rdSensorReg8_16( 0x48, &value);
  Serial.print("setting : ");
  Serial.println(value, HEX);
  if ( value == 0x0000) {
    myCAM.wrSensorReg8_16( 0x48, 0x0003);
  }
  else {
    myCAM.wrSensorReg8_16( 0x48, 0x0000);
  }
  myCAM.rdSensorReg8_16( 0x48, &value);
  Serial.print("setting : ");
  Serial.println(value, HEX);

  refresh();
}

void setup()
{
#if defined (__AVR__)
  Wire.begin();
#endif
#if defined(__arm__)
  Wire1.begin();
#endif
  Serial.begin(115200);
  Serial.println("hello");

  // set the slaveSelectPin as an output:
  pinMode(slaveSelectPin, OUTPUT);

  // initialize SPI:
  SPI.begin();
  myCAM.write_reg(ARDUCHIP_MODE, 0x00);
  myGLCD.InitLCD();

  myCAM.InitCAM();

  resetCAM();
  setFormats();
  //setSizes(0x140, 0x0f0, width, height);
  setSizes(width, height, width, height + OFFSET);
  load_patch_segment();
  call_vmt(0x52a);

  //    int mclk = 25000000;
  //    int scale = 65536;
  uint16_t addr, v;
  addr = 0x2611;
  myCAM.wrSensorReg8_16(0xF0, 0x01);
  myCAM.wrSensorReg8_16(0xC6, addr);
  //    v = (uint16_t) (mclk/scale);
  v = 0x17D;
  Serial.println(v, HEX);
  myCAM.wrSensorReg8_16(0xC8, v);
  myCAM.wrSensorReg8_16(0xC6, addr);
  myCAM.rdSensorReg8_16(0xC8, &v);
  Serial.println(v, HEX);

  delayMicroseconds(600000);;  //minimum delay 600 msec

  AF_mode();

  myCAM.wrSensorReg8_16(0xf0, 0x01);
  myCAM.wrSensorReg8_16(0xc6, 0x810D);
  myCAM.wrSensorReg8_16(0xc8, 0x0002);
  myCAM.wrSensorReg8_16(0xc6, 0x810E);
  myCAM.wrSensorReg8_16(0xc8, 0x00c4);

  call_init(0x400);

  Serial.println("end patch loading");

  doCapture(0x20);

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

void loop()
{
  char str[8];
  static int k = 0;
  uint8_t temp;
  uint16_t value, length_low, length_high;
  uint32_t length;
  int time = 0;
  myCAM.write_reg(ARDUCHIP_MODE, 0x01);		 			//Switch to CAM

  while (1)
  {
    if (Serial.available()) {
      temp = Serial.read();
      if (temp == 't') {
        toggleTestpattern();
      }
      if (temp == 'f') {
        AF_refocus();
        Serial.println("AF refocus");
      }
    }

    temp = myCAM.read_reg(ARDUCHIP_TRIG);
    time++;
    if (!(temp & VSYNC_MASK))				 			//New Frame is coming
    {
      //      Serial.print("VSYNC ");
      //      Serial.println(time);
      time = 0;
      myCAM.write_reg(ARDUCHIP_MODE, 0x00);    		//Switch to MCU
      myGLCD.resetXY();
      myCAM.write_reg(ARDUCHIP_MODE, 0x01);    		//Switch to CAM
      while (!(myCAM.read_reg(ARDUCHIP_TRIG) & 0x01)) {
        time++;
      } 	                                        //Wait for VSYNC is gone
      //      Serial.print("VSYNC gone ");
      //      Serial.println(time);
      time = 0;
    }
    else if (temp & SHUTTER_MASK)
    {
      AF_refocus();
      delay(4000);
      Serial.println("trigger");
      k = k + 1;
      strcat(str, "mt9d111");
      itoa(k, str, 10);
      strcat(str, ".jpg");								//Generate file name
      myCAM.write_reg(ARDUCHIP_MODE, 0x00);    		//Switch to MCU, freeze the screen

      GrabImage(str);
      Serial.println("grab done");
    }
  }
}

void GrabImage(char* str)
{
  File outFile;
  int i;
  uint16_t k1 = 0;
  uint16_t k2 = 0;
  uint16_t length_high1;
  uint16_t length_low1;
  char ch;

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0xA90f);
  myCAM.rdSensorReg8_16( 0xC8, &length_high1);
  //Serial.print("jpeg image length high ");
  //Serial.println(length_high1, HEX);

  myCAM.wrSensorReg8_16( 0xF0, 0x01);
  myCAM.wrSensorReg8_16( 0xC6, 0x2910);
  myCAM.rdSensorReg8_16( 0xC8, &length_low1);
  //Serial.print("jpeg image length low ");
  //Serial.println(length_low1, HEX);

  Serial.println(str);
  outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC );  // overwrite if file exists
  if (! outFile)
  {
    Serial.println("Open File Error");
    return;
  }

  //Switch to FIFO Mode
  myCAM.write_reg(ARDUCHIP_TIM, 0x10);
  //Flush the FIFO
  myCAM.flush_fifo();
  //Start capture
  myCAM.start_capture();

  //Polling the capture done flag
  while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK));

  //Write the JPEG header
  for ( i = 0; i < 0x9f; i++)
  {
    ch = pgm_read_byte(&JPEG_header[i]);
    outFile.write((uint8_t*)&ch, 1);
    Serial.write(ch);
  }

  ch = (uint8_t) (height >> 8);
  outFile.write((uint8_t*)&ch, 1);
  Serial.write(ch);
  ch = (uint8_t) (height & 0xFF);
  outFile.write((uint8_t*)&ch, 1);
  Serial.write(ch);
  ch = (uint8_t) (width >> 8);
  outFile.write((uint8_t*)&ch, 1);
  Serial.write(ch);
  ch = (uint8_t) (width & 0xFF);
  outFile.write((uint8_t*)&ch, 1);
  Serial.write(ch);
  for ( i = 0xA3; i < JPEGIMAGEOFFSET; i++)
  {
    ch = pgm_read_byte(&JPEG_header[i]);
    outFile.write((uint8_t*)&ch, 1);
    Serial.write(ch);
  }

  for ( k2 = 0; k2 < length_high1; k2++)
  {
    for ( k1 = 0; k1 < 0xffff; k1++) {
      ch = myCAM.read_fifo();
      outFile.write((uint8_t*)&ch, 1);
      Serial.write(ch);
    }
  }
  for ( k1 = 0; k1 < length_low1; k1++) {
    ch = myCAM.read_fifo();
    outFile.write((uint8_t*)&ch, 1);
    Serial.write(ch);
  }
  ch = (uint8_t) (0xFF);
  outFile.write((uint8_t*)&ch, 1);
  Serial.write(ch);
  ch = (uint8_t) (0xD9);
  outFile.write((uint8_t*)&ch, 1);
  Serial.write(ch);
  //Close the file
  outFile.close();

  //Clear the capture done flag
  myCAM.clear_fifo_flag();

  //Switch to LCD Mode
  myCAM.write_reg(ARDUCHIP_TIM, 0);
  Serial.println("file written");
  return;
}

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


Create motor_5.ino

Create motor_5.ino

#include <Wire.h>
double potcurval;    // variable to read the value from the analog pin
int angel; //Integer value of angle
 double angle =135;

 double curangle,kP=10.00,kI=25,kD=1.85,Last=0;
 double P=0,I=0,D=0,Drive,Error=0,Integral=0;

 void backward()
 {
   digitalWrite(12,HIGH);
   digitalWrite(9,LOW);
 }
  void forward()
 {
   digitalWrite(12,LOW);
   digitalWrite(9,HIGH);
 }
 void halt()
 {
    digitalWrite(12,LOW);
    digitalWrite(9,LOW);
 }
void setup()
{
  // myservo.attach(6);  // attaches the servo on pin 9 to the servo object
  pinMode(9,OUTPUT);
  pinMode(12,OUTPUT);
  Serial.begin(9600);
  pinMode(11,OUTPUT);
  Wire.begin(5);
  Wire.onReceive(receiveEvent);
  pinMode(13, OUTPUT);
}
 void Errorcalc()
 {
   potcurval=(double)analogRead(A0)+1;
   potcurval=(potcurval/1024)*5;
    curangle=(potcurval/5)*270;

                Error = curangle-angle;
 }
void loop()
{
           Serial.print("got: ");
	   Serial.println(angle);
	   if(angle > 127) digitalWrite(13, HIGH);
	   else digitalWrite(13, LOW);
                 Errorcalc();
                if (abs(Error) <.6){ // prevent integral 'windup'
                Integral = Integral + Error; // accumulate the error integral
                }
                else {
                Integral=0; // zero it if out of bounds
                }
                P = Error*kP; // calc proportional term
                I = Integral*kI; // integral term
                D = (Last-curangle)*kD; // derivative term

                Drive = P + I + D; // Total drive = P+I+D

                //Drive = (Drive/550)*255; // scale Drive to be in the range 0-255

                if(abs(Drive) < 60)
                {
                  Drive += (Drive/abs(Drive)) *60;
                }
                if (abs(Drive)>255) {
                Drive=(Drive/abs(Drive)) *255;
                }

                Serial.println(Error);
                if (Error < 0){ // Check which direction to go.
                forward();

                }
                else if(Error >=0){ // depending on the sign of Error
                 backward();

                }

                if(abs(Error)<2)
                {
                  halt();
                  Serial.println("break !!!");
                }

                analogWrite (11,abs(Drive)); // send PWM command to motor board
                Last=curangle;
   /*
    Serial.println("P :");
    Serial.println(P);
    Serial.println("I :");
    Serial.println(I);
    Serial.println("D :");
    Serial.println(D);
    */

}
void receiveEvent(int howMany)
{
  int x = Wire.read();
  angle = (double) x;
}

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


basic firmware using built-in RGB LED

basic firmware using built-in RGB LED

#define SET_ALARM_PORT 42620
#define DISCOVERY_PORT 42621

UDP Discovery;
UDP SetAlarm;

#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)
unsigned long lastSync = millis();

#define RED 0
#define GREEN 1
#define BLUE 2
#define HOUR 3
#define MINUTE 4
#define SET 5

byte alarm[6];

void setup() {
	Discovery.begin(DISCOVERY_PORT);
	SetAlarm.begin(SET_ALARM_PORT);
	for (byte b = 0; b < 6; b++) alarm[b] = EEPROM.read(b);
}

void loop() {
	byte buf[64];
	if (Discovery.parsePacket() > 0) {
		Discovery.flush();
		String myID = Spark.deviceID();
		myID.toCharArray((char*)buf, 64);
		Discovery.beginPacket(Discovery.remoteIP(), DISCOVERY_PORT);
		Discovery.write(buf, myID.length());
		Discovery.endPacket();
	}
	if (SetAlarm.parsePacket() > 4) {
		SetAlarm.read((char*)alarm, 5);
		SetAlarm.flush();
		SetAlarm.beginPacket(SetAlarm.remoteIP(), SET_ALARM_PORT);
		SetAlarm.write((byte*)"ACK", 3);
		SetAlarm.endPacket();
		alarm[SET] = 1;
		for (byte b = 0; b < 6; b++) EEPROM.write(b, alarm[b]);
	}
	if (alarm[SET] && alarm[HOUR] == Time.hour() && alarm[MINUTE] == Time.minute()) {
		RGB.control(true);
		RGB.brightness(0);
		RGB.color(alarm[RED], alarm[GREEN], alarm[BLUE]);
		for (byte b = 0; b < 255; b++) {
			RGB.brightness(b + 1);
			delay(64);
		}
		playMelody();
	}
	if (millis() - lastSync > ONE_DAY_MILLIS) {
		// Request time synchronization from the Spark Cloud
		Spark.syncTime();
		lastSync = millis();
	}
}

#define speakerPin A0

// notes in the melody:
// http://imslp.org/wiki/Peer_Gynt_Suite_No.1,_Op.46_%28Grieg,_Edvard%29#Full_Scores

// H, #G, #F // E, #F, #G // H, [#G, A], #G // #F, E, [#F, #G, #F, #G]
// [#G, A], H, #G, H // #C, #G, #C // H, #G, #F, (E)

// http://www.phy.mtu.edu/~suits/notefreqs.html

int melody[] = {
	1976, 1661, 1480,
	1319, 1480, 1661,
	1976, 1661, 1760, 1661, 1480,
	1319, 1480, 1661, 1480, 1661,

	1661, 1760, 1976, 1661, 1976,
	2217, 1661, 2217,
	1976, 1661, 1480, 1319
	};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
	8, 8, 8,
	8, 8, 8,
	10, 40, 40, 10, 8,
	8, 16, 16, 16, 16,

	40, 40, 10, 10, 8,
	8, 8, 8,
	8, 8, 8, 4
	};

void playMelody() {
  // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 28; thisNote++) {

    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 2000 / noteDurations[thisNote];
    tone(speakerPin, melody[thisNote], noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.20;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(speakerPin);
  }
}

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


Ajout du script Arduino

Ajout du script Arduino

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4 );

void setup()
{
  Serial.begin(9600);
  lcd.init(); // initialize the lcd
  lcd.backlight();
  lcd.print("Setup Arduino"); // Print a message to the LCD.
}

void loop()
{
  if (Serial.available())  {
    lcd.clear();
    lcd.print(Serial.readString());
  }
}

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


Adding the OLED menu renderer from  Matthew Nielsen, see https://github.com/jonblack/arduino-menusystem/pull/80/commits/d26dc026b227479e98d2d605b4afda5a0e3e8a3a

/*
 * oled_ssd1306.ino - Example code using the menu system library
 *
 * This example shows using the menu system with an OLED display controlled
 * controled over serial.
 *
 * It is targeted at a 128x64 or 128x32 OLED display that is based on the
 * SSD1306 driver IC (most on eBay and Amazon are) and connected via I2C.
 * It depends on the "SSD1306Ascii" library which can be found in the Arduino
 * IDE Library Manager or at https://github.com/greiman/SSD1306Ascii.
 *
 * If your particular display supports SPI then this code can be easily
 * modified based on the SPI examples in the "SSD1306Ascii" library.
 *
 * Contributed by Matthew Nielsen with all rights transfered to Jon Black
 * Copyright (c) 2015 arduino-menusystem
 * Licensed under the MIT license (see LICENSE)
 */

#include <MenuSystem.h>

/* The address of the OLED display. 0x3C is the default for of most modules */
#define I2C_ADDRESS 0x3C

#include <Arduino.h> // Used by SSD1306Ascii
/* Wire.h is not always required, depending on target platform */
// #include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
SSD1306AsciiWire oled;

class MyRenderer : public MenuComponentRenderer {
public:
    void render(Menu const& menu) const {
        oled.clear();

        if (menu.get_name() == "") {
            oled.println("Main Menu");
        } else {
            oled.println(menu.get_name());
        }

        for (int i = 0; i < menu.get_num_components(); ++i) {
            MenuComponent const* cp_m_comp = menu.get_menu_component(i);
            if (cp_m_comp->is_current()) {
                oled.print(">");
            } else {
                oled.print(" ");
            }
            cp_m_comp->render(*this);

            oled.println("");
        }
    }

    void render_menu_item(MenuItem const& menu_item) const {
        oled.print(menu_item.get_name());
    }

    void render_back_menu_item(BackMenuItem const& menu_item) const {
        oled.print(menu_item.get_name());
    }

    void render_numeric_menu_item(NumericMenuItem const& menu_item) const {
        oled.print(menu_item.get_name());
    }

    void render_menu(Menu const& menu) const {
        oled.print(menu.get_name());
    }
};
MyRenderer my_renderer;

// Forward declarations

void on_item1_selected(MenuComponent* p_menu_component);
void on_item2_selected(MenuComponent* p_menu_component);
void on_item3_selected(MenuComponent* p_menu_component);

// Menu variables

MenuSystem ms(my_renderer);
MenuItem mm_mi1("Level 1 - Item 1 (Item)", &on_item1_selected);
MenuItem mm_mi2("Level 1 - Item 2 (Item)", &on_item2_selected);
Menu mu1("Level 1 - Item 3 (Menu)");
MenuItem mu1_mi1("Level 2 - Item 1 (Item)", on_item3_selected);

// Menu callback function

void on_item1_selected(MenuComponent* p_menu_component) {
    oled.clear();
    oled.print("Item1 Selected");
    delay(1500); // so we can look the result on the display
}

void on_item2_selected(MenuComponent* p_menu_component) {
    oled.clear();
    oled.print("Item2 Selected");
    delay(1500); // so we can look the result on the display
}

void on_item3_selected(MenuComponent* p_menu_component) {
    oled.clear();
    oled.print("Item3 Selected");
    delay(1500); // so we can look the result on the display
}

void serial_print_help() {
    Serial.println("***************");
    Serial.println("w: go to previus item (up)");
    Serial.println("s: go to next item (down)");
    Serial.println("a: go back (right)");
    Serial.println("d: select \"selected\" item");
    Serial.println("?: print this help");
    Serial.println("h: print this help");
    Serial.println("***************");
}

void serial_handler() {
    char inChar;
    if ((inChar = Serial.read()) > 0) {
        switch (inChar) {
            case 'w': // Previus item
                ms.prev();
                ms.display();
                break;
            case 's': // Next item
                ms.next();
                ms.display();
                break;
            case 'a': // Back presed
                ms.back();
                ms.display();
                break;
            case 'd': // Select presed
                ms.select();
                ms.display();
                break;
            case '?':
            case 'h': // Display help
                serial_print_help();
                break;
            default:
                break;
        }
    }
}

// Standard arduino functions

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

    // Initialize the OLED display
    Wire.begin();
    oled.begin(&Adafruit128x64, I2C_ADDRESS);
    oled.setFont(System5x7);
    oled.print("Display Initialized");

    serial_print_help();

    ms.get_root_menu().add_item(&mm_mi1);
    ms.get_root_menu().add_item(&mm_mi2);
    ms.get_root_menu().add_menu(&mu1);
    mu1.add_item(&mu1_mi1);

    ms.display();
}

void loop() {
    serial_handler();
}

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


Arduino sketch, testing communication between each component. Simply activates lights (I haven't gotten my servos yet).

//Test kit

int light = 12;
int FLF = 2;
int FLB = 8;
int FRF = 3;
int FRB = 4;
int BLF = 6;
int BLB = 7;
int BRF = 9;
int BRB = 10;

void setup(){
  Serial.begin(9600);
  Serial.println("Light Test");
  for(int i = 0; i < 13; i++){
    pinMode(i, OUTPUT);
  }
}

void leftForward(boolean on){
 if(on){
   digitalWrite(FLF, HIGH);
   digitalWrite(FLB, HIGH);
 }else{
    digitalWrite(FLF, LOW);
    digitalWrite(FLB, LOW);
 }
}

void rightForward(boolean on){
  if(on){
   digitalWrite(FRF, HIGH);
   digitalWrite(FRB, HIGH);
 }else{
    digitalWrite(FRF, LOW);
    digitalWrite(FRB, LOW);
 }
}

void lights(boolean on){
  if(on){
   digitalWrite(light, HIGH);
 }else{
    digitalWrite(light, LOW);
 }
}

void leftBack(boolean on){
  if(on){
   digitalWrite(BLF, HIGH);
   digitalWrite(BLB, HIGH);
 }else{
    digitalWrite(BLF, LOW);
    digitalWrite(BLB, LOW);
 }
}

void rightBack(boolean on){
  if(on){
   digitalWrite(BRF, HIGH);
   digitalWrite(BRB, HIGH);
 }else{
    digitalWrite(BRF, LOW);
    digitalWrite(BRB, LOW);
 }
}

void loop(){
  char message = Serial.read();

  if(message == 'L'){
   leftForward(true);
  }else if(message == 'R'){
   rightForward(true);
  }else if(message == 'l'){
   leftForward(false);
  }else if(message == 'r'){
   rightForward(false);
  }else if(message == 'H'){
    lights(true);
  }else if(message == 'h'){
   lights(false);
  }else if(message == 'D'){
   rightBack(true);
  }else if(message == 'd'){
   rightBack(false);
  }else if(message == 'T'){
   leftBack(true);
  }else if(message == 't'){
   leftBack(false);
  }else{
   //Moo! I'm a cow
  }

}

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


Classic JoyStick

Classic JoyStick

Commodore 64/Amiga, Atari 2600/XL/ST, ZX Spectrum, Amstrad CPC, MSX and
many others compatible Joystick

 * Auth: John Milner / jfrmilner
 *
 * Version
 * 1.0
 *
 * Date
 * May 2016
 *
 * Hardware
 * ATmega32u4 based Arduino (Arduino Leonardo/Micro)
 * Competition Pro 5000 - http://www.vesalia.de/e_comp5000.htm (example)
 *
 * 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
 * VICE (C64 Emulator) - http://vice-emu.sourceforge.net/
 *
 * Pinout Reference (C64) - http://old.pinouts.ru/Inputs/ControlPortC64_pinout.shtml
 *
 * DE9 female plug on end view:
 * 5 4 3 2 1
 *  9 8 7 6
 * pin 1: JOY_UP
 * pin 2: JOY_DOWN
 * pin 3: JOY_LEFT
 * pin 4: JOY_RIGHT
 * pin 5: No Connection
 * pin 6: JOY_BUTTON
 * pin 7: No Connection
 * pin 8: Ground
 * pin 9: No Connection
 *
 */

#include <Joystick.h>

// Arduino Controller input Pins
const int JOY_UP = 2;
const int JOY_DOWN = 3;
const int JOY_LEFT = 4;
const int JOY_RIGHT = 5;
const int JOY_BUTTON = 6;

void setup()
{
  pinMode(JOY_UP, INPUT_PULLUP);
  pinMode(JOY_DOWN, INPUT_PULLUP);
  pinMode(JOY_LEFT, INPUT_PULLUP);
  pinMode(JOY_RIGHT, INPUT_PULLUP);
  pinMode(JOY_BUTTON, INPUT_PULLUP);

  // Initialize Joystick Library
  Joystick.begin(false);
}

void loop()
{
  // button
  !digitalRead(JOY_BUTTON) ? Joystick.pressButton(0) : Joystick.releaseButton(0);

  // digital xy axis
  Joystick.setXAxis(0);
  Joystick.setYAxis(0);
  if (!digitalRead(JOY_UP)) Joystick.setYAxis(-127);
  if (!digitalRead(JOY_DOWN)) Joystick.setYAxis(127);
  if (!digitalRead(JOY_LEFT)) Joystick.setXAxis(-127);
  if (!digitalRead(JOY_RIGHT)) Joystick.setXAxis(127);

  Joystick.sendState();

  delay(50);
}

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


going back and forth reduces calibration width


added code for the new Receiver

added code for the new Receiver

tested on Arduino as well as ATmega328p with the Sender module.

/*
**  ModuleNameATmega.ino
**  MakerWear ModuleName Module's ATmega Program.
**
**  Description
**  Description
**  Description
**
**
**  ATmega328 Pin Configurations:
**
**  Pin 1  (Reset):                          Pin 28  (A5):
**  Pin 2  (D0/RX):                          Pin 27  (A4):
**  Pin 3  (D1/TX):                          Pin 26  (A3):
**  Pin 4  (D2):                             Pin 25  (A2):
**  Pin 5  (D3/PWM):                         Pin 24  (A1):
**  Pin 6  (D4):                             Pin 23  (A0):       Module Input
**  Pin 7  (PWR):                            Pin 22  (GND):
**  Pin 8  (GND):                            Pin 21  (AREF):
**  Pin 9  (XTAL1):                          Pin 20  (AVCC):
**  Pin 10 (XTAL2):                          Pin 19  (D13):
**  Pin 11 (D5/PWM):                         Pin 18  (D12):
**  Pin 12 (D6/PWM):                         Pin 17  (D11/PWM):
**  Pin 13 (D7):                             Pin 16  (D10/PWM):
**  Pin 14 (D8):                             Pin 15  (D9/PWM):
**
**
**  Created on xx/yy/zz.
**  By Akbar Akbari
**  Modified on xx/yy/zz.
**  By Asghar Asghari
**
**  MakerWear Link:
**  Github Link:      github.com/myjeeed/MakerWear
**
*/

//#include <FilteredAnalogInput.h>
#include <IRremote2.h>

int input_pin = A0;                              //pin 23 on ATmega328
int filter_size = 15;                        //Noise reduction filter size
int ir_pin = 8;                               //D8 which is pin 14 on ATmega
int output_pin = 9;                          //pin 15 on ATmega

//FilteredAnalogInput input(input_pin, filter_size);

IRrecv irrecv(ir_pin);

decode_results results;
void setup()
{
  Serial.begin(9600);
   irrecv.enableIRIn(); // Start the receiver
}
 int output_val = 0;
void loop()
{

  if (irrecv.decode(&results)) {

    switch(results.value){
      case 0x001:
        output_val = 0;
        break;

      case 0x002:
        output_val = 1 * 32 + 16;
        break;

      case 0x004:
        output_val = 2 * 32 + 16;
        break;

      case 0x008:
        output_val = 3 * 32 + 16;
        break;

      case 0x010:
        output_val = 4 * 32 + 16;
        break;

      case 0x020:
        output_val = 5 * 32 + 16;
        break;

      case 0x040:
        output_val = 6 * 32 + 16;
        break;

      case 0x080:
        output_val = 255;
        break;
    }
        Serial.println(output_val);
    //
    irrecv.resume(); // Receive the next value
  }
  delay(100);
  analogWrite(output_pin, output_val);
}

error: pathspec 'Modules/Sensor/Receiver/ArduinoCodes/ReceiverATmega/ReceiverATmega.ino' did not match any file(s) known to git


Removed non-functional RF code.

Removed non-functional RF code.

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


Create VL53L1X_FastLED.ino

Create VL53L1X_FastLED.ino

////////////////////////////////////////////////////////////////
// FastLED: Control (5v) WS2812 RGB LED Modules in a strip
// -------------------------------------------------------
// Wiring info: https://learn.adafruit.com/digital-led-strip/wiring
// -5V  = 5V
// -GND = GND
// -DIN = Digital 2
////////////////////////////////////////////////////////////////

// LED library includes
#include <FastLED.h>
#define DATA_PIN 2

// lights config
#define NUM_LEDS 100
CRGB leds[NUM_LEDS];

// interval between hardware updates
static unsigned long lastLEDTime = 0;
const long ledInterval = 16;

////////////////////////////////////////////////////////////////
// VL53L1X: Read distance from sensor in mm
// ----------------------------------------
// Wiring info: https://learn.adafruit.com/adafruit-vl53l0x-micro-lidar-distance-sensor-breakout/arduino-code
// VIN -> VIN
// GND -> GND
// SCL -> SCL || A5
// SDA -> SDA || A4
////////////////////////////////////////////////////////////////

// sensor library includes
#include <Wire.h>
#include <VL53L1X.h>

// sensor object
VL53L1X sensor;
int sensorMM = 0;

// interval between hardware updates
static unsigned long lastSensorTime = 0;
const long sensorInterval = 100;

////////////////////////////////////////////////////////////////
// Main app:
// Read VL53L1X data and use it to light up WS2812 LEDs
////////////////////////////////////////////////////////////////

unsigned long now;

void setup() {
  initSerial();
  initSensor();
  initLEDs();
}

void loop() {
  now = millis(); // get durrent time. usually a single device interface would use something like `delay(100)`
  updateSensor();
  updateLEDs();
}

////////////////////////////
// Make serial connection for logging to Serial Monitor
////////////////////////////

void initSerial() {
  // Connect to serial so we can watch debug values
  Serial.begin(115200);
  Serial.setTimeout(0);
  Serial.println("<Arduino is ready>");
}

////////////////////////////
// Sensor communication
////////////////////////////

void initSensor() {
  Serial.println("mVL53L1X initializing");
  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C

  // Attempt to initialize the sensor library
  sensor.setTimeout(500);
  if (!sensor.init()) {
    Serial.println(F("Failed to detect and initialize VL53L1X"));
    while (1);
  } else {
    Serial.println("VL53L1X API Started");
  }

  // Configure the sensor
  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(50000);
  sensor.startContinuous(50);
  Serial.println("VL53L1X API Configured");
}

void updateSensor() {
  // set delay between updates
  if (now < lastSensorTime + sensorInterval) return;
  lastSensorTime = now;

  int distanceMM = sensor.read();
  if (sensor.timeoutOccurred()) {
    Serial.println(F("VL53L0X error: Timeout"));
  } else {
    Serial.println("Dist (mm): "+String(distanceMM));
    sensorMM = distanceMM;
  }
}

////////////////////////////
// LED communication
////////////////////////////

void initLEDs() {
  FastLED.addLeds<WS2812B, DATA_PIN>(leds, NUM_LEDS);
}

void updateLEDs() {
  // set delay between updates
  if (now < lastLEDTime + ledInterval) return;
  lastLEDTime = now;

  // update all LEDs every frame
  int numToLight = sensorMM / 10;
  for(int i = 0; i < NUM_LEDS; i++) {
    // are we below threshold or not?
    if(i < numToLight) {
      leds[i] = CRGB(10, 10, 10); // CRGB::White;
    } else {
      leds[i] = CRGB::Black;
    }
  }

  // Show the leds (only one of which is set to white, from above)
  FastLED.show();
}

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


Updated files

Updated files

Updated files to current version

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/dklilley/FeatherLogger_Arduino.git/'


Added internal voltage sample code

Added internal voltage sample code

long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1125300L / result; // Back-calculate AVcc in mV
  return result;
}

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

void loop() {
  Serial.println( readVcc(), DEC );
  delay(1000);
}

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


adding lesson 2 mode-switch routine

adding lesson 2 mode-switch routine

int buttonPin = 4;

int ledPin_R = 13;
int ledPin_G = 12;
int ledPin_B = 11;

int currentPinMode = 0;

void setup() {
  // set pin 4 for input, pin 11-13 for output
  pinMode(buttonPin, INPUT);
  pinMode(ledPin_R, OUTPUT);
  pinMode(ledPin_G, OUTPUT);
  pinMode(ledPin_B, OUTPUT);

  // turn off all those LEDs by setting them HIGH
  digitalWrite(ledPin_R, HIGH);
  digitalWrite(ledPin_G, HIGH);
  digitalWrite(ledPin_B, HIGH);
}

void loop() {
  // read input
  int reading = digitalRead(buttonPin);

  // advance our mode by 1!
  if (reading==HIGH){
    currentPinMode = currentPinMode + 1;
    if (currentPinMode>3) {
      currentPinMode = 0;
    }
  }

  switch (currentPinMode) {
    case 0: // red
      digitalWrite(ledPin_R, LOW);
      digitalWrite(ledPin_G, HIGH);
      digitalWrite(ledPin_B, HIGH);
      break;

    case 1: // green
      digitalWrite(ledPin_R, HIGH);
      digitalWrite(ledPin_G, LOW);
      digitalWrite(ledPin_B, HIGH);
      break;

    case 2: // blue
      digitalWrite(ledPin_R, HIGH);
      digitalWrite(ledPin_G, HIGH);
      digitalWrite(ledPin_B, LOW);
      break;
  }
}

error: pathspec 'lesson-2/simple_digital_input_modes.ino' did not match any file(s) known to git


Add key event message

Add key event message

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/mvines/futboard.git/'


changed angledrive.ino to handle inverted motors

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


Open loop on the top, closed on the bottom

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/FirstBuild/pizzaduino.git/'


Releasing v1.0.10

Releasing v1.0.10


Pulse ox with software timer and state diagram working.

float InputPin = A0; // Analog input pin from output of op amp
float sensorVoltage = 0;
float sensorCurrent = 0;
float LEDCurrentRed = 0;
float AbsorbanceRed = 0;
float LEDCurrentIR = 0;
float AbsorbanceIR = 0;
float CalculatedRatio;
float bloodOx = 0;
int LEDRed=D0;
int LEDIR=D1;
bool red_state;
bool ir_state;
bool state_diag;

#include<math.h>

//#define DEBUG_ON 1
#define MULT_CONSTANT (3.3/(15000000*4095))*1000000 //150000000 is resistance
#define LED_CURRENT 4.8/1000 // 4.8V by 1k Ohms

//SYSTEM_MODE(MANUAL);

Timer change_led_timer(3000, change_led_type);
//Timer change_ir_timer(6000, change_ir_type);
//Timer ir_timer(6000, read_ir_and_calc);
//Timer call_connect_timer(20000, call_connect);

void setup() {
Serial.begin(9600);
pinMode(LEDRed, OUTPUT);
pinMode(LEDIR, OUTPUT);
pinMode(InputPin, INPUT);
red_state = false;
ir_state  = true;
state_diag  = true; // Init state
//ir_timer.start();
change_led_timer.start();
//change_ir_timer.start();
//call_connect_timer.start();
}

void loop() {
    // red_led_on and start red_timer
    if(red_state)
    {
       read_red_and_calc();
       red_state  =  false;
       ir_state   =  false;
    }

    if(ir_state)
    {
      read_ir_and_calc();
      red_state = false;
      ir_state  = false;
    }
    //else
    //{
      // do nothing
    //}
} // loop

void red_led_on()
{
  digitalWrite(LEDIR, LOW); digitalWrite(LEDRed, HIGH);
}

void ir_led_on()
{
  digitalWrite(LEDRed, LOW); digitalWrite(LEDIR, HIGH);
}

void read_red_and_calc()
{
  ir_led_on();
  sensorVoltage = analogRead(InputPin);
  sensorCurrent = (sensorVoltage*MULT_CONSTANT);
  AbsorbanceRed = log10(sensorCurrent/LED_CURRENT);
#ifdef DEBUG_ON
  Serial.print("Voltage Red = ");
  Serial.println(sensorVoltage);
  Serial.print("Current Red = ");
  Serial.println(sensorCurrent);
#endif
}

void read_ir_and_calc()
{
  red_led_on();
  sensorVoltage = analogRead(InputPin);
  sensorCurrent = (sensorVoltage*MULT_CONSTANT);
  AbsorbanceIR = log10(sensorCurrent/LED_CURRENT);
#ifdef DEBUG_ON
  Serial.print("Voltage IR = ");
  Serial.println(sensorVoltage);
  Serial.print("Current IR = ");
  Serial.println(sensorCurrent);
#endif
  CalculatedRatio =  AbsorbanceRed/(AbsorbanceIR + AbsorbanceRed);
  bloodOx = -30.667*CalculatedRatio*CalculatedRatio + 10*CalculatedRatio  + 102.67;
  Serial.print("Blood Ox % = " );
  Serial.println(bloodOx);
}

void change_led_type()
{
    if(state_diag)
    {
      red_state = true;
      ir_state  = false;
    }
    else
    {
      red_state = false;
      ir_state  = true;
    }
    state_diag  = !state_diag;
}

void call_connect()
{
  Particle.connect();
}

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


minor RFID read update

minor RFID read update

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