Added soundmeter

Added soundmeter

/****************************************
Scrolling Sound Meter Sketch for the
Adafruit Microphone Amplifier
****************************************/

#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

// Include the Matrix code for display
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();

const int maxScale = 8;
const int redZone = 5;

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

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

   matrix.begin(0x70);  // pass in the address
}

void loop()
{
   unsigned long startMillis= millis();  // Start of sample window
   unsigned int peakToPeak = 0;   // peak-to-peak level

   unsigned int signalMax = 0;
   unsigned int signalMin = 1024;

   while (millis() - startMillis < sampleWindow)
   {
      sample = analogRead(0);
      if (sample < 1024)  // toss out spurious readings
      {
         if (sample > signalMax)
         {
            signalMax = sample;  // save just the max levels
         }
         else if (sample < signalMin)
         {
            signalMin = sample;  // save just the min levels
         }
      }
   }
   peakToPeak = signalMax - signalMin;
   Serial.println(peakToPeak);

   // map 1v p-p level to the max scale of the display
   int displayPeak = map(peakToPeak, 0, 512, 0, maxScale);
   Serial.println(displayPeak);
   // Update the display:
   for (int i = 0; i < 7; i++)  // shift the display left
   {
      matrix.displaybuffer[i] = matrix.displaybuffer[i+1];
   }

   // draw the new sample
   for (int i = 0; i <= maxScale; i++)
   {
      if (i >= displayPeak)  // blank these pixels
      {
         matrix.drawPixel(i, 7, 0);
      }
      else if (i < redZone) // draw in green
      {
         matrix.drawPixel(i, 7, LED_GREEN);
      }
      else // Red Alert!  Red Alert!
      {
         matrix.drawPixel(i, 7, LED_RED);
      }
   }
   matrix.writeDisplay();  // write the changes we just made to the display
}

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


[SocketIO] add example for use of ACK / callback handling

/*
 * WebSocketClientSocketIOack.ino
 *
 *  Created on: 20.07.2019
 *
 */

#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ArduinoJson.h>

#include <WebSocketsClient.h>
#include <SocketIOclient.h>

#include <Hash.h>

ESP8266WiFiMulti WiFiMulti;
SocketIOclient socketIO;

#define USE_SERIAL Serial

void socketIOEvent(socketIOmessageType_t type, uint8_t * payload, size_t length) {
    switch(type) {
        case sIOtype_DISCONNECT:
            USE_SERIAL.printf("[IOc] Disconnected!\n");
            break;
        case sIOtype_CONNECT:
            USE_SERIAL.printf("[IOc] Connected to url: %s\n", payload);
            break;
        case sIOtype_EVENT:
        {
            char * sptr = NULL;
            int id = strtol((char *)payload, &sptr, 10);
            USE_SERIAL.printf("[IOc] get event: %s id: %d\n", payload, id);
            if(id) {
                payload = (uint8_t *)sptr;
            }
            DynamicJsonDocument doc(1024);
            DeserializationError error = deserializeJson(doc, payload, length);
            if(error) {
                USE_SERIAL.print(F("deserializeJson() failed: "));
                USE_SERIAL.println(error.c_str());
                return;
            }

            String eventName = doc[0];
            USE_SERIAL.printf("[IOc] event name: %s\n", eventName.c_str());

            // Message Includes a ID for a ACK (callback)
            if(id) {
                // creat JSON message for Socket.IO (ack)
                DynamicJsonDocument docOut(1024);
                JsonArray array = docOut.to<JsonArray>();

                // add payload (parameters) for the ack (callback function)
                JsonObject param1 = array.createNestedObject();
                param1["now"] = millis();

                // JSON to String (serializion)
                String output;
                output += id;
                serializeJson(docOut, output);

                // Send event
                socketIO.send(sIOtype_ACK, output);
            }
        }
            break;
        case sIOtype_ACK:
            USE_SERIAL.printf("[IOc] get ack: %u\n", length);
            hexdump(payload, length);
            break;
        case sIOtype_ERROR:
            USE_SERIAL.printf("[IOc] get error: %u\n", length);
            hexdump(payload, length);
            break;
        case sIOtype_BINARY_EVENT:
            USE_SERIAL.printf("[IOc] get binary: %u\n", length);
            hexdump(payload, length);
            break;
        case sIOtype_BINARY_ACK:
            USE_SERIAL.printf("[IOc] get binary ack: %u\n", length);
            hexdump(payload, length);
            break;
    }
}

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

    //Serial.setDebugOutput(true);
    USE_SERIAL.setDebugOutput(true);

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

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

    // disable AP
    if(WiFi.getMode() & WIFI_AP) {
        WiFi.softAPdisconnect(true);
    }

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

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

    String ip = WiFi.localIP().toString();
    USE_SERIAL.printf("[SETUP] WiFi Connected %s\n", ip.c_str());

    // server address, port and URL
    socketIO.begin("10.11.100.100", 8880);

    // event handler
    socketIO.onEvent(socketIOEvent);
}

unsigned long messageTimestamp = 0;
void loop() {
    socketIO.loop();

    uint64_t now = millis();

    if(now - messageTimestamp > 2000) {
        messageTimestamp = now;

        // creat JSON message for Socket.IO (event)
        DynamicJsonDocument doc(1024);
        JsonArray array = doc.to<JsonArray>();

        // add evnet name
        // Hint: socket.on('event_name', ....
        array.add("event_name");

        // add payload (parameters) for the event
        JsonObject param1 = array.createNestedObject();
        param1["now"] = now;

        // JSON to String (serializion)
        String output;
        serializeJson(doc, output);

        // Send event
        socketIO.sendEVENT(output);

        // Print JSON for debugging
        USE_SERIAL.println(output);
    }
}

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


Create periodic_Pacifica.ino

Create periodic_Pacifica.ino

//***************************************************************
// This example shows one way to run a pattern for roughly a few
// minutes, every 10 minutes, and then turn it off and wait
// another 10 minutes.  Global brightness was used to fade the
// display in and out to make things a bit smoother.
//
// It it not very time accurate since it uses millis and does
// not account for the fade in/out time.  Use a  RTC (real time
// clock) if accurate and specific clock times are needed, such
// as the DS3231.  https://www.adafruit.com/product/3013
//
// EVERY_N_SECONDS can be replaced with EVERY_N_MINUTES
// or EVERY_N_HOURS as needed for the "wait" and "run" time
// sections.
//
//
// This example runs a slightly modified version of the Pacifica
// pattern by Mark Kriegsman.  Please see original code here:
//  https://github.com/FastLED/FastLED/blob/master/examples/Pacifica/Pacifica.ino
//
//
// Marc Miller, May 2020
//***************************************************************

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

uint8_t patternState = 1;  // 0=waiting, 1=fadeUp, 2=running, 3=fadeDown
uint8_t brightness = 0;
unsigned long startTime;
unsigned long currentTime;

//---------------------------------------------------------------
void setup() {
  Serial.begin(115200);  // Allows serial monitor output (check baud rate)
  delay( 2000); // 2 second delay for boot recovery, and a moment of silence
  FastLED.addLeds<LED_TYPE,DATA_PIN,CLOCK_PIN,COLOR_ORDER>(leds, NUM_LEDS)
        .setCorrection( TypicalLEDStrip );
  FastLED.setMaxPowerInVoltsAndMilliamps( 5, 2000);
  FastLED.setBrightness(brightness);
  FastLED.clear();
  FastLED.show();
  Serial.println("Setup done.  \n");
}

//---------------------------------------------------------------
void loop() {

  EVERY_N_MINUTES(10) {
    patternState = 1;  // Time to start running the pattern
    Serial.println("    Time to FadeUp...");
  }

  if (patternState == 1) {
    //fadeIn
    EVERY_N_MILLISECONDS(60) {
      brightness = brightness + 1;
      if (brightness == 255) {
        patternState = 2;  // time to run pattern for a bit
        startTime = millis();
        Serial.println("    FadeUp complete.\n    Running...");
      }
      FastLED.setBrightness(brightness);
    }
  }

  if (patternState == 2) {
    // run the pattern
    // 1 min * 60sec/min * 1000ms/sec = 60000 ms
    const uint32_t runTime = 60000;  // number of ms to run pattern
    currentTime = millis();
    if ( (currentTime - startTime) > runTime ) {
      patternState = 3;  // time to fade out
      Serial.println("    Time to FadeDown...");
    }
  }

  if (patternState == 3) {
    // fadeOut
    EVERY_N_MILLISECONDS(120) {
      brightness = brightness - 1;
      if (brightness == 0) {
        Serial.println("    FadeDown complete.\n  Waiting...");
        patternState = 0;  // back to waiting state
        FastLED.clear();
        FastLED.show();
      }
      FastLED.setBrightness(brightness);
    }
  }

  if (patternState > 0) {
    // run the pattern
    EVERY_N_MILLISECONDS( 20) {
      pacifica_loop();
      FastLED.show();
    }
  }

  EVERY_N_MINUTES(1) {
    if (patternState == 0) {
      Serial.println("  Waiting...");
    }
  }

} //end_main_loop

//---------------------------------------------------------------
// Please see original Pacifica code by Mark Kriegsman here:
//  https://github.com/FastLED/FastLED/blob/master/examples/Pacifica/Pacifica.ino

CRGBPalette16 pacifica_palette_1 =
    { 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
      0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x14554B, 0x28AA50 };
CRGBPalette16 pacifica_palette_2 =
    { 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
      0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x0C5F52, 0x19BE5F };
CRGBPalette16 pacifica_palette_3 =
    { 0x000208, 0x00030E, 0x000514, 0x00061A, 0x000820, 0x000927, 0x000B2D, 0x000C33,
      0x000E39, 0x001040, 0x001450, 0x001860, 0x001C70, 0x002080, 0x1040BF, 0x2060FF };

void pacifica_loop()
{
  // Increment the four "color index start" counters, one for each wave layer.
  // Each is incremented at a different speed, and the speeds vary over time.
  static uint16_t sCIStart1, sCIStart2, sCIStart3, sCIStart4;
  static uint32_t sLastms = 0;
  uint32_t ms = GET_MILLIS();
  uint32_t deltams = ms - sLastms;
  sLastms = ms;
  uint16_t speedfactor1 = beatsin16(3, 179, 269);
  uint16_t speedfactor2 = beatsin16(4, 179, 269);
  uint32_t deltams1 = (deltams * speedfactor1) / 256;
  uint32_t deltams2 = (deltams * speedfactor2) / 256;
  uint32_t deltams21 = (deltams1 + deltams2) / 2;
  sCIStart1 += (deltams1 * beatsin88(1011,10,13));
  sCIStart2 -= (deltams21 * beatsin88(777,8,11));
  sCIStart3 -= (deltams1 * beatsin88(501,5,7));
  sCIStart4 -= (deltams2 * beatsin88(257,4,6));

  // Clear out the LED array to a dim background blue-green
  fill_solid( leds, NUM_LEDS, CRGB( 2, 6, 10));

  // Render each of four layers, with different scales and speeds, that vary over time
  pacifica_one_layer( pacifica_palette_1, sCIStart1, beatsin16( 3, 11 * 256, 14 * 256), beatsin8( 10, 70, 130), 0-beat16( 301) );
  pacifica_one_layer( pacifica_palette_2, sCIStart2, beatsin16( 4,  6 * 256,  9 * 256), beatsin8( 17, 40,  80), beat16( 401) );
  pacifica_one_layer( pacifica_palette_3, sCIStart3, 6 * 256, beatsin8( 9, 10,38), 0-beat16(503));
  pacifica_one_layer( pacifica_palette_3, sCIStart4, 5 * 256, beatsin8( 8, 10,28), beat16(601));

  // Add brighter 'whitecaps' where the waves lines up more
  pacifica_add_whitecaps();

  // Deepen the blues and greens a bit
  pacifica_deepen_colors();
}

