Update to provide datums we variable

Update to provide datums we variable

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/MitchellJThomas/medir.git/'


Adding a Nucleo thread variant of the blink sketch.

/**
 * @file CosaNucleoBlink.ino
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2014, Mikael Patel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA  02111-1307  USA
 *
 * @section Description
 * Demonstration of Cosa Nucleo Threads; Blink LED with thread
 * delay and use an additional thread to control the LED blink
 * frequency.
 *
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/Pins.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/Nucleo/Thread.hh"

class LED : public Nucleo::Thread {
private:
  OutputPin m_pin;
  uint16_t m_delay;
public:
  LED(Board::DigitalPin pin) : Thread(), m_pin(pin, 1), m_delay(200) {}
  void set_delay(uint16_t ms) { m_delay = ms; }
  virtual void run();
};

void
LED::run()
{
  m_pin.toggle();
  delay(m_delay);
}

template <uint16_t LOW, uint16_t HIGH, uint16_t INC>
class LEDController : public Nucleo::Thread {
private:
  LED* m_led;
public:
  LEDController(LED* led) : Thread(), m_led(led) {}
  virtual void run();
};

template <uint16_t LOW, uint16_t HIGH, uint16_t INC>
void
LEDController<LOW, HIGH, INC>::run()
{
  for (uint16_t ms = LOW; ms < HIGH; ms += INC) {
    m_led->set_delay(ms);
    delay(1000);
  }
  for (uint16_t ms = HIGH; ms > LOW; ms -= INC) {
    m_led->set_delay(ms);
    delay(1000);
  }
}

LED buildin(Board::LED);
LEDController<20,200,20> controller(&buildin);

void setup()
{
  Watchdog::begin();
  Nucleo::Thread::begin(&buildin, 32);
  Nucleo::Thread::begin(&controller, 32);
}

void loop()
{
  Nucleo::Thread::begin();
}

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


Major rework and cleanup.

Major rework and cleanup.

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


Optimise data types

Optimise data types

You do not need an entire `int` just to store `HIGH`/`LOW`.

fatal: remote error: upload-pack: not our ref 8ea207a00107b685d119929bf0e3d4d30d8abd9d
fatal: the remote end hung up unexpectedly


Add first firmware to control motors and publish encoder state from MegaPi throught ROS

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/Bobox214/Dovlo.git/'


신호처리 시뮬레이션 코드 추가

신호처리 시뮬레이션 코드 추가

Arduino

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

  // test sample values from matlab documatation
  //float u[] = {1, 0, 1};
  //float v[] = {2, 7};
  //float u[] = {1, 1, 1};
  //float v[] = {1, 1, 0, 0, 0, 1, 1};
  float u[] = {-1, 2, 3, -2, 0, 1, 2};
  float v[] = {2, 4, -1, 1};
  bool isSame = false;

  int uLength = sizeof(u) / sizeof(float);
  int vLength = sizeof(v) / sizeof(float);
  int wLength = isSame ? uLength : uLength + vLength - 1 ;
  float w[wLength] = {};

  convolution(u, uLength, v, vLength, w, isSame);
  for (int i = 0; i < wLength; i++) {
    Serial.println(w[i]);
  }
}

void loop() {
}

void convolution(float *u, int uLength, float *v, int vLength, float *w, bool isSame) {
  float tmpArr[uLength + vLength - 1] = {};
  for (int i = 0; i < uLength + vLength - 1; i++) {
    int index = i;
    float tmpVal = 0;
    for (int j = 0; j < vLength; j++) {
      if (index >= 0 && index < uLength) {
        tmpVal += u[index] * v[j];
      }
      index--;
      tmpArr[i] = tmpVal;
    }
  }
  if (isSame) {
    int start = ceil((vLength - 1) / 2.0);
    for (int i = 0; i < uLength; i++) {
      w[i] = tmpArr[start+i];
    }
  } else {
    for (int i = 0; i < uLength + vLength - 1; i++) {
      w[i] = tmpArr[i];
    }
  }
}

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


Changed UziFirmware.ino to use the new EEPROMWearLevelingWriter.

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/RichoM/Uzi.git/'


Added a startup check for a program stored in the EEPROM.


Finished motion sensor code for display

Finished motion sensor code for display

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


Added minimal test sketch

Added minimal test sketch

/*
The OpenTRV project licenses this file to you
under the Apache Licence, Version 2.0 (the "Licence");
you may not use this file except in compliance
with the Licence. You may obtain a copy of the Licence at

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

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

Author(s) / Copyright (s): Deniz Erbilgin 2016
*/
/**
 * Minimal REV7 config for testing power consumption.
 * Aim is to:
 *     - todo init GPIO pins to safe mode.
 *     - todo init peripherals to safe low power mode.
 *     - loop endlessly.
 */

// INCLUDES & DEFINES
// Debug output flag
#define DEBUG
// REV7 / DORM1 all-in-one valve unit, secure TX.
//#define CONFIG_DORM1
// Get defaults for valve applications.
#include <OTV0p2_valve_ENABLE_defaults.h>
// All-in-one valve unit (DORM1).
#include <OTV0p2_CONFIG_REV20.h>
// I/O pin allocation and setup: include ahead of I/O module headers.
#include <OTV0p2_Board_IO_Config.h>
// OTV0p2Base Libraries
#include <OTV0p2Base.h>
// RadValve libraries
#include <OTRadValve.h>

// Debugging output
#ifndef DEBUG
#define DEBUG_SERIAL_PRINT(s) // Do nothing.
#define DEBUG_SERIAL_PRINTFMT(s, format) // Do nothing.
#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) // Do nothing.
#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) // Do nothing.
#define DEBUG_SERIAL_PRINTLN() // Do nothing.
#define DEBUG_SERIAL_TIMESTAMP() // Do nothing.
#else
// Send simple string or numeric to serial port and wait for it to have been sent.
// Make sure that Serial.begin() has been invoked, etc.
#define DEBUG_SERIAL_PRINT(s) { OTV0P2BASE::serialPrintAndFlush(s); }
#define DEBUG_SERIAL_PRINTFMT(s, fmt) { OTV0P2BASE::serialPrintAndFlush((s), (fmt)); }
#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) { OTV0P2BASE::serialPrintAndFlush(F(fs)); }
#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) { OTV0P2BASE::serialPrintlnAndFlush(F(fs)); }
#define DEBUG_SERIAL_PRINTLN() { OTV0P2BASE::serialPrintlnAndFlush(); }
// Print timestamp with no newline in format: MinutesSinceMidnight:Seconds:SubCycleTime
extern void _debug_serial_timestamp();
#define DEBUG_SERIAL_TIMESTAMP() _debug_serial_timestamp()
#endif // DEBUG

// OBJECTS & VARIABLES
/**
 * Peripherals present on REV7
 * - Pot        Set input to Hi-Z?  +
 * - PHT        IO_POWER_UP LOW
 * - Encoder    IO_POWER_UP LOW
 * - LED        Set pin HIGH?
 * - Button     Set to INPUT
 * - H-Bridge   Control pins HIGH, Current sense set to input.  +
 * - SHT21      read() once.        +
 * - RFM23B     ??                  +
 * - XTAL       Setup and leave running?
 * - UART       Disable
 */

/**
 * Dummy Types
 */
// Placeholder class with dummy static status methods to reduce code complexity.
typedef OTV0P2BASE::DummySensorOccupancyTracker OccupancyTracker;

/**
 * Supply Voltage instance
 */
// Sensor for supply (eg battery) voltage in millivolts.
// Singleton implementation/instance.
OTV0P2BASE::SupplyVoltageCentiVolts Supply_cV;

/*
 * Radio instance
 */
static constexpr bool RFM23B_allowRX = false;

static constexpr uint8_t RFM23B_RX_QUEUE_SIZE = OTRFM23BLink::DEFAULT_RFM23B_RX_QUEUE_CAPACITY;
static constexpr int8_t RFM23B_IRQ_PIN = -1;// PIN_RFM_NIRQ;
// XXX Is it really worth having a separate primary radio in this case?
OTRFM23BLink::OTRFM23BLink<OTV0P2BASE::V0p2_PIN_SPI_nSS, RFM23B_IRQ_PIN, RFM23B_RX_QUEUE_SIZE, RFM23B_allowRX> PrimaryRadio;//RFM23B;
///* constexpr */ OTRadioLink::OTRadioLink &PrimaryRadio = RFM23B
// Pick an appropriate radio config for RFM23 (if it is the primary radio).
// Nodes talking on fast GFSK channel 0.
static const uint8_t nPrimaryRadioChannels = 1;
static const OTRadioLink::OTRadioChannelConfig RFM23BConfigs[nPrimaryRadioChannels] = {
    // GFSK channel 0 full config, RX/TX, not in itself secure.
    OTRadioLink::OTRadioChannelConfig(OTRFM23BLink::StandardRegSettingsGFSK57600, true), };

/*
 * SHT21 instance
 */
OTV0P2BASE::RoomTemperatureC16_SHT21 TemperatureC16; // SHT21 impl.

// HUMIDITY_SENSOR_SUPPORT is defined if at least one humidity sensor has support compiled in.
// Simple implementations can assume that the sensor will be present if defined;
// more sophisticated implementations may wish to make run-time checks.
// If SHT21 support is enabled at compile-time then its humidity sensor may be used at run-time.
// Singleton implementation/instance.
typedef OTV0P2BASE::HumiditySensorSHT21 RelHumidity_t;
RelHumidity_t RelHumidity;

/**
 * Temp pot
 */
// Sensor for temperature potentiometer/dial UI control.
// Correct for DORM1/TRV1 with embedded REV7.
// REV7 does not drive pot from IO_POWER_UP.
typedef OTV0P2BASE::SensorTemperaturePot<OccupancyTracker, nullptr, 48, 296, false> TempPot_t;
TempPot_t TempPot;

/**
 * Ambient Light Sensor
 */
typedef OTV0P2BASE::SensorAmbientLight AmbientLight;
// Singleton implementation/instance.
AmbientLight AmbLight;

/**
 * Valve Actuator
 */
// DORM1/REV7 direct drive motor actuator.
static constexpr bool binaryOnlyValveControl = false;
static constexpr uint8_t m1 = MOTOR_DRIVE_ML;
static constexpr uint8_t m2 = MOTOR_DRIVE_MR;
typedef OTRadValve::ValveMotorDirectV1<m1, m2, MOTOR_DRIVE_MI_AIN, MOTOR_DRIVE_MC_AIN, decltype(Supply_cV), &Supply_cV, binaryOnlyValveControl> ValveDirect_t;
// Singleton implementation/instance.
// Suppress unnecessary activity when room dark, eg to avoid disturbance if device crashes/restarts,
// unless recent UI use because value is being fitted/adjusted.
ValveDirect_t ValveDirect([](){return(AmbLight.isRoomDark());});

// FUNCTIONS

/**
 * Panic Functions
 */
// Indicate that the system is broken in an obvious way (distress flashing the main LED).
// DOES NOT RETURN.
// Tries to turn off most stuff safely that will benefit from doing so, but nothing too complex.
// Tries not to use lots of energy so as to keep distress beacon running for a while.
void panic()
{
    // Reset radio and go into low-power mode.
    PrimaryRadio.panicShutdown();
    // Power down almost everything else...
    OTV0P2BASE::minimisePowerWithoutSleep();
    pinMode(OTV0P2BASE::LED_HEATCALL_L, OUTPUT);
    for( ; ; )
    {
        OTV0P2BASE::LED_HEATCALL_ON();
        OTV0P2BASE::nap(WDTO_15MS);
        OTV0P2BASE::LED_HEATCALL_OFF();
        OTV0P2BASE::nap(WDTO_120MS);
    }
}
// Panic with fixed message.
void panic(const __FlashStringHelper *s)
{
    OTV0P2BASE::serialPrintlnAndFlush(); // Start new line to highlight error.  // May fail.
    OTV0P2BASE::serialPrintAndFlush('!'); // Indicate error with leading '!' // May fail.
    OTV0P2BASE::serialPrintlnAndFlush(s); // Print supplied detail text. // May fail.
    panic();
}

