Add files via upload

Add files via upload

Coin_Counter_Verison_2 is the second version of the script currently used in the Blue Box AC Controller. (Latest is 11, I think)
It's actually not that far off form the latest version. Most of the revisions were used to figure out that we needed to use a analog Low Pass Filter in order to handle the inrush current EMI when the AC turns on.

#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
volatile int INTcount;
int pin = 2;
int result;
int timer;
unsigned long time1;
unsigned long minCounter;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
void setup()
{
Serial.begin(9600);
 lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight  ();

  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("HI!YourDuino.com");
  delay(1000);

// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Time Left: ");
  lcd.print(timer);
  lcd.print("min");
  lcd.setCursor(0,1);
  lcd.print("1 cent per min");

attachInterrupt(digitalPinToInterrupt(pin), timerControl, FALLING);
pinMode(13, OUTPUT);
}

void timerControl()
{
  INTcount = INTcount + 1;
  timer = timer + 1;

}
void loop() {
  lcd.setCursor(0,0);
  lcd.print("Time Left: ");
  lcd.print(timer);
  lcd.print("min");
  lcd.setCursor(0,1);
  lcd.print("1 cent per min");
  time1 = millis();
  Serial.println(minCounter);
  Serial.println(time1);
  if(timer == 1)
  {
    minCounter = millis() + 60000;
  }

  if(timer != 0 && minCounter <= millis())
  {
    timer = timer - 1;
    minCounter = millis() + 600000;
  }
 /*while(timer > 0)
 {
   digitalWrite(13,HIGH);
   delay(60000);
   timer = timer - 1;
 }

 if(timer < 0)
 {
  digitalWrite(13,LOW);
  delay(60000);
 }*/
}

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


Create Cock_Sketch.ino

Create Cock_Sketch.ino

/*
    Author: Alejandro Palacios (pamanes@gmail.com)
    Creation Date: Jan. 10, 2015
    Purpose:

    This is a clock program that pushes the time
    to Shift Registers in order to light up Nixie Tubes.

	H   H : M   M : S   S  (Nixies)
	|   |   |   |   |   |   (Rusian Driver has 10 output pins, each lighting up a number)
    D   D   D   D   D   D   (Russian Driver K155NA1)
	  \/      \/      \/    (4 pins to each Russian Driver)
	  SF3     SF2     SF1   (each shift register has 8 output pins - 74HC595)

    There are three Shift Registers, each controls two nixie tubes
*/

#include "common.h"
//define shifts pins for seconds
const int sDataPin = 4;
const int sLatchPin = 5;
const int sClockPin = 6;
//define shifts pins for minutes
const int mDataPin = 7;
const int mLatchPin = 8;
const int mClockPin = 9;
//define shifts pins for hours
const int hDataPin = 10;
const int hLatchPin = 11;
constint hClockPin = 12;
//pins for buttons
const int hButtonPin = 3;
const int mButtonPin = 13;
//buttons state
int hButtonState = 0;
int mButtonState = 0;
//flag when button released
qboolean hFlag = qtrue;
qboolean mFlag = qtrue;
//wat a sec each cycle
const int interval = 1000;
//keep track o ftime
unsigned long previousMillis = 0;
//this is to handle when millis resets
const unsigned long MAX = 4294967295;
//byte pushed out to shift registers
byte sLed = 0;
byte mLed = 0;
byte hLed = 0;

//clock variables, init at 12:00:00
int h = 12;
int m = 0;
int s = 0;

//define pins direction
void setup()
{
	//BUTTONS
	pinMode(hButtonPin, INPUT);
	pinMode(mButtonPin, INPUT);

	//SHIFTS
	pinMode(sLatchPin, OUTPUT);
	pinMode(sDataPin, OUTPUT);
	pinMode(sClockPin, OUTPUT);

	pinMode(mLatchPin, OUTPUT);
	pinMode(mDataPin, OUTPUT);
	pinMode(mClockPin, OUTPUT);

	pinMode(hLatchPin, OUTPUT);
	pinMode(hDataPin, OUTPUT);
	pinMode(hClockPin, OUTPUT);
}

//add either hour, minute or second
//and call ShowClock to refresh nixies
void clock(qboolean hAdd, qboolean mAdd, qboolean sAdd)
{
	if(hAdd == qtrue)
		h = h + 1;
	if(mAdd == qtrue)
		m = m + 1;
	if(sAdd == qtrue)
		s = s + 1;

	if(s>59){m = m + 1;s = 0;}
	if(m>59){h = h + 1;m = 0;}
	if(h>12){h = 1;m = 0;s = 0;}

	ShowClock();
}

//display to nixies
void ShowClock()
{
	//each shift register controls two nixies
	//split the value into two , then shift bits
	//of first digit and sum then update shifts
	sLed = (s % 10) + ((s / 10) << 4);
	mLed = (m % 10) + ((m / 10) << 4);
	hLed = (h % 10) + ((h / 10) << 4);

    UpdateShiftRegister();
}

void loop()
{
    // Get snapshot of time
    unsigned long currentMillis = millis();

    hButtonState = digitalRead(hButtonPin);//pin 3
    mButtonState = digitalRead(mButtonPin);//pin 13
    //flag for only processing one time when pressed
    if(!hFlag && hButtonState == LOW)
        hFlag = qtrue;
    if(!mFlag && mButtonState == LOW)
        mFlag = qtrue;
	//Note: They will be high and low randomly if not connected!

	//if hour button was pushed add hour
    if (hButtonState == HIGH && hFlag)
    {
        //add hour
        hFlag = qfalse;
        clock(qtrue, qfalse, qfalse);
    }
    //if minute button was pushed
    if (mButtonState == HIGH && mFlag)
    {
        //add minute
        mFlag = qfalse;
        clock(qfalse, qtrue, qfalse);
    }

    //handle reset to 0 when max unsigned long is reached (after 49 days)
    if(((unsigned long)(currentMillis - previousMillis) >= interval) ||
	((currentMillis < previousMillis) && ((unsigned long)(MAX - (previousMillis-1) + currentMillis) >= interval)))
    {
        // It's time to do something!
        clock(qfalse, qfalse, qtrue);
        previousMillis = currentMillis;
    }
}
//shift out
void UpdateShiftRegister()
{
    digitalWrite(sLatchPin, LOW);
    shiftOut(sDataPin, sClockPin, LSBFIRST, sLed);
    digitalWrite(sLatchPin, HIGH);

    digitalWrite(mLatchPin, LOW);
    shiftOut(mDataPin, mClockPin, LSBFIRST, mLed);
    digitalWrite(mLatchPin, HIGH);

    digitalWrite(hLatchPin, LOW);
    shiftOut(hDataPin, hClockPin, LSBFIRST, hLed);
    digitalWrite(hLatchPin, HIGH);
}

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


Added constantly updating test for sensors

/*
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_TRV20_PROTO
// 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.
 * - TMP112     read() once.
 * - 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;

/*
 * TMP112 instance
 */
OTV0P2BASE::RoomTemperatureC16_TMP112 TemperatureC16;

/*
 * SHT21 instance XXX Disabled
 */
//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.

    // 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();
// SHT21 not present by default.
//    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.
}

//========================================
// 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();

    delay(1000);
        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();
// SHT21 not present by default.
//    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();
}

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

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


Cleanup

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


Add arduino sketch

Add arduino sketch

// oc_sample_5.ino
// 両側に取り付けた赤外線測距センサーに反応して行動する二輪ロボットのプログラム

int pwm_a = 3;   //PWM control for motor outputs 1 and 2 is on digital pin 3
int pwm_b = 11;  //PWM control for motor outputs 3 and 4 is on digital pin 11
int dir_a = 12;  //direction control for motor outputs 1 and 2 is on digital pin 12
int dir_b = 13;  //direction control for motor outputs 3 and 4 is on digital pin 13

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

  pinMode(pwm_a, OUTPUT);  //Set control pins to be outputs
  pinMode(pwm_b, OUTPUT);
  pinMode(dir_a, OUTPUT);
  pinMode(dir_b, OUTPUT);

}

void loop()
{
  ///*
  char c = 0;
  if (Serial.available()) {
    c = Serial.read();
  }
  // シリアルからのデータ受信
  if( c == '0' ){
    stopped();
  }
  else if( c == '5' ){
    goForward(255);
  }
  else if( c == '2' ){
    goBackward(255);
  }
  else if( c == '6' ){
    turnRight(128);
  }
  else if( c == '7' ){
    turnLeft(128);
  }
  //*/
  //goForward(255);
  //Serial.println(aa);

  // 100ミリ秒停止
  delay(100);
}

// 引数で指定したpinに接続された赤外線測距センサーの距離値を取得する関数
// cm単位の距離を整数値で返す。範囲外（10cm未満、又は80cmより大きい）の場合は0を返す。
int getRange(int pin) {

// 引数で指定されたpinの電圧値を0から1023の値で取得する
  int voltage = analogRead(pin);

  // 取得した電圧値を距離（cm）に変換
  int range = ((6787 / (voltage - 3)) - 4);

  if( range >= 10 && range <= 80 ){
    return range;
  }
  else {
    return 0;
  }
}

void goForward(int speed) // forward
{
  digitalWrite(dir_a, HIGH);  //Reverse motor direction, 1 high, 2 low
  digitalWrite(dir_b, HIGH);  //Reverse motor direction, 3 low, 4 high
  analogWrite(pwm_a, speed);    //set both motors to run at (100/255 = 39)% duty cycle
  analogWrite(pwm_b, speed);
}

void goBackward(int speed) // backward
{
  digitalWrite(dir_a, LOW);  //Set motor direction, 1 low, 2 high
  digitalWrite(dir_b, LOW);  //Set motor direction, 3 high, 4 low
  analogWrite(pwm_a, speed);   //set both motors to run at 100% duty cycle (fast)
  analogWrite(pwm_b, speed);
}

void stopped() //stop
{
  digitalWrite(dir_a, LOW); //Set motor direction, 1 low, 2 high
  digitalWrite(dir_b, LOW); //Set motor direction, 3 high, 4 low
  analogWrite(pwm_a, 0);    //set both motors to run at 100% duty cycle (fast)
  analogWrite(pwm_b, 0);
}