// Add one layer of waves into the led array
void pacifica_one_layer( CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
{
  uint16_t ci = cistart;
  uint16_t waveangle = ioff;
  uint16_t wavescale_half = (wavescale / 2) + 20;
  for( uint16_t i = 0; i < NUM_LEDS; i++) {
    waveangle += 250;
    uint16_t s16 = sin16( waveangle ) + 32768;
    uint16_t cs = scale16( s16 , wavescale_half ) + wavescale_half;
    ci += cs;
    uint16_t sindex16 = sin16( ci) + 32768;
    uint8_t sindex8 = scale16( sindex16, 240);
    CRGB c = ColorFromPalette( p, sindex8, bri, LINEARBLEND);
    leds[i] += c;
  }
}

// Add extra 'white' to areas where the four layers of light have lined up brightly
void pacifica_add_whitecaps()
{
  uint8_t basethreshold = beatsin8( 9, 55, 65);
  uint8_t wave = beat8( 7 );

  for( uint16_t i = 0; i < NUM_LEDS; i++) {
    uint8_t threshold = scale8( sin8( wave), 20) + basethreshold;
    wave += 7;
    uint8_t l = leds[i].getAverageLight();
    if( l > threshold) {
      uint8_t overage = l - threshold;
      uint8_t overage2 = qadd8( overage, overage);
      leds[i] += CRGB( overage, overage2, qadd8( overage2, overage2));
    }
  }
}

// Deepen the blues and greens
void pacifica_deepen_colors()
{
  for( uint16_t i = 0; i < NUM_LEDS; i++) {
    leds[i].blue = scale8( leds[i].blue,  145);
    leds[i].green= scale8( leds[i].green, 200);
    leds[i] |= CRGB( 2, 5, 7);
  }
}

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


Testing a PWM detector ISR

Testing a PWM detector ISR

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


Add sketch that test ultrasonic readings on sensor platform

/*
  Test Ultrasonic sensor readings on sensor platform

  This sketch is designed to test the accuracy of the Ultrasonic
  sensor with the battery pack and circuit of the sensor platform.

  This sketch takes 5 readings and averages them to
  help verify similar calculations used in BridgeSensorGSM
  sketch. The results are written to the SD card

  Created 10 7 2014
  Modified 10 7 2014
*/
#include <LowPower.h>

#include <ARTF_SDCard.h>

// ARTF SDCard Dependency
#include <SdFat.h>
#include <String.h>

// Ultrasonic Settings
const byte ULTRASONIC_PIN = A6;
const int DISTANCE_INCREMENT = 5;
const int NUM_READINGS = 5;

// SD Card Settings
const byte SD_CS_PIN = 10;
#define OUTPUT_FILENAME "ultra.txt"

ARTF_SDCard sd(SD_CS_PIN);

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

int count = 1;
void loop()
{

  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

  String output = "";

  output += "Trial " + String(count) + "\n";
  output += "-------------------\n";

  // Take X readings
  int distanceReadings[NUM_READINGS];
  for (int i = 0; i < NUM_READINGS; ++i)
  {
    int reading = analogRead(ULTRASONIC_PIN);
    distanceReadings[i] = reading * DISTANCE_INCREMENT;

    output += String(i) + ". Analog:" + String(reading) + "; Calculated:" + String(distanceReadings[i]) + "\n";

    delay(300);
  }

  // Average the readings
  double sumDistance = 0.0;
  for (int i = 0; i < NUM_READINGS; ++i)
  {
    sumDistance += distanceReadings[i];
  }
  double avgDistance = sumDistance / NUM_READINGS;

  // Rounded measurements
  int roundedDistance = round(avgDistance);

  output += "Rounded:" + String(roundedDistance) + "\n\n";

  sd.begin();
  sd.writeFile(OUTPUT_FILENAME, output);

  delay(500);
  count += 1;
}

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


add vfo sketch

add vfo sketch

/*

DDS code based on Pete Juliano's super simple DDS code
http://www.jessystems.com/Images/Arduino/AD9850_Signal_Generator.txt

Rotary Encoder code based on my ATmega328 port
http://blog.templaro.com/reading-a-rotary-encoder-demo-code-for-atmega328/
of Oleg Mazurov's code written for ATmega644p
https://www.circuitsathome.com/mcu/rotary-encoder-interrupt-service-routine-for-avr-micros

  The circuit:
 * 5V to Arduino 5V pin
 * GND to Arduino GND pin

 * CLK to digital #4
 * FQ to digital #5
 * DAT to digital #6
 * RST to digital #7

 * Rotary Encoder left tab to digital #3
 * Rotary Encoder right tab to digital #2
 * Rotary Encoder middle tab to ground
 * Rotary Switch to digital #1

*/

// include the library code:
#include "Wire.h"
#include "Adafruit_LiquidCrystal.h"

// set rotary encoder pins
#define ENC_RD	PIND	//encoder port read
#define RotEncSwPin 1 // digital pin 4
#define A_PIN 2  // INT0 vector; digital pin 2
#define B_PIN 3  // INT1 vector; digital pin 3

// set up AD9850 pins
#define W_CLK 4
#define FQ_UD 5
#define DATAPIN 6
#define RESET 7

const double bandStart = 100000;  // start of Gnerator at 100 KHZ
const double bandEnd = 40000000; // End of Generator at 40 MHz --signal will be a bit flaky!
const double bandInit = 7150000; // where to initially set the frequency for tetsting Part II

double freq = bandInit ;  // this is a variable (changes) - set it to the beginning of the band
double freqDelta = 10000; // how much to change the frequency by, clicking the rotary encoder will change this.

byte counter = 0;
long lastClick = 0;
long lastBlink = 0;
boolean blinkState = false;

// Connect via i2c, default address #1 (nothing jumpered)
Adafruit_LiquidCrystal lcd(0);

void setup() {
  lcd.begin(16,2);
  lcd.setCursor(0,1); // This places a display on the LCD at turn on at the 2nd line
  lcd.print(" 5R8SV Sig Gen "); //Any LCD message can be place here. Just make sure there are 16 spaces between the "" marks

  // Set up DDS
  pinMode(FQ_UD, OUTPUT);
  pinMode(W_CLK, OUTPUT);
  pinMode(DATAPIN, OUTPUT);
  pinMode(RESET, OUTPUT);

  // Set up Rotary Encoder
  pinMode(A_PIN, INPUT_PULLUP);
  pinMode(B_PIN, INPUT_PULLUP);
  attachInterrupt(0, evaluateRotary, CHANGE);
  attachInterrupt(1, evaluateRotary, CHANGE);
  pinMode(RotEncSwPin, INPUT_PULLUP);

 // start up the DDS...
  pulseHigh(RESET);
  pulseHigh(W_CLK);
  pulseHigh(FQ_UD);
  // start the oscillator...
  send_frequency(freq);
  display_frequency(freq);
}

void loop() {
  int freqCursorPosition = 4;

  // change freq dependent on rotary encoder spin direction
  if(counter != 0) {
    if (counter == 1) {
      freq=constrain(freq-freqDelta,bandStart,bandEnd);
    } else {
      freq=constrain(freq+freqDelta,bandStart,bandEnd);
    }
    counter = 0;
    display_frequency(freq); // push the frequency to LCD display
    send_frequency(freq);  // set the DDS to the new frequency
  }

  // check for the click of the rotary encoder
  if (!digitalRead(RotEncSwPin) && millis() - lastClick > 200) { // push button debounce
    // if user clicks rotary encoder, change the size of the increment
    if (freqDelta == 10) {
      freqDelta = 1000000;
    } else {
      freqDelta /= 10;
    }
    lastClick = millis();
  }

  //blink the cursor to show selected frequency resolution
  if (millis() - lastBlink > 300) {
    freqCursorPosition = 8;
    for (long tempDelta = 10; tempDelta/freqDelta != 1; tempDelta *= 10) {
      freqCursorPosition--;
      if (freqCursorPosition == 2 || freqCursorPosition == 6) {  //hop the punctuation
        freqCursorPosition--;
      }
    }
    lcd.setCursor(freqCursorPosition,0);
    if(blinkState) {
      lcd.noBlink();
    } else {
      lcd.blink();
    }
    blinkState = !blinkState;
    lastBlink = millis();
  }

}

// subroutine to display the frequency...
void display_frequency(double frequency) {
  int currentCursor;
  byte currentDigit;

  lcd.noBlink(); // suppress blinking after printing Mhz
  currentCursor = 0;
  for (long freqDiv = 10000000; freqDiv > 1; freqDiv /=10) {
    currentDigit = ((long(freq)/freqDiv)%10);
    if (currentCursor == 2) {
      lcd.setCursor(currentCursor,0);
      lcd.print(".");
      currentCursor++;
    } else if (currentCursor == 6) {
      lcd.setCursor(currentCursor,0);
      lcd.print(",");
      currentCursor++;
    }
    lcd.setCursor(currentCursor,0);
    if (currentCursor == 0 && currentDigit == 0) {
      lcd.print(" ");
    } else {
      lcd.print(currentDigit);
    }
    currentCursor++;
  }
  lcd.print("0 MHz");
}

// Subroutine to generate a positive pulse on 'pin'...
void pulseHigh(int pin) {
  digitalWrite(pin, HIGH);
  digitalWrite(pin, LOW);
}

// calculate and send frequency code to DDS Module...
void send_frequency(double frequency) {
  int32_t freq = (frequency) * 4294967295/124997797;
  for (int b=0; b<4; b++, freq>>=8) {
    shiftOut(DATAPIN, W_CLK, LSBFIRST, freq & 0xFF);
  }
  shiftOut(DATAPIN, W_CLK, LSBFIRST, 0x00);
  pulseHigh(FQ_UD);
}

void evaluateRotary() {
/* encoder routine. Expects encoder with four state changes between detents */
/* and both pins open on detent */

  static uint8_t old_AB = 3;  //lookup table index
  static int8_t encval = 0;   //encoder value
  static const int8_t enc_states [] PROGMEM =
  {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};  //encoder lookup table
  /**/
  old_AB <<=2;  //remember previous state
  old_AB |= (( ENC_RD >>2 ) & 0x03 );
  encval += pgm_read_byte(&(enc_states[( old_AB & 0x0f )]));

  if( encval > 3 ) {  //four steps forward
    counter = 1;
    encval = 0;
  }
  else if( encval < -3 ) {  //four steps backwards
   counter = 2;
   encval = 0;
  }
}


Update pt_remote controlled car.ino

Update pt_remote controlled car.ino

pt_remote controlled car/pt_remote controlled car.ino

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


sleepy dog demo

sleepy dog demo

// Adafruit Watchdog Library Sleep Example
//
// Simple example of how to do low power sleep with the watchdog timer.
//
// Author: Tony DiCola

#include <Adafruit_SleepyDog.h>

void setup() {
  Serial.begin(115200);
  while (!Serial) ; // wait for Arduino Serial Monitor (native USB boards)
  Serial.println("Adafruit Watchdog Library Sleep Demo!");
  Serial.println();
}

void loop() {
  Serial.println("delay");
  delay(2000);

  //Serial.println("sleep");
  int sleepMS = Watchdog.sleep(2000);

  Serial.print("I'm awake now!  I slept for ");
  Serial.print(sleepMS, DEC);
  Serial.println(" milliseconds.");
  Serial.println();
}

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


Added Arduino sketch

Added Arduino sketch

Added .ino file for leapdrone-serial-to-ppm

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/davidmichaelhuber/leapdrone.git/'


1. update readme.md 2. add motor control and speed detect arduino code

/*
Copyright 2017 ADLINK Technology Inc.
Developer: Chester, Tseng
Email: chester.tseng@adlinktech.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <ArduinoJson.h>
#include <MsTimer2.h>

const int out1_pin = 5;
const int out2_pin = 6;
const int out3_pin = 9;
const int out4_pin = 10;
const int decoder_pin_1 = 2;
const int decoder_pin_2 = 3;
volatile int decoder_pin_1_counter = 0;
volatile int decoder_pin_2_counter = 0;

volatile int decoder_pin_1_delay_counter = 0;
volatile int decoder_pin_2_delay_counter = 0;

// Report internal;
const int report_period = 100;

void setup() {
  // Set 4 pwm channel pin to output
  pinMode(out1_pin, OUTPUT);
  pinMode(out2_pin, OUTPUT);
  pinMode(out3_pin, OUTPUT);
  pinMode(out4_pin, OUTPUT);

  // Set 4 PWM channel pin to duty cycle: 0
  analogWrite(out1_pin, 0);
  analogWrite(out2_pin, 0);
  analogWrite(out3_pin, 0);
  analogWrite(out4_pin, 0);

  // Start serial port
  Serial.begin(115200);
  while (!Serial) {
  }

 // Set 2 external interrupt pin to input and attach it's ISR
  pinMode(decoder_pin_1, INPUT);
  pinMode(decoder_pin_2, INPUT);
  attachInterrupt(digitalPinToInterrupt(decoder_pin_1), decoder_1_isr, FALLING);
  attachInterrupt(digitalPinToInterrupt(decoder_pin_2), decoder_2_isr, FALLING);

  // Start timer for reporting wheel speed
  MsTimer2::set(report_period, report_decoder_result_isr); // 100ms period
  MsTimer2::start();
}

void loop() {
    DynamicJsonBuffer jsonBuffer;
    if (Serial.available()) {
      String commad_string = Serial.readString();
      JsonObject& root = jsonBuffer.parseObject(commad_string);
      //Serial.println(commad_string);
      String out_1 = root["out_1"];
      String out_2 = root["out_2"];
      String out_3 = root["out_3"];
      String out_4 = root["out_4"];
      if (out_1 != NULL) {
        int out1_value = root["out_1"];
        analogWrite(out1_pin, out1_value);
        //Serial.println(out1_value);
      }
      if (out_2 != NULL) {
        int out2_value = root["out_2"];
        analogWrite(out2_pin, out2_value);
        //Serial.println(out2_value);
      }
      if (out_3 != NULL) {
        int out3_value = root["out_3"];
        analogWrite(out3_pin, out3_value);
        //Serial.println(out3_value);
      }
      if (out_4 != NULL) {
        int out4_value = root["out_4"];
        analogWrite(out4_pin, out4_value);
        //Serial.println(out4_value);
      }
    }
}

void decoder_1_isr() {
  decoder_pin_1_counter += 1;
}

void decoder_2_isr() {
  decoder_pin_2_counter += 1;
}

void report_decoder_result_isr() {
  // This is a workaround to prevent from motor idle when speed  = 0;
  if ((decoder_pin_1_counter == 0) && (decoder_pin_1_delay_counter > 10)) {
    analogWrite(out1_pin, 0);
    analogWrite(out2_pin, 0);
    decoder_pin_1_delay_counter = 0;
  }

  if ((decoder_pin_2_counter == 0) && (decoder_pin_2_delay_counter > 10)) {
    analogWrite(out3_pin, 0);
    analogWrite(out4_pin, 0);
    decoder_pin_2_delay_counter = 0;
  }

  char str[16];
  sprintf(str, "%d,%d\r\n", decoder_pin_1_counter, decoder_pin_2_counter);
  Serial.print(str);
  decoder_pin_1_counter = 0;
  decoder_pin_2_counter = 0;

  decoder_pin_1_delay_counter += 1;
  decoder_pin_2_delay_counter += 1;
}

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


Fixed EsploraKart example.........

Fixed EsploraKart example.........

/*
  Esplora Kart

  This sketch turns the Esplora into a PC game pad.

  It uses the both the analog joystick and the four switches.
  By moving the joystick in a direction or by pressing a switch,
  the PC will "see" that a key is pressed. If the PC is running
  a game that has keyboard input, the Esplora can control it.

  The default configuration is suitable for SuperTuxKart, an
  open-source racing game. It can be downloaded from
  http://supertuxkart.sourceforge.net/ .

  Created on 22 november 2012
  By Enrico Gueli <enrico.gueli@gmail.com>
*/

#include <Esplora.h>

/*
  You're going to handle eight different buttons. You'll use arrays,
  which are ordered lists of variables with a fixed size. Each array
  has an index (counting from 0) to keep track of the position
  you're reading in the array, and each position can contain a number.

  This code uses three different arrays: one for the buttons you'll read;
  a second to hold the current states of those buttons; and a third to hold
  the keystrokes associated with each button.
 */

/*
  This array holds the last sensed state of each of the buttons
  you're reading.
  Later in the code, you'll read the button states, and compare them
  to the previous states that are stored in this array. If the two
  states are different, it means that the button was either
  pressed or released.
 */
boolean buttonStates[8];

/*
  This array holds the names of the buttons being read.
  Later in the sketch, you'll use these names with
  the method Esplora.readButton(x), where x
  is one of these buttons.
 */
const byte buttons[] = {
  JOYSTICK_DOWN,
  JOYSTICK_LEFT,
  JOYSTICK_UP,
  JOYSTICK_RIGHT,
  SWITCH_RIGHT, // fire
  SWITCH_LEFT, // bend
  SWITCH_UP, // nitro
  SWITCH_DOWN, // look back
};

/*
  This array tells what keystroke to send to the PC when a
  button is pressed.
  If you look at this array and the above one, you can see that
  the "cursor down" keystroke is sent when the joystick is moved
  down, the "cursor up" keystroke when the joystick is moved up
  and so on.
*/
const char keystrokes[] = {
  KEY_DOWN_ARROW,
  KEY_LEFT_ARROW,
  KEY_UP_ARROW,
  KEY_RIGHT_ARROW,
  ' ',
  'V',
  'N',
  'B'
};

/*
  This is code is run only at startup, to initialize the
  virtual USB keyboard.
*/
void setup() {
  Keyboard.begin();
}

/*
  After setup() is finished, this code is run continuously.
  Here we continuously check if something happened with the
  buttons.
*/
void loop() {

  // Iterate through all the buttons:
  for (byte thisButton=0; thisButton<8; thisButton++) {
    boolean lastState = buttonStates[thisButton];
    boolean newState = Esplora.readButton(buttons[thisButton]);
    if (lastState != newState) { // Something changed!
      /*
        The Keyboard library allows you to "press" and "release" the
        keys as two distinct actions. These actions can be
        linked to the buttons we're handling.
       */
      if (newState == PRESSED) {
        Keyboard.press(keystrokes[thisButton]);
      }
      else if (newState == RELEASED) {
        Keyboard.release(keystrokes[thisButton]);
      }
    }

    // Store the new button state, so you can sense a difference later:
    buttonStates[thisButton] = newState;
  }

  /*
    Wait a little bit (50ms) between a check and another.
    When a mechanical switch is pressed or released, the
    contacts may bounce very rapidly. If the check is done too
    fast, these bounces may be confused as multiple presses and
    may lead to unexpected behaviour.
   */
  delay(50);
}

/*
  Esplora Kart

  This sketch turns the Esplora into a PC game pad.

  It uses the both the analog joystick and the four switches.
  By moving the joystick in a direction or by pressing a switch,
  the PC will "see" that a key is pressed. If the PC is running
  a game that has keyboard input, the Esplora can control it.

  The default configuration is suitable for SuperTuxKart, an
  open-source racing game. It can be downloaded from
  http://supertuxkart.sourceforge.net/ .

  Created on 22 november 2012
  By Enrico Gueli <enrico.gueli@gmail.com>
*/

#include <Esplora.h>

/*
  You're going to handle eight different buttons. You'll use arrays,
  which are ordered lists of variables with a fixed size. Each array
  has an index (counting from 0) to keep track of the position
  you're reading in the array, and each position can contain a number.

  This code uses three different arrays: one for the buttons you'll read;
  a second to hold the current states of those buttons; and a third to hold
  the keystrokes associated with each button.
 */

/*
  This array holds the last sensed state of each of the buttons
  you're reading.
  Later in the code, you'll read the button states, and compare them
  to the previous states that are stored in this array. If the two
  states are different, it means that the button was either
  pressed or released.
 */
boolean buttonStates[8];

/*
  This array holds the names of the buttons being read.
  Later in the sketch, you'll use these names with
  the method Esplora.readButton(x), where x
  is one of these buttons.
 */
const byte buttons[] = {
  JOYSTICK_DOWN,
  JOYSTICK_LEFT,
  JOYSTICK_UP,
  JOYSTICK_RIGHT,
  SWITCH_RIGHT, // fire
  SWITCH_LEFT, // bend
  SWITCH_UP, // nitro
  SWITCH_DOWN, // look back
};

/*
  This array tells what keystroke to send to the PC when a
  button is pressed.
  If you look at this array and the above one, you can see that
  the "cursor down" keystroke is sent when the joystick is moved
  down, the "cursor up" keystroke when the joystick is moved up
  and so on.
*/
const char keystrokes[] = {
  KEY_DOWN_ARROW,
  KEY_LEFT_ARROW,
  KEY_UP_ARROW,
  KEY_RIGHT_ARROW,
  ' ',
  'V',
  'N',
  'B'
};

/*
  This is code is run only at startup, to initialize the
  virtual USB keyboard.
*/
void setup() {
  Keyboard.begin();
}

/*
  After setup() is finished, this code is run continuously.
  Here we continuously check if something happened with the
  buttons.
*/
void loop() {

  // Iterate through all the buttons:
  for (byte thisButton=0; thisButton<8; thisButton++) {
    boolean lastState = buttonStates[thisButton];
    boolean newState = Esplora.readButton(buttons[thisButton]);
    if (lastState != newState) { // Something changed!
      /*
        The Keyboard library allows you to "press" and "release" the
        keys as two distinct actions. These actions can be
        linked to the buttons we're handling.
       */
      if (newState == PRESSED) {
        Keyboard.press(keystrokes[i]);
      }
      else if (newState == RELEASED) {
        Keyboard.release(keystrokes[i]);
      }
    }

    // Store the new button state, so you can sense a difference later:
    buttonStates[i] = newState;
  }

  /*
    Wait a little bit (50ms) between a check and another.
    When a mechanical switch is pressed or released, the
    contacts may bounce very rapidly. If the check is done too
    fast, these bounces may be confused as multiple presses and
    may lead to unexpected behaviour.
   */
  delay(50);
}


added first blinking lights sketch

added first blinking lights sketch

int led = 9;
int fadeAmount = 5;
int brightness = 0;

void setup()
{

  /* add setup code here */
	pinMode(led,OUTPUT);
}

void loop()
{

  /* add main program code here */

	analogWrite(led, brightness);

	brightness = brightness + fadeAmount;
	if (brightness == 0 || brightness == 255)
		fadeAmount = -fadeAmount;

	delay(30);

	/*digitalWrite(led, HIGH);
	delay(1000);
	digitalWrite(led, LOW);
	delay(1000);*/
}

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


Start an example of using the BLE by copying the example 06-AppTutorial/01-BasicGain_wApp

/*
*   BasicGain_wApp
*
*   Created: Chip Audette, June 2020
*   Purpose: Process audio using Tympan by applying gain.
*      Also, illustrate how to change Tympan setting via the TympanRemote App.
*
*   Blue potentiometer adjusts the digital gain applied to the audio signal.
*
*   Uses default sample rate of 44100 Hz with Block Size of 128
*
*   TympanRemote App: https://play.google.com/store/apps/details?id=com.creare.tympanRemote&hl=en_US
*
*   MIT License.  use at your own risk.
*/

//here are the libraries that we need
#include <Tympan_Library.h>  //include the Tympan Library

//create audio library objects for handling the audio
Tympan                    myTympan(TympanRev::D);  //do TympanRev::D or TympanRev::C
AudioInputI2S_F32         i2s_in;        //Digital audio *from* the Tympan AIC.
AudioEffectGain_F32       gain1, gain2;  //Applies digital gain to audio data.
AudioOutputI2S_F32        i2s_out;       //Digital audio *to* the Tympan AIC.  Always list last to minimize latency

//Make all of the audio connections
AudioConnection_F32       patchCord1(i2s_in, 0, gain1, 0);    //connect the Left input
AudioConnection_F32       patchCord2(i2s_in, 1, gain2, 0);    //connect the Right input
AudioConnection_F32       patchCord11(gain1, 0, i2s_out, 0);  //connect the Left gain to the Left output
AudioConnection_F32       patchCord12(gain2, 0, i2s_out, 1);  //connect the Right gain to the Right output

//define class for handling the GUI on the app
#include "TympanRemoteFormatter.h"
TympanRemoteFormatter myGUI;  //Creates the GUI-writing class for interacting with TympanRemote App

// define the setup() function, the function that is called once when the device is booting
const float input_gain_dB = 10.0f; //gain on the microphone
float digital_gain_dB = 0.0;      //this will be set by the app
void setup() {

  //begin the serial comms (for debugging)
  myTympan.beginBothSerial();
  delay(3000);
  myTympan.println("BasicGain_wApp: starting setup()...");

  //allocate the dynamic memory for audio processing blocks
  AudioMemory_F32(10);

  //Enable the Tympan to start the audio flowing!
  myTympan.enable(); // activate the Tympan's audio module

  //Choose the desired input
  myTympan.inputSelect(TYMPAN_INPUT_ON_BOARD_MIC);     // use the on board microphones
  //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_MIC);    // use the microphone jack - defaults to mic bias 2.5V
  //myTympan.inputSelect(TYMPAN_INPUT_JACK_AS_LINEIN); // use the microphone jack - defaults to mic bias OFF

  //Set the desired volume levels
  myTympan.volume_dB(0);                   // headphone amplifier.  -63.6 to +24 dB in 0.5dB steps.
  myTympan.setInputGain_dB(input_gain_dB); // set input volume, 0-47.5dB in 0.5dB setps

  //Create the GUI description (but not yet transmitted to the App...that's after it connects)
  createTympanRemoteLayout();

  Serial.println("Setup complete.");
} //end setup()

// define the loop() function, the function that is repeated over and over for the life of the device
void loop() {

  //look for in-coming serial messages (via USB or via Bluetooth)
  if (Serial.available()) respondToByte((char)Serial.read());   //USB Serial
  if (Serial1.available()) respondToByte((char)Serial1.read()); //BT Serial

} //end loop();

// ///////////////// Servicing routines

//respond to serial commands
void respondToByte(char c) {
  myTympan.print("Received character "); myTympan.println(c);

  switch (c) {
    case 'J': case 'j':
      printTympanRemoteLayout();
      break;
    case 'k':
      changeGain(3.0);
      printGainLevels();
      break;
    case 'K':
      changeGain(-3.0);
      printGainLevels();
      break;
  }
}

// Print the layout for the Tympan Remote app, in a JSON-ish string
// (single quotes are used here, whereas JSON spec requires double quotes.  The app converts ' to " before parsing the JSON string).
// Please don't put commas or colons in your ID strings!
void printTympanRemoteLayout(void) {
  myTympan.println(myGUI.asString());
}

//define the GUI for the App
void createTympanRemoteLayout(void) {

  // Create some temporary variables
  TR_Page *page_h;  //dummy handle for a page
  TR_Card *card_h;  //dummy handle for a card

  //Add first page to GUI
  page_h = myGUI.addPage("MyFirstPage");
      card_h = page_h->addCard("Change Loudness");
        #if 0
          card_h->addButton("-","K");   //assumes default ID and default width.
          card_h->addButton("+","k");   //assumes default ID and default width
        #else
          card_h->addButton("-","K","minusButton",6);  //displayed string, command, button ID, button width (out of 12)
          card_h->addButton("+","k","plusButton",6);   //displayed string, command, button ID, button width (out of 12)
        #endif

  //add some pre-defined pages to the GUI
  myGUI.addPredefinedPage("serialMonitor");
  myGUI.addPredefinedPage("plot");
}

//change the gain from the App
void changeGain(float change_in_gain_dB) {
  digital_gain_dB = digital_gain_dB + change_in_gain_dB;
  gain1.setGain_dB(digital_gain_dB);  //set the gain of the Left-channel gain processor
  gain2.setGain_dB(digital_gain_dB);  //set the gain of the Right-channel gain processor
}

//Print gain levels
void printGainLevels(void) {
  myTympan.print("Analog Input Gain (dB) = ");
  myTympan.println(input_gain_dB); //print text to Serial port for debugging
  myTympan.print("Digital Gain (dB) = ");
  myTympan.println(digital_gain_dB); //print text to Serial port for debugging
}

error: pathspec 'examples/07-Bluetooth/01-BasicGain_wApp_BLE/01-BasicGain_wApp_BLE.ino' did not match any file(s) known to git


TFTPクライアントのサンプルプログラム

TFTPクライアントのサンプルプログラム

/*******************************************************************************
Example 58(=32+26): センサデバイス用 TFTPクライアント 設定

本ESPモジュールは、TFTPサーバ上の設定ファイルをダウンロードし、モジュール内の
設定を変更します。

※本サンプル作成の段階では、(暫定的に)下記ライブラリを使用しました。
    https://github.com/copercini/arduino-esp32-SPIFFS
※今後、esp-idfや上記ライブラリを基にしたものが公式サポートされると思います。

Raspberry PiへのTFTPサーバのインストール方法
    $ sudo apt-get install tftpd-hpa

    設定ファイル(/etc/default/tftpd-hpa) 例
    # /etc/default/tftpd-hpa
    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/srv/tftp"
    TFTP_ADDRESS="0.0.0.0:69"

TFTPサーバの起動と停止
    /etc/init.d/tftpd-hpa start
    /etc/init.d/tftpd-hpa stop

転送用のファイルを保存
    $ echo "Hello! This is from RasPi" > /srv/tftp/esp8266_tftpc_1.ini

【注意事項】
・ESPモジュールのTFTPクライアントを起動したままにすると、危険です
・TFTPサーバ起動したままにすると、Raspberry Piが脅威にさらされます。
・ウィルスやワームが侵入すると、同じネットワーク上の全ての機器へ感染する恐れが
　高まります。

                                           Copyright (c) 2016-2017 Wataru KUNINO
*******************************************************************************/
#include <WiFi.h>                           // ESP32用WiFiライブラリ
#include <WiFiUdp.h>                        // UDP通信を行うライブラリ
#include "esp_deep_sleep.h"                 // ESP32用Deep Sleep ライブラリ
#define PIN_EN 2                            // GPIO 2(24番ピン)をセンサの電源に
#define PIN_AIN 34                          // GPIO 34 ADC1_CH6(6番ピン)をADCに
#define SSID "1234ABCD"                     // 無線LANアクセスポイントのSSID
#define PASS "password"                     // パスワード
#define SENDTO "192.168.0.255"              // 送信先のIPアドレス
#define PORT 1024                           // 送信のポート番号
#define SLEEP_P 50*1000000                  // スリープ時間 50秒(uint32_t)
#define DEVICE "tftpc_1,"                   // デバイス名(5文字+"_"+番号+",")
#define TFTP_PORT_C 69                      // TFTP接続用ポート番号(既定)
#define TFTP_PORT_T 1234                    // TFTP転送用ポート番号(任意)
#define TFTP_TIMEOUT 10                     // TFTP待ち受け時間(ms)
#define TFTP_FILENAME "/srv/tftp/esp8266_tftpc_1.ini" // TFTP受信ファイル名
char data[512];                             // TFTPデータ用変数
WiFiUDP tftp;                               // TFTP通信用のインスタンスを定義

void setup(){                               // 起動時に一度だけ実行する関数
    pinMode(PIN_AIN,INPUT);                 // アナログ入力の設定
    pinMode(PIN_EN,OUTPUT);                 // センサ用の電源を出力に
    Serial.begin(115200);                   // 動作確認のためのシリアル出力開始
    Serial.println("ESP32 eg.26 TFTP");     // 「ESP32 eg.26」をシリアル出力表示
    WiFi.mode(WIFI_STA);                    // 無線LANをSTAモードに設定
    delay(10);                              // ESP32に必要な待ち時間
    WiFi.begin(SSID,PASS);                  // 無線LANアクセスポイントへ接続
    while(WiFi.status() != WL_CONNECTED){   // 接続に成功するまで待つ
        delay(500);                         // 待ち時間処理
        digitalWrite(PIN_EN,!digitalRead(PIN_EN));      // LEDの点滅
        Serial.print(".");
    }
    Serial.println(WiFi.localIP());         // 本機のIPアドレスをシリアル出力
    tftpStart();                            // TFTPの開始
    while( tftpGet() );                     // データ受信
}

void tftpStart(){
    tftp.begin(TFTP_PORT_T);                // TFTP(受信)の開始
    tftp.beginPacket(SENDTO, TFTP_PORT_C);  // TFTP送信先を設定
    tftp.write(0x0); tftp.write(0x01);      // Read Requestコマンド(RRQ)
    tftp.print(TFTP_FILENAME);              // ファイル名
    tftp.write(0x0);                        // ファイル名の終端
    tftp.print("netascii");                 // ASCIIモード
    tftp.write(0x0);                        // モード名の終端
    tftp.endPacket();                       // TFTP送信の終了(実際に送信する)
    Serial.println("Send TFTP RRQ");        // 送信完了をシリアル端末へ表示
}

int tftpGet(){
    int len=0,time=0;
    IPAddress ip;

    while(len<5){                           // 未受信の間、繰り返し実行
        delay(1);                           // 1msの待ち時間
        len = tftp.parsePacket();           // 受信パケット長を変数lenに代入
        time++;                             // 時間のカウント
        if(time>TFTP_TIMEOUT) return 0;     // タイムアウト(応答値は0)
    }
    ip=tftp.remoteIP();                     // サーバのIPアドレスを取得
    tftp.read(data, 511);                   // 最大511バイトまで受信する
    Serial.print("Recieved (");
    for(int i=0;i<4;i++) Serial.print(data[i],DEC); // コマンド、ブロック番号
    Serial.print(") ");
    Serial.print(len - 4);                  // 受信データ長を表示
    Serial.print(" Bytes from ");
    Serial.println(ip);                     // サーバのIPアドレスを表示
    if(len > 511){
        Serial.println("FILE SIZE ERROR");  // 複数ブロックの転送には対応しない
        return -1;                          // ERROR(応答値は-1)
    }
    if(data[0]==0x0 && data[1]==0x3){       // TFTP転送データの時
        Serial.print(&data[4]);             // TFTP受信データを表示する
        Serial.println("[EOF]");
        tftp.beginPacket(ip, TFTP_PORT_T);  // TFTP ACK送信先を設定
        tftp.write(0x0); tftp.write(0x04);  // 受信成功コマンド(ACK)を送信
        tftp.write(data[2]);                // ブロック番号の上位1バイトを送信
        tftp.write(data[3]);                // ブロック番号の下位1バイトを送信
        tftp.endPacket();                   // TFTP送信の終了(実際に送信する)
        return len;
    }
    return -1;                              // ERROR(応答値は-1)
}

void loop() {
    WiFiUDP udp;                            // UDP通信用のインスタンスを定義
    int adc;                                // 整数型変数adcを定義

    digitalWrite(PIN_EN,HIGH);              // センサ用の電源をONに
    delay(5);                               // 起動待ち時間
    adc=(int)mvAnalogIn(PIN_AIN);           // AD変換器から値を取得
    digitalWrite(PIN_EN,LOW);               // センサ用の電源をOFFに
    udp.beginPacket(SENDTO, PORT);          // UDP送信先を設定
    udp.print(DEVICE);                      // デバイス名を送信
    udp.println(adc);                       // 変数adcの値を送信
    Serial.println(adc);                    // シリアル出力表示
    udp.endPacket();                        // UDP送信の終了(実際に送信する)
    delay(200);                             // 送信待ち時間
    esp_deep_sleep(SLEEP_P);                // Deep Sleepモードへ移行
}

float mvAnalogIn(uint8_t PIN){
    int in0,in3;
    float ad0,ad3;

    analogSetPinAttenuation(PIN,ADC_11db);
    in3=analogRead(PIN);

    if( in3 > 2599 ){
        ad3 = -1.457583e-7 * (float)in3 * (float)in3
            + 1.510116e-3 * (float)in3
            - 0.573300;
    }else{
        ad3 = 8.378998e-4 * (float)in3 + 1.891456e-1;
    }
    if( in3 < 200 ){
        analogSetPinAttenuation(PIN,ADC_0db);
        in0=analogRead(PIN);
        ad0 = 2.442116e-4 * (float)in0 + 1.075584e-1;
        if( in3 >= 100 ){
            ad3 = ad3 * ((float)in3 - 100.) / 100.
                + ad0 * (200. - (float)in3) / 100.;
        }else{
            ad3 = ad0;
        }
    }
    return ad3 * 1000.;
}

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


Added state-machine

Added state-machine

// Include to use LCD display
//#include <LiquidCrystal.h>
// Include to show
#include <stdio.h>

//const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
//LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int btn1 = 9;
const int btn2 = 10;

void setup() {
  //lcd.begin(16, 2);
  Serial.begin(9600);
  //lcd.print(stringTime);
  Serial.println("00:00:00");

  // Initialize Button Input
  pinMode(btn1, INPUT_PULLUP);
  pinMode(btn2, INPUT_PULLUP);
}

long lastTimestamp = 0;
long elapsedSeconds = 0;
long lastEvtBtn1 = 0;
long lastEvtBtn2 = 0;
bool clockEnabled = false;

enum valid_states {
  WAIT = 0,
  DISPLAY_TIME = 1,
  START_STOP_CLOCK = 2,
  RESET = 3
};

int machine_state = 0;

bool tick_flag = false;
bool btn1_flag = false;
bool btn2_flag = false;

void displayElapsedTime(long elapsedSeconds) {
  char stringTime[9];

  int hours = elapsedSeconds/(60*60);
  int minutes = (elapsedSeconds-(hours*60*60))/60;
  int seconds = elapsedSeconds-(hours*60*60)-(minutes*60);

  // Format time to display
  sprintf(stringTime, "%02d:%02d:%02d", hours, minutes, seconds);

  // Display on LCD
  //lcd.clear();
  //lcd.setCursor(0,0);
  //lcd.print(stringTime);
  Serial.println(stringTime);
}

void loop() {
  // Este evento se llama cada segundo
  if((millis()-lastTimestamp)>1000) {
    tick_flag = true;
    lastTimestamp = millis();
  }

  // Eventos generados cada vez que se presiona un botón
  //btn1_flag |= !digitalRead(btn1);
  //btn2_flag |= !digitalRead(btn2);

  // Con eliminador de rebote:
  if((millis()-lastEvtBtn1)>100 && !digitalRead(btn1)) {
    btn1_flag = 1;
    lastEvtBtn1 = millis();
  }
  if((millis()-lastEvtBtn2)>100 && !digitalRead(btn2)) {
    btn2_flag = 1;
    lastEvtBtn2 = millis();
  }

  switch(machine_state) {
    case WAIT:
      if(btn1_flag) {
        btn1_flag = false;
        machine_state = START_STOP_CLOCK;
        break;
      }
      if(btn2_flag) {
        btn2_flag = false;
        machine_state = RESET;
        break;
      }
      if(tick_flag) {
        tick_flag = false;
        machine_state = DISPLAY_TIME;
        break;
      }
      break;

    case DISPLAY_TIME:
      // Display on screen or serial
      displayElapsedTime(elapsedSeconds);

      // Increase clock only if clockEnabled
      if(clockEnabled)
        elapsedSeconds += 1;

      // automatically change state for next run
      machine_state = WAIT;
      break;

    case START_STOP_CLOCK:
      clockEnabled = !clockEnabled;
      machine_state = WAIT;
      break;

    case RESET:
      elapsedSeconds = 0;
      machine_state = WAIT;
      break;
  }
}

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


added reset sketch for UniqueID example

added reset sketch for UniqueID example

/*
Copyright 2013 project Ardulink http://www.ardulink.org/

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This sketch is an example to understand how Arduino can recognize ALProtocol.
However, it can easily be reused for their own purposes or as a base for a library.
Read carefully the comments. When you find "this is general code you can reuse"
then it means that it is generic code that you can use to manage the ALProtocol.
When you find "this is needed just as example for this sketch" then it means that
you code useful for a specific purpose. In this case you have to modify it to suit
your needs.
*/
#include <EEPROM.h>

/*
Unique ID is suggested by connected PC. Then it is stored and used for ever.
Unique ID is stored in EEPROM at a given address. A magic number (2 bytes) "LZ"
is used to understand if it is already stored or not.
Actually Unique ID is a UUID in the string format (36 bytes instead of just 16, yes it could be better).
https://en.wikipedia.org/wiki/Universally_unique_identifier
So the final length to store the unique id is 38 bytes.
*/
#define UNIQUE_ID_EEPROM_ADDRESS 0
#define UNIQUE_ID_LENGTH 38
#define UNIQUE_ID_MAGIC_NUMBER_HIGH 76
#define UNIQUE_ID_MAGIC_NUMBER_LOW 90

void resetUniqueID() {

  char buffer[UNIQUE_ID_LENGTH + 1];
  for(int i = 0; i < UNIQUE_ID_LENGTH + 1; i++) {
    buffer[i] = 0;
  }
  EEPROM.put( UNIQUE_ID_EEPROM_ADDRESS, buffer );
}

void setup(){
  resetUniqueID();
}

void loop(){
}

error: pathspec 'deploy-dist/rootfolder/examples/UniqueID/sketch/resetUniqueID/resetUniqueID.ino' did not match any file(s) known to git


Updated Sensor Code

Updated Sensor 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/sassystacks/DASS.git/'


added arduino code

added arduino code

#include "FastLED.h"
#include <Keyboard.h>

#define MAX_HELLIGKEIT_STRIPES 180
#define FADE_NEXT_ON_AT 30
#define MIN_HELLIGKEIT_PULSE 100

#define MAX_HELLIGKEIT_CIRCLE 150

#define CIRCLE_SPEED 4
#define STRIPE_SPEED 10

#define NUM_LEDS_circle 24

#define NUM_LEDS_stripe 60
#define START_LED_STRIPE 12

#define DATA_PIN_circle 4

#define NUM_STRIPES 4
#define DATA_PIN_stripe1 5
#define DATA_PIN_stripe2 6
#define DATA_PIN_stripe3 9
#define DATA_PIN_stripe4 8

#define sensor_input 3
#define button_input 12

CRGB leds_circle[NUM_LEDS_circle];
CRGB leds_stripe[NUM_STRIPES][NUM_LEDS_stripe];

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(sensor_input, INPUT);
  pinMode(button_input, INPUT);
  digitalWrite(button_input, HIGH);
  Keyboard.begin();
  //Serial.begin(9600);

  FastLED.addLeds<WS2812, DATA_PIN_circle, GRB>(leds_circle, NUM_LEDS_circle);
  FastLED.addLeds<WS2812, DATA_PIN_stripe1, GRB>(leds_stripe[0], NUM_LEDS_stripe);
  FastLED.addLeds<WS2812, DATA_PIN_stripe2, GRB>(leds_stripe[1], NUM_LEDS_stripe);
  FastLED.addLeds<WS2812, DATA_PIN_stripe3, GRB>(leds_stripe[2], NUM_LEDS_stripe);
  FastLED.addLeds<WS2812, DATA_PIN_stripe4, GRB>(leds_stripe[3], NUM_LEDS_stripe);
  clear_display(0);
  clear_display(1);
  FastLED.show();

}