/**
 * @brief   Set pins and on-board peripherals to safe low power state.
 */

//========================================
// SETUP
//========================================

// Setup routine: runs once after reset.
// Does some limited board self-test and will panic() if anything is obviously broken.
void setup()
{
    // Set appropriate low-power states, interrupts, etc, ASAP.
    OTV0P2BASE::powerSetup();
    // IO setup for safety, and to avoid pins floating.
    OTV0P2BASE::IOSetup();

    OTV0P2BASE::serialPrintAndFlush(F("\r\nOpenTRV: ")); // Leading CRLF to clear leading junk, eg from bootloader.
    V0p2Base_serialPrintlnBuildVersion();

    OTV0P2BASE::LED_HEATCALL_ON();

    // Give plenty of time for the XTal to settle.
    delay(1000);

    // Have 32678Hz clock at least running before going any further.
    // Check that the slow clock is running reasonably OK, and tune the fast one to it.
    if(!::OTV0P2BASE::HWTEST::calibrateInternalOscWithExtOsc()) { panic(F("Xtal")); } // Async clock not running or can't tune.
//    if(!::OTV0P2BASE::HWTEST::check32768HzOsc()) { panic(F("xtal")); } // Async clock not running correctly.

    // Initialise the radio, if configured, ASAP because it can suck a lot of power until properly initialised.
    PrimaryRadio.preinit(NULL);
    // Check that the radio is correctly connected; panic if not...
    if(!PrimaryRadio.configure(nPrimaryRadioChannels, RFM23BConfigs) || !PrimaryRadio.begin()) { panic(F("r1")); }

    // Buttons should not be activated DURING boot for user-facing boards; an activated button implies a fault.
    // Check buttons not stuck in the activated position.
    if(fastDigitalRead(BUTTON_MODE_L) == LOW) { panic(F("b")); }

    // Collect full set of environmental values before entering loop() in normal mode.
    // This should also help ensure that sensors are properly initialised.

    // No external sensors are *assumed* present if running alt main loop
    // This may mean that the alt loop/POST will have to initialise them explicitly,
    // and the initial seed entropy may be marginally reduced also.
    const int cV = Supply_cV.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("V: ");
    DEBUG_SERIAL_PRINT(cV);
    DEBUG_SERIAL_PRINTLN();
    const int heat = TemperatureC16.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("T: ");
    DEBUG_SERIAL_PRINT(heat);
    DEBUG_SERIAL_PRINTLN();
    const uint8_t rh = RelHumidity.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("RH%: ");
    DEBUG_SERIAL_PRINT(rh);
    DEBUG_SERIAL_PRINTLN();
    const int light = AmbLight.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("L: ");
    DEBUG_SERIAL_PRINT(light);
    DEBUG_SERIAL_PRINTLN();
    const int tempPot = TempPot.read();
    DEBUG_SERIAL_PRINT_FLASHSTRING("temp pot: ");
    DEBUG_SERIAL_PRINT(tempPot);
    DEBUG_SERIAL_PRINTLN();

    ValveDirect.read();

    // Initialised: turn main/heatcall UI LED off.
    OTV0P2BASE::LED_HEATCALL_OFF();

    // Do OpenTRV-specific (late) setup.
    PrimaryRadio.listen(false);

    // Long delay after everything set up to allow a non-sleep power measurement.
    delay(10000);
}

//========================================
// MAIN LOOP
//========================================
/**
 * @brief   Sleep in low power mode if not sleeping.
 */
void loop()
{
    // Ensure that serial I/O is off while sleeping.
    OTV0P2BASE::powerDownSerial();
    // Power down most stuff (except radio for hub RX).
    OTV0P2BASE::minimisePowerWithoutSleep();
    // Normal long minimal-power sleep until wake-up interrupt.
    // Rely on interrupt to force quick loop round to I/O poll.
    OTV0P2BASE::sleepUntilInt();
}

/**
 * @note    Power consumption figures (all in mA).
 * Date/commit:         Device: Wake (Sleep) @ Voltage
 * 20161111/0e6ec96     REV7:   1.5 (1.1) @ 2.5 V       REV11:  0.45 (0.03) @ 2.5 V
 * 20161111/f2eed5e     REV7:   0.46 (0.04) @ 2.5 V
 */

/**
 * @note    REV7 Power consumption investigation.
 *          Figures are not overly accurate due to hot airgun changing board temp. Shouldn't make enough of a difference for our purposes.
 * Baseline:                1.08 mA
 * - Motor decoupling caps: 1.08 mA
 * - Potentiometer:         1.02 mA
 * - BAV99 Suppressors:     1.02 mA
 * - TANT RF decoupling:    1.01 mA
 * - Motor diodes:          1.01 mA
 * - Op Amp:                0.99 mA
 * - Inductor:              178 mA (I think this is due to ML+MR being held high)
 * - H-Bridge Transistors:  0.99 mA
 * - All decoupling:        0.98 mA
 * - All H-Bridge resistors:0.98 mA
 * - Encoder:               0.98 mA
 * - Some resistors:        0.48 mA
 */

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


Ready to verify on oscilloscope. Looks good on serial.

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


Let there be light

Let there be light

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


Create barometer.ino

Create barometer.ino

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


Fix semi-colon … Thanks MATLAB!

Fix semi-colon … Thanks MATLAB!

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/Duke-Medical-Instrumentation/InceptionTI.git/'


Test for motor using enable pins and buttons operation.

#include <Stepper.h>

#define P1 P4_5
#define P2 P1_1

const int stepsPerRevolution = 200;

Stepper myStepper(stepsPerRevolution, 12,13,5,9);

short forward;
short backward;

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);

  // initialize the serial port:
  Serial.begin(9600);

  // Enable pin pull-up for the buttons
  pinMode(P4_5, INPUT_PULLUP);
  pinMode(P1_1, INPUT_PULLUP);

  // Set modes for enable pins
  pinMode(18, OUTPUT);
  pinMode(19, OUTPUT);
}

void loop() {

  // Read button pins
  forward = digitalRead(P1);
  backward = digitalRead(P2);
  Serial.print(forward);

  // Enable or disable motor
  if (forward == 0 || backward == 0) {
    digitalWrite(18, HIGH);
    digitalWrite(19, HIGH);
  }
  else {
    digitalWrite(18, LOW);
    digitalWrite(19, LOW);
  }

  // Turn motor if a button is pressed
  if (forward == 0) {
    myStepper.step(1);
  }

  if (backward == 0) {
    myStepper.step(-1);
  }

  // Delay before next loop. Determines how fast the motor turns
  delay(4);

}

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


added weatherstation

added weatherstation

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/werar/iothome.git/'


Create mqtt_dragino_2xrele.ino

Create mqtt_dragino_2xrele.ino

#include <Process.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "MQTTclient.h"

#define I2C_ADDR  0x27
#define En_pin    2
#define Rw_pin    1
#define Rs_pin    0
#define D4_pin    4
#define D5_pin    5
#define D6_pin    6
#define D7_pin    7
#define BACKLIGHT_PIN   3

int rele1 = 4;
int rele2 = 6;

#define MQTT_HOST "190.97.168.236"
char message_buff[100];
char message_buff2[100];
char message[256];
String id_sensor = "prueba12";

LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin,
                      D4_pin, D5_pin, D6_pin, D7_pin);

void setup() {
    Serial.begin(9600);
  Bridge.begin();
  mqtt.begin(MQTT_HOST, 1883);
    mqtt.subscribe("/rr/temp", someEvent);
  lcd.begin (20, 4);
  pinMode(rele1, OUTPUT);
  pinMode(rele2, OUTPUT);
  digitalWrite(rele1, HIGH);
  digitalWrite(rele2, HIGH);

  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);

  // Position cursor and write some text
  lcd.home();
  lcd.print("RELE 1: OFF, RELE 2: OFF");
    mqtt.publish("test/dos", "conectado!");
}

void loop() {

  mqtt.monitor();

}