void turnLeft(int speed)  // turn left
{
  digitalWrite(dir_a, HIGH);  //Reverse motor direction, 1 high, 2 low
  digitalWrite(dir_b, LOW);  //Reverse motor direction, 3 low, 4 high
  analogWrite(pwm_a, speed);    //set both motors to run at (100/255 = 39)% duty cycle
  analogWrite(pwm_b, speed);
}

void turnRight(int speed)  // turn right
{
  digitalWrite(dir_a, LOW);  //Reverse motor direction, 1 high, 2 low
  digitalWrite(dir_b, HIGH);  //Reverse motor direction, 3 low, 4 high
  analogWrite(pwm_a, speed);    //set both motors to run at (100/255 = 39)% duty cycle
  analogWrite(pwm_b, speed);
}

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


Triangles and curtains, annnnd two.. two brothers

#include "pixelmap/pixelmap.h"
#include <FastLED.h>
#include <Logging.h>

// Weird thing I had to do to get the Logging library working with teensy
extern "C"{
  int _getpid(){ return -1;}
  int _kill(int pid, int sig){ return -1; }
  int _write(){return -1;}
}

#define LOGLEVEL LOG_LEVEL_INFOS

using namespace pixelmap;

Input* input;

LEDStrip strip1 = LEDStrip(150);
LEDStrip strip2 = LEDStrip(150);
LEDStrip strip3 = LEDStrip(150);
LEDStrip strip4 = LEDStrip(150);
LEDStrip strip5 = LEDStrip(57);

LEDs leds1 = LEDs(&strip1, 0, 150);
LEDs leds2 = LEDs(&strip2, 0, 150);
LEDs leds3 = LEDs(&strip3, 0, 150);
LEDs leds4 = LEDs(&strip4, 0, 150);
LEDs leds5 = LEDs(&strip5, 0, 57);

Visualization* viz;
CurtainAnimation* anim1;
CurtainAnimation* anim2;
CurtainAnimation* anim3;
CurtainAnimation* anim4;
TriangleAnimation* anim5;

void setup() {
  Log.Init(LOGLEVEL, 9600);
  delay(1000);
  Log.Info("Starting setup()\n");
  Serial.flush();
  delay(1000);

  //input = new WaveInput();
  input = new MSGEQ7Input(
    1,    // left pin
    0,    // right pin
    12,   // strobe pin
    13,   // reset pin,
    1000, // max amplitude
    250   // min amplutide
  );

  viz = new RippleVisualization(input, 75, 1);

  anim1 = new CurtainAnimation(viz, leds1);
  anim2 = new CurtainAnimation(viz, leds2);
  anim3 = new CurtainAnimation(viz, leds3);
  anim4 = new CurtainAnimation(viz, leds4);
  anim5 = new TriangleAnimation(viz, leds5);

  // Far right curtain
  anim1->init(
     25,    // height in pixels
     6,     // width in pixels
     1.0,   // height in ratio of visualiation
     0.25,  // width in ratio of visualiation
     0.0,   // rotation in radians
     0.45,  // x distance from visualization start in ratio of visualization
    -0.7,   // y "
     0.0);  // z "

  // Middle right curtain
  anim2->init(
     25,    // height in pixels
     6,     // width in pixels
     1.0,   // height in ratio of visualiation
     0.25,  // width in ratio of visualiation
     0.0,   // rotation in radians
     0.13,   // x distance from visualization start in ratio of visualization
    -0.5,   // y "
     0.0);  // z "

  // Middle left curtain
  anim3->init(
     25,    // height in pixels
     6,     // width in pixels
     1.0,   // height in ratio of visualiation
     0.25,  // width in ratio of visualiation
     0.0,   // rotation in radians
    -0.38,  // x distance from visualization start in ratio of visualization
    -0.5,   // y "
     0.0);  // z "

  // Far left curtain
  anim4->init(
     25,    // height in pixels
     6,     // width in pixels
     1.0,   // height in ratio of visualiation
     0.25,  // width in ratio of visualiation
     0.0,   // rotation in radians
    -0.7,   // x distance from visualization start in ratio of visualization
    -0.7,   // y "
     0.0);  // z "

  anim5->init(1.0);

  FastLED.addLeds<WS2811, 6, RGB>(strip1.leds, 150);
  FastLED.addLeds<WS2811, 7, RGB>(strip2.leds, 150);
  FastLED.addLeds<WS2811, 8, RGB>(strip3.leds, 150);
  FastLED.addLeds<WS2811, 9, RGB>(strip4.leds, 150);
  FastLED.addLeds<WS2811, 10, GRB>(strip5.leds, 57);

  Looper* looper = Looper::instance();
  looper->addInput(input);
  looper->addVisualization(viz);
  looper->addAnimation(anim1);
  looper->addAnimation(anim2);
  looper->addAnimation(anim3);
  looper->addAnimation(anim4);
  looper->addAnimation(anim5);

  Log.Info("Finished setup()\n");
  delay(100);
}

void loop() {
  Looper::instance()->loop();
}

error: pathspec 'examples/cymatic-curtains-with-triangles/cymatic-curtains-with-triangles.ino' did not match any file(s) known to git


add akene_index

add akene_index

/*
  Sigfox index sender (network and board test)

  Note         :
  With card(s) : 1. Olimexino-328 (Arduino IDE set on "Duemilanove" with ATMega328)
                 https://www.olimex.com/Products/Duino/AVR/OLIMEXINO-328/
                 2. Akene V1 (Sigfox UNB modem TD1208)
                 http://snootlab.com/lang-en/snootlab-shields/889-akene-v1-en.html
  License      : MIT

*/

/* library */
// Arduino core
#include <SoftwareSerial.h>
// AVR low-power library (see https://github.com/rocketscream/Low-Power)
#include "LowPower.h"

// some const
#define TEST_LED     13

// some types
union payload_t
{
  struct
  {
    uint32_t index;
  };
  uint8_t byte[12];
};

// some prototypes
void sig_send_index(uint32_t index);
uint32_t bswap_32 (uint32_t x);
uint16_t bswap_16(uint16_t x);

// some vars
// Akene UNB modem : S_RX is D5, S_TX is D4
SoftwareSerial modem(4,5); //uC Rx D4, Tx D5
uint32_t tick_8s = 0;
uint32_t index = 0;
bool debug_mode = 0;

// link stdout (printf) to Serial object
// create a FILE structure to reference our UART
static FILE console_out = {0};
// create a FILE structure to reference our UNB modem
static FILE modem_out = {0};

// create serial outputs functions
// This works because Serial.write, although of
// type virtual, already exists.
static int console_putchar (char c, FILE *stream)
{
  Serial.write(c);
  return 0;
}

static int modem_putchar (char c, FILE *stream)
{
  modem.write(c);
  return 0;
}

void setup()
{
  // IO setup
  pinMode(TEST_LED, OUTPUT);
  // test led on
  digitalWrite(TEST_LED, HIGH);
  // open serial communications, link Serial to stdio lib
  Serial.begin(9600);
  // set the data rate for the SoftwareSerial port
  modem.begin(9600);
  //modem.setTimeout(5000);
  // fill in the UART file descriptor with pointer to writer
  fdev_setup_stream(&console_out, console_putchar, NULL, _FDEV_SETUP_WRITE);
  fdev_setup_stream(&modem_out,   modem_putchar,   NULL, _FDEV_SETUP_WRITE);
  // standard output device STDOUT is console
  stdout = &console_out;
  // fill in the UART file descriptor with pointer to writer
  fdev_setup_stream(&console_out, console_putchar, NULL, _FDEV_SETUP_WRITE);
  fdev_setup_stream(&modem_out,   modem_putchar,   NULL, _FDEV_SETUP_WRITE);
  // standard output device STDOUT is console
  stdout = &console_out;
  // UNB modem boot time
  fprintf_P(&console_out, PSTR("system startup\r\n"));
  fprintf_P(&console_out, PSTR("wait 3s for UNB modem boot time...\r\n"));
  delay(3000);
  // test led off
  digitalWrite(TEST_LED, LOW);
  // set reroute (console <-> UNB modem) ?
  fprintf_P(&console_out, PSTR("PRESS \"r\" key to reroute to UNB modem\r\n"));
  fprintf_P(&console_out, PSTR("PRESS \"d\" key to set debug mode\r\n"));
  fprintf_P(&console_out, PSTR("wait 4s...\r\n"));
  uint8_t k_loop = 0;
  char key;
  while (k_loop++ < 4)
  {
    delay(1000);
    key = Serial.read();
    if (key != -1) break;
  }
  // check user choice : debug
  if (key == 'd')
  {
    debug_mode = 1;
    fprintf_P(&console_out, PSTR("debug mode on\r\n"));
  }
  // check user choice : reroute
  else if (key == 'r')
  {
    // debug mode : reroute console to UNB modem
    fprintf_P(&console_out, PSTR("reroute to UNB modem (reset board to exit this mode)\r\n"));
    while (1)
    {
      // read from port 0, send to port 1:
      while (Serial.available())
        modem.write(Serial.read());
      // read from port 1, send to port 0:
      while (modem.available())
        Serial.write(modem.read());
    }
  } else {
    // startup message
    fprintf_P(&console_out, PSTR("system ready\r\n"));
  }
}

void loop() {
  // vars
  char inChar = ' ';
  // update tick
  tick_8s++;
  // send Sigfox frame
  // send index: every 15 mins
  if (tick_8s % 112 == 0)
    sig_send_index(index++);
  // debug mode
  if (debug_mode) {
    fprintf_P(&console_out, PSTR("tick_8s=%d\r\n"), tick_8s);
    // arduino printf don't include "%f" for printf
    Serial.print("Index: ");
    Serial.println(index);
  }
  // ensure outgoing serial data is complete before sleep
  Serial.flush();
  modem.flush();
  // enter power down state for 8 s with ADC and BOD module disabled
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

void sig_send_index(uint32_t index) {
  payload_t frame;
  char buffer[30];
  // init var
  memset(&frame, 0, sizeof(frame));
  // set frame field
  frame.index = index;
  // format hex string (ex : 0101fe5ec8990000...)
  strcpy_P(buffer, PSTR(""));
  uint8_t i = 0;
  char digits[3];
  do
  {
    sprintf(digits, "%02x", frame.byte[i]);
    strcat(buffer, digits);
  } while(++i < sizeof(frame));
  // send command
  fprintf_P(&modem_out, PSTR("AT$SS=%s\r"), buffer);
  // debug message
  if (debug_mode) {
    fprintf_P(&console_out, PSTR("send \"AT$SS=%s\"\r\n"), buffer);
  }
}

// *** swap byte order function for 32 and 16 bits ***
uint32_t bswap_32(uint32_t x)
{
  unsigned char c[4], temp;

  memcpy (c, &x, 4);
  temp = c[0];
  c[0] = c[3];
  c[3] = temp;
  temp = c[1];
  c[1] = c[2];
  c[2] = temp;
  memcpy (&x, c, 4);
  return (x);
}

uint16_t bswap_16(uint16_t x)
{
  return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8));
}

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