void loop() {

  CRGB color_rgb;
  CHSV hsv_color;
  int circle_direction[NUM_LEDS_circle];
  int circle_value[NUM_LEDS_circle];
  int stripe_direction[NUM_LEDS_stripe];
  int stripe_value[NUM_LEDS_stripe];
  int previous_led, touched, ct_fade;
  // read the value from the sensor:

  hsv_color.h=0;
  hsv_color.s=0;
  hsv_color.v=0;

  // Geldeinwurf Kreis dreht sich

  for (int ct_x = 0; ct_x < NUM_LEDS_circle; ct_x++)
  {
    circle_value[ct_x]=0;
    circle_direction[ct_x]=0;
  }

  circle_direction[0]=1;
  while(digitalRead(sensor_input)) {

    for (int ct_x = 0; ct_x < NUM_LEDS_circle; ct_x++)
    {
      if (circle_direction[ct_x]==1) {
        circle_value[ct_x]=circle_value[ct_x]+CIRCLE_SPEED;
      }
      if (circle_direction[ct_x]==2) {
        circle_value[ct_x]=circle_value[ct_x]-CIRCLE_SPEED;
      }

      if (circle_value[ct_x]>MAX_HELLIGKEIT_CIRCLE) {
        circle_direction[ct_x]=2;
      }

      if (circle_value[ct_x]==0) {
        circle_direction[ct_x]=0;
      }

      if ((circle_value[ct_x]>30)&&(circle_direction[ct_x]==1)) {
        if (ct_x==0) {
          previous_led=NUM_LEDS_circle-1;
        }
        else {
          previous_led=ct_x-1;
        }
        circle_direction[previous_led]=1;
      }

      hsv_color.v=circle_value[ct_x];
      hsv2rgb_rainbow(hsv_color,leds_circle[ct_x]);
    }
    FastLED.show();
  }

  clear_display(0);
  FastLED.show();

  // Lade Säule auf

  for (int ct_x = START_LED_STRIPE; ct_x < NUM_LEDS_stripe; ct_x++)
  {
    stripe_value[ct_x]=0;
    stripe_direction[ct_x]=0;
  }

  stripe_direction[START_LED_STRIPE]=1;
  while(stripe_value[NUM_LEDS_stripe-1]<MAX_HELLIGKEIT_STRIPES) {

    for (int ct_x = START_LED_STRIPE; ct_x < NUM_LEDS_stripe; ct_x++)
    {
      if (stripe_direction[ct_x]==1) {
        stripe_value[ct_x]=stripe_value[ct_x]+STRIPE_SPEED;
      }

      if (stripe_value[ct_x]>MAX_HELLIGKEIT_STRIPES) {
        stripe_direction[ct_x]=0;
      }

      if ((stripe_value[ct_x]>FADE_NEXT_ON_AT)&&(stripe_direction[ct_x]==1)) {
        if (ct_x<NUM_LEDS_stripe-1) {
          previous_led=ct_x+1;
        }
        stripe_direction[previous_led]=1;
      }

      hsv_color.v=stripe_value[ct_x];
      hsv2rgb_rainbow(hsv_color,color_rgb);
      for (int ct_stripe = 0; ct_stripe<NUM_STRIPES;ct_stripe++){
        leds_stripe[ct_stripe][ct_x]=color_rgb;
      }
    }
    FastLED.show();

  }

  // Säule ist bereit und pulsiert
  touched=0;
  while(!touched) {
    ct_fade=MAX_HELLIGKEIT_STRIPES;
    while ((!touched)&&(ct_fade>MIN_HELLIGKEIT_PULSE)) {
      hsv_color.v=ct_fade;
      for (int ct_led = START_LED_STRIPE; ct_led < NUM_LEDS_stripe; ct_led++)
      {
        for (int ct_stripe = 0; ct_stripe<NUM_STRIPES;ct_stripe++){
          hsv2rgb_rainbow(hsv_color,leds_stripe[ct_stripe][ct_led]);
        }
        if (!digitalRead(button_input)) {
          touched=1;
        }
      }
      FastLED.show();
      ct_fade--;
    }
    while ((!touched)&&(ct_fade<MAX_HELLIGKEIT_STRIPES)) {
      hsv_color.v=ct_fade;
      for (int ct_led = START_LED_STRIPE; ct_led < NUM_LEDS_stripe; ct_led++)
      {
        for (int ct_stripe = 0; ct_stripe<NUM_STRIPES;ct_stripe++){
          hsv2rgb_rainbow(hsv_color,leds_stripe[ct_stripe][ct_led]);
        }
        if (!digitalRead(button_input)) {
          touched=1;
        }
      }
      FastLED.show();
      ct_fade++;
    }
  }
  Keyboard.print('p');

  for (int ct_x = MAX_HELLIGKEIT_STRIPES; ct_x >= 0; ct_x--)
  {
    hsv_color.v=ct_x;
    for (int ct_led = START_LED_STRIPE; ct_led < NUM_LEDS_stripe; ct_led++)
    {
      for (int ct_stripe = 0; ct_stripe<NUM_STRIPES;ct_stripe++){
        hsv2rgb_rainbow(hsv_color,leds_stripe[ct_stripe][ct_led]);
      }
    }
  FastLED.show();
  }

}