void someEvent(const String& topic, const String& subtopic, const String& message) {

  mqtt.publish("test/dos", "Recibido_Control_D1");
   if (message == "rele10") {
    digitalWrite(rele1, HIGH);
    lcd.clear();
    lcd.print("RELE 1: ON");

  }
  else if (message == "rele11"){
    digitalWrite(rele1, LOW);
        lcd.clear();
    lcd.print("RELE 1: OFF");

  }

 else if (message == "rele20"){
    digitalWrite(rele2, HIGH);
            lcd.clear();
    lcd.print("RELE 2: ON");

  }  else if (message == "rele21"){
    digitalWrite(rele2, LOW);
            lcd.clear();
    lcd.print("RELE 2: OFF");

  }

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


Renaming to adapt to ino command tool

Renaming to adapt to ino command tool

/*
  Analog input, analog output, serial output

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

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

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

 This example code is in the public domain.

 */

// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = 0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

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

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

void loop() {
  // read the analog in value:
  for (int thisPin = 0; thisPin < 6; thisPin++) {
  sensorValue = analogRead(thisPin);

  // print the results to the serial monitor:
  //Serial.print("sensor = " );
  Serial.print(sensorValue);
  Serial.print(",");
  //Serial.print("\t output = ");
  //Serial.println(outputValue);
  delay(2);
  }
   Serial.println("");
  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(2);
}

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


example code

example code

error: pathspec 'Examples/tinyscreen-spritetile-testbed/tinyscreen-spritetile-testbed.ino' did not match any file(s) known to git


Adding example sketch to demonstrate sending, receiving and link statistics.

/*
 * Sketch to demonstrate RF12_Stream. Prints incoming
 * data. Periodically sends data and prints statistics about the link
 * (number of packets sent and received, and number of retries).  The
 * firmware size is under 8kB when compiled for the ATtiny84 so it may
 * be possible to run the sketch on the RFM12B to Pi expansion board,
 * http://shop.openenergymonitor.com/raspberry-pi/.
 *
 * Copyright S R Marple, 2013.
 * Released under MIT License, http://opensource.org/licenses/mit-license.php
 */

#include <CircBuffer.h>
#include <AsyncDelay.h>
#include <RF12.h>
#include <RF12_Stream.h>

#if defined(UBRRH) || defined(UBRR0H) || defined(USBCON)
Stream &mySerial = Serial;
#else
// No hardware serial or USB interface
#define USE_SW_SERIAL
#include <SoftwareSerial.h>
#endif

#ifdef CALUNIUM
// Calunium, use pin mapping for v2.0/v2.1
#define RFM12B_CS 14
#define RFM12B_IRQ_PIN 6
#define RFM12B_IRQ_NUM 2
#define LED_PIN LED_BUILTIN

#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined (__AVR_ATmega328P__)
// Jeenode mapping?
#define RFM12B_CS 10
#define RFM12B_IRQ_PIN 2
#define RFM12B_IRQ_NUM 0
#define LED_PIN LED_BUILTIN

#elif defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny44__)
// Assume pin-mapping used for Martin Harizanov's RFM2Pi board
#define RFM12B_CS 1
#define RFM12B_IRQ_PIN 2
#define RFM12B_IRQ_NUM 0
#define LED_PIN 8
#endif

#ifdef USE_SW_SERIAL
SoftwareSerial swSerial(7, 3);
Stream &mySerial = swSerial;
#endif

#if RAMEND >= 4096
// eg ATmega644(P), ATmega1284(P), ATmega1280 or ATmega2560
uint8_t rxBuffer[1024];
uint8_t txBuffer[1024];

#elif RAMEND >= 2048
// eg ATmega328
uint8_t rxBuffer[512];
uint8_t txBuffer[512];

#else
// eg ATtiny84
uint8_t rxBuffer[30];
uint8_t txBuffer[30];
#endif

RF12_Stream rfm12b(rxBuffer, sizeof(rxBuffer),
		   txBuffer, sizeof(txBuffer));

unsigned long sendInterval_ms = 2000UL;
unsigned long statsInterval_ms = 20000UL;

AsyncDelay sendDelay;
AsyncDelay statsDelay;
#ifdef LED_PIN
AsyncDelay activityDelay;
#endif

void setup(void)
{
#ifdef SS
  pinMode(SS, OUTPUT);
#endif

#ifdef LED_PIN
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
#endif

#ifdef USE_SW_SERIAL
  swSerial.begin(9600);
#else
  Serial.begin(9600);
#endif

  if (rfm12b.begin(RFM12B_CS, RFM12B_IRQ_PIN, RFM12B_IRQ_NUM, 1, RF12_433MHZ)) {
    sendDelay.start(sendInterval_ms, AsyncDelay::MILLIS);
  }
  else
    while (1)
      mySerial.println("RFM12B not found");

#ifdef LED_PIN
  digitalWrite(LED_PIN, LOW);
#endif
  activityDelay.expire();
}

void loop(void)
{
  bool activity = false;

  rfm12b.poll();
  if (sendDelay.isExpired()) {
    long myMillis = millis();

    mySerial.print("TX: Millis is ");
    mySerial.println(myMillis);
    rfm12b.print("Millis is ");
    rfm12b.println(myMillis);
    sendDelay.start(sendInterval_ms, AsyncDelay::MILLIS);
  }

  if (rfm12b.available()) {
    mySerial.print("RX: ");
    while (rfm12b.available())
      mySerial.write(char(rfm12b.read()));
    mySerial.println();
    activity = true;
  }

  if (statsDelay.isExpired()) {
    mySerial.println("--");
    mySerial.print("TX packets: ");
    mySerial.println(RF12_Stream::txPackets);

    mySerial.print("RX packets: ");
    mySerial.println(RF12_Stream::rxPackets);

    mySerial.print("Retries: ");
    mySerial.println(RF12_Stream::retries);
    statsDelay.start(statsInterval_ms, AsyncDelay::MILLIS);
  }

#ifdef LED_PIN
  if (activityDelay.isExpired()) {
    if (activity) {
      digitalWrite(LED_PIN, HIGH);
      activityDelay.start(250, AsyncDelay::MILLIS);
    }
    else
      digitalWrite(LED_PIN, LOW);
  }
#endif
}

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


Inverting value of potenciometer

Inverting value of potenciometer

#include <SoftwareSerial.h>
#include <Servo.h>

#define TACOMETER 5
#define GUIDAO A0
#define SERVO_PIN 9

Servo servoBrk;

float TacAct = 0, TacPast = 0, Vact=0, Vpast=0, velocity = 0;
float transicao=0;
int Vguidao;

void setup()
{
    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
    //Configurando a entrada digital
    pinMode(TACOMETER, INPUT_PULLUP);

    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/

    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
    /* configurando o servomotor*/
    servoBrk.attach(SERVO_PIN);
    servoBrk.write(map(0, '0', '9', 0, 90));

    /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/

  /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
  // Configurando a porta serial
  Serial.begin(9600);
  while (!Serial) {
    ; // Espera a porta serial conectar
  }
  /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
}

void loop() // run over and over
{
  int count = 0, cmd;
  /* Laço principal */
  for(;;)
  {
     /* Leitura de todos os sensores */
     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
     /* Leitura de todos os sensores */

     TacAct = digitalRead(TACOMETER); // Tacometro

     Vguidao = analogRead(GUIDAO);

     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/

     /* Processamento de todas as informaçes */
     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/
  if(count < 120)
  {
       if((TacAct-TacPast)!=0)
       {
         transicao = 1;
       }
       else
       {
         transicao = 0;
       }

       Vact = 1*transicao/1 + Vact;
       if(Vact < 0)
         Vact = 0;
       else if(Vact > 1000)
         Vact = 1000;

       count++;
  }
  else
  {
    velocity = Vact;
    Vact = 0;
    count = 0;
  }
     /*zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*/

     /* Envio das informacoes */

     switch(cmd = Serial.read())
     {

       case 'A' :

       //Serial.println("mixed = ");
       Serial.print(1023 - Vguidao);
       Serial.print(' ');
       Serial.println(velocity);

       break;

       case '0':
       case '1':
       case '2':
       case '3':
       case '4':
       case '5':
       case '6':
       case '7':
       case '8':
       case '9':

       cmd = map(cmd, '0', '9', 0, 90); // 0 <= pot_direction <= 179
       servoBrk.write(cmd);
       Serial.println(cmd);

       break;

       default :

       break;

     }

     /* Atualizacao das variaveis */
     Vpast = Vact;
     TacPast = TacAct;
     delay(1);

  }

}

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


Added ArduinoIDE file for the sensors

Added ArduinoIDE file for the sensors

/*
 * Rosserial sensor value publisher
 * Publishes the value of the sensor to ros
 * Sensor types: Sharp 041SK, Sharp GP2D12 and !!NOGIETS!!
 *
 * Usage:
 * Run roscore
 * Type in terminal: rosrun rosserial_python serial_node.py /dev/ttyACM#
 * where # is the number of the serial port the Arduino is attached to
 * Call the topic with: rostopic echo [$SENSOR_TYPE]_sensor
 */

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

ros::NodeHandle  nh;

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

int sensorpin_41 = 0; // analog pin used to connect the sharp 041SK
int sensorpin_12 = 1; // analog pin used to connect the sharp GP2D12

void setup()
{
  nh.initNode();
  nh.advertise(sensor_publisher);
  //nh.advertise(sharp12_sensor);
}

void loop()
{
  double sensor_value41 = analogRead(sensorpin_41);
  //int dis41 = (1/sensor_value41) * 26874;  // oude calibratie van chris
  int dis41 = 27205.2633 * pow(sensor_value41, -1.0183);
  distance.Frontleft = dis41;

  double sensor_value12 = analogRead(sensorpin_12);
  int dis12 = 38161.1739 * pow(sensor_value12, -0.9298) + 2936752.6632 * pow(sensor_value12,-2.2758995196);
  distance.Frontright = dis12;

  sensor_publisher.publish( &distance );

  nh.spinOnce();
  delay(500);
}

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


Create Maze.ino

Create Maze.ino

Maze code in the Arduino IDE for sensing low and high reflectance, using left line follower method.

#include <QTRSensors.h>
#include <Wire.h>
#include <LiquidCrystal.h>
//#include "LCD.h"
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// This example is designed for use with six QTR-1A sensors or the first six sensors of a
// QTR-8A module.  These reflectance sensors should be connected to analog inputs 0 to 5.
// The QTR-8A's emitter control pin (LEDON) can optionally be connected to digital pin 2,
// or you can leave it disconnected and change the EMITTER_PIN #define below from 2 to
// QTR_NO_EMITTER_PIN.

// The setup phase of this example calibrates the sensor for ten seconds and turns on
// the LED built in to the Arduino on pin 13 while calibration is going on.
// During this phase, you should expose each reflectance sensor to the lightest and
// darkest readings they will encounter.
// For example, if you are making a line follower, you should slide the sensors across the
// line during the calibration phase so that each sensor can get a reading of how dark the
// line is and how light the ground is.  Improper calibration will result in poor readings.
// If you want to skip the calibration phase, you can get the raw sensor readings
// (analog voltage readings from 0 to 1023) by calling qtra.read(sensorValues) instead of
// qtra.readLine(sensorValues).

// The main loop of the example reads the calibrated sensor values and uses them to
// estimate the position of a line.  You can test this by taping a piece of 3/4" black
// electrical tape to a piece of white paper and sliding the sensor across it.  It
// prints the sensor values to the serial monitor as numbers from 0 (maximum reflectance)
// to 1000 (minimum reflectance) followed by the estimated location of the line as a number
// from 0 to 5000.  1000 means the line is directly under sensor 1, 2000 means directly
// under sensor 2, etc.  0 means the line is directly under sensor 0 or was last seen by
// sensor 0 before being lost.  5000 means the line is directly under sensor 5 or was
// last seen by sensor 5 before being lost.

#define NUM_SENSORS             3  // number of sensors used
#define NUM_SAMPLES_PER_SENSOR  4  // average 4 analog samples per sensor reading
#define EMITTER_PIN             2  // emitter is controlled by digital pin 2

// sensors 0 through 5 are connected to analog inputs 0 through 5, respectively
QTRSensorsAnalog qtra((unsigned char[]) {0, 1, 2, 3, 4, 5},
  NUM_SENSORS, NUM_SAMPLES_PER_SENSOR, EMITTER_PIN);
unsigned int sensorValues[NUM_SENSORS];

#define FRONT    sensorValues[1]
#define LEFT     sensorValues[0]
#define RIGHT    sensorValues[2]

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *leftMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
Adafruit_DCMotor *rightMotor = AFMS.getMotor(2);

void setup() {
    Serial.begin(9600);           // set up Serial library at 9600 bps
 // Serial.println("Adafruit Motorshield v2 - DC Motor test!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz

  delay(500);
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);    // turn on Arduino's LED to indicate we are in calibration mode
  // read raw sensor values
  qtra.read(sensorValues);

  // print the sensor values as numbers from 0 to 1023, where 0 means maximum reflectance and
  // 1023 means minimum reflectance
  for (unsigned char i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(sensorValues[i]);
    Serial.print('\t'); // tab to format the raw data into columns in the Serial monitor
  }
  Serial.println();

  delay(250);

  /*for (int i = 0; i < 400; i++)  // make the calibration take about 10 seconds
  {
    qtra.calibrate();       // reads all sensors 10 times at 2.5 ms per six sensors (i.e. ~25 ms per call)
  }*/
  digitalWrite(13, LOW);     // turn off Arduino's LED to indicate we are through with calibration

}

void loop() {
    // read calibrated sensor values and obtain a measure of the line position from 0 to 5000
  // To get raw sensor values, call:
    //qtra.read(sensorValues); //instead of unsigned int position = qtra.readLine(sensorValues);
  unsigned int position = qtra.readLine(sensorValues);

  // print the sensor values as numbers from 0 to 1000, where 0 means maximum reflectance and
  // 1000 means minimum reflectance, followed by the line position
 /*for (unsigned char i = 0; i < NUM_SENSORS; i++)
  {
    Serial.print(sensorValues[i]);
    Serial.print('\t');
  }*/

  uint8_t i;

 // if all three sensors see very low reflectance, take some appropriate action for this
  // situation.
  if (LEFT < 750 && FRONT < 750 && RIGHT < 750)
  {
    rightMotor->run(BRAKE);
    leftMotor->run(BRAKE);
    // do something.  Maybe this means we're at the edge of a course or about to fall off
    // a table, in which case, we might want to stop moving, back up, and turn around.
    return;
  }

  // compute our "error" from the line position.  We will make it so that the error is zero
  // when the middle sensor is over the line, because this is our goal.  Error will range from
  // -1000 to +1000.  If we have sensor 0 on the left and sensor 2 on the right,  a reading of
  // -1000 means that we see the line on the left and a reading of +1000 means we see the
  // line on the right.
  int error = position - 1000;

  int leftMotorSpeed = 100;
  int rightMotorSpeed = 100;
  if (error < -500) { // the line is on the left
    rightMotor->run(FORWARD);
    leftMotor->run(FORWARD);  // turn left
  }
  else  // the line is on the right
    rightMotorSpeed = 0;  // turn right
// set motor speeds using the two motor speed variables above
}

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


cc3000 echo example

cc3000 echo example