Updated XivelyClient example

Updated XivelyClient example

/*
  Xively sensor client with Strings

 This sketch connects an analog sensor to Xively,
 using an Arduino Yún.

 created 15 March 2010
 updated 27 May 2013
 by Tom Igoe

 */

// include all Libraries needed:
#include <Process.h>
#include "passwords.h"      // contains my passwords, see below

/*
  NOTE: passwords.h is not included with this repo because it contains my passwords.
 You need to create it for your own version of this application.  To do so, make
 a new tab in Arduino, call it passwords.h, and include the following variables and constants:

 #define APIKEY        "foo"                  // replace your pachube api key here
 #define FEEDID        0000                   // replace your feed ID
 #define USERAGENT     "my-project"           // user agent is the project name
 */

// set up net client info:
const unsigned long postingInterval = 60000;  //delay between updates to xively.com
unsigned long lastRequest = 0;      // when you last made a request
String dataString = "";

void setup() {
  // start serial port:
  Bridge.begin();
  Console.begin();

  while(!Console);    // wait for Network Console to open
  Console.println("Xively client");

  // Do a first update immediatly
  updateData();
  sendData();
  lastRequest = millis();
}

void loop() {
  // get a timestamp so you can calculate reading and sending intervals:
  long now = millis();

  // if the sending interval has passed since your
  // last connection, then connect again and send data:
  if (now - lastRequest >= postingInterval) {
    updateData();
    sendData();
    lastRequest = now;
  }
}

void updateData() {
  // convert the readings to a String to send it:
  dataString = "Temperature,";
  dataString += random(10) + 20;
  // add pressure:
  dataString += "\nPressure,";
  dataString += random(5) + 100;
}

// this method makes a HTTP connection to the server:
void sendData() {
  // form the string for the API header parameter:
  String apiString = "X-ApiKey: ";
  apiString += APIKEY;

  // form the string for the URL parameter:
  String url = "https://api.xively.com/v2/feeds/";
  url += FEEDID;
  url += ".csv";

  // Send the HTTP PUT request

  // Is better to declare the Process here, so when the
  // sendData function finishes the resources are immediatly
  // released. Declaring it global works too, BTW.
  Process xively;
  Console.print("\n\nSending data... ");
  xively.begin("curl");
  xively.addParameter("-k");
  xively.addParameter("--request");
  xively.addParameter("PUT");
  xively.addParameter("--data");
  xively.addParameter(dataString);
  xively.addParameter("--header");
  xively.addParameter(apiString);
  xively.addParameter(url);
  xively.run();
  Console.println("done!");

  // If there's incoming data from the net connection,
  // send it out the Console:
  while (xively.available()>0) {
    char c = xively.read();
    Console.write(c);
  }

}

/*
  Xively sensor client with Strings

 This sketch connects an analog sensor to Xively,
 using an Arduino Yun.

 created  15 March 2010
 updated 27 May 2013
 by Tom Igoe

 NOT CURRENTLY WORKING as of Arduino 1.5.3 27 May 2013

 */

// include all Libraries needed:
#include <Process.h>
#include "passwords.h"      // contains my passwords, see below

/*
  NOTE: passwords.h is not included with this repo because it contains my passwords.
 You need to create it for your own version of this application.  To do so, make
 a new tab in Arduino, call it passwords.h, and include the following variables and constants:

 #define APIKEY        "foo"                  // replace your pachube api key here
 #define FEEDID        0000                   // replace your feed ID
 #define USERAGENT     "my-project"           // user agent is the project name
  */

// set up net client info:
boolean lastConnected = false;      // state of the connection last time through the main loop
const unsigned long postingInterval = 60000;  //delay between updates to Pachube.com
unsigned long lastRequest = 0;      // when you last made a request
String dataString = "";
Process xively;

void setup() {
  // start serial port:
  Serial.begin(9600);
  Bridge.begin();
  delay(2000);

  while(!Serial);    // wait for Serial Monitor to open
  Serial.println("Xively client");

  // reserve space for dataString:
  dataString.reserve(100);
  sendData();
}

void loop() {
  // get a timestamp so you can calculate reading and sending intervals:
  long now = millis();

  // convert the readings to a String to send it:
  dataString = "temp,";
  dataString += random(10) + 20;
  // add pressure:
  dataString += "\nPressure,";
  dataString += random(5) + 100;

  // if there's incoming data from the net connection,
  // send it out the serial port:
  if (xively.available()>0) {
    char c = xively.read();
    Serial.write(c);
  }

  // if you're not connected, and the sending interval has passed since
  // your last connection, then connect again and send data:
  if(now - lastRequest >= postingInterval) {
    sendData();
    lastRequest = now;
  }
}

// this method makes a HTTP connection to the server:
void sendData() {
  Serial.println("Sending data");
  dataString = "--data \'" + dataString;
  dataString += "\'";

  // form the string for the API header parameter:
  String apiString =  "--header \"X-ApiKey: ";
  apiString += APIKEY;
  apiString += "\"";

  // form the string for the URL parameter:
  String url =  " \"https://api.xively.com/v2/feeds/";
  url += FEEDID;
  url += ".csv\"";

  // send the HTTP PUT request:
  xively.begin("curl");
  xively.addParameter("-k");
  xively.addParameter("--request PUT");
  xively.addParameter(dataString);
  xively.addParameter(apiString);
  xively.addParameter(url);
  xively.run();
}


add autobaud_bitlash.ino

add autobaud_bitlash.ino

// auto serial baudrate discover
//
// target : Arduino Mega (ATMega2560)
// note   : - use timer1 for 0.5 uS accuracy time measure
//            (arduino core micros() is just 4us accuracy).
//          - signal to detect must be wire on pin 2.
//          - use bitlash for console manager (see https://github.com/billroy/bitlash)
//          - use Timer for schedule tasks (see  https://github.com/JChristensen/Timer)

// library
#include "bitlash.h"
#include "Timer.h"

// const
// pin 2 = interrupt 1 on UNO board
const byte SERIAL_IN_PIN = 2;
const byte SERIAL_IN_INT = 0;

// vars
word times_buffer[60];
byte level;
volatile word isr_times_buffer[60];
byte isr_index_buffer;
word start_bit;
word max_step, min_step;
byte max_index, min_index;
unsigned long baud;
Timer t;

// ISR call when edges rising/falling occurs on SERIAL_IN_PIN
void isr_serial_change() {
  // vars
  word time;
  // check timer1 overflow flag
  if (TIFR1 & 0x01) {
    // reset overflow flag and timer
    TIFR1 = TIFR1 | 0x01;
    // on overflow time is 0xFFFF
    time  = 0xFFFF;
  } else {
    // save time between two edges, reset timer
    time  = TCNT1;
  }
  // reset timer
  TCNT1 =  0;
  // update slots array
  if (isr_index_buffer > 59)
    isr_index_buffer = 0;
  isr_times_buffer[isr_index_buffer++] = time;
}

void update_time_buffer(void) {
  // copy ISR buffer to times array (avoid long ISRs stop)
  cli();
  for (byte i = 0; i < 60; i++) {
    times_buffer[i] = isr_times_buffer[i];
  }
  sei();

  // search minimal/maximal time step
  max_step = 0;
  min_step = 0xFFFF;
  start_bit = 0;
  level = 0;

  for (byte i = 0; i < 60; i++) {
    // skip special values
    if ((times_buffer[i] != 0) and (times_buffer[i] != 0xFFFF))  {
      // search max step
      if (times_buffer[i] > max_step) {
        max_step = times_buffer[i];
        max_index = i;
      }
      // search min step
      if (times_buffer[i] < min_step) {
        min_step = times_buffer[i];
        min_index = i;
      }
    }
    if (times_buffer[i] != 0)
      level++;
  }

  // compute baudrate
  baud = 2 * (1e6 / min_step);

  // count start bit
  for (byte i = 0; i < 60; i++) {
    // count start bit
    if (times_buffer[i] > (min_step * 15)) {
      start_bit++;
    }
  }
}

numvar printRAW(void) {
  // display array
  /*
  for (byte i = 0; i < 60; i++) {
    Serial.print(times_buffer[i]);
    Serial.print(" ");
  }
  Serial.println();*/

  // display min_step time and compute baudrate
  printf_P(PSTR("start bit : %5d\r\n"), start_bit);
  printf_P(PSTR("min step  : %5d us\r\n"), min_step/2);
  printf_P(PSTR("max step  : %5d us\r\n"), max_step/2);
  printf_P(PSTR("level     : %5d\r\n"), level);

  return 0;
}

bool is_baud(long theoric, long measure) {
  return (measure > (theoric - theoric * 0.1)) and (measure < (theoric + theoric *0.1));
}

numvar printBaud(void) {
  printf_P(PSTR("baud measured  : %6lu bps\r\n"), baud);
  // convert measured baud to estimated baud
  long estim_baud = 0;

  if (is_baud(300, baud))
    estim_baud = 300;
  else if (is_baud(600, baud))
    estim_baud = 600;
  else if (is_baud(1200, baud))
    estim_baud = 1200;
  else if (is_baud(2400, baud))
    estim_baud = 2400;
  else if (is_baud(4800, baud))
    estim_baud = 4800;
  else if (is_baud(9600, baud))
    estim_baud = 9600;
  else if (is_baud(14400, baud))
    estim_baud = 14400;
  else if (is_baud(19200, baud))
    estim_baud = 19200;
  else if (is_baud(28800, baud))
    estim_baud = 28800;
  else if (is_baud(38400, baud))
    estim_baud = 38400;
  else if (is_baud(57600, baud))
    estim_baud = 57600;
  else if (is_baud(115200, baud))
    estim_baud = 115200;

  printf_P(PSTR("baud estimated : %6lu bps\r\n"), estim_baud);
  return 0;
}