void clear_display(int channel)
{
  int ct_led;

  if (channel==0) {
    for (int ct_x = 0; ct_x < NUM_LEDS_circle; ct_x++)
    {
      leds_circle[ct_x] = CRGB::Black;
    }
  }
  else {
    for (int ct_x = 0; ct_x < NUM_LEDS_stripe; ct_x++)
    {
      for (int ct_stripe = 0; ct_stripe<NUM_STRIPES;ct_stripe++){
        leds_stripe[ct_stripe][ct_x] = CRGB::Black;
      }
    }
  }

}

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


RF receiver to serial out

RF receiver to serial out

/**
 * Listen to the RF transmitter and print it to the serial monitor.
 */
#include <VirtualWire.h>

// Pin 11 is the default receiver pin.
// @see http://www.airspayce.com/mikem/arduino/VirtualWire_8h.html#ae62b601260ae59e7e83c1e63ae0c064b

int received_reset_interval = 60 * 60 * 1000; // How often to reset the received counter.
int received_count; // How many transmissions have been received.
unsigned long received_last_reset;

void setup()
{
  pinMode(13, OUTPUT);

  // initialize serial communication
  Serial.begin(9600);
  Serial.println("setup");

  received_count = 0;
  received_last_reset = millis();

  // Initialise the IO and ISR
  vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);      // Bits per sec
  // vw_set_tx_pin(11);
  vw_rx_start();       // Start the receiver PLL running
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  unsigned long now = millis();
  if (now - received_last_reset > received_reset_interval) {
    received_last_reset = now;
    received_count = 0;
  }

  if (vw_get_message(buf, &buflen)) {
      int i;
      digitalWrite(13, HIGH); // Flash a light to show received good message
      // Message with a good checksum received, output it to serial.
      Serial.print("R: ");
      for (i = 0; i < buflen; i++) {
          Serial.print(char(buf[i]));
      }
      Serial.println("");

      ++received_count;
      Serial.print("C: ");
      Serial.println(received_count);

      digitalWrite(13, LOW);
  }

}

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