/*
 *                SSSSS  kk                            tt
 *               SS      kk  kk yy   yy nn nnn    eee  tt
 *                SSSSS  kkkkk  yy   yy nnn  nn ee   e tttt
 *                    SS kk kk   yyyyyy nn   nn eeeee  tt
 *                SSSSS  kk  kk      yy nn   nn  eeeee  tttt
 *                               yyyyy
 *
 * SkynetClient for http://skynet.im, OPEN COMMUNICATIONS NETWORK & API FOR
 * THE INTERNET OF THINGS.
 *
 * This sketch parses any messages it receives and echos them back to the
 * sender.
 *
 * This sketch requires a port of the Adafruit CC3000 firmare library. Until
 * Adafruit accepts it, delete theirs and grab ours at:
 * https://github.com/jacobrosenthal/Adafruit_CC3000_Library/tree/feature/inherit-client
 *
 * Also requires the ArduinoJsonParser
 * https://github.com/bblanchon/ArduinoJsonParser
 *
 * You will notice we're using F() in Serial.print. It is covered briefly on
 * the arduino print page but it means we can store our strings in program
 * memory instead of in ram.
 *
 * You can turn on debugging within SkynetClient.h by uncommenting
 * #define SKYNETCLIENT_DEBUG but note this takes up a ton of program space
 * which means you'll probably have to debug on a Mega
 */

#include <EEPROM.h>
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <string.h>
#include "utility/debug.h"
#include "SPI.h"
#include "SkynetClient.h"
#include <JsonParser.h>

// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed

#define WLAN_SSID       "myNetwork"           // cannot be longer than 32 characters!
#define WLAN_PASS       "myPassword"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data
                                   // received before closing the connection.  If you know the server
                                   // you're accessing is quick to respond, you can reduce this value.

#define HOSTNAME      "skynet.im"
#define PORT          80

Adafruit_CC3000_Client client = Adafruit_CC3000_Client();

SkynetClient skynetclient(client);

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

  /* Initialise the module */
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
    Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }

  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }

  Serial.println(F("Connected!"));

  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }

  skynetclient.setMessageDelegate(onMessage);

}

void onMessage(const char * const data) {

  JsonParser<16> parser;

  Serial.print("Parse ");
  Serial.println(data);

  JsonHashTable hashTable = parser.parseHashTable((char*)data);

  if (!hashTable.success())
  {
      Serial.println("JsonParser.parseHashTable() failed");
      return;
  }

  char* payload = hashTable.getString("payload");
  Serial.print("payload=");
  Serial.println(payload);

  char* fromUuid = hashTable.getString("fromUuid");
  Serial.print("fromUuid=");
  Serial.println(fromUuid);

  skynetclient.sendMessage(fromUuid, payload);
}

void loop() {
  while(!skynetclient.monitor()){
    bool skynetStatus = false;
    do {
      skynetStatus = skynetclient.connect(HOSTNAME, PORT);
    } while (!skynetStatus);

    Serial.println(F("Connected!"));

    char uuid[UUIDSIZE];

    skynetclient.getUuid(uuid);
    Serial.print(F("uuid: "));
    Serial.println(uuid);

    skynetclient.getToken(uuid);
    Serial.print(F("token: "));
    Serial.println(uuid);
  }
}

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


IR Break Beam Sensor

IR Break Beam Sensor

// 5pin
/* 24l01    85
   1  gnd   4
   2  vcc   8
   3  ce    1
   4  csn   3
   5  sck   7
   6  mosi  6
   7  miso  5
*/

// 3pin
/* 24l01    85
   1  gnd   4
   2  vcc   8
   3  ce    x
   4  csn   x
   5  sck   7
   6  mosi  6
   7  miso  5
*/
#include <LowPower.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/pgmspace.h>
#include <Average.h>
#include <nRF24L01.h>
#include <RF24.h>

#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC
#define adc_enable()  (ADCSRA |=  (1<<ADEN)) // re-enable ADC

//#define _TEST
#define _DIGITAL
#define _3PIN
//#define _5PIN

#ifdef _3PIN
// 3pin
#define CE_PIN 3
#define CSN_PIN 3
#else
// 5pin
#define CE_PIN 5
#define CSN_PIN 4
#endif

#define DEVICE_ID 65
#define CHANNEL 100

const uint64_t pipes[2] = { 0xFFFFFFFFFFLL, 0xCCCCCCCCCCLL };

typedef struct {
  uint32_t _salt;
  uint16_t volt;
  int16_t data1;
  int16_t data2;
  uint8_t devid;
} data;

data payload;

RF24 radio(CE_PIN, CSN_PIN);

#define IRENPIN 4 // p3 / A2
#define DATA1PIN A3 // p2

Average<float> ave(2);

void setup() {
  delay(20);
  adc_disable();
  unsigned long startmilis = millis();

#ifdef _DIGITAL
  pinMode(DATA1PIN, INPUT_PULLUP);
#endif
  pinMode(IRENPIN, OUTPUT);
  digitalWrite(IRENPIN, LOW);

  radio.begin();
  radio.setChannel(CHANNEL);
  radio.setPALevel(RF24_PA_LOW);
  radio.setDataRate(RF24_250KBPS);
  //radio.setAutoAck(1);
  radio.setRetries(15, 15);
  radio.setPayloadSize(11);
  radio.openWritingPipe(pipes[0]);
  radio.stopListening();
  //radio.powerDown();

  unsigned long stopmilis = millis();
  payload.data2 = ( stopmilis - startmilis ) * 10 ;

  payload._salt = 0;
  payload.devid = DEVICE_ID;

}

void loop() {
  unsigned long startmilis = millis();
  payload._salt++;
  digitalWrite(IRENPIN, HIGH);
  payload.volt = readVcc();
#ifdef _DIGITAL
  //delay(3);
  payload.data1  = digitalRead(DATA1PIN) * 10 ;
#else
  //delay(3);
  payload.data1  = readData1() * 10;
#endif
  digitalWrite(IRENPIN, LOW);

  radio.powerUp();
  radio.write(&payload , sizeof(payload));
  radio.powerDown();

  unsigned long stopmilis = millis();

  payload.data2 = ( stopmilis - startmilis ) * 10 ;

  if ((millis() - startmilis) > 1000) {
    sleep();
    return;
  }

  sleep();

}

void sleep() {
#ifdef _TEST
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
#else
  for (int i = 0; i < 7; i++) {
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  }
  LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
#endif
}

int readVcc() {
  adc_enable();
  ADMUX = _BV(MUX3) | _BV(MUX2);

  delay(2);
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA, ADSC)); // measuring

  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
  uint8_t high = ADCH; // unlocks both

  long result = (high << 8) | low;

  //result = 1126400L / result; // Calculate Vcc (in mV);
  result = 1074835L / result;

  //Disable ADC
  adc_disable();

  return (int)result; // Vcc in millivolts
}

int16_t readData1() {

  adc_enable();
  delay(2);
  for (int k = 0; k < 2; k = k + 1) {
    uint16_t value = analogRead(DATA1PIN);
    ave.push(value);
    delay(5);
  }
  return ave.mean();
  adc_disable();
}

error: pathspec '_28-attiny85-nrf24-3pin-ir/_28-attiny85-nrf24-3pin-ir.ino' did not match any file(s) known to git


fix typo

fix typo

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/wsnook/sandbox.git/'


Added initial version of arduino code

Added initial version of arduino code

/**

*/

#include <SPI.h>
#include <MFRC522.h>

//Add the SdFat Libraries
#include <SdFat.h>
#include <SdFatUtil.h>

/*
   For the RFID to work while MP3 plays, you have to change
   #define USE_MP3_REFILL_MEANS USE_MP3_INTx
   to
   #define USE_MP3_REFILL_MEANS USE_MP3_Polled
   in SFEMP3Shield.h
*/
#include <SFEMP3Shield.h>

#define RST_PIN         5           // Configurable, see typical pin layout above
#define SS_PIN          10          // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

MFRC522::MIFARE_Key key;

// Init array that will store new NUID
byte nuidPICC[4];

// Below is not needed if interrupt driven. Safe to remove if not using.
#if defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_Timer1
#include <TimerOne.h>
#elif defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer
#include <SimpleTimer.h>
#endif

SdFat sd;

SFEMP3Shield MP3player;

void setup() {
  Serial.begin(115200);
  while (!Serial);    // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

  //Initialize the SdCard.
  if (!sd.begin(SD_SEL, SPI_FULL_SPEED)) sd.initErrorHalt();
  // depending upon your SdCard environment, SPI_HAVE_SPEED may work better.
  if (!sd.chdir("/")) sd.errorHalt("sd.chdir");

  //Initialize the MP3 Player Shield
  uint8_t result = MP3player.begin();
  //check result, see readme for error codes.
  if (result != 0) {
    Serial.print(F("Error code: "));
    Serial.print(result);
    Serial.println(F(" when trying to start MP3 player"));
    if ( result == 6 ) {
      Serial.println(F("Warning: patch file not found, skipping.")); // can be removed for space, if needed.
      Serial.println(F("Use the \"d\" command to verify SdCard can be read")); // can be removed for space, if needed.
    }
  }

  SPI.begin();        // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card

  for (byte i = 0; i < 6; i++) {
    key.keyByte[i] = 0xFF;
  }

  Serial.print(F("Using rfid key (for A and B):"));
  dump_byte_array(key.keyByte, MFRC522::MF_KEY_SIZE);
  Serial.println();
}

/**
   Main loop.
*/
void loop() {
#if defined(USE_MP3_REFILL_MEANS) \
      && ( (USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer) \
      ||   (USE_MP3_REFILL_MEANS == USE_MP3_Polled)      )

  MP3player.available();
#endif

  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
    return;

  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
    return;

  // Show some details of the PICC (that is: the tag/card)
  Serial.print(F("Card UID:"));
  dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
  Serial.println();
  Serial.print(F("PICC type: "));
  MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
  Serial.println(mfrc522.PICC_GetTypeName(piccType));

  // Check for compatibility
  if ( piccType != MFRC522::PICC_TYPE_MIFARE_1K ) {
    Serial.println(F("Unsupported card."));
    return;
  }

  if (mfrc522.uid.uidByte[0] == nuidPICC[0] &&
      mfrc522.uid.uidByte[1] == nuidPICC[1] &&
      mfrc522.uid.uidByte[2] == nuidPICC[2] &&
      mfrc522.uid.uidByte[3] == nuidPICC[3] ) {
    Serial.println(F("Card already read"));
    return;
  }

  // Store NUID into nuidPICC array
  for (byte i = 0; i < 4; i++) {
    nuidPICC[i] = mfrc522.uid.uidByte[i];
  }

  char folder[17];
  readBlock(1, 0, folder);
  Serial.print(F("Folder on rfid: "));
  Serial.println(folder);
  playFolder(folder);

  delay(100);
}

void readBlock(uint8_t sector, uint8_t relativeBlock, char *outputBuffer) {
  if (relativeBlock > 3) {
    Serial.println(F("Invalid block number"));
    return;
  }

  // Block 4 is trailer block
  byte trailerBlock   = (sector * 4) + 3;
  byte absoluteBlock = (sector * 4) + relativeBlock;
  MFRC522::StatusCode status;

  // Authenticate using key A
  Serial.println(F("Authenticating using key A..."));
  status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, trailerBlock, &key, &(mfrc522.uid));
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("PCD_Authenticate() failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
    return;
  }

  // Read data from the block
  Serial.print(F("Reading data from block "));
  Serial.print(absoluteBlock);
  Serial.println(F(" ..."));
  byte buffer[18];
  byte bufferSize = sizeof(buffer);
  status = (MFRC522::StatusCode) mfrc522.MIFARE_Read(absoluteBlock, buffer, &bufferSize);
  if (status != MFRC522::STATUS_OK) {
    Serial.print(F("MIFARE_Read() failed: "));
    Serial.println(mfrc522.GetStatusCodeName(status));
  }
  Serial.print(F("Data in block ")); Serial.print(absoluteBlock); Serial.println(F(":"));
  dump_byte_array(buffer, 16);
  Serial.println();
  Serial.println();

  // Halt PICC
  mfrc522.PICC_HaltA();
  // Stop encryption on PCD
  mfrc522.PCD_StopCrypto1();

  for (byte i = 0; i < bufferSize; i++) {
    outputBuffer[i] = buffer[i];
  }
  outputBuffer[bufferSize] = '\0';

}

/**
   Helper routine to dump a byte array as hex values to Serial.
*/
void dump_byte_array(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}