// link stdout (printf) to Serial object
// create a FILE structure to reference our UART and LCD output function
static FILE uartout = {0};

// create a output function
// This works because Serial.write, although of
// type virtual, already exists.
static int uart_putchar (char c, FILE *stream)
{
  Serial.write(c);
  return 0;
}

void setup(void) {
  // vars init
  isr_index_buffer = 0;
  // timer1 init
  // disable global interrupts
  cli();
  TCCR1A = 0;
  // set timer runs at clock speed/8 (= 2 MHz -> 0.5us/step)
  TCCR1B = (1 << CS11);
  // enable global interrupts
  sei();
  // init bitlash
  initBitlash(57600);
  // add bitlash function
  addBitlashFunction("raw", (bitlash_function) printRAW);
  addBitlashFunction("bd", (bitlash_function) printBaud);
  // fill in the UART file descriptor with pointer to writer
  fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
  // standard output device STDOUT is uart
  stdout = &uartout ;
  // launch timer task
  int updateJob = t.every(500, update_time_buffer);
  // IO init
  pinMode(SERIAL_IN_PIN, INPUT);
  attachInterrupt(SERIAL_IN_INT, isr_serial_change, CHANGE);
}

void loop(void) {
  // bitlash job
  runBitlash();
  // timer job
  t.update();
}

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


add Arduino sketch

add Arduino sketch

#include <Servo.h>

const int NMB = 5;
Servo servos[NMB];
//Servo myclaw;
//Servo myelbow;
//Servo mywrist;
// create servo object to control a servo
// a maximum of eight servo objects can be created

const int INC = 5; // angle increment in degrees
const int CONSTRAINTS[NMB][2] = { {20, 120}, {30, 180}, {0, 180}, {0, 180}, {0, 180} };
const int PINS[NMB] = {3, 5, 6, 9 ,10};
//const int CLAW[]  = {20, 120};
//const int ELBOW[] = {30, 180};
//const int WRIST[] = {0,  180};

void printState()
{
  for (int i=0; i < NMB; ++i) {
    Serial.print(servos[i].read());
    if (i != NMB-1) Serial.print(',');
  }

  //Serial.print(myclaw.read());  Serial.print(',');
  //Serial.print(mywrist.read()); Serial.print(',');
  //Serial.print(myelbow.read());
  Serial.println();
}

void allHome()
{
  // set servos to mid-point
  for (int i=0; i < NMB; ++i) {
    servos[i].writeMicroseconds(1500);
  }
  //myclaw.writeMicroseconds(1500);
  //mywrist.writeMicroseconds(1500);
  //myelbow.writeMicroseconds(1500);
}

void moveServo(int ac_ServoIdx, int ac_Inc)
{
  if (ac_ServoIdx < 0 || ac_ServoIdx >= NMB)
    return;
  //int pos = servos[ac_ServoIdx].read();
  int pos = constrain( /*pos +*/ ac_Inc, CONSTRAINTS[ac_ServoIdx][0], CONSTRAINTS[ac_ServoIdx][1] );
  servos[ac_ServoIdx].write(pos);
  delay(15);
}

void setup()
{
  //open serial
  Serial.begin(9600);
  for (int i=0; i < NMB; ++i) {
    servos[i].attach(PINS[i]);
  }
  //myclaw.attach(3);  // attaches the servo on pin 3 to the servo object
  //mywrist.attach(5);  // attaches the servo on pin 6 to the servo object
  //myelbow.attach(6);  // attaches the servo on pin 6 to the servo object

  allHome();
}

void loop()
{

  // if there's any serial available, read it:
  while (Serial.available() > 0) {
    int values[NMB];
    // look for the next valid integer in the incoming serial stream:
    for (int i = 0; i < NMB; ++i) {
      values[i] = Serial.parseInt();
    }

    // look for the newline. That's the end of your
    // sentence:
    if (Serial.read() == '\n') {

      Serial.print('<');
      for (int i = 0; i < NMB; ++i) {
        Serial.print(values[i]);
        if (i != NMB-1) Serial.print(',');

        moveServo(i, values[i]);
      }
      Serial.println('>');

      printState();
    }
  }

//    if (Serial.available() > 0) {
//     int inByte = Serial.read();
//     switch (inByte) {
//      case 'A':
//        moveServo(myclaw, INC, CLAW);
//        break;
//      case 'a':
//        moveServo(myclaw, -INC, CLAW);
//        break;
//      case 'S':
//        moveServo(mywrist, INC, WRIST);
//        break;
//      case 's':
//        moveServo(mywrist, -INC, WRIST);
//        break;
//      case 'D':
//        moveServo(myelbow, INC, ELBOW);
//        break;
//      case 'd':
//        moveServo(myelbow, -INC, ELBOW);
//        break;
//
//      default:
//        allHome();
//
//      }
}

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


Create brakeLights_with_button.ino

Create brakeLights_with_button.ino

//***************************************************************
// Brake lights triggerd by a button example.
//
// Open the serial monitor to see some feedback as the button is
// pressed, held, and released.
//
// This is the hardware debounced button wiring setup I use:
// http://i.imgur.com/hOgQwjX.jpg
// It does not include the capacitor typically included in a
// debounce setup, but this has always worked fine for me.
//
// Marc Miller, July 2017
//***************************************************************

//---------------------------------------------------------------
// This sketch uses JChristensen's Button Library from:
//   https://github.com/JChristensen/Button
//
#include "Button.h"    // Include the Button library

// Set the digital pin for the debounced pushbutton, and declare the button
const uint8_t brakeButtonPin = 4;
Button brakeButton(brakeButtonPin, true, true, 50);

//---------------------------------------------------------------
#include "FastLED.h"
#define DATA_PIN    11
#define CLK_PIN   13
#define LED_TYPE    LPD8806
#define COLOR_ORDER GRB
#define NUM_LEDS    8
CRGB leds[NUM_LEDS];
#define BRIGHTNESS 255

uint8_t BrakeStatus = 0;  // Status of brake lights.  [0=Off, 1=Activated, 2=On]

CHSV black (0,0,0);  // black
CHSV brakeRed (0,255,255);  // red full brightness
CHSV brakeDimRed (0,255,32);  // dim red
CHSV accent (185,120,70);  // alternate accent color

// setup pixel groups
byte center[] = {3,4};  // center ring
byte first[] = {2,3,4,5};  // first ring
byte second[] = {1,2,5,6};  // second ring
byte third[] = {0,1,6,7};  // third ring

//---------------------------------------------------------------
void setup() {
  Serial.begin(115200);  // Allows serial monitor output (check baud rate)
  delay(1500); // short delay for recovery
  //FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
}

//---------------------------------------------------------------
void loop()
{
  readbutton();  // check the button

  if (BrakeStatus == 0) { brakeOff(); }
  if (BrakeStatus == 1) { brakeActivated(); }
  if (BrakeStatus == 2) { brakeOn(); }
  FastLED.show();

}//end_main_loop

//---------------------------------------------------------------
// Functions

//---------------------------------------------------------------
//Check the button and set the appropriate flag
void readbutton() {
  brakeButton.read();  // check the state of the brake button

  if(brakeButton.isPressed()) {
    BrakeStatus = 2;
    EVERY_N_MILLISECONDS(250){
      Serial.print(BrakeStatus); Serial.println("  Brake is On...");
    }
  } else {
    BrakeStatus = 0;
    EVERY_N_MILLISECONDS(500){
      Serial.print(BrakeStatus); Serial.println("  Brake Off");
    }
  }

  if(brakeButton.wasPressed()) {
    BrakeStatus = 1;
    Serial.print(BrakeStatus); Serial.println("  Running brake activated sequence.");
  }

}//end_readbutton

//---------------------------------------------------------------
// Brake lights activated sequence
void brakeActivated(){

  for (uint8_t i=0; i<(sizeof(third)/sizeof((third)[0])); i++) {
   leds[third[i]] = black;
  }
  for (uint8_t i=0; i<(sizeof(center)/sizeof((center)[0])); i++) {
   leds[center[i]] = brakeRed;
  }
  FastLED.show();
  delay(200);

  for (uint8_t i=0; i<(sizeof(first)/sizeof((first)[0])); i++) {
    leds[first[i]] = brakeRed;
  }
  FastLED.show();
  delay(200);

  for (uint8_t i=0; i<(sizeof(first)/sizeof((first)[0])); i++) {
   leds[first[i]] = accent;
  }
  for (uint8_t i=0; i<(sizeof(second)/sizeof((second)[0])); i++) {
    leds[second[i]] = brakeRed;
  }
  FastLED.show();
  delay(200);

  for (uint8_t i=0; i<(sizeof(first)/sizeof((first)[0])); i++) {
   leds[first[i]] = black;
  }
  for (uint8_t i=0; i<(sizeof(second)/sizeof((second)[0])); i++) {
    leds[second[i]] = accent;
  }
  for (uint8_t i=0; i<(sizeof(third)/sizeof((third)[0])); i++) {
    leds[third[i]] = brakeRed;
  }
  FastLED.show();
  delay(200);

}//end_brakeLightsOn

//---------------------------------------------------------------
// Brake lights On
void brakeOn(){
  fill_solid(leds,NUM_LEDS,CRGB::Black);
  for (uint8_t i=0; i<(sizeof(third)/sizeof((third)[0])); i++) {
    leds[third[i]] = brakeRed;
  }
}

//---------------------------------------------------------------
// Brake lights Off
void brakeOff(){
  fill_solid(leds,NUM_LEDS,CRGB::Black);
  for (uint8_t i=0; i<(sizeof(third)/sizeof((third)[0])); i++) {
    leds[third[i]] = brakeDimRed;  // use dim red
  }
}

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


Create blink.ino

Create blink.ino

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

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}

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


Initial commit

Initial commit

/*************************************************************

CIRCADIAN CLOCK project by Anais Moisy

Arduino Yun
Stepper motor
Motor shield
NeoPixel Ring

Demo & Details @
https://player.vimeo.com/video/127464892
http://anaismoisy.com/essay-cardican-clock/

*************************************************************/