Create base2clock5.ino

Create base2clock5.ino

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

// adjust this value to tune the clock. 5000 should be close, lower if clock runs slow, higher if fast.
#define INTERVAL_TIME 4995

//int's representing led's. 1 = on, 0 = off. Initially they will all be off.
int p1,p2,p3,p4,p5,p6,p7,p8,p9 = 0;
int iterations = 0;
boolean increment, reset_fast, reset_slow, time_set, setting_time = false;
unsigned long mils, prev_mils = 0;

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

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

  attachInterrupt(0, setTimeSlow , FALLING); // pin 2

  prev_mils = millis();

  //time set buttons as inputs.
  pinMode(4, INPUT);
  digitalWrite(4, HIGH);
} // end setup()

void loop(){
  //reinitialize time setting booleans to false.
  reset_fast = false;
  reset_slow = false;
  setting_time = false;

  //see if the time is being set.
  if(digitalRead(4) == LOW){
    reset_fast = true;
    resetTimeSetFlags();
  }

  if(!time_set){ // time has never been set so just blink the lights.
    if(p8 == 1)
      p8 = p7 = p6 = p5 = p4 = p3 = p2 = p1 = 0;
    else
      p8 = p7 = p6 = p5 = p4 = p3 = p2 = p1 = 1;
    lightLights();
  } else { //time has been set, so increment as instructed.
    if(!increment){
      iterations++;
      if(iterations == 12){
        iterations = 0;
        increment = true;
      }
    }
    if(increment){
      increment = false;
      if(setting_time || !setIncrementFlag()){
        doIncrement();
      }
    }
  } //end time_set is true

  // figure out the loop delay, typically 5 seconds, 1 second if the time has never been set
  // and we are blinking the lights, 0.1 second if we are coarse setting the time and 1 second
  // if we are fine setting the time.
  if(reset_fast){
    delay(100);
    iterations = 0;
  } else if(!time_set) {
    delay(1000);
  } else delay(INTERVAL_TIME);
} // end loop()