void playFolder(char *folder) {
  Serial.println(F("Music Files found:"));
  SdFile file;
  char filename[20];
  sd.chdir(folder, true);
  while (file.openNext(sd.vwd(), O_READ))
  {
    file.getFilename(filename);
    if ( isFnMusic(filename) ) {
      MP3player.stopTrack();
      uint8_t result = MP3player.playMP3(filename);

      //check result, see readme for error codes.
      if (result != 0) {
        Serial.print(F("Error code: "));
        Serial.print(result);
        Serial.println(F(" when trying to play track"));
      } else {

        Serial.println(F("Playing:"));

        char title[30]; // buffer to contain the extract the Title from the current filehandles
        char artist[30]; // buffer to contain the extract the artist name from the current filehandles
        char album[30]; // buffer to contain the extract the album name from the current filehandles

        //we can get track info by using the following functions and arguments
        //the functions will extract the requested information, and put it in the array we pass in
        MP3player.trackTitle((char*)&title);
        MP3player.trackArtist((char*)&artist);
        MP3player.trackAlbum((char*)&album);

        //print out the arrays of track information
        Serial.write((byte*)&title, 30);
        Serial.println();
        Serial.print(F("by:  "));
        Serial.write((byte*)&artist, 30);
        Serial.println();
        Serial.print(F("Album:  "));
        Serial.write((byte*)&album, 30);
        Serial.println();
      }
      file.close();
      return;
    } else {
      Serial.print(F("Not a music file: "));
      Serial.println(filename);
    }
    file.close();
  }

}

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


Init: Arduino Code Eva

Init: Arduino Code Eva

for Agent Eva

/*
   Author: Jorge Rolando Encinas
   Grupo: 10
   Materia: Agentes Inteligentes
*/

#include <SparkFun_TB6612.h>
#include <Ultrasonic.h>
#include <Clamp.h>

// these constants are used to allow you to make your motor configuration
// line up with function names like forward.  Value can be 1 or -1
const int offsetA = 1;
const int offsetB = 1;

// Pins for all inputs, keep in mind the PWM defines must be on PWM pins
#define AIN1 2
#define BIN1 7
#define AIN2 4
#define BIN2 8
#define PWMA 5
#define PWMB 6
#define STBY 9

// Pins for RPM
#define encoderLeft       A0  //    motor left encoder
#define encoderRight      A1  //    motor right encoder

Motor motor1(AIN1, AIN2, PWMA, offsetA, STBY);
Motor motor2(BIN1, BIN2, PWMB, offsetB, STBY);

Ultrasonic ultrasonic(12, 13);

Clamp clamp;
static int serialMsg = 0;
int pinza = 0;

// vars for setup encoders for angles
int previousDigitalLeft = digitalRead(encoderLeft);
int previousDigitalRight = digitalRead(encoderRight);
int digitalLeft;
int digitalRight;
// vars for angle events
int encoderCountLeft = 0;
int encoderCountRight = 0;
int speedLeft = 0;
int speedRight = 0;
int pointsLeft = 0;
int pointsRight = 0;
// end of vars of angles
String report;

void setup() {
  Serial.begin(38400);
  clamp.attach(10);
  motor1.brake();
  motor2.brake();
  Serial.print("$I,OK");
}

void loop() {
  updateEventListener();
  updateAngle();
  updateClamp();
}

void updateAngle(){
  digitalLeft = digitalRead(encoderLeft);
  if (digitalLeft != previousDigitalLeft) {
    encoderCountLeft++;
    previousDigitalLeft = digitalLeft;
    Serial.print("$L,");
    Serial.println(encoderCountLeft);
  }
  digitalRight = digitalRead(encoderRight);
  if (digitalRight != previousDigitalRight) {
    encoderCountRight++;
    previousDigitalRight = digitalRight;
    Serial.print("$R,");
    Serial.println(encoderCountRight);
  }
  if (encoderCountLeft < pointsLeft) //40 es
    motor1.drive(speedLeft);
  else
    motor1.brake();
  if (encoderCountRight < pointsRight) //40 es
    motor2.drive(speedRight);
  else
    motor2.brake();
}

void updateClamp() {
  if (pinza == 0)
    clamp.setValue(100);
  else
    clamp.setValue(0);
  //  clamp.setValue(1*100);
}

void example2() {
  motor1.drive(30, 1000);
  motor1.brake();
  motor1.drive(-30, 1000);
  motor1.brake();
  delay(1000);
}

void updateUltrasonic() {
  Serial.print("$U,");
  Serial.println(ultrasonic.distanceRead());
}

void updateEventListener() {
  if (Serial.available() > 0) {
    delay(4);
    serialMsg = Serial.read(); //$
    if (serialMsg == '$') {
      serialMsg = Serial.read();
      switch (serialMsg) {
        Serial.read();
        case 'A': // Angulos o avances
          encoderCountLeft = 0;
          speedLeft = Serial.parseInt() * 255/100;
          Serial.read(); // ','
          pointsLeft = Serial.parseInt();
          encoderCountRight = 0;
          speedRight = Serial.parseInt() * 255/100;
          Serial.read(); // ','
          pointsRight = Serial.parseInt();
          break;
        case 'P': // Pinza
          pinza = Serial.parseInt();
          break;
        case 'U': // Ultrasonic
          updateUltrasonic();
          break;
        case 'e': // Test
          break;
        default:
          Serial.print("No case found: '");
          Serial.print(char(serialMsg));
          Serial.println("'");
          break;
      }
    }
  } else {
    ;//updateUltrasonic();
  }
}

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


Return to a common shift

Return to a common shift

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


crank the current down a bit - might be better

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


Added required println

Added required println

BitBangingMpu6050/Right Hand Arduino Code.ino

error: pathspec 'BitBangingMpu6050/Right' did not match any file(s) known to git
error: pathspec 'Hand' did not match any file(s) known to git
error: pathspec 'Arduino' did not match any file(s) known to git
error: pathspec 'Code.ino' did not match any file(s) known to git


Fix merge conflicts, update log statements

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/onordbo/mood-cloud.git/'


Initial version

Initial version

Reports moisture level, battery percentage and battery voltage.

#include <SPI.h>
#include <MySensor.h>

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

#define CHILD_ID_MOISTURE 0
#define CHILD_ID_BATTERY 1
#define SENSOR_ANALOG_PIN 0
#define SENSOR_POWER_PIN 8
#define SLEEP_TIME 300000 // Sleep time between reads (in milliseconds)
#define STABILIZATION_TIME 500 // Let the sensor stabilize before reading
#define BATTERY_FULL 3700 // 3,700 millivolts
#define BATTERY_ZERO 1700 // 1,700 millivolts

MySensor gw;
MyMessage msg(CHILD_ID_MOISTURE, V_HUM);
MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);

void setup()
{
  pinMode(SENSOR_POWER_PIN, OUTPUT);
  gw.begin();

  gw.sendSketchInfo("Plant moisture w bat", "1.1");

  gw.present(CHILD_ID_MOISTURE, S_HUM);
  delay(250);
  gw.present(CHILD_ID_BATTERY, S_CUSTOM);
}

void loop()
{
  digitalWrite(SENSOR_POWER_PIN, HIGH); // Power on the sensor
  gw.sleep(STABILIZATION_TIME);
  int moistureLevel = (1023 - analogRead(SENSOR_ANALOG_PIN)) / 10.23;
  digitalWrite(SENSOR_POWER_PIN, LOW);
  gw.send(msg.set(moistureLevel));
  long voltage = readVcc();
  gw.send(voltage_msg.set(voltage / 1000.0, 3)); // redVcc returns millivolts and set wants volts and how many decimals (3 in our case)
  gw.sendBatteryLevel(round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO)));
  gw.sleep(SLEEP_TIME);
}

long readVcc() {
  // From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
  // Read 1.1V reference against AVcc
  // set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
  ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
  ADMUX = _BV(MUX3) | _BV(MUX2);
#else
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif

  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Start conversion
  while (bit_is_set(ADCSRA, ADSC)); // measuring

  uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
  uint8_t high = ADCH; // unlocks both

  long result = (high << 8) | low;

  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}

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


Still working on PID.

Still working on PID.

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


button press auto

button press auto

int inPin = 7;  // the pin number for input (for me a push button)
int onPinA = 8; // Pin for controlling the remote
int offPinA = 9;
int ledPin = 13;

int current;         // Current state of the button
                     // (LOW is pressed b/c i'm using the pullup resistors)
long millis_held;    // How long the button was held (milliseconds)
long secs_held;      // How long the button was held (seconds)
long prev_secs_held; // How long the button was held in the previous check
byte previous = HIGH;
unsigned long firstTime; // how long since the button was first pressed

void setup() {
  Serial.begin(9600);         // Use serial for debugging

  pinMode(ledPin, OUTPUT);
  pinMode(onPinA, OUTPUT);
  pinMode(offPinA, OUTPUT);

  digitalWrite(onPinA, HIGH);  //
  digitalWrite(offPinA, LOW);  // Transistor should be low
  digitalWrite(inPin, HIGH);  //
}

void loop() {
  current = digitalRead(inPin);
  digitalWrite(pinnum, HIGH);
  // if the button state changes to pressed, remember the start time
  if (current == LOW && previous == HIGH && (millis() - firstTime) > 200) {
    firstTime = millis();
  }

  millis_held = (millis() - firstTime);
  secs_held = millis_held / 1000;

  // This if statement is a basic debouncing tool, the button must be pushed for at least
  // 100 milliseconds in a row for it to be considered as a push.
  if (millis_held > 50 && secs_held < 6 ) {

    if (current == LOW && secs_held > prev_secs_held) {
      ledblink(1, 50, ledPin); // Each second the button is held blink the indicator led
    }

    // check if the button was released since we last checked
    if (current == HIGH && previous == LOW) {
      // HERE YOU WOULD ADD VARIOUS ACTIONS AND TIMES FOR YOUR OWN CODE
      // ===============================================================================

      // Button pressed for less than 6 seconds, turn on.
      if (secs_held < 6) {
        Serial.print("Short Press: ");
        Serial.print(secs_held);
        Serial.print("   Milliseconds held: ");
        Serial.println(millis_held);
        //Turn on sockets
        turnSocketsOn();
      }
    }

      // ===============================================================================
  } else if (secs_held >= 6) {
      // Button held for more than 6 seconds, turn off.
      Serial.print("Long Press: ");
      Serial.print(secs_held);
      Serial.print("   Milliseconds held: ");
      Serial.println(millis_held);
      //Turn off sockets
      turnSocketsOff();
  }

  previous = current;
  prev_secs_held = secs_held;
}

// Just a simple helper function to blink an led in various patterns
void ledblink(int times, int lengthms, int pinnum){
  for (int x=0; x<times;x++) {
    digitalWrite(pinnum, LOW);
    delay (lengthms);
    digitalWrite(pinnum, HIGH);
    delay(lengthms);
  }
}

//Function to send a radio signal to turn sockets on
void turnSocketsOn() {
  // For RPi parsing
  Serial.println("status : 1");
  //  delay
  delay(2000);
  Serial.println("Turning sockets on: ");
  //  turn on 3 times
  digitalWrite(onPinA, LOW);
  delay(1000);
  digitalWrite(onPinA, HIGH);
  delay(1000);

  digitalWrite(onPinA, LOW);
  delay(1000);
  digitalWrite(onPinA, HIGH);
  delay(1000);

  digitalWrite(onPinA, LOW);
  delay(1000);
  digitalWrite(onPinA, HIGH);
  Serial.println("Sockets on complete.");
  // Send ON signal to PI
}
//Function to send a radio signal to turn sockets off
void turnSocketsOff() {
  // For RPi parsing
  Serial.println("status : 0");
  Serial.println("Turning sockets off: ");
  // turn off 3 times
  digitalWrite(offPinA, HIGH);
  delay(1000);
  digitalWrite(offPinA, LOW);
  delay(1000);

  digitalWrite(offPinA, HIGH);
  delay(1000);
  digitalWrite(offPinA, LOW);
  delay(1000);

  digitalWrite(offPinA, HIGH);
  delay(1000);
  digitalWrite(offPinA, LOW);

  Serial.println("Sockets off complete. ");
  // Send OFF signal to PI
}

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