int delaylegnth_speed = 50;  //speed to go to the correct 'time' when it is launched
unsigned long delay_day1 = 5;  //I guess I will need only one delay and change it dynamicaly (see email to get how it is calculated)
unsigned long delay_day2 = 5;
unsigned long delay_night = 5;
int i=0;
int steps_day1 = 206; //tricks to get a full 360 degree (I don't know why it is not doing it in 200 steps)
int steps_night = 406;
int steps_day2 = 606;
int steps_current_time = 53; //number of steps to go to the correct 'time' when it is launched (see email to get how it is calculated)
unsigned long start_time;

//for the LEDs
#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#define NEOPIN 6  // define pins
#define BRIGHTNESS 64 // set max brightness
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, NEOPIN, NEO_GRB + NEO_KHZ800); // strip object

void setup() {

  //establish motor direction toggle pins
  pinMode(12, OUTPUT); //CH A -- HIGH = forwards and LOW = backwards???
  pinMode(13, OUTPUT); //CH B -- HIGH = forwards and LOW = backwards???

  //establish motor brake pins
  pinMode(9, OUTPUT); //brake (disable) CH A
  pinMode(8, OUTPUT); //brake (disable) CH B

  Serial.begin(9600);
  start_time = millis();

  Serial.println("Setup complete");

  //setup LEDs
  Wire.begin();        	// Begin I2C
  pinMode(NEOPIN, OUTPUT);
  strip.begin();
  strip.setBrightness(BRIGHTNESS); // set brightness
  delay(500);
  colorWipe(strip.Color(0, 0, 0), 1); // Red
  delay(500);

}

void loop(){

  //make needle turn fast to the right time
  while(i < steps_current_time){

    step1(delaylegnth_speed);
    step2(delaylegnth_speed);
    step3(delaylegnth_speed);
    step4(delaylegnth_speed);
  }

  Serial.println("Time was initialized");
  Serial.println("I is: " + String(i));

  start_time = millis();
  Serial.println("HEEEERREEE startime: ");
  Serial.println(String(start_time));
  Serial.println(String(millis()));

  //set the new step limit for day 1
  steps_current_time = steps_day1;

  //make needle turn right speed until sunset day1
  while(i < steps_day1){

      step1(1);
      waitTime(delay_day1);

      step2(1);
      waitTime(delay_day1);

      step3(1);
      waitTime(delay_day1);

      step4(1);
      waitTime(delay_day1);
  }

  Serial.println("I is: " + String(i));
  Serial.println("Day 1 is over!");
  steps_current_time = steps_night;

  if (i==steps_day1){
  delay(5);
  colorWipe(strip.Color(255, 255, 255), 1); // Red
  delay(5);
  }

  //make needle turn right speed until sunrise day2
  while(i < steps_night){

      step1(1);
      waitTime(delay_night);

      step2(1);
      waitTime(delay_night);

      step3(1);
      waitTime(delay_night);

      step4(1);
      waitTime(delay_night);
  }

  if (i==steps_night){
  delay(5);
  colorWipe(strip.Color(0, 0, 0), 1); // Red
  delay(5);
  }

  //set the new step limit for day 2
  Serial.println("I is: " + String(i));
  Serial.println("Night 1 is over!");
  steps_current_time = steps_day2;

  //make needle turn right speed until sunset day2
  while(i < steps_day2){

      step1(1);
      waitTime(delay_day2);

      step2(1);
      waitTime(delay_day2);

      step3(1);
      waitTime(delay_day2);

      step4(1);
      waitTime(delay_day2);
  }

  Serial.println("I is: " + String(i));
  Serial.println("Day 2 is over!");

}

//delay between steps for day1
boolean waitTime(unsigned long time)
{

  Serial.println("time day one is being called:");
  Serial.println(start_time);
  Serial.println("Starttime + delay_day_1 is:");
  Serial.println(start_time + delay_day1);
  while ((start_time + time) > millis())
  {
    delay(5);
  }

  Serial.println("Setting new Starttime to now:");
  Serial.println(millis());
    start_time = millis();
    return true;
}

void step1(int delayMilliseconds)
{
 if (i < steps_current_time)
    {
    digitalWrite(9, LOW);  //ENABLE CH A
    digitalWrite(8, HIGH); //DISABLE CH B

    digitalWrite(12, HIGH);   //Sets direction of CH A
    analogWrite(3, 255);   //Moves CH A
    Serial.println("step 1");
    Serial.println("delay is: " + String(delayMilliseconds));
    delay(delayMilliseconds);
    i++;
    }
}

void step2(int delayMilliseconds)
{
  if (i < steps_current_time)
    {
    digitalWrite(9, HIGH);  //DISABLE CH A
    digitalWrite(8, LOW); //ENABLE CH B

    digitalWrite(13, LOW);   //Sets direction of CH B
    analogWrite(11, 255);   //Moves CH B
    Serial.println("step 2");
    Serial.println("delay is: " + String(delayMilliseconds));
    delay(delayMilliseconds);
    i++;
    }
}

void step3(int delayMilliseconds)
{
  if (i < steps_current_time)
    {
    digitalWrite(9, LOW);  //ENABLE CH A
    digitalWrite(8, HIGH); //DISABLE CH B

    digitalWrite(12, LOW);   //Sets direction of CH A
    analogWrite(3, 255);   //Moves CH A
    Serial.println("step 3");
    Serial.println("delay is: " + String(delayMilliseconds));
    delay(delayMilliseconds);
    i++;
    }
}

void step4(int delayMilliseconds)
{
  if (i < steps_current_time)
    {
    digitalWrite(9, HIGH);  //DISABLE CH A
    digitalWrite(8, LOW); //ENABLE CH B

    digitalWrite(13, HIGH);   //Sets direction of CH B
    analogWrite(11, 255);   //Moves CH B
    Serial.println("step 4");
    Serial.println("delay is: " + String(delayMilliseconds));
    delay(delayMilliseconds);
    i++;
    }
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
	strip.setPixelColor(i, c);
	strip.show();
	delay(wait);
  }
}

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


changed line to arrow

changed line to arrow

error: pathspec 'Microcontroller' did not match any file(s) known to git
error: pathspec 'Code/libraries/my_lib/examples/base_uno_w_lib/base_uno_w_lib.ino' did not match any file(s) known to git


adding arduino sketch code

adding arduino sketch code

#include <Adafruit_NeoPixel.h>

// Download library from https://github.com/adafruit/Adafruit_NeoPixel

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

int mode = 0;
int delayTime = 10;

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  Serial.begin(14400);
}

void loop() {
  // Some example procedures showing how to display to the pixels:

  if(Serial.available()){
     if(Serial.peek() == 'm'){
       Serial.read();
       mode = Serial.parseInt();
     }else if(Serial.peek() == 'v'){
       Serial.read();
       delayTime = Serial.parseInt();
     }

     while(Serial.available() > 0)
       Serial.read();
  }

  Serial.println(mode);

  switch( mode ){
    case 1:
      colorWipe(strip.Color(255, 0, 0), delayTime); // Red
      break;
    case 2:
      colorWipe(strip.Color(0, 255, 0), delayTime); // Green
      break;
    case 3:
      colorWipe(strip.Color(0, 0, 255), delayTime); // Blue
      break;
    case 4:
      theaterChase(strip.Color(127, 127, 127), delayTime); // White
      break;
    case 5:
      theaterChase(strip.Color(127,   0,   0), delayTime); // Red
      break;
    case 6:
      theaterChase(strip.Color(  0,   0, 127), delayTime); // Blue
      break;
    case 7:
      rainbow(20);
      break;
    case 8:
      rainbowCycle(20);
      break;
    case 9:
     theaterChaseRainbow( delayTime );
      break;

  }

  /*
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 255, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  // Send a theater pixel chase in...
  theaterChase(strip.Color(127, 127, 127), 50); // White
  theaterChase(strip.Color(127,   0,   0), 50); // Red
  theaterChase(strip.Color(  0,   0, 127), 50); // Blue

  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
  */
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

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

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

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
        }
        strip.show();

        delay(wait);

        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, 0);        //turn every third pixel off
        }
    }
  }
}

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

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


Initial Commit

Initial Commit

// Define all the relay ports
#define relayLight 31
#define relayExtractorMotor 32
#define relayFilter 33
#define relayHeater 34

void setup() {
  // Initialze relay pins
  pinMode(relayLight, OUTPUT);
  pinMode(relayExtractorMotor, OUTPUT);
  pinMode(relayFilter, OUTPUT);
  pinMode(relayHeater, OUTPUT);

}

void loop() {

  // Test Code for relay

  for(int iCounter=31;iCounter < 39;iCounter++){

    digitalWrite(iCounter, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500);              // wait for a second
    digitalWrite(iCounter, LOW);    // turn the LED off by making the voltage LOW
    delay(400);             // wait for a second
  }

}

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


first version of arduino file

first version of arduino file

#include <DStepper.h>

const int stepPer = 200;

DStepper stepper1(stepPer, 4, 5, 6, 7);
DStepper stepper2(stepPer, 8, 9, 10, 11);

int begin;
char ins[2];
int i;
void goAhead(){

  for(i = 0; i < 50; i++){
        stepper1.step(4);
	stepper2.step(4);
  }

	Serial.println("Go ahead");
}

void goBack(){

	stepper1.step(-stepPer);
	stepper2.step(-stepPer);
	Serial.println("Go Back");
}

void turnLeft(){

	stepper1.step(-stepPer);
	stepper2.step(stepPer);
	Serial.println("Turn Left");

}

void turnRight(){

	stepper1.step(stepPer);
	stepper2.step(-stepPer);
	Serial.println("Turn Right");
}

void stepControl(char inst){

	switch(inst){
		// go ahead
		case '1': goAhead();
			break;
		// go back
		case '2': goBack();
			break;
		// turn left
		case '3': turnLeft();
			break;
		// turn right
		case '4': turnRight();
			break;
		default:
			Serial.println("Error");
	}
}

void other(char inst){

}

void setup(){
	stepper1.setSpeed(60);
	stepper2.setSpeed(60);

	Serial.begin(9600);
}