void setTimeSlow(){
  increment = false;
  time_set = true;
  iterations = 0;
  p9 = 0;

  mils = millis();
  if(mils - prev_mils > 150)
    doIncrement();
  prev_mils = mils;

}

void resetTimeSetFlags(){
  setting_time = true;
  increment = true;
  time_set = true;
  iterations = 0;
  p9 = 0;
}

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

void doIncrement(){
  p9 = 0;

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

  lightLights();
} // end doIncrement()

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

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


Combined the ESP8266 with the sketch

Combined the ESP8266 with the sketch

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


add misc sketch for playing with an RTC module

// Date and time functions using a DS3231 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

// Pinout of the RTC modules:
// from top (chip side) pins on top
//   1 - Vdd
//   2 - SDA
//   3 - SCL
//   4 - no-connect
//   5 - GND
// power the RTC from a GPIO pin
#define RTC_PWR_PIN 16  // AKA "XPO" to module's Vdd
#define SDA_PIN 2  // on ESP8266
#define SCL_PIN 4

// interval in ms to print the current time
static unsigned long interval = 2000;

RTC_DS3231 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
unsigned long lastMillis = 0;

void setup () {

#ifndef ESP8266
  while (!Serial); // for Leonardo/Micro/Zero
#endif

  Serial.begin(115200);

  // power the RTC from a GPIO
  pinMode(RTC_PWR_PIN, OUTPUT);
  digitalWrite(RTC_PWR_PIN, HIGH);
  // setup the I2C pins for the RTC
  Wire.begin(SDA_PIN, SCL_PIN);  // SDA, SCL

  delay(3000); // wait for console opening

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  Serial.println();
  Serial.println("Set clock by sending a line of 6 integers:");
  Serial.println("yyyy mm dd hh mm ss");
}

void loop () {
  if (Serial.available()) {
    // command line format:
    //   yyyy mm dd hh mm ss
    int year = Serial.parseInt();
    int month = Serial.parseInt();
    int day = Serial.parseInt();
    int hour = Serial.parseInt();
    int minute = Serial.parseInt();
    int second = Serial.parseInt();

    // get here as quickly as possible
    rtc.adjust(DateTime(year, month, day, hour, minute, second));
    Serial.print("Setting time to: ");
    printDateTime(year, month, day, hour, minute, second);

    // now consume the rest of the input line
    Serial.readString();
  }

  // no delays in the loop so there is little delay between sending the time
  // string and setting the RTC time
  unsigned long currentMillis = millis();
  if ((unsigned long)(currentMillis - lastMillis) >= interval) {
    lastMillis = currentMillis;
    DateTime now = rtc.now();
    printDateTime(now.year(), now.month(), now.day(),
                  now.hour(), now.minute(), now.second());
  }
}

/*
 * Utility function to print a datetime in RFC3339 format
 * https://tools.ietf.org/html/rfc3339#page-6
 */
char *printDateTime(int year, int month, int day,
                    int hour, int minute, int second)
{
  char buf[32];
  sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02dZ",
          year, month, day, hour, minute, second);
  Serial.println(buf);
}

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