Initial commit

Initial commit

/*
Copyright (C) 2012-2013 Chris Osgood <chris at luadev.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.  No
other versions are acceptable.

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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/

///////////////////////////////////////////////////////////////////////////////

// Check for MultiWii
#if defined(MSP_VERSION)
  #define MULTIWII
#else
  #include <EEPROM.h>
#endif

#define AUL_SERIALRATE 19200

#define AUL_MIN_BITTIME 4
#define AUL_MAX_BITTIME 136
#define AUL_DEFAULT_BITTIME 32

#define AUL_MICROS_TO_TICKS(x)  ((x) * (F_CPU / 1000000) / g_timerScale)
#define AUL_MICROS_TO_TICKS_R(x) ((x) * g_timerScale / (F_CPU / 1000000))

#if defined(__AVR_ATmega8__)
#define AUL_SET_TIMER_MODE TCCR2 = g_timerConfig
#else
#define AUL_SET_TIMER_MODE TCCR2B = g_timerConfig
#endif

// Default PD2/INT0
#define AUL_DEFAULT_PIN 18

#define AUL_BUFSIZE 300

#define AUL_SERIALTIMEOUT ((F_CPU >> 7) / (9600 >> 4))

#define AUL_PININPUT  ((*g_signalDDR)  &= ~(g_signalPinPortNum))
#define AUL_PINOUTPUT ((*g_signalDDR)  |=  (g_signalPinPortNum))
#define AUL_PINHIGH   ((*g_signalPORT) |=  (g_signalPinPortNum))
#define AUL_PINLOW    ((*g_signalPORT) &= ~(g_signalPinPortNum))

#define AUL_PINREAD   ((*g_signalPIN) & (g_signalPinPortNum))

#define AUL_DELAYTICKS(x) \
  TCNT2 = 0; \
  while (TCNT2 < (x));

#if defined(__AVR_ATmega8__)
#define AUL_SYNC_PRESCALER \
  SFIOR = (1 << PSR2); \
  while (SFIOR & (1 << PSR2));
#else
#define AUL_SYNC_PRESCALER \
  GTCCR = (1 << PSRASY); \
  while (GTCCR & (1 << PSRASY));
#endif

// Save space on MultWii since baud rate changes are not supported and it is the
// only thing that requires a value greater than uint8
#if defined(MULTIWII)
  #define AUL_ASCII_INT_TYPE uint8_t
#else
  #define AUL_ASCII_INT_TYPE uint32_t
#endif

#define AUL_EEPROM_PIN 4
#define AUL_EEPROM_BITTIME 5
#define AUL_EEPROM_BAUD 6

///////////////////////////////////////////////////////////////////////////////
// Globals
///////////////////////////////////////////////////////////////////////////////

static uint8_t g_timerConfig;
static uint16_t g_timerScale;

// Approximate microseconds for each bit when sending
static uint8_t g_bitTimeSend;
static uint8_t g_bitTimeSendHalf;

// Calculated leader timing for receive
static uint8_t g_bitTime, g_shortBitTime;

static volatile uint8_t* g_signalDDR;
static volatile uint8_t* g_signalPORT;
static volatile uint8_t* g_signalPIN;
static int8_t g_signalPinPortNum, g_signalPinNum;

#if defined(MULTIWII)
static uint32_t g_baudRate = 0;
#else
static uint32_t g_baudRate = AUL_SERIALRATE;
#endif

///////////////////////////////////////////////////////////////////////////////
// stdlib type utility functions (mostly to save space)
///////////////////////////////////////////////////////////////////////////////

// int to ASCII base 10
// Returns the address of the null terminator
static char* AUL_itoa(AUL_ASCII_INT_TYPE n, char *b)
{
   uint8_t i = 0, s;

   do {
      s = n % 10;
      n = n / 10;
      b[i++] = '0' + s;
   } while (n > 0);

   b[i] = '\0';

   strrev(b);

   return &b[i];
}

// ASCII to int base 10
static AUL_ASCII_INT_TYPE AUL_atoi(const char* s)
{
  AUL_ASCII_INT_TYPE b = 0;
  while (*s) b = (b << 3) + (b << 1) + (*s++ - '0');
  return(b);
}

///////////////////////////////////////////////////////////////////////////////
// Serial port.  MultiWii helpers.
///////////////////////////////////////////////////////////////////////////////

#if !defined(MULTIWII)

#define AUL_SerialInit(x) Serial.begin(g_baudRate)
#define AUL_SerialAvailable() Serial.available()
#define AUL_SerialRead() Serial.read()
#define AUL_SerialWrite(x) Serial.write(x)
#define AUL_SerialWriteBuf(x,y) Serial.write(x,y)
#define AUL_SerialWriteStr(x) Serial.write((const char*)x)

#else // MULTIWII

static volatile uint8_t* g_serialUCSRA;
static volatile uint8_t* g_serialUDR;
static uint8_t g_serialRXC, g_serialUDRE;

static void AUL_SerialInit(uint8_t port)
{
  #define AUL_INIT_PORT(x) \
    UCSR##x##C = (1 << UCSZ##x##1) | (1 << UCSZ##x##0); \
    UCSR##x##B = (1 << RXEN##x) | (1 << TXEN##x); \
    g_serialUCSRA = &UCSR##x##A; \
    g_serialUDR = &UDR##x; \
    g_serialRXC = (1 << RXC##x); \
    g_serialUDRE = (1 << UDRE##x);

  switch (port)
  {
  case 0:
    AUL_INIT_PORT(0)
    break;
  #if defined(UBRR1H)
  case 1:
    AUL_INIT_PORT(1)
    break;
  #endif
  #if defined(UBRR2H)
  case 2:
    AUL_INIT_PORT(2)
    break;
  #endif
  #if defined(UBRR3H)
  case 3:
    AUL_INIT_PORT(3)
    break;
  #endif
  #if defined(UBRR4H)
  case 4:
    AUL_INIT_PORT(4)
    break;
  #endif
  default:
    break;
  }
}

#define AUL_SerialAvailable() \
  ((*g_serialUCSRA) & g_serialRXC)

#define AUL_SerialRead() \
  (*g_serialUDR)

#define AUL_SerialWrite(x) \
  { while (!((*g_serialUCSRA) & g_serialUDRE)); (*g_serialUDR) = (x); }

static void AUL_SerialWriteBuf(const uint8_t* b, int16_t len)
{
  int16_t i;
  for (i = 0; i < len; i++)
    AUL_SerialWrite(b[i]);
}

static void AUL_SerialWriteStr(const char* b)
{
  int16_t i;
  for (i = 0; b[i] != '\0'; i++)
    AUL_SerialWrite(b[i]);
}

#endif // MULTIWII

///////////////////////////////////////////////////////////////////////////////
// Signal pin
///////////////////////////////////////////////////////////////////////////////

// Clear all timers and PWM settings
static void DisableAllTimers()
{
  #define AUL_RESET_PORT(x) \
    TCCR##x##B = 0; \
    TCCR##x##A = 0;

  // For mega8 and similar
  #if defined(TCCR0)
    TCCR0 = 0;
  #endif
  #if defined(TCCR1)
    TCCR1 = 0;
  #endif
  #if defined(TCCR2)
    TCCR2 = 0;
  #endif

  #if defined(TCCR0B)
    AUL_RESET_PORT(0)
  #endif
  #if defined(TCCR1B)
    AUL_RESET_PORT(1)
  #endif
  #if defined(TCCR2B)
    AUL_RESET_PORT(2)
  #endif
  #if defined(TCCR3B)
    AUL_RESET_PORT(3)
  #endif
  #if defined(TCCR4B)
    AUL_RESET_PORT(4)
  #endif
  #if defined(TCCR5B)
    AUL_RESET_PORT(5)
  #endif
  #if defined(TCCR6B)
    AUL_RESET_PORT(6)
  #endif
}

static void SignalPinStatus(char* buf)
{
  #define AUL_WRITE_PORT_INFO(x) \
    *pos++ = #x[0]; \
    pos = AUL_itoa(pincnt, pos); \
    *pos++ = ':'; \
    pincnt += 8;

  char* pos = buf;
  int8_t pincnt = 0;

  pos[0] = 'P';
  pos[1] = 'I';
  pos[2] = 'N';
  pos[3] = 'S';
  pos[4] = ':';
  pos += 5;

  #if defined(PORTB)
    AUL_WRITE_PORT_INFO(B)
  #endif
  #if defined(PORTC)
    AUL_WRITE_PORT_INFO(C)
  #endif
  #if defined(PORTD)
    AUL_WRITE_PORT_INFO(D)
  #endif
  #if defined(PORTE)
    AUL_WRITE_PORT_INFO(E)
  #endif
  #if defined(PORTF)
    AUL_WRITE_PORT_INFO(F)
  #endif
  #if defined(PORTG)
    AUL_WRITE_PORT_INFO(G)
  #endif
  #if defined(PORTH)
    AUL_WRITE_PORT_INFO(H)
  #endif
  #if defined(PORTI)
    AUL_WRITE_PORT_INFO(I)
  #endif
  #if defined(PORTJ)
    AUL_WRITE_PORT_INFO(J)
  #endif
  #if defined(PORTK)
    AUL_WRITE_PORT_INFO(K)
  #endif
  #if defined(PORTL)
    AUL_WRITE_PORT_INFO(L)
  #endif

  #if defined(PORTA)
    AUL_WRITE_PORT_INFO(A)
  #endif

  *pos = '\0';
}

static void SignalPinInit(int8_t pin)
{
  #define AUL_SETUP_PORT(x) \
    if (pin < (pincnt += 8)) \
    { \
      g_signalDDR = &DDR##x; \
      g_signalPORT = &PORT##x; \
      g_signalPIN = &PIN##x; \
      g_signalPinPortNum = (1 << (pin - (pincnt - 8))); \
      goto finished; \
    }

  int8_t pincnt = 0;

  g_signalPinNum = pin;

  #if defined(PORTB)
    AUL_SETUP_PORT(B);
  #endif
  #if defined(PORTC)
    AUL_SETUP_PORT(C);
  #endif
  #if defined(PORTD)
    AUL_SETUP_PORT(D);
  #endif
  #if defined(PORTE)
    AUL_SETUP_PORT(E);
  #endif
  #if defined(PORTF)
    AUL_SETUP_PORT(F);
  #endif
  #if defined(PORTG)
    AUL_SETUP_PORT(G);
  #endif
  #if defined(PORTH)
    AUL_SETUP_PORT(H);
  #endif
  #if defined(PORTI)
    AUL_SETUP_PORT(I);
  #endif
  #if defined(PORTJ)
    AUL_SETUP_PORT(J);
  #endif
  #if defined(PORTK)
    AUL_SETUP_PORT(K);
  #endif
  #if defined(PORTL)
    AUL_SETUP_PORT(L);
  #endif

  #if defined(PORTA)
    AUL_SETUP_PORT(A);
  #endif

finished:
  AUL_PINHIGH; // Enable pull-up
  AUL_PININPUT;
}

///////////////////////////////////////////////////////////////////////////////
// SENDING on signal pin
///////////////////////////////////////////////////////////////////////////////

static void SendByte(uint8_t b)
{
  uint8_t i;
  for (i = 1; i; i <<= 1)
  {
    if (b & i)
    {
      AUL_PINHIGH;
      AUL_DELAYTICKS(g_bitTimeSend);
      AUL_PINLOW;
      AUL_DELAYTICKS(g_bitTimeSend);
    }
    else
    {
      AUL_PINHIGH;
      AUL_DELAYTICKS(g_bitTimeSendHalf);
      AUL_PINLOW;
      AUL_DELAYTICKS(g_bitTimeSendHalf);
      AUL_PINHIGH;
      AUL_DELAYTICKS(g_bitTimeSendHalf);
      AUL_PINLOW;
      AUL_DELAYTICKS(g_bitTimeSendHalf);
    }
  }
}

///////////////////////////////////////////////////////////////////////////////
// RECEIVE on signal pin
///////////////////////////////////////////////////////////////////////////////

#define AUL_SPINPINHIGH \
  TCNT2 = 0; \
  while (AUL_PINREAD) { if (TCNT2 > 250) goto timeout; }

#define AUL_SPINPINLOW \
  TCNT2 = 0; \
  while (!AUL_PINREAD) { if (TCNT2 > 250) goto timeout; }

#define AUL_NT_SPINPINHIGH \
  while (AUL_PINREAD) { if (TCNT2 > 250) goto timeout; }

#define AUL_NT_SPINPINLOW \
  while (!AUL_PINREAD) { if (TCNT2 > 250) goto timeout; }

#define AUL_READBIT \
  AUL_SPINPINHIGH \
  AUL_NT_SPINPINLOW \
  if (TCNT2 <= g_shortBitTime) \
  { \
    AUL_SPINPINHIGH \
    AUL_NT_SPINPINLOW \
    b = 0; \
  } \
  else \
    b = 1;

static int8_t ReadLeader()
{
  uint8_t i;

  // Skip the first few to let things stabilize
  for (i = 0; i < 9; i++)
  {
    AUL_SPINPINHIGH
    AUL_NT_SPINPINLOW
  }

#ifndef AUL_FIXED_TIMING
  // Calculate timing from header
  AUL_SPINPINHIGH
  AUL_NT_SPINPINLOW
  g_bitTime = TCNT2;
  g_shortBitTime = (g_bitTime >> 1) + (g_bitTime >> 2);
#else
  // Use fixed timing
  g_bitTime = g_bitTimeSend << 1;
  g_shortBitTime = g_bitTimeSend + g_bitTimeSendHalf;
#endif

  // Read until we get a 0 bit
  while (1)
  {
    uint8_t b;
    AUL_READBIT // Sets b to the bit value

    if (!b)
      return 0;
  }

timeout:
  return -1;
}

static void SetBitTime(uint16_t t)
{
  if (t < AUL_MIN_BITTIME)
    t = AUL_MIN_BITTIME;
  else if (t > AUL_MAX_BITTIME)
    t = AUL_MAX_BITTIME;

  if (t * (F_CPU / 1000000) < 242)
  {
    g_timerScale = 2;
    g_timerConfig = (1 << CS20);
  }
  else if (t * (F_CPU / 1000000) / 8 < 242)
  {
    g_timerScale = 16;
    g_timerConfig = (1 << CS21);
  }
  else if (t * (F_CPU / 1000000) / 32 < 242)
  {
    g_timerScale = 64;
    g_timerConfig = (1 << CS21) | (1 << CS20);
  }
  else
  {
    return; // invalid time, no change
  }

  g_bitTimeSend = AUL_MICROS_TO_TICKS(t);
  g_bitTimeSendHalf = (g_bitTimeSend >> 1);
}

#if !defined(MULTIWII)
static uint32_t EERead32(int pos)
{
  uint32_t value;
  ((char*)&value)[0] = EEPROM.read(pos);
  ((char*)&value)[1] = EEPROM.read(pos + 1);
  ((char*)&value)[2] = EEPROM.read(pos + 2);
  ((char*)&value)[3] = EEPROM.read(pos + 3);
  return value;
}

static void EEWrite32(int pos, uint32_t value)
{
  EEPROM.write(pos, ((char*)&value)[0]);
  EEPROM.write(pos + 1, ((char*)&value)[1]);
  EEPROM.write(pos + 2, ((char*)&value)[2]);
  EEPROM.write(pos + 3, ((char*)&value)[3]);
}
#endif // !MULTIWII

///////////////////////////////////////////////////////////////////////////////
// Main
///////////////////////////////////////////////////////////////////////////////

void AUL_loop(uint8_t port)
{
  // Disable interrupts and timers
  cli();
  DisableAllTimers();

  #if defined(MULTIWII)
    #if defined(BUZZERPIN_OFF)
      BUZZERPIN_OFF;
    #endif
    #if defined(LEDPIN_OFF)
      LEDPIN_OFF;
    #endif
  #endif

  #if defined(MULTIWII)
    AUL_SerialInit(port);
    SetBitTime(AUL_DEFAULT_BITTIME);
    SignalPinInit(AUL_DEFAULT_PIN);
  #else
    if (EEPROM.read(0) != 'a' ||
        EEPROM.read(1) != 'u' ||
        EEPROM.read(2) != 'l')
    {
      EEPROM.write(0, 'a');
      EEPROM.write(1, 'u');
      EEPROM.write(2, 'l');
      EEPROM.write(3, 1); // version
      EEPROM.write(AUL_EEPROM_PIN, AUL_DEFAULT_PIN);
      EEPROM.write(AUL_EEPROM_BITTIME, AUL_DEFAULT_BITTIME);
      EEWrite32(AUL_EEPROM_BAUD, AUL_SERIALRATE);
    }

    SignalPinInit(EEPROM.read(AUL_EEPROM_PIN));
    SetBitTime(EEPROM.read(AUL_EEPROM_BITTIME));

    g_baudRate = EERead32(AUL_EEPROM_BAUD);
    AUL_SerialInit(port);

    sei(); // Re-enable interrupts for Serial
  #endif

  // Set timer2 to count ticks
  AUL_SET_TIMER_MODE;

  // The buffer always has the leader at the start
  uint8_t buf[AUL_BUFSIZE] = { 0xFF, 0xFF, 0x7F };
  uint8_t lastPin = 0;
  int16_t buflen, i;

  while (1)
  {
    if (AUL_SerialAvailable())
    {
      buflen = 3;
      buf[buflen++] = AUL_SerialRead();

      // Temporarily set timer2 to count ticks/128
#if defined(__AVR_ATmega8__)
      TCCR2 = (1 << CS22) | (1 << CS20);
#else
      TCCR2B = (1 << CS22) | (1 << CS20);
#endif
      AUL_SYNC_PRESCALER;
      TCNT2 = 0;
      // Buffer data until the serial timeout
      do {
         if (AUL_SerialAvailable())
         {
           buf[buflen++] = AUL_SerialRead();
           TCNT2 = 0;
         }
      } while (TCNT2 < AUL_SERIALTIMEOUT);

      // Set timer2 back to normal
      AUL_SET_TIMER_MODE;

      if (buf[3] == '$' && buf[4] == 'M' && buf[5] == '<')
      {
#if !defined(MULTIWII)
        int8_t setbaud = 0;
#endif

        buf[buflen] = '\0';

        switch(buf[6])
        {
        case 'B': { // BITTIME
          SetBitTime(AUL_atoi((const char*)&buf[7]));
          break; }
        case 'P': // SELECT PORT
          SignalPinInit(AUL_atoi((const char*)&buf[7]));
          break;
#if !defined(MULTIWII)
        case 'R': // BAUD RATE
          g_baudRate = AUL_atoi((const char*)&buf[7]);

          if (g_baudRate < 9600)
            g_baudRate = 9600;

          setbaud = 1;
          break;
        case 'W': // WRITE EEPROM settings
          EEPROM.write(AUL_EEPROM_PIN, g_signalPinNum);
          EEPROM.write(AUL_EEPROM_BITTIME, AUL_MICROS_TO_TICKS_R(g_bitTimeSend));
          EEWrite32(AUL_EEPROM_BAUD, g_baudRate);
          AUL_SerialWriteStr("saved:");
          break;
#endif // !MULTIWII
        default:
          break;
        }

        // Send status afterwards
        char* pos = (char*)&buf[3];
        *pos++ = 'P';
        pos = AUL_itoa(g_signalPinNum, pos);
        pos[0] = ':';
        pos[1] = 'B';
        pos += 2;
        pos = AUL_itoa(AUL_MICROS_TO_TICKS_R(g_bitTimeSend), pos);
        pos[0] = ':';
        pos[1] = 'R';
        pos += 2;
        pos = AUL_itoa(g_baudRate, pos);
        *pos++ = ':';

        SignalPinStatus(pos);

        AUL_SerialWriteStr((const char*)&buf[3]);
        AUL_SerialWrite('\n');

#if !defined(MULTIWII)
        if (setbaud)
        {
          // Arduino Serial.flush does not work correctly
          Serial.flush();

          // Temporarily set timer2 to count ticks/128
#if defined(__AVR_ATmega8__)
          TCCR2 = (1 << CS22) | (1 << CS20);
#else
          TCCR2B = (1 << CS22) | (1 << CS20);
#endif
          AUL_DELAYTICKS(AUL_SERIALTIMEOUT);
          AUL_DELAYTICKS(AUL_SERIALTIMEOUT);
          AUL_SET_TIMER_MODE;

          AUL_SerialInit(port);
        }
#endif // !MULTIWII
      }
      else
      {
        AUL_PINOUTPUT;
        AUL_SYNC_PRESCALER;

        // Send data over signal pin
        for (i = 0; i < buflen; i++)
          SendByte(buf[i]);

        // Trailer
        AUL_PINHIGH;
        AUL_DELAYTICKS(g_bitTimeSendHalf);

        AUL_PININPUT; // Pull-up is enabled from previous PINHIGH
        lastPin = 1;
      }
    }
    else
    {
      // Here we look for a low to high transition on the signal pin
      uint8_t curPin = AUL_PINREAD;

      if (!lastPin && curPin)
      {
        AUL_SYNC_PRESCALER;

        // Buffer data from signal pin then write to serial port
        if (ReadLeader() == 0)
        {
          uint8_t i, byt, b;
          buflen = 3;

          // Read bytes until timeout
          while (1)
          {
            for (i = 0, byt = 0; i < 8; i++)
            {
              AUL_READBIT // Sets b to the bit value
              byt |= b << i;
            }

            buf[buflen++] = byt;
          }

timeout:
          AUL_SerialWriteBuf(&buf[3], buflen - 3);
        }
      }

      lastPin = curPin;
    }
  }
}

#if !defined(MULTIWII)

int main(int argc, char* argv[])
{
  AUL_loop(0);
  return 0;
}

#endif // !MULTIWII

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


Added Arduino code

Added Arduino code

#include <Adafruit_NeoPixel.h>
#include <string.h>

#define PIN 6
#define NUMPIXELS 28
#define ARRAYSIZE 38
#define MAXWIDTH 4
#define MINWIDTH 1
#define MAXDIST 1000

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);

  int b[ARRAYSIZE];
  int c[ARRAYSIZE];
  int d[ARRAYSIZE];

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

    //lazy array initialization - fix hacked bounds
  for(int i=0; i<ARRAYSIZE; i++) {
    d[i] = c[i] = b[i] = 0;
  }
}

void loop() {
  int angle = 0;
  int distance = 1000;
  int centreled;
  float dist;
  String  inputstring;
  String dist_string;
  String angle_string;
  int refresh=0;

//these for loops are for testing only, they'll be replaced with a Serial.read() when connected to the other thing
//
//for(distance=1000; distance > 50; distance=distance-100){
//  for(angle=0;angle<360;angle=angle+10){
while (Serial.available()){
  inputstring = Serial.readStringUntil('A');
  refresh = 1;
}
    dist_string = inputstring.substring(0,4);
    angle_string = inputstring.substring(4,8);
    angle = angle_string.toInt();
    distance = dist_string.toInt();

if(distance==0){
  distance = 1000;
}
    //lazy array initialization - fix hacked bounds
     for(int i=0; i<ARRAYSIZE; i++) {
    d[i] = c[i] = b[i] = 0;
  }

//  Serial.print("Distance: ");
//  Serial.print(distance);
//  Serial.print(" Angle: ");
//  Serial.print(angle);
//  Serial.print(" Refresh: ");
//  Serial.println(refresh);

  centreled = map(angle,0,360,0,NUMPIXELS);

  delay(40);

  dist = map(distance,0,MAXDIST,MAXWIDTH,MINWIDTH);

    //make the ramp one-sided
    for(int i=0; i<(dist+1); i++) {
      b[i] = 255*float(i/dist);
      if(distance==1000){
        b[i] = 0;
      }
    }

    //make the ramp two sided
    for(int i=0; i<(2*dist)+1; i++) {
      int disti = dist-(i-dist);
      if(i<dist) c[i] = b[i];
      if(i>=dist & i<(2*dist)+1) c[i] = b[disti];
      if(i>=(2*dist)+1) c[i] = 0;
    }

    //centre the ramp around the right pixel and set the pixel colour
    for(int i=0; i<NUMPIXELS; i++) {
      int index = (centreled-i+int(dist)) % (NUMPIXELS);
      pixels.setPixelColor(i,0,c[index],c[index]);
    }

  if(refresh == 1){
          pixels.show(); // This sends the updated pixel color to the hardware.
      refresh = 0;
  }

  }
//}
//}

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


Create main.ino

Create main.ino

/*
 * ZoomMRT-3B_MIDI_USB
 *
 * Created: 13/3/2017
 * Author: HyDz
 * USB Midified ZoomMRT-3B for Traktor
 *
 */