void loop(){

	if(Serial.available()){

		Serial.println("loop step1");

		begin = Serial.read();

		Serial.println("loop step2");
                Serial.println(begin);
		if(begin==35){

		Serial.println("loop step3");
	 		Serial.readBytes(ins, 2);
			switch(ins[0]){
				case '1':
					Serial.println("switch step1");
					stepControl(ins[1]);
					break;
				case '2':
					Serial.println("switch step2");
					other(ins[1]);
					break;
				default:
					break;
			}

                        Serial.println("end of if #");
			begin = 0;
		}

                Serial.println("end of available");

	}
}

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


Bug fix

Bug fix

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/MichalMares/Ardularm.git/'


A7 with Deepsleep

A7 with Deepsleep

Added Deepsleep of 10minutes, checks temp’s from sensors against saved
sensor value in EEPROM, if different then start moden and send data,
else sleep for 10minutes again

error: pathspec 'Prototypes/A7' did not match any file(s) known to git
error: pathspec 'Test/A7_Test_Sleep/A7_Test_Sleep.ino' did not match any file(s) known to git


Update ds3231.ino

Update ds3231.ino

Forced RTC to adjust time

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


Added motor functionality

Added motor functionality

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


Latch the differential flag if it becomes set.

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


Added anchor_configurator sketch

Added anchor_configurator sketch

#include <Pozyx.h>
#include <Pozyx_definitions.h>
#include <Wire.h>
#include <stdlib.h>

// change this if you want to perform remote configuration
uint16_t remote_id = NULL;

#define MAX_DEVICES                20
uint8_t devlist_size = 0;
uint16_t device_ids[MAX_DEVICES];

void setup() {
  Serial.begin(115200);
  while(!Serial); // for the Arduino Leonardo/Micro only

  Pozyx.begin();

  Serial.println("\n\nAnchor configurator started.");
  Serial.println("------------------------------------");

  if(remote_id == NULL) {
    Serial.print(F("Configuring the local pozyx device with network id: 0x"));
    uint16_t netid = 0;
    Pozyx.getNetworkId(&netid);
    Serial.println(netid, HEX);
  }else{
    uint8_t whoami=0;
    Pozyx.getWhoAmI(&whoami, remote_id);
    if(whoami == 0x43){
      Serial.print(F("Configuring the remote pozyx device with network id: 0x"));
      Serial.println(remote_id, HEX);
    }else{
      Serial.print(F("Cannot connect to the remote device with network id 0x"));
      Serial.println(remote_id, HEX);
      delay(50);
      abort();
    }
  }

  printLocalizationOptions(remote_id);
  printMain(remote_id);
}

#define STATE_MAIN                0
#define STATE_ADD_HEX             1
#define STATE_ADD_X               2
#define STATE_ADD_Y               3
#define STATE_ADD_Z               4
#define STATE_REMOVE_ID           5
#define STATE_OPTION_ALGORITHM      6
#define STATE_OPTION_DIM            7
#define STATE_OPTION_NUM_ANCHORS    8
#define STATE_OPTION_ANCHOR_SEL     9
#define STATE_MANUAL_IDS          10

String input;
int state = STATE_MAIN;
int dev_Selected;
device_coordinates_t new_device;
int algorithm = -1;
int numAnchors;
int selected_anchor_num = 0;
uint16_t anchor_sel[15];

void loop() {

  if (Serial.available() > 0) {    // is a character available?
    char rx_byte = Serial.read();       // get the character

    if(rx_byte != '\r' && rx_byte != '\n')
      input += rx_byte;

    if(rx_byte == '\r') {

      if(state == STATE_MAIN)
      {
        if(input == "add")
        {
          Serial.println("\tAdding new anchor:");
          Serial.print("\tplease give network id (hex): ");
          state = STATE_ADD_HEX;
        }
        else if(input == "remove")
        {
          Serial.print("\tGive network id of device to remove (hex): ");
          state = STATE_REMOVE_ID;
        }
        else if(input == "remove all")
        {
          Pozyx.clearDevices(remote_id);
          Pozyx.saveConfiguration(POZYX_FLASH_NETWORK, NULL, 0, remote_id);
          printMain(remote_id);
        }
        else if(input == "localization options")
        {
          Serial.println("\tselect positioning algoirthm [LS, UWB_only, default] ");
          state = STATE_OPTION_ALGORITHM;
        }else{
          Serial.println("\tUnknown command.");
        }
      }else if(state == STATE_ADD_HEX)
      {
        char input_hex[sizeof(input)];
        input.toCharArray(input_hex, sizeof(input));
        long network_id = strtol(input_hex, NULL, 16);
        if(network_id >0 && network_id <= 0xFFFF)
        {
          new_device.network_id = (uint16_t)network_id;
          Serial.print("0x");
          Serial.println(network_id, HEX);
          Serial.print("\tSet anchor x-coordinate(mm): ");
          state = STATE_ADD_X;
        }else{
          Serial.print(F("\n\tNot a valid network id, try again: "));
        }
      }else if(state == STATE_ADD_X)
      {
        int x_mm = input.toInt();
        if(x_mm >=-100000 && x_mm < 100000)
        {
          new_device.pos.x = x_mm;
          Serial.println(x_mm);
          Serial.print(F("\tSet anchor y-coordinate(mm): "));
          state = STATE_ADD_Y;
        }else{
          Serial.print(F("\n\tNot a valid x-coordinate, try again: "));
        }
      }else if(state == STATE_ADD_Y)
      {
        int y_mm = input.toInt();
        if(y_mm >=-100000 && y_mm < 100000)
        {
          new_device.pos.y = y_mm;
          Serial.println(y_mm);
          Serial.print(F("\tSet anchor z-coordinate(mm): "));
          state = STATE_ADD_Z;
        }else{
          Serial.print(F("\n\tNot a valid y-coordinate, try again: "));
        }
      }else if(state == STATE_ADD_Z)
      {
        int z_mm = input.toInt();
        if(z_mm >=-100000 && z_mm < 100000)
        {
          new_device.pos.z = z_mm;
          Serial.println(z_mm);

          new_device.flag = 0x1;
          int result = Pozyx.addDevice(new_device, remote_id);
          Pozyx.saveConfiguration(POZYX_FLASH_NETWORK, NULL, 0, remote_id);
          if(result == POZYX_SUCCESS)
          {
            Serial.println(F("\tAnchor successfully added."));
          }else{
            Serial.println(F("\tFailed to add anchor."));
          }
          state = STATE_MAIN;
          printMain(remote_id);
        }else{
          Serial.print(F("\n\tNot a valid x-coordinate, try again: "));
        }
      }else if(state == STATE_REMOVE_ID)
      {
        char input_hex[sizeof(input)];
        input.toCharArray(input_hex, sizeof(input));
        long network_id = strtol(input_hex, NULL, 16);
        if(network_id >0 && network_id <= 0xFFFF)
        {
          Serial.print("0x");
          Serial.println(network_id, HEX);
          // remove anchor
          remove_anchor(network_id, remote_id);
          Pozyx.saveConfiguration(POZYX_FLASH_NETWORK, NULL, 0, remote_id);
          Serial.println("\tAnchor removed");

          state = STATE_MAIN;
          printMain(remote_id);

        }else{
          Serial.println(F("\n\tNot a valid network id, try again:"));
        }
      } else if(state == STATE_OPTION_ALGORITHM)
      {
        algorithm = -1;

        if(input == "LS") {
          algorithm = POZYX_POS_ALG_LS;
        }else if(input == "UWB_only" || input == "default") {
          algorithm = POZYX_POS_ALG_UWB_ONLY ;
        }else{
          Serial.println("\tInvalid input");
        }

        if(algorithm != -1)
        {
          Serial.println(F("\tSelect the localization dimension [2D, 2.5D, 3D]"));
          state = STATE_OPTION_DIM;
        }
      }else if(state == STATE_OPTION_DIM)
      {
        int dim = -1;
        if(input == "2D")
        {
          dim = 2;
        }else if(input == "2.5D"){
          dim = 1;
        }else if(input == "3D"){
          dim = 3;
        }else{
          Serial.println("\tInvalid input");
        }

        if(dim != -1)
        {
          Pozyx.setPositionAlgorithm(algorithm,dim, remote_id);
          Serial.println(F("\tChoose the number of anchors to use [3-15]"));
          state = STATE_OPTION_NUM_ANCHORS;
        }
      }else if(state == STATE_OPTION_NUM_ANCHORS)
      {
        numAnchors = input.toInt();
        if(numAnchors >= 3 && numAnchors <= 15 )
        {
          Serial.println(F("\tSelect the anchor selection method [manual, automatic]"));
          state = STATE_OPTION_ANCHOR_SEL;
        }else{
          Serial.println(F("\tInvalid input"));
        }
      }else if(state == STATE_OPTION_ANCHOR_SEL)
      {
        if(input == "manual")
        {
          Pozyx.setSelectionOfAnchors(POZYX_ANCHOR_SEL_MANUAL, numAnchors, remote_id );
          uint8_t regs[2] = {POZYX_POS_ALG, POZYX_POS_NUM_ANCHORS};
          Pozyx.saveConfiguration(POZYX_FLASH_REGS, regs, 2, remote_id);
          state = STATE_MANUAL_IDS;
          Serial.print(F("\tenter network id of anchor 1 (hex): "));
          selected_anchor_num = 1;
        }else if(input == "automatic")
        {
          Pozyx.setSelectionOfAnchors(POZYX_ANCHOR_SEL_AUTO , numAnchors, remote_id );
          uint8_t regs[2] = {POZYX_POS_ALG, POZYX_POS_NUM_ANCHORS};
          Pozyx.saveConfiguration(POZYX_FLASH_REGS, regs, 2, remote_id);
          Serial.println(F("\tLocalization options saved"));
          printLocalizationOptions(remote_id);
          state = STATE_MAIN;
          printMain(remote_id);
        }else{
          Serial.println(F("\tInvalid input, please try again"));
        }
      }else if(state == STATE_MANUAL_IDS)
      {
        char input_hex[sizeof(input)];
        input.toCharArray(input_hex, sizeof(input));
        long network_id = strtol(input_hex, NULL, 16);
        if(network_id >0 && network_id <= 0xFFFF)
        {
          Serial.print("0x");
          Serial.println(network_id, HEX);

          anchor_sel[selected_anchor_num-1] = network_id;

          if(selected_anchor_num < numAnchors)
          {
            Serial.print(F("\tenter network id of anchor "));
            Serial.print(++selected_anchor_num);
            Serial.print(F(" (hex): "));
          }else
          {
            Pozyx.setPositioningAnchorIds(anchor_sel, numAnchors, remote_id);
            Pozyx.saveConfiguration(POZYX_FLASH_ANCHOR_IDS, NULL, 0, remote_id);
            printLocalizationOptions(remote_id);
            state = STATE_MAIN;
            printMain(remote_id);
          }

        }else{
          Serial.print(F("\n\tNot a valid network id, try again: "));
        }
      }

      input = "";
    }

  } // end: if (Serial.available() > 0)

}