Create IR2Keyboard.ino (#292)

Create IR2Keyboard.ino (#292)

Maybe useful 😀

/*
this is just an example of creative (maybe useful) use of IR in a PC, as a media center or some other automatizations.
the idea is fordward the IR commands (from any spare remote you may have) to keyboard pulses, combos, shortcuts, etc.
Keyboard funtions only available on "leonardo" and "micro". for more keys read into  https://www.arduino.cc/en/Reference/KeyboardModifiers
for IR decoding im using the amazing lib from:  http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
Remote class emulate media keys. need to be added manually to the arduino lib.  http://stefanjones.ca/blog/arduino-leonardo-remote-multimedia-keys/
this is optional, you dont need Remote class to run the IR or Keyboard; its only for media keys
 */

 /*
Remote methods:
http://stefanjones.ca/blog/arduino-leonardo-remote-multimedia-keys/
Volume
  Remote.increase(void);
  Remote.decrease(void);
  Remote.mute(void);
Playback
  Remote.play(void);
  Remote.pause(void);
  Remote.stop(void);
Track Controls
  Remote.next(void);
  Remote.previous(void);
  Remote.forward(void);
  Remote.rewind(void);
Send an empty report to prevent repeated actions
  Remote.clear();
   */

#include <IRremote.h>
#define T 15
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
//boolean flechas = false;
boolean rotacion = false;

void setup()
{
  pinMode(0,OUTPUT);
  pinMode(1,OUTPUT);
  digitalWrite(0,HIGH);
  digitalWrite(1,LOW);//using pin 0 and 1 to power the IRreciver, pin 2 is serial input.
  Serial.begin(57600);
  Keyboard.begin();
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    //DellRemote(results.value);
    PanasonicRemote(results.value);
    //mapping(results.value);
    delay(300);//estaba en 100//500 es muy largo
    irrecv.resume(); // Receive the next value
  }
  else{  delay(200);}//estaba en 100
}

void mapping(long code){
  //use this funtion to map the codes of all your buttons. some buttons send different codes if they are hold down
  if ((code == 0x801C2B2E) or (code == 0xB4AFB411) or (code == 0xD17D8037)){Serial.println("adelante/fordware button");  }
  else if ((code == 0xB7AFB8C8) or (code == 0xD07D7EA2) or (code == 0x801CAB2F)){Serial.println("atras/previous button");  }
  else {Serial.print(results.value, HEX); Serial.println("-----DESCONOCIDO/unkonw code! ");  }
}

void PanasonicRemote(long code){
  //here i have mapped some buttons of my blueray remote.
  if (code == 0xD00A0AD){/*adelante*/    Keyboard.releaseAll();delay(T); Keyboard.press(KEY_LEFT_ALT); Keyboard.press(KEY_RIGHT_ARROW); delay(T); Keyboard.releaseAll(); /*Remote.forward();  Remote.clear();*/}//Ctrl + ->    fordward 10 seconds VLC
  else if (code == 0xD00202D){/*atras*/  Keyboard.releaseAll();delay(T);  Keyboard.press(KEY_LEFT_ALT); Keyboard.press(KEY_LEFT_ARROW); delay(T); Keyboard.releaseAll(); /*Remote.rewind();  Remote.clear();*/} //Ctrl + <-    rewind 10 seconds VLC
  else if (code == 0xD00525F){/*next*/   Keyboard.releaseAll();delay(T);  Remote.next();  Remote.clear();}
  else if (code == 0xD00929F){/*prev*/   Keyboard.releaseAll();delay(T);  Remote.previous();  Remote.clear();}
  //else if (code == 0xD00000D){/*stop*/   Keyboard.releaseAll();delay(T);  Remote.stop();  Remote.clear();}
  else if (code == 0x1000405){/*vol +*/    Keyboard.releaseAll();delay(T);Remote.increase();  Remote.clear();}
  else if (code == 0x1008485){/*vol -*/    Keyboard.releaseAll();delay(T);Remote.decrease();  Remote.clear(); }
  else if (code == 0xD00BCB1){/*POWER*/    Keyboard.releaseAll();delay(T);Remote.mute();  Remote.clear();}
  else if ((code == 0xD00606D) or (code == 0xD00505D)){/*play/pause*/  Keyboard.releaseAll();delay(T);  Remote.play();  Remote.clear();}
  else if (code == 0xD00818C){/*return*/   Keyboard.releaseAll(); delay(T); Keyboard.write(KEY_ESC);}
  else if (code == 0xD00414C){/*OK*/       Keyboard.releaseAll(); delay(T); Keyboard.print(" "); /*evitar doble pulsaciondelay(300);*/}
  else if (code == 0x100BCBD){/*tvPower*/  Keyboard.releaseAll();delay(T);Keyboard.press(KEY_LEFT_CTRL); Keyboard.press(KEY_UP_ARROW); delay(T); Keyboard.releaseAll();}//volumen en VLC
  else if (code == 0x100A0A1){/*input AV*/ Keyboard.releaseAll();delay(T);Keyboard.press(KEY_LEFT_CTRL); Keyboard.press(KEY_DOWN_ARROW); delay(T); Keyboard.releaseAll();}//volumen en VLC
  else if (code == 0xD00808D){/*open/close*/Keyboard.releaseAll();delay(T);Keyboard.press(KEY_LEFT_CTRL); Keyboard.press(KEY_PAGE_UP); delay(T); Keyboard.releaseAll();}//cambiar canal HEXCHAT
  else if (code == 0xD004944){/*display*/  Keyboard.releaseAll();delay(T);Keyboard.press(KEY_LEFT_CTRL); Keyboard.press(KEY_PAGE_DOWN); delay(T); Keyboard.releaseAll();}//cambiar canal HEXCHAT
  else if (code == 0xD803AB7){/*DLNA*/     if (rotacion){Keyboard.releaseAll();rotacion=false;delay(T);}
                                           else{Keyboard.releaseAll(); delay(T); Keyboard.press(KEY_LEFT_GUI); delay(T); Keyboard.write(KEY_TAB);rotacion=true;}}
                                           //rotation mode  //iniciar animacion de rotacion de ventanas  //start window rotation with compiz
  else if (code == 0xD00A1AC){/*arrow up*/     Keyboard.write(KEY_UP_ARROW);}
  else if (code == 0xD00616C){/*arrow down*/   Keyboard.releaseAll();delay(T);Keyboard.write(KEY_DOWN_ARROW);}
  else if (code == 0xD00E1EC){/*arrow right*/  Keyboard.write(KEY_LEFT_ARROW);}
  else if (code == 0xD00111C){/*arrow left*/   Keyboard.write(KEY_RIGHT_ARROW);}
  else if (code == 0xD00D9D4){/*TOP MENU*/     Keyboard.print("f");}//f pone a pantalla completa en VLC    fullscreen
  else if (code == 0xD00010C){/*S sub menu*/   Keyboard.print("v");}//v cambia subs en VLC   change subs
  else if (code == 0xD00CCC1){/*AUDIO*/    Keyboard.print("b");}//b cambia audio en VLC    change audio track
  else if (code == 0xD002825){/*#5*/       Keyboard.write(KEY_RETURN);}//useful to press enter on the file you want to play.
  else {Serial.print(results.value, HEX); Serial.println("-----DESCONOCIDO!");  }
}

//void DellRemote(long code){
//  if ((code == 0x801C2B2E) or (code == 0xB4AFB411) or (code == 0xD17D8037))
//      {/*adelante*/    Keyboard.releaseAll();delay(T);flechas = false;Keyboard.press(KEY_LEFT_ALT); Keyboard.press(KEY_RIGHT_ARROW); delay(T); Keyboard.releaseAll(); /*Remote.forward();  Remote.clear();*/}
//      //adelantar en VLC      forward
//  else if ((code == 0xB7AFB8C8) or (code == 0xD07D7EA2) or (code == 0x801CAB2F))
//      {/*atras*/       Keyboard.releaseAll();delay(T);flechas = false;Keyboard.press(KEY_LEFT_ALT); Keyboard.press(KEY_LEFT_ARROW); delay(T); Keyboard.releaseAll(); /*Remote.rewind();  Remote.clear();*/}
//      //retroceder en VLC   backwards
//
//  else if ((code == 0x98BD82C2) or (code == 0xD218D2C)  or (code == 0xBD218D2C))
//      {/*next*/   Keyboard.releaseAll();delay(T);flechas = false;Remote.next();  Remote.clear();}
//  else if ((code == 0x7CA73789) or (code == 0x63D971B3) or (code == 0x801CAB21))
//      {/*prev*/   Keyboard.releaseAll();delay(T);flechas = false;Remote.previous();  Remote.clear();}
//  else if ((code == 0x851FCFD5) or (code == 0xB599B51F) or (code == 0x801CAB31))
//      {/*stop*/   Keyboard.releaseAll();delay(T);flechas = false;Remote.stop();  Remote.clear();}
//  else if ((code == 0x5ECE5800) or (code == 0x419B5F52) or (code == 0x801CAB2C))
//      {/*play/pause*/  Keyboard.releaseAll();delay(T);flechas = false;Remote.play();  Remote.clear();}
//  else if ((code == 0x948C3B0)  or (code == 0x17B591EA) or (code == 0x801CABA4))
//      {/*backspace*/   Keyboard.write(KEY_ESC);delay(T);flechas = false;Keyboard.releaseAll();}
//  else if ((code == 0x2AF7C446) or (code == 0x31D33AF4) or (code == 0x801CAB5C))
//      {/*check*/      if(flechas){Keyboard.releaseAll();delay(T);flechas = false;}else{ Keyboard.print(" ");}}
//
//  else if ((code == 0x801CABCE) or (code == 0xC838DBEF) or (code == 0x11A1DED))
//      {/*page up*/      Keyboard.releaseAll();delay(T);flechas = false;Keyboard.press(KEY_LEFT_CTRL); Keyboard.press(KEY_UP_ARROW); delay(T); Keyboard.releaseAll();}
//      //volumen en VLC
//  else if ((code == 0x41A22A4)  or (code == 0xC738DA5A) or (code == 0x801CABCF))
//      {/*page down*/   Keyboard.releaseAll();delay(T);flechas = false;Keyboard.press(KEY_LEFT_CTRL); Keyboard.press(KEY_DOWN_ARROW); delay(T); Keyboard.releaseAll();}
//      //volumen en VLC
//
//  else if ((code == 0x1EBE32)   or (code == 0x529FB6FC) or (code == 0x801C2B10))
//      {/*vol up*/      Keyboard.releaseAll();delay(T);flechas = false;Remote.increase();  Remote.clear();}
//  else if ((code == 0x801CAB11) or (code == 0xA2AB03A3) or (code == 0xE48B8D9))
//      {/*vol down*/     Keyboard.releaseAll();delay(T);flechas = false;Remote.decrease();  Remote.clear(); }
//  else if ((code == 0xFB6B19B4) or (code == 0x1662CD72) or (code == 0x801C2B0D))
//      {/*mute*/      Keyboard.releaseAll();delay(T);flechas = false;Remote.mute();  Remote.clear();}
//
//  else if ((code == 0x2E88114A) or (code == 0x4B9B7430) or (code == 0x801CAB58)){/*arrow up*/
//  //iniciar animacion de rotacion de ventanas
//  //start window rotation with compiz
//      Keyboard.releaseAll();
//      delay(T);
//      Keyboard.write(KEY_UP_ARROW);
//      Keyboard.press(KEY_LEFT_GUI);
//      delay(T);
//      Keyboard.write(KEY_TAB);flechas=true;}//rotation mode
//
//  else if ((code == 0x2EA26AFB) or (code == 0xAD79DDED) or (code == 0x801CAB59))
//      {/*arrow down*/  Keyboard.releaseAll();delay(T);flechas = false;Keyboard.print("b");delay(T);Keyboard.write(KEY_DOWN_ARROW);}
//      //b cambia audio en VLC    change audio track
//  else if ((code == 0x3B726EB4) or (code == 0x54A4E562) or (code == 0x801C2B5B))
//      {/*arrow right*/  if (flechas){Keyboard.write(KEY_LEFT_ARROW);}else{Keyboard.print("v");}}
//      //v cambia subs en VLC   change subs
//  else if ((code == 0x801CAB5A) or (code == 0x3C727047) or (code == 0x55A4E6F5))
//      {/*arrow left*/  if (flechas){Keyboard.write(KEY_RIGHT_ARROW);}else{Keyboard.print("f");}}
//      //f pone a pantalla completa en VLC    fullscreen
//  //else {Serial.print(results.value, HEX); Serial.println("-----DESCONOCIDO!");  }
//}

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


Initial commit with code

Initial commit with code

/*
 Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 version 2 as published by the Free Software Foundation.
 */

/**
 * Example for Getting Started with nRF24L01+ radios.
 *
 * This is an example of how to use the RF24 class.  Write this sketch to two
 * different nodes.  Put one of the nodes into 'transmit' mode by connecting
 * with the serial monitor and sending a 'T'.  The ping node sends the current
 * time to the pong node, which responds by sending the value back.  The ping
 * node can then see how long the whole cycle took.
 */

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

//
// Hardware configuration
//

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10

RF24 radio(9,10);

//
// Topology
//

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

//
// Role management
//
// Set up role.  This sketch uses the same software for all the nodes
// in this system.  Doing so greatly simplifies testing.
//

// The various roles supported by this sketch
typedef enum { role_ping_out = 1, role_pong_back } role_e;

// The debug-friendly names of those roles
const char* role_friendly_name[] = { "invalid", "Ping out", "Pong back"};

// The role of the current running sketch
role_e role = role_pong_back;

void setup(void)
{
  //
  // Print preamble
  //

  Serial.begin(57600);
  printf_begin();
  printf("\n\rRF24/examples/GettingStarted/\n\r");
  printf("ROLE: %s\n\r",role_friendly_name[role]);
  printf("*** PRESS 'T' to begin transmitting to the other node\n\r");

  //
  // Setup and configure rf radio
  //

  radio.begin();

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);

  // optionally, reduce the payload size.  seems to
  // improve reliability
  //radio.setPayloadSize(8);

  //
  // Open pipes to other nodes for communication
  //

  // This simple sketch opens two pipes for these two nodes to communicate
  // back and forth.
  // Open 'our' pipe for writing
  // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

  //if ( role == role_ping_out )
  {
    //radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
  }
  //else
  {
    //radio.openWritingPipe(pipes[1]);
    //radio.openReadingPipe(1,pipes[0]);
  }

  //
  // Start listening
  //

  radio.startListening();

  //
  // Dump the configuration of the rf unit for debugging
  //

  radio.printDetails();
}