#include "MIDIUSB.h"
#include <inputs.h>
#include <outputs.h>

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

for (int i=2, i<=7, i++){pinMode(i, INPUT);} // Set Inputs

for (int i=22, i<=35, i++){pinMode(i, INPUT);} // Set Inputs

for (int i=36, i<=52, i++){pinMode(i, OUTPUT);} // Set Outputs

}

void loop(){
void getMidiIn();
void setMidiOut();
}

void noteOn(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOn);
}

void noteOff(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOff);
}

void controlChange(byte channel, byte control, byte value) {
  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
  MidiUSB.sendMIDI(event);
}

void getMidiIn(){

}

void setMidiOut(){

}

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


add YunTimestamp example

add YunTimestamp example

//*****************************************************************************
//
// YunTimestamp - This is the simplest example, all it does is read the
//                current time as a unix timestamp from
//                m2.exosite.com/timestamp. This example is useful for
//                debugging connectivity issues.
//
// Copyright (c) 2015 Exosite LLC.  All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:

//  * Redistributions of source code must retain the above copyright notice,
//    this list of conditions and the following disclaimer.
//  * Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//  * Neither the name of Exosite LLC nor the names of its contributors may
//    be used to endorse or promote products derived from this software
//    without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
//*****************************************************************************

#include <EEPROM.h>
#include <SPI.h>
#include <Bridge.h>
#include <Process.h>
#include <YunClient.h>
#include <Exosite.h>