void printLocalizationOptions(uint16_t remote_id)
{
  uint8_t algorithm = 0;
  Pozyx.getPositionAlgorithm(&algorithm, remote_id);
  uint8_t dimension = 0;
  Pozyx.getPositionDimension(&dimension, remote_id);

  Serial.print(F("using the "));
  if(algorithm == POZYX_POS_ALG_UWB_ONLY  )
    Serial.print(F("UWB-only"));
  else if(algorithm == POZYX_POS_ALG_LS  )
    Serial.print(F("Least squares"));
  Serial.print(F(" algorithm in "));
  if(dimension == POZYX_2D )
    Serial.println(F("2D."));
  else if(dimension == POZYX_2_5D )
    Serial.println(F("3D with fixed height (2.5D)."));
  else if(dimension == POZYX_3D )
    Serial.println(F("3D."));

  uint8_t mode = 0;
  Pozyx.getAnchorSelectionMode(&mode, remote_id);
  uint8_t numAnchors = 0;
  Pozyx.getNumberOfAnchors(&numAnchors, remote_id);

  Serial.print(F("using "));
  Serial.print(numAnchors);
  Serial.print(F(" anchors that are "));
  if(mode == POZYX_ANCHOR_SEL_MANUAL)
  {
    Serial.println(F("manually selected."));
    uint16_t anchors[numAnchors];
    for(int i=0;i<numAnchors;i++)    {
      anchors[i] = 0;
    }

    int status = Pozyx.getPositioningAnchorIds(anchors, numAnchors, remote_id);
    for(int i=0;i<numAnchors;i++)
    {
      Serial.print("\t0x");
      Serial.print(anchors[i],HEX);
    }
    Serial.println();
  }else if(mode == POZYX_ANCHOR_SEL_AUTO)
    Serial.println(F("automatically selected."));
}

void printMain(uint16_t remote_id)
{
  Serial.println(F("\nCurrent devices in device list: (max 20)"));

  int result = Pozyx.getDeviceListSize(&devlist_size, remote_id);
  if(devlist_size > 0)
  {
    uint16_t devices[devlist_size];
    result = Pozyx.getDeviceIds(device_ids, devlist_size, remote_id);

    int i;
    for(i=0; i<devlist_size; i++)
    {
      coordinates_t anchor_coor;
      Serial.print("\tAnchor ");
      Serial.print(i+1);
      Serial.print(") 0x");
      Serial.print(device_ids[i], HEX);
      result = Pozyx.getDeviceCoordinates(device_ids[i], &anchor_coor, remote_id);
      Serial.print("\tx= ");
      Serial.print(anchor_coor.x);
      Serial.print("\ty= ");
      Serial.print(anchor_coor.y);
      Serial.print("\tz= ");
      Serial.println(anchor_coor.z);
    }
  }else
  {
    Serial.println("\tNone.");
  }

  Serial.println(F("Options [add, remove, remove all, localization options]"));
}

void remove_anchor(uint16_t network_id, uint16_t remote_id)
{
  uint8_t devlist_size = 0;
  int result = Pozyx.getDeviceListSize(&devlist_size, remote_id);

  if(devlist_size > 0)
  {
    uint16_t device_ids[devlist_size];
    device_coordinates_t devices[devlist_size];
    result = Pozyx.getDeviceIds(device_ids, devlist_size, remote_id);

    // load all the current devices
    for(int i=0; i<devlist_size; i++)    {
      coordinates_t tmp;
      result = Pozyx.getDeviceCoordinates(device_ids[i], &tmp, remote_id);
      devices[i].network_id = device_ids[i];
      devices[i].flag = 1;
      devices[i].pos = tmp;
    }

    // clear the current devices
    Pozyx.clearDevices(remote_id);

    // add all the devices except the one to delete
    for(int i=0; i<devlist_size; i++)
    {
      if(device_ids[i] != network_id)
      {
        Pozyx.addDevice(devices[i], remote_id);
      }
    }
  }
}

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


hmm, returning the 5041 pos is a piece of cake

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


Create GoalCode.ino

Create GoalCode.ino

/*
*
*  Aansluitingen HCSR04 - Arduino
*  Vcc - 5V
*  Trig - 2
*  Echo - 3
*  Gnd - GND
*/

#include "HCSR04.h"
HCSR04 ultrasonic(2, 3); //Trig, Echo

int cm;

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

void loop()
{
  cm = ultrasonic.Ranging(CM); //CM of INCH
  if(cm >= 0)
    Serial.println(cm);
  delay(100);
}

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


added upper limit, stable

added upper limit, stable


add tcp sketch

add tcp sketch

/***************************************************
  Adafruit CC3000 Breakout/Shield TCP Echo Server

  This is a simple implementation of the echo
  protocol, RFC 862 http://tools.ietf.org/html/rfc862 ,
  for the Arduino platform and Adafruit CC3000 breakout
  or shield.  This sketch will create a TCP server that
  listens by default on port 7 and echos back any data
  received.  Up to 3 clients can be connected concurrently
  to the server.  This sketch is meant as an example of how
  to write a simple server with the Arduino and CC3000.

  See the CC3000 tutorial on Adafruit's learning system
  for more information on setting up and using the
  CC3000:
    http://learn.adafruit.com/adafruit-cc3000-wifi

  Requirements:

  This sketch requires the Adafruit CC3000 library.  You can
  download the library from:
    https://github.com/adafruit/Adafruit_CC3000_Library

  For information on installing libraries in the Arduino IDE
  see this page:
    http://arduino.cc/en/Guide/Libraries

  Usage:

  Update the SSID and, if necessary, the CC3000 hardware pin
  information below, then run the sketch and check the
  output of the serial port.  After connecting to the
  wireless network successfully the sketch will output
  the IP address of the server and start listening for
  connections.  Once listening for connections, connect
  to the server from your computer  using a telnet client
  on port 7.

  For example on Linux or Mac OSX, if your CC3000 has an
  IP address 192.168.1.100 you would execute in a command
  window:

    telnet 192.168.1.100 7

  After connecting, notice that as you type input and
  press enter to send it the CC3000 will echo back exactly
  what you typed.  Press ctrl-] and type quit at the prompt
  to close the telnet session.

  On Windows you'll need to download a telnet client.  PuTTY
  is a good, free GUI client:
    http://www.chiark.greenend.org.uk/~sgtatham/putty/

  License:

  This example is copyright (c) 2013 Tony DiCola (tony@tonydicola.com)
  and is released under an open source MIT license.  See details at:
    http://opensource.org/licenses/MIT

  This code was adapted from Adafruit CC3000 library example
  code which has the following license:

  Designed specifically to work with the Adafruit WiFi products:
  ----> https://www.adafruit.com/products/1469

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include "utility/debug.h"
#include "utility/socket.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       "CL Eng Devices"           // cannot be longer than 32 characters!
#define WLAN_PASS       "mak3 all the Things talk"
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define LISTEN_PORT           7    // What TCP port to listen on for connections.  The echo protocol uses port 7.

Adafruit_CC3000_Server echoServer(LISTEN_PORT);

int led = 8;

void setup(void)
{
  pinMode(led, OUTPUT);
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n"));

  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);

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

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

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

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

  /* Display the IP address DNS, Gateway, etc. */
  while (! displayConnectionDetails()) {
    delay(1000);
  }

  /*********************************************************/
  /* You can safely remove this to save some flash memory! */
  /*********************************************************/
  Serial.println(F("\r\nNOTE: This sketch may cause problems with other sketches"));
  Serial.println(F("since the .disconnect() function is never called, so the"));
  Serial.println(F("AP may refuse connection requests from the CC3000 until a"));
  Serial.println(F("timeout period passes.  This is normal behaviour since"));
  Serial.println(F("there isn't an obvious moment to disconnect with a server.\r\n"));

  // Start listening for connections
  echoServer.begin();

  Serial.println(F("Listening for connections..."));
}

void loop(void)
{
  // Try to get a client which is connected.
  Adafruit_CC3000_ClientRef client = echoServer.available();
  if (client) {
     // Check if there is data available to read.
     if (client.available() > 0) {
       // Read a byte and write it to all clients.
       uint8_t ch = client.read();
       client.write(ch);
       if (ch == 49) {
         digitalWrite(led, HIGH);
       } else if (ch ==50) {
         digitalWrite(led, LOW);
       } else {
         Serial.println(ch);
       }
     }
  }
}