void loop(void)
{
  //
  // Ping out role.  Repeatedly send the current time
  //

  if (role == role_ping_out)
  {
    // First, stop listening so we can talk.
    radio.stopListening();

    // Take the time, and send it.  This will block until complete
    unsigned long time = millis();
    printf("Now sending %lu...",time);
    bool ok = radio.write( &time, sizeof(unsigned long) );

    if (ok)
      printf("ok...");
    else
      printf("failed.\n\r");

    // Now, continue listening
    radio.startListening();

    // Wait here until we get a response, or timeout (250ms)
    unsigned long started_waiting_at = millis();
    bool timeout = false;
    while ( ! radio.available() && ! timeout )
      if (millis() - started_waiting_at > 200 )
        timeout = true;

    // Describe the results
    if ( timeout )
    {
      printf("Failed, response timed out.\n\r");
    }
    else
    {
      // Grab the response, compare, and send to debugging spew
      unsigned long got_time;
      radio.read( &got_time, sizeof(unsigned long) );

      // Spew it
      printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
    }

    // Try again 1s later
    delay(1000);
  }

  //
  // Pong back role.  Receive each packet, dump it out, and send it back
  //

  if ( role == role_pong_back )
  {
    // if there is data ready
    if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      unsigned long got_time;
      bool done = false;
      while (!done)
      {
        // Fetch the payload, and see if this was the last one.
        done = radio.read( &got_time, sizeof(unsigned long) );

        // Spew it
        printf("Got payload %lu...",got_time);

	// Delay just a little bit to let the other unit
	// make the transition to receiver
	delay(20);
      }

      // First, stop listening so we can talk
      radio.stopListening();

      // Send the final one back.
      radio.write( &got_time, sizeof(unsigned long) );
      printf("Sent response.\n\r");

      // Now, resume listening so we catch the next packets.
      radio.startListening();
    }
  }

  //
  // Change roles
  //

  if ( Serial.available() )
  {
    char c = toupper(Serial.read());
    if ( c == 'T' && role == role_pong_back )
    {
      printf("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK\n\r");

      // Become the primary transmitter (ping out)
      role = role_ping_out;
      radio.openWritingPipe(pipes[0]);
      radio.openReadingPipe(1,pipes[1]);
    }
    else if ( c == 'R' && role == role_ping_out )
    {
      printf("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK\n\r");

      // Become the primary receiver (pong back)
      role = role_pong_back;
      radio.openWritingPipe(pipes[1]);
      radio.openReadingPipe(1,pipes[0]);
    }
  }
}
// vim:cin:ai:sts=2 sw=2 ft=cpp

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


Change Length

Change Length

Sensor Code UPDATED(ET) NEW 7 DIGIT/arduinoSensorTX7DIGIT/arduinoSensorTX7DIGIT.ino

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


aggiunto simulatore eth

aggiunto simulatore eth

/*
 Basic MQTT example

 This sketch demonstrates the basic capabilities of the library.
 It connects to an MQTT server then:
  - publishes "hello world" to the topic "outTopic"
  - subscribes to the topic "inTopic", printing out any messages
    it receives. NB - it assumes the received payloads are strings not binary

 It will reconnect to the server if the connection is lost using a blocking
 reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to
 achieve the same result without blocking the main loop.

*/

#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>

String puntoAcq;
String temp;
String terUm;
String AriaUm;
String timeAcq;

long lastMsg = 0;
char msg[50];
int value = 0;

// Update these with values suitable for your network.
byte mac[]    = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 101);
IPAddress server(192, 168, 1, 69);

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i=0;i<length;i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

EthernetClient ethClient;
PubSubClient client(ethClient);

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("arduinoClient")) {
      Serial.println("connected");

      // ... and resubscribe
      client.subscribe("acqDati");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

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

  client.setServer(server, 1883);
  client.setCallback(callback);

  Ethernet.begin(mac, ip);
  // Allow the hardware to sort itself out
  delay(1500);
}

void loop()
{
  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  puntoAcq = String(random(1,4));
  temp = String(random(-40,50));
  terUm = String(random(0, 1024));
  AriaUm = String(random(0, 1024));
  timeAcq = String(random(1,31)) + "/"+ String(random(1,13)) + "/" + String(2018);

  String msg= puntoAcq + ',' + temp + ',' + terUm + ',' + AriaUm + ',' + timeAcq;

  long now = millis();
  if (now - lastMsg > 2000) {
    lastMsg = now;
    ++value;
    Serial.print("messaggio pubblicato: ");
    Serial.println(msg);
    char buf[64];
    msg.toCharArray(buf, 64);
    client.publish("acqDati", buf);

}
}

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


Firmware to turn the weapon on

Firmware to turn the weapon on

#define LED_SAT 2
#define RELAY 1
#define PPM 3

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(LED_SAT, OUTPUT);
  pinMode(RELAY, OUTPUT);
  pinMode(PPM, INPUT);
  digitalWrite(LED_SAT, LOW);
  digitalWrite(RELAY, LOW);
}

void loop() {
  // PPM
  int pulse_width = pulseIn(PPM, HIGH);

  // SAT LED
  if(500 < pulse_width && pulse_width < 2500){
    digitalWrite(LED_SAT, HIGH);   // turn the LED on (HIGH is the voltage level)
  }else{
    digitalWrite(LED_SAT, LOW);
    digitalWrite(RELAY, LOW); // fail safe
    return;
  }

  // RELAY
  if(1650 < pulse_width && pulse_width < 2500){
    digitalWrite(RELAY, HIGH);
  }else{
    digitalWrite(RELAY, LOW); // fail safe
  }
}

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


Add Apple Remote example

Add Apple Remote example

#include <AppleRemote.h>

#include <hexbug_spider.h>

#define SIGNAL_MAX_LENGTH 70

#define PIN_IR_INPUT      2
#define PIN_IR_OUTPUT     3

int last_code = 0;

unsigned int signal[SIGNAL_MAX_LENGTH];

IRDump *irdumper;
AppleRemote *appleRemote;

void setup()
{
  Serial.begin(115200);
  Serial.println("Apple Remote for Arduino.");

  appleRemote = new AppleRemote(PIN_IR_OUTPUT, APPLE_REMOTE_MODEL_A);
  irdumper = new IRDump();
}

void receive_signals() {
  unsigned int *s = signal;

  bool captured;
  int code;

  code = 0;

  captured = irdumper->Capture(PIN_IR_INPUT, s, SIGNAL_MAX_LENGTH, 9500);

  if (captured) {
    code = appleRemote->Match(s);

    switch (code) {
      case APPLE_REMOTE_RIGHT:
        Serial.println("[right]");
        break;
      case APPLE_REMOTE_LEFT:
        Serial.println("[left]");
        break;
      case APPLE_REMOTE_UP:
        Serial.println("[up]");
        break;
      case APPLE_REMOTE_DOWN:
        Serial.println("[down]");
        break;
      case APPLE_REMOTE_REPEAT:
        Serial.println("[repeat]");
        code = last_code;
        break;
      default:
        Serial.println("[?]");
        code = 0;
        return;
    }

    if (code > 0) {

      int i;

      for (i = 0; i < 5; i++) {
        switch (code) {
          case APPLE_REMOTE_RIGHT:
            hexbug_spider_right();
            break;
          case APPLE_REMOTE_LEFT:
            hexbug_spider_left();
            break;
          case APPLE_REMOTE_UP:
            hexbug_spider_forward();
            break;
          case APPLE_REMOTE_DOWN:
            hexbug_spider_backward();
            break;
          default:
            return;
        }
        delay(50);
      }

      last_code = code;
    }
  }
}

void loop() {
  receive_signals();
}

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


Light optimalisations Master

Light optimalisations Master

error: pathspec 'SmartKitchen-Emdebbed' did not match any file(s) known to git
error: pathspec 'System/Software/Arduino/Final_Main_Master/Final_Main_Master.ino' did not match any file(s) known to git


Pushbutton example

Pushbutton example

const int BUTTON_PIN = 12;
const int LED_PIN = 13;

// See https://www.arduino.cc/en/Tutorial/StateChangeDetection

void setup() {
  // Initialize the button pin as a input.
  pinMode(BUTTON_PIN, INPUT);
  // initialize the LED as an output.
  pinMode(LED_PIN, OUTPUT);
  // Initialize serial communication for debugging.
  Serial.begin(9600);

}

int buttonState = 0;
int lastButtonState = 0;

void loop() {
  buttonState = digitalRead(BUTTON_PIN);

  if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {
      // If the current state is HIGH then the button
      // went from off to on:
      Serial.println("on");

      // Light the LED.
      digitalWrite(LED_PIN, HIGH);
      delay(100);
      digitalWrite(LED_PIN, LOW);

    } else {
      Serial.println("off");
    }
    // Delay a little bit to avoid bouncing.
    delay(50);
  }
  lastButtonState = buttonState;
}

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


Initial check-in of Oscilloscope.

Initial check-in of Oscilloscope.

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


Added the AccelStepper example.

Added the AccelStepper example.

/* This example shows how to use the AMIS-30543 stepper motor
driver with the AccelStepper library.

You will need to install the AccelStepper library for this
example to work.  Documentation and installation instructions for
the AccelStepper library are available here:

    http://www.airspayce.com/mikem/arduino/AccelStepper/

Before using this example, be sure to change the
setCurrentMilliamps line to have an appropriate current limit for
your system.  Also, see this library's documentation for
information about how to connect the driver:

    http://pololu.github.io/amis-30543-arduino/
*/

#include <SPI.h>
#include <AMIS30543.h>
#include <AccelStepper.h>

const uint8_t amisDirPin = 2;
const uint8_t amisStepPin = 3;
const uint8_t amisSlaveSelect = 4;

AMIS30543 stepper;
AccelStepper accelStepper(AccelStepper::DRIVER, amisStepPin, amisDirPin);

void setup()
{
  SPI.begin();
  stepper.init(amisSlaveSelect);
  delay(1);

  stepper.resetSettings();
  stepper.setCurrentMilliamps(132);
  stepper.setStepMode(32);
  stepper.enableDriver();

  accelStepper.setMaxSpeed(2000.0);
  accelStepper.setAcceleration(500.0);
}

void loop()
{
  accelStepper.runToNewPosition(0);
  delay(500);
  accelStepper.runToNewPosition(10000);
  delay(500);
}

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


Update EEPROMCalibrationFutabaT8FGSuperSketch.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/HarrisonOfTheNorth/BitChannels.git/'