/*==============================================================================
* No Configuration Variables
*=============================================================================*/

unsigned long time;
char macString[18];  // Used to store a formatted version of the MAC Address

class YunClient client;
Exosite exosite(&client);

/*==============================================================================
* setup
*
* Arduino setup function.
*=============================================================================*/
void setup(){
  Bridge.begin();
  Serial.begin(115200);
  Serial.println("Boot");

  getYunMAC(macString, 18);

  // Print Some Useful Info
  Serial.print(F("MAC Address: "));
  Serial.println(macString);

  Serial.print(F("Unique Identifier: "));
  Serial.println(macString);

  Serial.print(F("Exo Arduino Lib Ver: "));
  Serial.println(ACTIVATOR_VERSION);
}

/*==============================================================================
* loop
*
* Arduino loop function.
*=============================================================================*/
void loop(){
  //Write to "uptime" and read from "uptime" and "command" datasources.
  Serial.println("---- Check Time ----");
  if ((time = exosite.time()) != 0){
    Serial.println("OK");
    Serial.print("Got Timestamp: ");
    Serial.println(time);
  }else{
    Serial.println("Error, Couldn't Get Timestamp");
  }

  delay(5000);
}

/*==============================================================================
* getYunMac
*
* Send bash command to Linux side to read WiFi MAC address.
*=============================================================================*/
void getYunMAC(char* MACptr, byte bufSize) {
  Process p;    // Create a process and call it "p"
  p.runShellCommand("/sbin/ifconfig -a | /bin/grep HWaddr |/bin/grep wlan0 | /usr/bin/awk '{print $5}'");

  for(int i = 0; i < (bufSize-1) && p.available() > 0; i++) {
    MACptr[i] = p.read();
    MACptr[i+1] = 0;
  }
}

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


Add starter example

Add starter example

/******************************************************************
Example starting point sketch for ParticleIoT library

This example uses the built-in LED only.
It is provided as a quick start for your own sketches.

http://www.github.com/rlisle/Patriot

Written by Ron Lisle

BSD license, check LICENSE for more information.
All text above must be included in any redistribution.

Changelog:
2017-03-11: Initial creation
******************************************************************/

#include <IoT.h>
IoT *iot;

void setup() {
    iot = IoT::getInstance();
    iot->setControllerName("ParticleIoT");
    iot->setPublishName("RonsRV");         // Set all devices to the same event name
    iot->begin();

    iot->addLight(D7, 'Led');
    // Alexa will repsond to "Alexa, turn lights on" or "Alexa, turn on lights"
    iot->addBehavior('Led', new Behavior('Lights','>',0, 100));
}

void loop() {
    iot->loop();
}

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


One more example

One more example

#include <adel.h>

/** Turn a blinking light on and off with a button
 *
 *  This is a weird version of buttonblink in which the buttons take 1s to take
 *  effect. It's a very easy change to make to the Adel program (just add an
 *  adelay after the button), but very hard for regular Arduino programs.
 */

#define LED_PIN 3
#define BUTTON_PIN 6

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT);
}

/** Wait for a button
 */
adel waitbutton(int pin)
{
   abegin:
   while (1) {
      await (digitalRead(pin) == HIGH);
      adelay (50);
      if (digitalRead(pin) == HIGH) {
         await (digitalRead(pin) == LOW);
         afinish;
      }
   }
   aend;
}

/** Delayed button
 *  Waits for a second after the button is pressed
 */
adel delayedbutton(int pin)
{
  abegin:
  andthen( waitbutton(pin) );
  adelay(1000);
  aend;
}

/** blink
 *
 *  Blink an LED continuously at some interval
 */
adel blink(int pin, int interval)
{
  abegin:
  while (1) {
    digitalWrite(pin, HIGH);
    adelay(interval);
    digitalWrite(pin, LOW);
    adelay(interval);
  }
  aend;
}

adel buttonblink()
{
  abegin:
  andthen( delayedbutton(BUTTON_PIN) );
  auntil(  delayedbutton(BUTTON_PIN), blink(LED_PIN, 300) );
  aend;
}

void loop()
{
  arepeat( buttonblink() );
}

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


added arduino sketch

added arduino sketch

void setup() {
  Serial.begin(9600);
  Serial.println("Ready");
  pinMode(5,OUTPUT); //fw motor 1
  pinMode(6,OUTPUT); //bk motor 1
  pinMode(7,OUTPUT); //fw motor 2
  pinMode(8,OUTPUT); //bk motor 2
  pinMode(9,OUTPUT); //analog motor 1
  pinMode(10,OUTPUT);//analog motor 2
}

void motorAction(int fwm, int bkm,int anm,int motspeed) {
      if (motspeed > 0 ) {
        digitalWrite(fwm,HIGH);
        digitalWrite(bkm,LOW);
      } else if (motspeed < 0) {
        digitalWrite(fwm,LOW);
        digitalWrite(bkm,HIGH);
      } else {
        digitalWrite(fwm,LOW);
        digitalWrite(bkm,LOW);
      }
      analogWrite(anm,abs(motspeed));
}

void loop() {
  int x;
  int y;
  while (Serial.available() >0) {
    int x = Serial.parseInt();
    int y = Serial.parseInt();
    if (Serial.read() == *"q") {
      motorAction(5,6,9,x);
      motorAction(7,8,10,y);
      Serial.print(x);
      Serial.print(" ");
      Serial.println(y);
    }
  }
}

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


V0.6.3 Add audio record to SD example

V0.6.3 Add audio record to SD example

/*
  File: AudioRecordSD.ino
  Purpose:
    Record audio from mic and store to SD
  Original:
    The sample come from MediaTek Lab forum, the contribution of zhyena
      http://labs.mediatek.com/forums/posts/list/135.page
*/
#include "vmmm.h"
#include "LTask.h"
#include <LAudio.h>
//#include "vmio.h"
#include <LSD.h>
#include <LStorage.h>
#define Drv LSD

VMINT res = 0;
void cb(VMINT result) {
  res = result;
}
static boolean record_start(void *userData) {
  VMINT16 filename[32];
  vm_record_start("E", "\\", "1", VM_FORMAT_AMR, filename, cb); // drv_name: "C"- Internal flash, "E"-SD, usd vm_get_removable_driver to get the correct drv_name  //vm_record_start((VMSTR)drv, "\\", "1", VM_FORMAT_AMR, filename, cb);
  return true;
}

static boolean record_stop(void* userData) {
  vm_record_stop();
  return true;
}
void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(115200);
  LAudio.begin();
  LAudio.setVolume(6);
  Drv.begin();
}
boolean record_flag = false;
unsigned long start_time, record_time;
void loop() {
  int button = analogRead(A0);
  Serial.println(button);
  if (record_flag == false)
  {
    if (button >= 500)
    {
      LTask.remoteCall(&record_start, NULL);
      record_flag = true;
      digitalWrite(13, HIGH);
      start_time = millis();
    }
  }
  else
  {
    if (button < 500)
    {
      LTask.remoteCall(&record_stop, NULL);
      record_time = millis();

      if (record_time >= start_time)
        record_time -= start_time;
      else
        record_time = 4294967295 - start_time + record_time;
      delay(1000);
      LAudio.playFile(storageSD, "1.amr"); // storageFlash
      delay(1000 + record_time);
      record_flag = false;
      digitalWrite(13, LOW);
    }
  }
}

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


Adding TrollCircuit Project

Adding TrollCircuit Project

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/guax/arduino-sketchbook.git/'


Matrix Math example EKF w/ known corresp.

#include <MatrixMath.h>
#include <rate.h>

#define N  (5)
/*
 * State = x, y, heading, linear vel, angular vel
 */
float last_mean[N] = {0};
float last_covar[N][N] = {0};

Rate rate(10.0);

void setup() {
  Serial.begin(9600);
  // put your setup code here, to run once:
  for (int i = 0; i < N; i++) {
    last_covar[i][i] = .1;
  }
}

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

  rate.sleep();
}

void ekf_known_correspondences(float* last_mean, float* last_covar, float* ctrl, float* mes, int* cor, float* m) {
  // mu hat
  float temp[N];
  // TODO calc temp from control
  float temp_mean[N];
  Matrix.Add((float*) last_mean, (float*) temp, N, N, (float*) temp_mean);

  // jacobian of motion model G
  float G[N][N] = {0};

  // sigma hat
  float temp_sigma[N][N];
  float temp2[N][N];
  float R[N][N];
  Matrix.Multiply((float*) G, (float*) last_covar, N, N, N, (float*) temp2);
  Matrix.Transpose((float*) G, N, N, (float*) G);
  Matrix.Multiply((float*) temp2, (float*) G, N, N, N, (float*) temp2);
  Matrix.Add((float*) temp2, (float*) R, N, N, (float*) temp_sigma);
}

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


Adds example

Adds example

// Use hardware or software serial. In this instance we use Seria1, which is pin 0 & 1 on
// teensy LC. DO NOT SET AS SERIAL or bad things will happen.
#define Bluetooth Serial1
//#define BT_NOVERBOSE

// Including this file will pull in Bluetooth.
#include "EZBlueSmirfUART.h"

void setup() {
  Serial.begin(9600);
  BT_BondPrivatelyWith("00066673E605", "00066673E631");
}

void loop() {
  BT_Echo();
}

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