/**************************************************************************/
/*!
    @brief  Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;

  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}

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


Add echo server example.

Add echo server example.

/***************************************************
  Adafruit CC3000 Breakout/Shield TCP Echo Server

  This is a simple implementation of the echo
  protocol, RFC 862 http://tools.ietf.org/html/rfc862 ,
  for the Arduino platform and Adafruit CC3000 breakout
  or shield.  This sketch will create a TCP server that
  listens by default on port 7 and echos back any data
  received.  Up to 3 clients can be connected concurrently
  to the server.  This sketch is meant as an example of how
  to write a simple server with the Arduino and CC3000.

  See the CC3000 tutorial on Adafruit's learning system
  for more information on setting up and using the
  CC3000:
    http://learn.adafruit.com/adafruit-cc3000-wifi

  Requirements:

  This sketch requires the Adafruit CC3000 library.  You can
  download the library from:
    https://github.com/adafruit/Adafruit_CC3000_Library

  For information on installing libraries in the Arduino IDE
  see this page:
    http://arduino.cc/en/Guide/Libraries

  Usage:

  Update the SSID and, if necessary, the CC3000 hardware pin
  information below, then run the sketch and check the
  output of the serial port.  After connecting to the
  wireless network successfully the sketch will output
  the IP address of the server and start listening for
  connections.  Once listening for connections, connect
  to the server from your computer  using a telnet client
  on port 7.

  For example on Linux or Mac OSX, if your CC3000 has an
  IP address 192.168.1.100 you would execute in a command
  window:

    telnet 192.168.1.100 7

  After connecting, notice that as you type input and
  press enter to send it the CC3000 will echo back exactly
  what you typed.  Press ctrl-] and type quit at the prompt
  to close the telnet session.

  On Windows you'll need to download a telnet client.  PuTTY
  is a good, free GUI client:
    http://www.chiark.greenend.org.uk/~sgtatham/putty/

  License:

  This example is copyright (c) 2013 Tony DiCola (tony@tonydicola.com)
  and is released under an open source MIT license.  See details at:
    http://opensource.org/licenses/MIT

  This code was adapted from Adafruit CC3000 library example
  code which has the following license:

  Designed specifically to work with the Adafruit WiFi products:
  ----> https://www.adafruit.com/products/1469

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include "utility/debug.h"
#include "utility/socket.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_DIV2); // 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 LISTEN_PORT           7    // What TCP port to listen on for connections.  The echo protocol uses port 7.
#define MAX_CLIENTS           3    // The CC3000 docs advise that it has 4 sockets available to client code.
                                   // One socket is consumed listening for new connections, and the remaining sockets
                                   // are available for client connections.
                                   // In practice it appears you can go higher than 4 sockets (up to about 7), but
                                   // be careful as it might cause the CC3000 to behave unexpectedly.

// Define a simple forward linked list structure to keep track of
// connected clients.  This client list is kept as a linked list
// because the CC3000 client instances have a non-trivial amount of
// internal state (buffers, etc.) which we don't want to spend memory
// consuming unless a client is connected.  Because the size of the list
// is small and random access to entries is rare (happens only on
// disconnect) a forward list (i.e. no back/previous pointer) is
// sufficient.
struct ClientList {
  int socket;
  Adafruit_CC3000_Client client;
  ClientList* next;
};

// Global variable to hold the ID of the listening socket.
int listenSocket;

// Global variable to hold the start of the connected client list.
ClientList* clients;

// Global variable to keep track of how many clients are connected.
int clientCount;

// Function to add a new client to the connected client list.
void addNewClient(int socket) {
  // Allocate memory for a new list entry.
  // In general be very careful with heap/dynamic memory use in an Arduino sketch
  // because the function stack and heap share the same limited amount of memory and
  // can easily overflow.  In this case the number of connected clients is low
  // so the risk of using up all the memory is low.
  ClientList* client = (ClientList*) malloc(sizeof(ClientList));
  if (client == NULL) {
    Serial.println(F("Error! Couldn't allocate space to store a new client."));
    return;
  }
  // Setup the new client as the front of the connected client list.
  client->next = clients;
  client->socket = socket;
  client->client = Adafruit_CC3000_Client(socket);
  clients = client;
  // Increment the count of connected clients.
  clientCount++;
}

// Remove a client from the connected client list.
void removeClient(struct ClientList* client) {
  if (client == NULL) {
    // Handle null client to delete.  This should never happen
    // but is good practice as a precaution.
    return;
  }
  if (clients == client) {
    // Handle the client to delete being at the front of the list.
    clients = client->next;
  }
  else {
    // Handle the client to delete being somewhere inside the list.
    // Iterate through the list until we find the entry before the
    // client to delete.
    ClientList* i = clients;
    while (i != NULL && i->next != client) {
      i = i->next;
    }
    if (i == NULL) {
      // Couldn't find the client to delete, do nothing.
      return;
    }
    // Remove the client from the list.
    i->next = client->next;
  }
  // Free the memory associated with the client and set the
  // pointer to null as a precaution against dangling references.
  free(client);
  client = NULL;
  // Decrement the count of connected clients.
  clientCount--;
}

// Set up the echo server and start listening for connections.  Should be called once
// in the setup function of the Arduino sketch.
void echoSetup() {
  // Most of the calls below are to CC3000 firmware API's. You can find the documentaiton for these calls at:
  //   http://software-dl.ti.com/ecs/simplelink/cc3000/public/doxygen_API/v1.11.1/html/index.html

  // Set the CC3000 inactivity timeout to 0 (never timeout).  This will ensure the CC3000
  // does not close the listening socket when it's idle for more than 60 seconds (the
  // default timeout).  See more information from:
  //   http://e2e.ti.com/support/low_power_rf/f/851/t/292664.aspx
  unsigned long aucDHCP       = 14400;
  unsigned long aucARP        = 3600;
  unsigned long aucKeepalive  = 30;
  unsigned long aucInactivity = 0;
  if (netapp_timeout_values(&aucDHCP, &aucARP, &aucKeepalive, &aucInactivity) != 0) {
    Serial.println(F("Error setting inactivity timeout!"));
    while(1);
  }
  // Create a TCP socket
  listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (listenSocket < 0) {
    Serial.println(F("Couldn't create listening socket!"));
    while(1);
  }
  // Set the socket's accept call as non-blocking.
  // This is required to support multiple clients accessing the server at once.  If the listening
  // port is not set as non-blocking your code can't do anything while it waits for a client to connect.
  if (setsockopt(listenSocket, SOL_SOCKET, SOCKOPT_ACCEPT_NONBLOCK, SOCK_ON, sizeof(SOCK_ON)) < 0) {
    Serial.println(F("Couldn't set socket as non-blocking!"));
    while(1);
  }
  // Bind the socket to a TCP address.
  sockaddr_in address;
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = htonl(0);     // Listen on any network interface, equivalent to INADDR_ANY in sockets programming.
  address.sin_port = htons(LISTEN_PORT);  // Listen on the specified port.
  if (bind(listenSocket, (sockaddr*) &address, sizeof(address)) < 0) {
    Serial.println(F("Error binding listen socket to address!"));
    while(1);
  }
  // Start listening for connectings.
  // The backlog parameter is 0 as it is not supported on TI's CC3000 firmware.
  if (listen(listenSocket, 0) < 0) {
    Serial.println(F("Error opening socket for listening!"));
    while(1);
  }
  // Initialize client list as empty.
  clients = NULL;
  clientCount = 0;
  Serial.println(F("Listening for connections..."));
}

// Update the state of clients, and accept new client connections.  Should be called
// by the Arduino sketch's loop function.
void echoLoop() {
  // Iterate through all the connected clients.
  ClientList* i = clients;
  while (i != NULL) {
    // Save the next client so the current one can be removed when it disconnects
    // without breaking iteration through the clients.
    ClientList* next = i->next;
    // If there's data available, read it a character at a time from the
    // CC3000 library's internal buffer.
    while (i->client.available() > 0) {
      uint8_t ch = i->client.read();
      // Echo the read byte back out to the client immediately.
      if (i->client.write(ch) == 0) {
        Serial.println(F("Error writing character to client!"));
      }
    }
    // Check if the client is disconnected and remove it from the active client list.
    if (!i->client.connected()) {
      Serial.print(F("Client on socket "));
      Serial.print(i->socket);
      Serial.println(F(" disconnected."));
      removeClient(i);
      // Note that i is now NULL!  Don't try to dereference it or you will
      // have a bad day (your Arduino will reset).
    }
    // Continue iterating through clients.
    i = next;
  }
  // Handle new client connections if we aren't at the limit of connected clients.
  if (clientCount < MAX_CLIENTS) {
    // Accept a new socket connection.  Because we set the listening socket to be non-blocking
    // this will quickly return a result with either a new socket, an indication that nothing
    // is trying to connect, or an error.
    // The NULL parameters allow you to read the address of the connected client but are
    // unused in this sketch.  See TI's documentation (linked in the setup function) for
    // more details.
    int newSocket = accept(listenSocket, NULL, NULL);
    // Check if a client is connected to a new socket.
    if (newSocket > -1) {
      Serial.print(F("New client connected on socket "));
      Serial.println(newSocket);
      // Add the client to the list of connected clients.
      addNewClient(newSocket);
    }
  }
}

void setup(void)
{
  Serial.begin(115200);
  Serial.println(F("Hello, CC3000!\n"));

  Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);

  /* 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!"));

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

  /* Display the IP address DNS, Gateway, etc. */
  while (! displayConnectionDetails()) {
    delay(1000);
  }

  // Initialize the echo server
  echoSetup();
}

void loop(void)
{
  // Update the echo server.
  echoLoop();
}

/**************************************************************************/
/*!
    @brief  Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;

  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    return true;
  }
}

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


Create ds18b20.ino

Create ds18b20.ino

#include <Process.h>
#include "MQTTclient.h"
#include "DHT.h"
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS_PIN A3
float  tempC2 = 0;
float  tempC3 = 0;
unsigned long time;

OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);
//DeviceAddress probe01 =  {0x28, 0xC7, 0xEB, 0xF0, 0x05, 0x00, 0x00, 0xEA};

#define MQTT_HOST "190.97.168.236"
#define DHTPIN A0
//#define DHTPIN2 A1

#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);
//DHT dht2(DHTPIN2, DHTTYPE);

char message_buff[100];
char message_buff2[100];
char message[256];
String id_sensor = "test4";

float t2;

void setup() {

  Serial.begin(9600);
  Bridge.begin();
  mqtt.begin(MQTT_HOST, 1883);
  dht.begin();
  sensors.begin();
  //sensors.setResolution(probe01, 10);

  mqtt.subscribe("test/temp", someEvent);

}

void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();

 sensors.requestTemperatures();

 tempC2 = sensors.getTempCByIndex(0),4;
 //tempC2 = sensors.getTempC(probe01);
   if (millis() > (time + 20000)) {
       time = millis();

 String pubString = "" + String(t) + "," + String(tempC2) + "," + String(h) + "," + id_sensor + "";
   pubString.toCharArray(message_buff, pubString.length()+1);
   mqtt.publish("test/temp",message_buff );

   }
   else{

  mqtt.monitor();
   }

}

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

}

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


Added Button Control to motion gesture

Added Button Control to motion gesture

The user needs to hold the button (SW2) while moving the board.
The CC3200 needs to be held vertically with the LEDS facing the outside
world (not facing the person holding it)

(readings are not accurate all the time... >.< )

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