Clean up, remove data logging, add radioblip2

//
// Receive RFM12B packets and publish to  MQTT server 192.168.178.27
// 1) Temperature Node (group 33, node 22)
//      --> time stamp, RF12 group ID, node ID, Vcc, T1, T2
// 2) RFM12B raw data
//      --> time stamp, RF12 group ID, node ID, all data bytes received
//
// Blink LED #13 for each package received
//
// 150725 YunHub 1.05
//

#include <Bridge.h>
#include <JeeLib.h>
#include <YunClient.h>
#include <PubSubClient.h>

byte rf12_group, rf12_nodeid;
String timeStamp, dataStr, rawdataStr;
char message_buff[255];

// Update these with values suitable for your network.
byte server[] = { 192, 168, 178, 27 };

// Temperature node data structure. Timestamp created locally, at time of receival.
struct
{
    String timeStamp;   // "+%Y-%m-%d %T": format "YYYY-MM-DD hh:mm:ss"
    byte rf12_group;    // RF12 group ID
    byte rf12_nodeid;   // RF12 node ID
    float Vcc;          // Supply voltage
    float T1;            // Temperature reading
    float T2;            // Temperature reading
} TNodeData;

// Temperature node data structure. Timestamp created locally, at time of receival.
struct
{
    String timeStamp;   // "+%Y-%m-%d %T": format "YYYY-MM-DD hh:mm:ss"
    byte rf12_group;    // RF12 group ID
    byte rf12_nodeid;   // RF12 node ID
    float Vcc;          // Supply voltage
} RadioBlip2Data;

// ===========================================================
// MQTT callback function, called for incoming messages
// ===========================================================
void callback(char *topic, byte *payload, unsigned int length)
{
    // counter
    int i = 0;
    // buffer for payload-to-string conversion
    char message_buff[255];

    // copy payload to buffer, append \0
    for (i = 0; i < length; i++)
    {
        message_buff[i] = payload[i];
    }
    message_buff[i] = '\0';
}

YunClient yun;
PubSubClient client(server, 1883, callback, yun);

void setup ()
{
    // start-up the Yun bridge
    Bridge.begin();
    delay(2000);

    Serial.begin(57600);
    Serial.println("***");
    Serial.println("*** 150725 YunHub 1.05");
    Serial.println("***");

    // initialize digital pin 13 as an output.
    pinMode(13, OUTPUT);

    rf12_initialize(1, RF12_868MHZ, 0); // group id = 0 to receive from all groups
}

void loop ()
{

    if (rf12_recvDone() && rf12_crc == 0)
    {

        digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)

        // Connect to MQTT server if not available
        if (!client.connected())
        {
            client.connect("arduinoYunClient");
            client.publish("ConnectMessage", "YunChen connected.");
        }

        // identify sender via group & nodeid
        // node id is in the first 5 bits of rf12_hdr --> & RF12_HDR_MASK
        rf12_group = rf12_grp;
        rf12_nodeid = rf12_hdr & RF12_HDR_MASK;
        timeStamp = getTimeStamp();

        ////////////////////////////////////
        //  Raw Data (group ALL, id ALL)  //
        ////////////////////////////////////
        rawdataStr = timeStamp + ","
                     + String(rf12_group) + ","
                     + String(rf12_nodeid);
        for (byte i = 0; i < rf12_len; ++i)
        {
            rawdataStr += ",";
            rawdataStr += rf12_data[i];
        }

        // publish to MQTT server
        rawdataStr.toCharArray(message_buff, 255);
        client.publish("RF12_RawData", message_buff);

        ///////////////////////////////
        //  TNode (group 33, id 22)  //
        ///////////////////////////////
        if (rf12_group == 33 and rf12_nodeid == 22)
        {
            TNodeData.rf12_group = rf12_group;
            TNodeData.rf12_nodeid = rf12_nodeid;
            TNodeData.timeStamp = timeStamp;
            TNodeData.Vcc = int(word(rf12_data[1], rf12_data[0])) / 1000.0;
            TNodeData.T1 = int(word(rf12_data[3], rf12_data[2])) / 100.0;
            TNodeData.T2 = int(word(rf12_data[5], rf12_data[4])) / 100.0;

           dataStr = TNodeData.timeStamp + ","
                      + String(TNodeData.rf12_group) + ","
                      + String(TNodeData.rf12_nodeid) + ","
                      + String(TNodeData.Vcc) + ","
                      + String(TNodeData.T1) + ","
                      + String(TNodeData.T2);

            // publish interpreted TNode data to MQTT server
            dataStr.toCharArray(message_buff, 255);
            client.publish("TNode", message_buff);
        }

        ////////////////////////////////////
        //  RadioBlip2 (group 33, id 17)  //
        ////////////////////////////////////
        if (rf12_group == 33 and rf12_nodeid == 17)
        {
            RadioBlip2Data.rf12_group = rf12_group;
            RadioBlip2Data.rf12_nodeid = rf12_nodeid;
            RadioBlip2Data.timeStamp = timeStamp;
            RadioBlip2Data.Vcc = 1.0 + rf12_data[5] * 0.02;

           dataStr = RadioBlip2Data.timeStamp + ","
                      + String(RadioBlip2Data.rf12_group) + ","
                      + String(RadioBlip2Data.rf12_nodeid) + ","
                      + String(RadioBlip2Data.Vcc);

            // publish interpreted TNode data to MQTT server
            dataStr.toCharArray(message_buff, 255);
            client.publish("RadioBlip2", message_buff);
        }

    }
    digitalWrite(13, LOW);   // turn the LED off (HIGH is the voltage level)
    client.loop();
}

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

// This function returns a string with the time stamp
String getTimeStamp()
{
    String result;
    Process time;
    // date is a command line utility to get the date and the time
    // in different formats depending on the additional parameter
    time.begin("date");
    time.addParameter("+%Y-%m-%d %T");  // parameters: D for the complete date mm/dd/yy, T for the time hh:mm:ss
    time.run();  // run the command

    // read the output of the command
    while (time.available() > 0)
    {
        char c = time.read();
        if (c != '\n')
            result += c;
    }

    return result;
}

error: pathspec 'projects/YunHub/YunHub_1.05_MQTT/YunHub_1.05_MQTT.ino' did not match any file(s) known to git


Error in analogWrite parameter

Error in analogWrite parameter

error: pathspec 'LCD' did not match any file(s) known to git
error: pathspec 'TFT' did not match any file(s) known to git
error: pathspec 'Screen/lcd_1/lcd_1.ino' did not match any file(s) known to git


Create script.ino

Create script.ino

#include <ArduinoJson.h>
#include <Average.h>
#include <dht11.h>
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <SD.h>

const int xPin = A1;
//#define X_pin 1  // analog pin connected to X output
const int yPin = A2;
//#define Y_pin 2  // analog pin connected to Y output
const int Dht11BodyPin = 2;
//#define DHT11_BODY 2
const int Dht11AmbPin = 3;
//#define DHT11_AMB 3
const int soundPin = A0;
//#define heating 24
const int heatingPin = 24;
//#define humid 26
const int humidPin = 26;

long randNumber; // This variable is used only to test the code without any sensor plugged
const int chipSelect = 4;
File dataLog;

// Update these Value with the ones suitable for you
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Ethernet MAC address (DO NOT TOUCH! IT IS STANDARDIZED!)
byte raspberry_ip[] = {169, 254, 210, 16}; // Rasp Pi IP address
byte arduino_ip[] = {169, 254, 210, 17}; // Arduino IP address
char raspberry_ip_str[] = "169.254.210.16";
char arduino_ip_str[] = "169.254.210.17";

// Variable related to --> Joystick
const byte size = 11;
Average<int> array_X(size);
Average<int> array_Y(size);
const int sampleWindowAcc = 20;
int startAcc;
int k = 0;
int k1 = 0;
int xDev = 0;
int yDev = 0;

// Variable related to --> Cry_sensor
const int sampleWindowS = 200; // Sample window width in ms (50ms = 20Hz --> 200ms --> 5Hz) for the microphone
unsigned int sample;
unsigned long startS; // Used to determine time starting in millis() for the microphone
unsigned int signalMax = 0; // Used to save the maximum in "sampleWindowS"
unsigned int signalMin = 1024; // Used to save the minimum in "sampleWindowS"
int j = 0;

// Variable related to --> DHT11
const int sampleWindowDHT11_1 = 1000; // Sample window width in mS (50ms = 20Hz --> 200ms --> 5Hz) for DHT11
const int sampleWindowDHT11_2 = 1000;
unsigned long startDHT11_1; // Used to determine time starting in millis() for DHT11
unsigned long startDHT11_2;
dht11 DHT; // Object DHT11

// Variable related to --> JSON
const int len = 500;
char buffer[len];
//StaticJsonBuffer<len> jsonBuffer;
DynamicJsonBuffer jsonBuffer;
JsonObject& sensor = jsonBuffer.createObject();
JsonObject& DHT11_1 = sensor.createNestedObject("DHT11_1");
JsonObject& DHT11_2 = sensor.createNestedObject("DHT11_2");
JsonObject& Acc = sensor.createNestedObject("Acc");
//JsonArray& TimeAcc = Acc.createNestedArray("TimeAcc");
JsonArray& Movement = Acc.createNestedArray("Movement");
JsonObject& Microphone = sensor.createNestedObject("Microphone");
//JsonArray& Time = Microphone.createNestedArray("Time");
JsonArray& dB = Microphone.createNestedArray("dB");
unsigned long startPrint;

//// Variable related to --> Networking
EthernetClient ethClient;
PubSubClient mqttClient(ethClient);

String unix_time;
String local_time;

boolean heating_state = LOW;
boolean humid_state = LOW;

void setup() {
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  else {
    Serial.println("Card initialized");
  }
  pinMode(humidPin, OUTPUT);
  pinMode(heatingPin, OUTPUT);
  digitalWrite(heatingPin, heating_state);
  digitalWrite(humidPin, humid_state);
  startAcc = millis();
  startS = millis();
  startDHT11_1 = millis();
  startDHT11_2 = millis();
  startPrint = millis();
  Microphone["ID"] = ("Microphone");
  DHT11_1["ID"] = ("DHT11 Sensor1");
  DHT11_2["ID"] = ("DHT11 Sensor2");
  Acc["ID"] = ("Accelerometer");
  for (int i = 0; i <= 5; i++) {
    //TimeAcc.add(0);
    Movement.add(0);
    //Time.add(0);
    dB.add(0);
  }
  Serial.begin(9600);
  while (!Serial) {
    // wait serial port initialization
  }
  mqttClient.setServer(raspberry_ip,1883);
  mqttClient.setCallback(callback);

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

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

  readSound(Microphone);
  readDHT11(DHT11_1);
  readDHT11(DHT11_2);
  readAcc(Acc);
  digitalWrite(heatingPin, heating_state);
  digitalWrite(humidPin, humid_state);
  if (millis() - startPrint > 1010) {
    sensor.printTo(Serial);
    Serial.println();
    startPrint = millis();
  }
}
/*  ###################################
    #              SENSORS            #
    ###################################
*/

void readAcc(JsonObject & SubSensor) {
  //Read from the accelerometer and do somethins...
  mqttClient.publish("requesting", "unix");
  mqttClient.publish("requesting", "local");
  if (millis() - startAcc > sampleWindowAcc) {
    array_X.push(analogRead(X_pin));
    array_Y.push(analogRead(Y_pin));
    k++;
    startAcc = millis();
  }
  if (k >= 10) {
    k = 0;
    xDev = array_X.stddev();
    yDev = array_Y.stddev();

    SubSensor["Time"] = unix_time.toInt(); //Take hour from RPi
    Movement.set(k1, (xDev + yDev) / 2);
    k1++;
    if (k1 > 5) {
      k1 = 0;
      SubSensor.printTo(buffer, sizeof(buffer));
      mqttClient.publish("accelerometer", buffer); // Message published to the topic
//      Serial.println(buffer);
//      if (dataLog) {
//        String r1 = SubSensor["ID"];
//        dataLog.print("ID: ");
//        dataLog.println(r1);
//        dataLog.print("Value: ");
//        int a = Acc["Movement"][0];
//        Serial.println(a);
//        Movement[0].printTo(buffer,sizeof(buffer))
//        dataLog.print(Acc["Movement"][0]);
//        dataLog.print(", ");
//        dataLog.println(Acc[Movement][1]);
//        dataLog.print(", ");
//        dataLog.println(Movement[2]);
//        dataLog.print(", ");
//        dataLog.println(Movement[3]);
//        dataLog.print(", ");
//        dataLog.println(Movement[4]);
//        dataLog.print("Time: ");
//        dataLog.println(local_time);
//        dataLog.println();
//      }
//      else {
//        Serial.println("error opening datalog.txt");
//      }
    }

  }
}

void readSound(JsonObject & SubSensor) {
  unsigned int peakToPeak = 0;   // peak-to-peak level

  sample = analogRead(soundPin);
  if (sample < 1024)  // toss out spurious readings
    if (sample > signalMax)
      signalMax = sample;  // save just the max levels
    else if (sample < signalMin)
      signalMin = sample;  // save just the min levels

  if (millis() - startS > sampleWindowS) {
    peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
    double volts = (peakToPeak * 3.3);  // convert to volts
    signalMax = 0;
    signalMin = 1024;
    startS = millis();
    //Time.set(j, 999); //prendi l'ora da rasp
    SubSensor["Time"] = unix_time.toInt(); //Take hour from RPi
    dB.set(j, volts);
    j++;
    if (j > 5) {
      j = 0;
      SubSensor.printTo(buffer, sizeof(buffer));
      mqttClient.publish("temperature", buffer); // Message published to the topic
    }
  }
}

void readDHT11(JsonObject & SubSensor) {
  if ((millis() - startDHT11_1 > sampleWindowDHT11_1) ||  (millis() - startDHT11_2 > sampleWindowDHT11_2)) {
    mqttClient.publish("requesting", "unix");
    mqttClient.publish("requesting", "local");
    //    int temp = random(25, 35); // This variable is used only to test the code without any sensor plugged
    //    int hum = random(10, 100); // This variable is used only to test the code without any sensor plugged
    int PIN;
    if (SubSensor["ID"] == "DHT11 Sensor1") {
      startDHT11_1 = millis();
      PIN = Dht11BodyPin;
    }
    else {
      startDHT11_2 = millis();
      PIN = Dht11AmbPin;
    }
    switch (DHT.read(PIN)) {
      case DHTLIB_OK:
        SubSensor["Status"] = "OK";
        break;
      case DHTLIB_ERROR_CHECKSUM:
        SubSensor["Status"] = "Checksum error";
        break;
      case DHTLIB_ERROR_TIMEOUT:
        SubSensor["Status"] = "Time out error";
        break;
      default:
        SubSensor["Status"] = "Unknown error";
        break;
    }
    int temp = DHT.temperature;
    int hum = DHT.humidity;
    SubSensor["Temp"] = temp;
    SubSensor["Hum"] = hum;
    SubSensor["Time"] = unix_time.toInt(); //Take hour from RPi
    //    const char *DHT11_1 = sensor["DHT11_1"].asString();
    //SubSensor.prettyPrintTo(Serial);
    if (dataLog) {
      String r1 = SubSensor["ID"];
      //String r4 = SubSensor["Time"];
      dataLog.print("ID: ");
      dataLog.println(r1);
      dataLog.print("Temperature: ");
      dataLog.println(temp);
      dataLog.print("Humidity: ");
      dataLog.println(hum);
      dataLog.print("Time: ");
      dataLog.println(local_time);
      dataLog.println();
    }
    else {
      Serial.println("error opening datalog.txt");
    }
    SubSensor.printTo(buffer, sizeof(buffer));
    mqttClient.publish("temperature", buffer); // Message published to the topic
  }
}

/*  ###################################
    #              ETHERNET           #
    ###################################
*/

// This functions is called when a message arrived (it acts as an "Interrupt" if you get me ;)  )
void callback(char* topic, byte* payload, unsigned int length)
{
  Serial.print("Message arrived on [");
  Serial.print(topic);
  Serial.print("]: ");
  if (dataLog) {
    dataLog.print("Message arrived on [");
    dataLog.print(topic);
    dataLog.print("]: ");
  }
  else {
    Serial.println("error opening datalog.txt");
  }
  for (int i = 0; i < length; i++)
  {
    Serial.print((char)payload[i]); // payload is the message coming from the broker
    dataLog.print((char)payload[i]);
  }
  dataLog.println();
  dataLog.println();
  dataLog.flush();
  Serial.println();
  if (strcmp (topic, "time_unix") == 0) {
    unix_time = ((String)(char *)payload).substring(0, (length - 3));
  }
  else if ((strcmp(topic, "moisturizing") == 0) || (strcmp(topic, "heating") == 0)) {
    String action = (char *)payload;
    action = action.substring(0, length);
    acting(topic, action);
  }
  else if (strcmp (topic, "time_local") == 0) {
    local_time = ((String)(char *)payload);
  }
  else {
    Serial.print("Topic ("); Serial.print(topic); Serial.println(") doesn't recognize!");
  }
}

void reconnect()
{
  // Loop until we're reconnected
  while (!mqttClient.connected())
  {
    Serial.println("Attempting MQTT connection...");
    // Attempt to connect
    if (mqttClient.connect(raspberry_ip_str))
    {
      Serial.println("Connected!");
      // Once connected, publish an announcement...
      //mqttClient.publish("outTopic","How r u, RPi?"); // Message published to the topic
      // ... and resubscribe
      //mqttClient.subscribe("time_unix");
      //Serial.println("Message published and inTopic subscribed in reconnect()...");
      mqttClient.subscribe("time_unix");
      mqttClient.subscribe("time_local");
      mqttClient.subscribe("heating");
      mqttClient.subscribe("moisturizing");
      dataLog = SD.open("datalog.txt", FILE_WRITE);
    }
    else
    {
      Serial.print("Failed, rc=");
      Serial.println(mqttClient.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      dataLog.close();
      delay(5000);
    }
  }
}

/*  ###################################
    #              ACTING             #
    ###################################
*/

void acting(char* topic, String action) {
  Serial.println("Entry in acting funcionalities...");
  if (strcmp(topic, "heating") == 0) {
    if (action.equals("ON")) {
      Serial.println("Heating ON");
      heating_state = HIGH;
      if (dataLog) {
        dataLog.println("Heating ON");
        dataLog.println();
        dataLog.flush();
      }
      else {
        Serial.println("error opening datalog.txt");
      }
      //HEATER ON
    }
    else {
      Serial.println("Heating OFF");
      heating_state = LOW;
      if (dataLog) {
        dataLog.println("Heating OFF");
        dataLog.println();
        dataLog.flush();
      }
      else {
        Serial.println("error opening datalog.txt");
      }
      //HEATER OFF
    }
  }
  if (strcmp(topic, "moisturizing") == 0) {
    if (action == "ON") {
      humid_state = HIGH;
      Serial.println("Moisturizing ON");
      if (dataLog) {
        dataLog.println("Moisturizing ON");
        dataLog.println();
        dataLog.flush();
      }
      else {
        Serial.println("error opening datalog.txt");
      }
      //HUMIDIFIER' ON
    }
    else {
      humid_state = LOW;
      Serial.println("Moisturizing OFF");
      if (dataLog) {
        dataLog.println("Moisturizing OFF");
        dataLog.println();
        dataLog.flush();
      }
      else {
        Serial.println("error opening datalog.txt");
      }
      //HUMIDIFIER OFF
    }
  }
}

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


added shift animation with ease in/out, now replicating random colors with other random colors

#include <PololuLedStrip.h>
PololuLedStrip<12> ledStrip;

#define RANDOM_SEED_PIN A1

#define EASE_EXPONENT 3 // cubic
#define EASE_COUNT 64
#define EASE_DELAY 4
#define EASE_ANIM_MARGIN 15

#define ANIM_LED_COUNT 64
#define LED_COUNT (ANIM_LED_COUNT + EASE_ANIM_MARGIN)
#define MAX_LED (LED_COUNT)
rgb_color colors[LED_COUNT];
rgb_color render[LED_COUNT];

int effects[LED_COUNT];

float ease[ANIM_LED_COUNT];

#define BRIGHTNESS_DIVISOR 15.0
#define DEFAULT_BRIGHTNESS_PERCENT 20
#define DIM_BRIGHTNESS_PERCENT (DEFAULT_BRIGHTNESS_PERCENT / 2)
#define BRIGHT_BRIGHTNESS_PERCENT (DEFAULT_BRIGHTNESS_PERCENT * 2)
#define MAX_BRIGHTNESS_PERCENT (DEFAULT_BRIGHTNESS_PERCENT * 4)

#define FADE_RATE 0.9999
#define FADE_DELAY 10
#define FADE_TIMES 40

// Standard colors
rgb_color black = {0, 0, 0};
rgb_color gray = {10, 10, 10};
rgb_color white = {20, 20, 20};
rgb_color red = {20, 0, 0};
rgb_color orange = {20, 10, 0};
rgb_color yellow = {20, 20, 0};
rgb_color ltgreen = {10, 20, 0};
rgb_color green = {0, 20, 0};
rgb_color seafoam = {0, 20, 10};
rgb_color cyan = {0, 20, 20};
rgb_color ltblue = {0, 10, 20};
rgb_color blue = {0, 0, 20};
rgb_color purple = {10, 0, 20};
rgb_color magenta = {20, 0, 20};
rgb_color pink = {20, 0, 10};
rgb_color dkgray = {5, 5, 5};

#define NPALETTE 16
#define NPRETTY_COLORS 13
rgb_color palette[NPALETTE] = { white, red, orange, yellow, ltgreen, green, seafoam, cyan, ltblue, blue, purple, magenta, pink, black, gray, dkgray };
rgb_color adjusted_palette[NPALETTE];

rgb_color scale_color(rgb_color color, float scale){
  return (rgb_color){
    ((color.red / BRIGHTNESS_DIVISOR) * 255) * scale,
    ((color.green / BRIGHTNESS_DIVISOR) * 255) * scale,
    ((color.blue / BRIGHTNESS_DIVISOR) *255) * scale
  };
}

void set_brightness(int brightness_percent = DEFAULT_BRIGHTNESS_PERCENT){
  float percent = brightness_percent / 100.0;
  for(int i = 0; i < NPALETTE; i++){
    adjusted_palette[i] = scale_color(palette[i], percent);
  }
}

//void flood(rgb_color color){
//  for(int i = 0; i < LED_COUNT; i++){
//    if(effects[i] == RANDOM)
//      colors[i]
//    colors[i] = color;
//  }
//}

void erase(bool display = false){
  for(int i = 0; i < ANIM_LED_COUNT; i++){
    colors[i] = black;
    effects[i] = 0;
  }
  if(display){
    ledStrip.write(colors, ANIM_LED_COUNT);
  }
}

rgb_color add_color(rgb_color color1, rgb_color color2){
  rgb_color new_color;
  new_color.red = min(255, color1.red + color2.red);
  new_color.green = min(255, color1.green + color2.green);
  new_color.blue = min(255, color1.blue + color2.blue);
  return new_color;
}

rgb_color subtract_color(rgb_color color1, rgb_color color2){
  rgb_color new_color;
  new_color.red = max(0, color1.red - color2.red);
  new_color.green = max(0, color1.green - color2.green);
  new_color.blue = max(0, color1.blue - color2.blue);
  return new_color;
}

void setup_colors(bool swap = true){
  if(swap == true){
    for(int i = 0; i < NPALETTE; i++){
      unsigned char value = palette[i].red;
      palette[i].red = palette[i].green;
      palette[i].green = value;
    }
  }
  memcpy(adjusted_palette, palette, sizeof(palette));
}

#define NO_EFFECT 0
#define BREATHE_ON 1
#define RANDOM 2

#define BLINK_ON 10

// blink group 1-6
#define BLINK_ON_1 11
#define BLINK_ON_2 12
#define BLINK_ON_3 13
#define BLINK_ON_4 14
#define BLINK_ON_5 15
#define BLINK_ON_6 16

// blink group a-b
#define BLINK_ON_A 21
#define BLINK_ON_B 22

#define BLINK_MIN BLINK_ON
#define BLINK_MAX BLINK_ON_B

#define STATIC_ON 101

void push_color(rgb_color color, bool display = false){
  for(int i = MAX_LED - 1; i >= 1; i--){
    colors[i] = colors[i-1];
    effects[i] = effects[i-1];
  }
  colors[0] = color;
  effects[0] = NO_EFFECT;

  if(display){
    ledStrip.write(colors, ANIM_LED_COUNT);
  }
}

#define MAX_BLINK 6000
#define BLINK_0 0
#define BLINK_1 999
#define BLINK_2 1999
#define BLINK_3 2999
#define BLINK_4 3999
#define BLINK_5 4999
#define BLINK_6 5999
#define BLINK_A BLINK_1
#define BLINK_B BLINK_4
int blink_counter = 0;
bool blink_state = true; // false means blank

// blink groups
bool blink_state_1 = true;
bool blink_state_2 = true;
bool blink_state_3 = true;
bool blink_state_4 = true;
bool blink_state_5 = true;
bool blink_state_6 = true;
bool blink_state_a = true;
bool blink_state_b = true;

void start_effect(int effect){
  effects[0] = effect;
}

void start_blinking_r(){
  effects[0] = BLINK_ON_1 + random((BLINK_ON_6 - BLINK_ON_1) + 1);
}

#define BREATHE_TIME 500
#define BREATHE_BRIGHTNESS_MAX DEFAULT_BRIGHTNESS_PERCENT
#define BREATHE_MAX_STEP 22
#define BREATHE_BRIGHTNESS_MIN 0
#define DEFAULT_BRIGHTNESS_SCALE (DEFAULT_BRIGHTNESS_PERCENT / 100.0)
#define MINIMUM_BRIGHTNESS_SCALE 0.02

int breathe_counter = 0;
int breathe_step = 0;
int breathe_direction = 1;

// ruby: (0..90).step(5).each { |i| puts (Math.cos(i * Math::PI / 180)).round(4) }
float breathe_steps[] = {
  1.0,
  0.9962,
  0.9848,
  0.9659,
  0.9397,
  0.9063,
  0.866,
  0.8192,
  0.766,
  0.7071,
  0.6428,
  0.5736,
  0.5,
  0.4226,
  0.342,
  0.2588,
  0.1736,
  0.0872,
  0.0,
  0.0,  // a few extra make it feel more natural
  0.0,
  0,0
};

void start_breathing(){
  effects[0] = BREATHE_ON;
}

void start_static(){
  effects[0] = STATIC_ON;
}

rgb_color blend_colors(rgb_color color1, rgb_color color2){
  rgb_color result;
  result.red = (color1.red + color2.red) / 2;
  result.green = (color1.green + color2.green) / 2;
  result.blue = (color1.blue + color2.blue) / 2;
  return result;
}

void do_blend(){
  colors[0] = blend_colors(colors[0], colors[1]);
  colors[1] = colors[0];
}

// only works proper used immediately after placing a standard color
void do_max(){
  colors[0] = scale_color(colors[0], MAX_BRIGHTNESS_PERCENT / 100.0);
}

void do_dim(){
  colors[0].red = colors[0].red >> 1;
  colors[0].green = colors[0].green >> 1;
  colors[0].blue = colors[0].blue >> 1;
}

void do_bright(){
  colors[0].red = colors[0].red << 1;
  colors[0].green = colors[0].green << 1;
  colors[0].blue = colors[0].blue << 1;
}

void fade(float rate = FADE_RATE){
  unsigned char *p;
  p = (unsigned char *)colors;
  for(int i = 0; i < ANIM_LED_COUNT * 3; i++){
    *(p + i) *= rate;
  }
}

void do_fade(float rate = FADE_RATE){
  for(int i = 0; i < FADE_TIMES; i++){
    fade(rate);
    ledStrip.write(colors, ANIM_LED_COUNT);
    delay(FADE_DELAY);
  }
  for(int i = 0; i < ANIM_LED_COUNT; i++){
    effects[i] = NO_EFFECT;
  }
}

void do_flood(){
  for(int i = 1; i < ANIM_LED_COUNT; i++){
    if(effects[0] == RANDOM){
      colors[i] = random_color();
    } else {
      colors[i] = colors[0];
    }
    effects[i] = effects[0];
  }
}

rgb_color random_color(){
  return palette[random(NPRETTY_COLORS)];
}

void do_random(){
  push_color(random_color());
  effects[0] = RANDOM;
}

void do_mirror(){
  for(int i = 0; i < ANIM_LED_COUNT / 2; i++){
    colors[ANIM_LED_COUNT - i - 1] = colors[i];
    effects[ANIM_LED_COUNT - i - 1] = effects[i];
  }
}

void do_repeat(int times = 1){
  for(int i = 0; i < times; i++){
    if(effects[0] == RANDOM){
      push_color(random_color());
    } else {
      push_color(colors[0]);
    }
    effects[0] = effects[1];
  }
}

void render_buffer(){
  for(int i = 0; i < ANIM_LED_COUNT; i++){
    int effect = effects[i];

    if(effect ==  STATIC_ON) colors[i] = random_color();

    if(effect >= BLINK_MIN && effect <= BLINK_MAX){
      if((effect == BLINK_ON && blink_state) ||
            (effect == BLINK_ON_1 && blink_state_1) ||
            (effect == BLINK_ON_2 && blink_state_2) ||
            (effect == BLINK_ON_3 && blink_state_3) ||
            (effect == BLINK_ON_4 && blink_state_4) ||
            (effect == BLINK_ON_5 && blink_state_5) ||
            (effect == BLINK_ON_6 && blink_state_6) ||
            (effect == BLINK_ON_A && blink_state_a) ||
            (effect == BLINK_ON_B && blink_state_b)) {
          render[i] = scale_color(colors[i], DEFAULT_BRIGHTNESS_SCALE);
        } else {
          render[i] = scale_color(colors[i], MINIMUM_BRIGHTNESS_SCALE);
        }
    }

    else if(effects[i] == BREATHE_ON) render[i] = scale_color(colors[i], DEFAULT_BRIGHTNESS_SCALE * breathe_steps[BREATHE_MAX_STEP - breathe_step]);

    else render[i] = scale_color(colors[i], DEFAULT_BRIGHTNESS_SCALE);
  }
}

void display_buffer(){
  ledStrip.write(render, ANIM_LED_COUNT);
}

bool paused = false;

void flush(){
  if(!paused){
    render_buffer();
    display_buffer();
  }
}

// Compute a random seed by sampling an unconnected analog input pin
int random_seed(){
  int seed = analogRead(RANDOM_SEED_PIN);
  for(int i = 0; i < 16; i++){
    seed = (seed << 1) ^ analogRead(0);
  }
  randomSeed(seed);
}

float ease_power_in(float percent, int power){
  return pow(percent, power);
}

float ease_power_out(float percent, int power){
  return 1 - pow(1 - percent, power);
}

float ease_elastic_out(float percent){
  return sin(-13 * M_PI_2 * (percent + 1)) * pow(2, -10 * percent) + 1;
}
// elastic in: return sin(13 * M_PI_2 * p) * pow(2, 10 * (p - 1));

void generate_power_ease(int count, int power){
  float midpoint = count / 2;
  for(int i = 0; i < midpoint; i++){
    float percent = i / midpoint;
    ease[i] = 0.5 * (ease_power_in(percent, power));
    ease[i + int(midpoint)] = (0.5 * (ease_power_out(percent, power))) + 0.5;
  }
}

// power ease in then elastic ease out
void generate_elastic_ease(int count, int power){
  float midpoint = count / 2;
  for(int i = 0; i < midpoint; i++){
    float percent = i / midpoint;
    ease[i] = 0.5 * (ease_power_in(percent, power));
    ease[i + int(midpoint)] = (0.5 * (ease_elastic_out(percent))) + 0.5;
  }
}

void shift(int count){
  for(int i = 0; i < count; i++){
    render[i] = black;
  }
  for(int i = count; i < ANIM_LED_COUNT; i++){
    render[i] = scale_color(colors[i - count], DEFAULT_BRIGHTNESS_SCALE);
  }

  ledStrip.write(render, ANIM_LED_COUNT);
}

void unshift(int count){
  for(int i = 0; i < ANIM_LED_COUNT - count; i++){
    render[i] = scale_color(colors[i + count], DEFAULT_BRIGHTNESS_SCALE);
  }

  ledStrip.write(render, ANIM_LED_COUNT);
}

void do_elastic_shift(int count){
  count = count == 0 ? 1 : count;
  if(count >= 1){
    for(int i = 0; i < EASE_COUNT; i++){
      int pos = ease[i] * count;
      delay(EASE_DELAY);
      shift(pos);
    }
    for(int i = 0; i < count; i++){
      push_color(black);
    }

//    for(int i = 0; i < ANIM_LED_COUNT; i++){
//      colors[i] = render[i];
//    }
//    for(int i = 0; i < count; i++){
//      effects[i] = NO_EFFECT;
//    }
//    for(int i = ANIM_LED_COUNT - 1; i >= count; i--){
//      effects[i] = effects[i - count];
//    }

    for(int i = 0; i < ANIM_LED_COUNT; i++){
      int index = ANIM_LED_COUNT - 1;
      if(i >= count){
        effects[index] = effects[index - count];
      } else {
        effects[index] = NO_EFFECT;
      }
    }
  } else {
//    count *= -1;
//    for(int i = 0; i < EASE_COUNT; i++){
//      int pos = ease[i] * count;
//      delay(EASE_DELAY);
//      unshift(count - pos); // broken
//    }
  }
}

void setup() {
  //Serial.begin(115200);  // open serial connection to USB Serial
                         //port(connected to your computer)
  Serial1.begin(57600);  // open internal serial connection to
                         //MT7688
  //pinMode(13, OUTPUT); // in MT7688, this maps to device

  random_seed();
  setup_colors(false);
  erase(true);
  generate_elastic_ease(EASE_COUNT, EASE_EXPONENT);
}

#define MAX_STRING_LENGTH 16

bool is_command(char *str, char *command){
  return strcmp(str, command) == 0;
}

void loop(){
  char str[MAX_STRING_LENGTH];
  char arg[MAX_STRING_LENGTH];
  rgb_color color;

  if(Serial1.available() > 0){
    int c = Serial1.readBytesUntil('|', str, MAX_STRING_LENGTH);
    str[c] = 0;

    // reset the effects so the automatic render won't interfere
    blink_state = true;
    blink_state_1 = false;
    blink_state_2 = false;
    blink_state_3 = false;
    blink_state_4 = false;
    blink_state_5 = false;
    blink_state_6 = false;
    blink_state_a = false;
    blink_state_b = false;
    blink_counter = 0;
    breathe_step = 0;
    breathe_counter = 0;

    //Serial.println(str);

// fast blink, breathe
// static, flame
// invert hue, swing hue, back and forth between two arbitrary colors, rgb cube
// rainbow colors incremental, or continuously changing
// shooting up
// push-down animation when a new build is seen (to emphasize its adding)
// fade based on build time
// change refresh rate based on time of day (afterhours it doesn't need to check that often)
// show something if the data hasn't updated in a long time
// automatically stop and restart the script at night
// show something if the data has been unchanged for some time, like after hours
// detect if the group of builds has been added to, then do an insertion animation
// after pause, allow breathing and blinking to come to a halt first
// rotation
// transitions
// if something is not recognized assume it's an argument for the next command
// copy -- everything up to black is copied on top of black
// repeat x the unrecognized argument as an integer
// stop sign timing and opposite timing
// reverse, inverse mirror
// brief flash, or something, to alert to a new (green?) build
// some way to visually tell which are changes from a little while ago (like the fading yellow highlight on web pages)
// demo - do random stuff

    if(is_command(str, "repeat")){
      int times = String(arg).toInt();
      if(times == 0) times = 1;
      do_repeat(times);
      strcpy(arg, "");
    }

    if     (is_command(str, "pause"))    paused = true;
    else if(is_command(str, "continue")) paused = false;
    else if(is_command(str, "erase"))    erase(true);
    else if(is_command(str, "blink"))    start_effect(BLINK_ON);
    else if(is_command(str, "blink1"))   start_effect(BLINK_ON_1);
    else if(is_command(str, "blink2"))   start_effect(BLINK_ON_2);
    else if(is_command(str, "blink3"))   start_effect(BLINK_ON_3);
    else if(is_command(str, "blink4"))   start_effect(BLINK_ON_4);
    else if(is_command(str, "blink5"))   start_effect(BLINK_ON_5);
    else if(is_command(str, "blink6"))   start_effect(BLINK_ON_6);
    else if(is_command(str, "blinkr"))   start_blinking_r();
    else if(is_command(str, "blinka"))   start_effect(BLINK_ON_A);
    else if(is_command(str, "blinkb"))   start_effect(BLINK_ON_B);
    else if(is_command(str, "breathe"))  start_effect(BREATHE_ON);
    else if(is_command(str, "flush"))    flush();
    else if(is_command(str, "blend"))    do_blend();
    else if(is_command(str, "max"))      do_max();
    else if(is_command(str, "dim"))      do_dim();
    else if(is_command(str, "bright"))   do_bright();
    else if(is_command(str, "fade"))     do_fade();
    else if(is_command(str, "flood"))    do_flood();
    else if(is_command(str, "random"))   do_random();
    else if(is_command(str, "mirror"))   do_mirror();
    else if(is_command(str, "eshift"))   do_elastic_shift(String(arg).toInt());
    else if(is_command(str, "static"))   start_static();
    else if(is_command(str, "red"))      push_color(red);
    else if(is_command(str, "green"))    push_color(green);
    else if(is_command(str, "blue"))     push_color(blue);
    else if(is_command(str, "black"))    push_color(black);
    else if(is_command(str, "yellow"))   push_color(yellow);
    else if(is_command(str, "orange"))   push_color(orange);
    else if(is_command(str, "purple"))   push_color(purple);
    else if(is_command(str, "cyan"))     push_color(cyan);
    else if(is_command(str, "magenta"))  push_color(magenta);
    else if(is_command(str, "pink"))     push_color(pink);
    else if(is_command(str, "white"))    push_color(white);
    else if(is_command(str, "gray"))     push_color(gray);
    else if(is_command(str, "ltgreen"))  push_color(ltgreen);
    else if(is_command(str, "seafoam"))  push_color(seafoam);
    else if(is_command(str, "ltblue"))   push_color(ltblue);
    else if(is_command(str, "dkgray"))   push_color(dkgray);
    else strcpy(arg, str);
  }
  else
  {
    bool should_flush = false;

    blink_counter = (blink_counter + 1) % MAX_BLINK;
    if(blink_counter == BLINK_0){
      if(blink_state){
        blink_state = false;
      } else {
        blink_state = true;
      }
      should_flush = true;
    }

    if(blink_counter == BLINK_1){
      blink_state_6 = false;
      blink_state_1 = true;
      blink_state_a = true;
      blink_state_b = false;
      should_flush = true;
    }

    if(blink_counter == BLINK_2){
      blink_state_1 = false;
      blink_state_2 = true;
      should_flush = true;
    }

    if(blink_counter == BLINK_3){
      blink_state_2 = false;
      blink_state_3 = true;
      should_flush = true;
    }

    if(blink_counter == BLINK_4){
      blink_state_3 = false;
      blink_state_4 = true;
      blink_state_a = false;
      blink_state_b = true;
      should_flush = true;
    }

    if(blink_counter == BLINK_5){
      blink_state_4 = false;
      blink_state_5 = true;
      should_flush = true;
    }

    if(blink_counter == BLINK_6){
      blink_state_5 = false;
      blink_state_6 = true;
      should_flush = true;
    }

    breathe_counter = (breathe_counter + 1) % BREATHE_TIME;
    if(breathe_counter == 0){
      int next_breathe_step = breathe_step + breathe_direction;
      if(next_breathe_step < 0 || next_breathe_step >= BREATHE_MAX_STEP){
        breathe_direction *= -1;
      }
      breathe_step = breathe_step + breathe_direction;
      should_flush = true;
    }

    if(should_flush){
      flush();
    }
  }
}

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


DS3231 Real Time Clock eklendi

DS3231 Real Time Clock eklendi

(modülü ilk defa çalıştırırken veya yeni pil takıldığında gerçek saati sistemden alabilmesi için arduino örneklerden Time>TimeRTCSet kodunu çalıştır)

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


Added Brake Functionality

Added Brake Functionality

#include <Servo.h>
#include <SPI.h>
#include <CmdMessenger.h>
#include <Base64.h>
#include <Streaming.h>

#define STEER_RUN 	2000
#define STEER_LUN       1000
#define STEER_TIME 	800
#define STEER_INTER_1   2 //pin 21
#define STEER_INTER_2   3 //pin 20
#define STEER_INTER_G   4 //pin 19
#define STEER_PIN	9

#define BRAKE_UNIT 	1800
#define BRAKE_TIME 	500
#define BRAKE_ON_PIN    0 //pin 2
#define BRAKE_OFF_PIN   1 //pin 3
#define BRAKE_PIN	8

#define ACCEL_UNIT 	100
#define ACCEL_MIN	1000
#define ACCEL_MAX	2000
#define SLAVE_SELECT    53

#define RELAY_STEER
#define RELAY_ACCEL     32
#define RELAY_POWER     31
#define RELAY_RAM       33
#define RELAY_DIRECTION 30

#define BAUD_RATE	115200

Servo steer;
Servo brake;

int readSpeed;
volatile int steeringAngle = 0;
int steerSetTime;
boolean forwardDirection = true;
volatile boolean brake_state = false;
int brakeSetTime;
int time;
int buf;
int intbuf;
int i = 0;
int currentSpeed = 0;

// Mustnt conflict / collide with our message payload data. Fine if we use base64 library ^^ above
char field_separator = ',';
char command_separator = ';';
CmdMessenger cmdMessenger = CmdMessenger(Serial, field_separator, command_separator);

enum
{
  kCOMM_ERROR    = 000, // Lets Arduino report serial port comm error back to the PC (only works for some comm errors)
  kACK           = 001, // Arduino acknowledges cmd was received
  kARDUINO_READY = 002, // After opening the comm port, send this cmd 02 from PC to check arduino is ready
  kERR           = 003, // Arduino reports badly formatted cmd, or cmd not recognised

  // Now we can define many more 'send' commands, coming from the arduino -> the PC, eg
  // kICE_CREAM_READY,
  // kICE_CREAM_PRICE,
  // For the above commands, we just call cmdMessenger.sendCmd() anywhere we want in our Arduino program.

  kSEND_CMDS_END, // Mustnt delete this line
};

// Commands we send from the PC and want to recieve on the Arduino.
// We must define a callback function in our Arduino program for each entry in the list below vv.
// They start at the address kSEND_CMDS_END defined ^^ above as 004
messengerCallbackFunction messengerCallbacks[] =
{
  Steering,     // 004
  Accelerate,  // 005
  Stop,         // 006
  //switchDirection, //007
  NULL
};

void arduino_ready()
{
  // In response to ping. We just send a throw-away Acknowledgement to say "im alive"
  cmdMessenger.sendCmd(kACK,"Arduino ready");
}

void unknownCmd()
{
  // Default response for unknown commands and corrupt messages
  cmdMessenger.sendCmd(kERR,"Unknown command");
}

void attach_callbacks(messengerCallbackFunction* callbacks)
{
  int i = 0;
  int offset = kSEND_CMDS_END;
  while(callbacks[i])
  {
    cmdMessenger.attach(offset+i, callbacks[i]);
    i++;
  }
}

/************************************************************/
// Steering fucntions

void steerPulse()
{
  if(time >= steerSetTime)
  {
    stopSteering();
    steerSetTime = 0;
  }
  setTime();
}

//void moveSteering(bool right)
//{
//  if(right)
//  {
//    steer.writeMicroseconds(1100);
//    cmdMessenger.sendCmd(kACK,"I send right");
//  }
//  else
//  {
//    steer.writeMicroseconds(1900);
//    cmdMessenger.sendCmd(kACK,"I send left");
//  }
//}

void stopSteering()
{
  steer.writeMicroseconds(1500);
}

void Steering()
{
  while( cmdMessenger.available())
  {
    buf = cmdMessenger.readInt();
  }
  cmdMessenger.sendCmd(kACK,"I got Steer");
  intbuf = buf & 0x7FFF;
  //intbuf = buf & 127255;      //B01111111111111111
  steerSetTime = STEER_TIME + time;

  if (steeringAngle > buf)
  {
    steer.write(2000);
    //delay(1250);
    //moveSteering(false);
    cmdMessenger.sendCmd(kACK,"I got left");
  }
  else if (steeringAngle < buf)
  {
    steer.write(1000);
    //moveSteering(true);
    cmdMessenger.sendCmd(kACK,"I got right");
  }
  steeringAngle = intbuf;
}

/************************************************************/
//Acceleration fucntions
// Accerlerate gets called by CmdMessenger and reads an int value
// to set the acceleration to. It calls formatDACommand to
// ensure a correctly formated value is passed to the DAC

void switchDirection(boolean forward)
{
//  while( cmdMessenger.available())
//  {
//    buf = cmdMessenger.readInt();
//  }
  if(forward)
  {
    stopAccel();
    forwardDirection = true;
    digitalWrite(RELAY_DIRECTION,HIGH);
  }
  else
  {
    stopAccel();
    forwardDirection = false;
    digitalWrite(RELAY_DIRECTION,LOW);
  }
}

unsigned int formatDACommand(unsigned int value)
{
  value = value<<1;
  value = value & 8190;          //B0001111111111110
  return value;
}

void setAccel(unsigned int value)
{
  //currentForwardSpeed += value;

  value = formatDACommand(value);
  digitalWrite(SLAVE_SELECT,LOW);
  SPI.transfer(value>>8);
  SPI.transfer(value);
  digitalWrite(SLAVE_SELECT,HIGH);
}

void stopAccel()
{
  readSpeed = readSpeed & 0;
  currentSpeed = 0;
  setAccel(0);
}

void Accelerate()
{
  while( cmdMessenger.available())
  {
    buf = cmdMessenger.readInt();
  }
  cmdMessenger.sendCmd(kACK,"I got Accel");
  if(buf < 0 && forwardDirection == true)
  {
    switchDirection(false);
    setAccel(-buf);
  }
  else if (buf > 0 && forwardDirection == false)
  {
    switchDirection(true);
    setAccel(buf);
  }
  else
	setAccel(abs(buf));
}

/************************************************************/
//Stop fucntions

void Stop()
{
  cmdMessenger.sendCmd(kACK,"I got Stop");
  stopAll();
}

void stopAll()
{
  stopAccel();
  stopSteering();
  if(!brake_state)
    applyBrake();
}

void brakeState()
{
  brake_state = !brake_state;
  stopBrake();
}

void stopBrake()
{
  brake.write(1500);
}

// Call applyBrake() to start the brake motor braking
// the interupt function stopBrake() will stop the motor
// when the switch on either end goes from low to high
// To release brake call applyBrake() again.
void applyBrake()
{
  if(brake_state)
    brake.write(1000);
  else
    brake.write(2000);
}

/************************************************************/
//Time fucntions

void setTime()
{
  time = millis();
}

/************************************************************/
//The Setup

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

  cmdMessenger.print_LF_CR(); //more readable comment out for real
  cmdMessenger.attach(kARDUINO_READY, arduino_ready);
  cmdMessenger.attach(unknownCmd);
  attach_callbacks(messengerCallbacks);
  arduino_ready();

  setTime();

  //Inits the Accerator stuff to change speed or resistance on the
  // maxim chip
  pinMode(SLAVE_SELECT, OUTPUT);
  SPI.setDataMode(SPI_MODE0);
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.setBitOrder(MSBFIRST);
  SPI.begin();

  steer.attach(STEER_PIN);

  attachInterrupt(BRAKE_ON_PIN, brakeState, RISING);
  attachInterrupt(BRAKE_OFF_PIN, brakeState, RISING);
  brake.attach(BRAKE_PIN);

  steer.writeMicroseconds(1500);
  brake.writeMicroseconds(1500);

  pinMode(RELAY_ACCEL,OUTPUT);
  //pinMode(RELAY_STEER,OUTPUT);
  pinMode(RELAY_POWER,OUTPUT);
  //pinMode(RELAY_RAM,OUTPUT);
  pinMode(RELAY_DIRECTION,OUTPUT);

  digitalWrite(RELAY_ACCEL,LOW);
  //digitalWrite(RELAY_STEER,LOW);
  digitalWrite(RELAY_POWER,LOW);
  //digitalWrite(RELAY_RAM,LOW);
  digitalWrite(RELAY_DIRECTION,HIGH);
}

void loop()
{
  cmdMessenger.feedinSerialData();
  steerPulse();
  brakePulse();
}

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


added the arduino code

added the arduino code

int joyPin1 = 0;                 // slider variable connecetd to analog pin 0
int joyPin2 = 1;                 // slider variable connecetd to analog pin 1
int digital = 4;

void setup() {
  Serial.begin(9600);
  pinMode(digital, INPUT);
}

void loop() {
  int value1 = analogRead(joyPin1);
  int value2 = analogRead(joyPin2);
  Serial.print(value1);
  Serial.print(",");
  Serial.print(value2);
  Serial.print(",");
  Serial.println(digitalRead(digital));
  delay(1000);

}

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


added over the air command interface to maze drone

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/manashmndl/bluebrain.git/'


Initial version of the firmware

Initial version of the firmware

#include <SoftwareSerial.h>

#define PIN_W 3
#define PIN_B 9
#define PIN_G 10
#define PIN_R 11

typedef enum {
  WHITE = 0,
  RED   = 1,
  GREEN = 2,
  BLUE  = 3
} color_t;

uint8_t colorToPin[4] = { PIN_W, PIN_R, PIN_G, PIN_B };

#define BT_KEY 8
#define BT_RX 13
#define BT_TX 12
#define BT_BAUD 9600

SoftwareSerial bt(BT_TX, BT_RX);

void setup() {
  pinMode(PIN_W, OUTPUT);
  pinMode(PIN_R, OUTPUT);
  pinMode(PIN_G, OUTPUT);
  pinMode(PIN_B, OUTPUT);

  TCCR1B &= ~(7 << CS10);
  TCCR2B &= ~(7 << CS20);

  TCCR1B |= 1;
  TCCR2B |= 1;

  digitalWrite(3, 1);
  digitalWrite(9, 1);
  digitalWrite(10, 1);
  digitalWrite(11, 1);

  Serial.begin(38400);
  bt.begin(BT_BAUD);
}

unsigned long startTime = 0;
uint8_t startColor[4] = { 0, 0, 0, 0 };

struct action {
  uint16_t fadeTime;
  uint8_t color[4];
} action[2];

int8_t actionIndex = 0;

void loop() {
  doAction();
  readAction();
}

void doAction() {
  static int8_t doing = 0;
  if(doing == 1) {
    unsigned long t = millis() - startTime;
    if(action[0].fadeTime == 0 || t >= action[0].fadeTime) {
      doing = 0;
      for(int i = 0; i < 4; i++) {
        analogWrite(colorToPin[i], 255 - action[0].color[i]);
        startColor[i] = action[0].color[i];
      }
      actionIndex = 0;
    } else {
      for(int i = 0; i < 4; i++) {
        analogWrite(colorToPin[i], 255 - (startColor[i] + ((action[0].color[i] - startColor[i]) * t) / action[0].fadeTime));
      }
    }
  } else if(actionIndex == 1) {
    startTime = millis();
    doing = 1;
  }
}

void readAction() {
  static int index = 0;
  while(bt.available()) {
    char c = bt.read();
    bt.write(c);
    if(c == '\r') {
      bt.write('\n');
      if(index == sizeof(action[0]) * 2) {
        bt.write(":D\r\n");
        actionIndex++;
      } else {
        bt.write(":(\r\n");
      }
      index = 0;
      continue;
    } else {
      if(c >= '0' && c <= '9') {
        c -= '0';
      } else if(c >= 'A' && c <= 'F') {
        c -= 'A' - 10;
      } else {
        continue;
      }
    }
    switch(index) {
      case 0: action[actionIndex].fadeTime  = c << 12; break;
      case 1: action[actionIndex].fadeTime |= c <<  8; break;
      case 2: action[actionIndex].fadeTime |= c <<  4; break;
      case 3: action[actionIndex].fadeTime |= c; break;
      case 4: case 6: case 8: case 10:
              action[actionIndex].color[index/2 - 2] =  c << 4; break;
      case 5: case 7: case 9: case 11:
              action[actionIndex].color[index/2 - 2] |= c; break;
    }
    index++;
  }
}

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


Testing frequency setting spped

Testing frequency setting spped

// si5351-speedtest.ino

#include <Wire.h>
#include <si5351.h>

#define TWI_SPEED 400000L

si5351 si;

void setup()
{
	Serial.begin(9600);
	Serial.println("SI5351 Speed test");

	Wire.begin();

	TWBR = ((F_CPU / TWI_SPEED) - 16) >> 1;								// Set I2C speed to 400kHz

	si.begin();
	si.set_xtal(27000000, -9);											// XTAL = 27.000 MHz with -9ppm correction
	si.pll_integer_config(PLL_A, 30);									// PLL_A = 30 * XTAL
	si.clk_config(CLK0, (SRC_PLL << CLKx_SRC) | (IDRV_8 << CLKx_IDRV)); // CLK0 powerd up, fractional mode, MultiSynth0, PLL A, not inverted, 8mA drive
	si.set_phase(CLK0, 0);												// no phase offset for CLK0
	si.clk_enable(CLK0);												// enable CLK0 output

	uint32_t timer_start, timer_stop;
	uint32_t i;

	Serial.println();
	Serial.println("Performing 10000 iterations of set_frequency()");

	timer_start = micros();
	for(i=0;i<10000;i++)
		si.set_frequency(CLK0,14285000+i);
	timer_stop = micros();

	Serial.print("Duration: ");
	Serial.print(timer_stop - timer_start);
	Serial.println(" us");
	Serial.print("Average per call: ");
	Serial.print((float)(timer_stop - timer_start)/10000);
	Serial.println(" us");

	Serial.println();
	Serial.println("Performing 10000 iterations of simple_set_frequency()");

	timer_start = micros();
	for(i=0;i<10000;i++)
		si.simple_set_frequency(CLK0,14285000+i);
	timer_stop = micros();

	Serial.print("Duration: ");
	Serial.print(timer_stop - timer_start);
	Serial.println(" us");
	Serial.print("Average per call: ");
	Serial.print((float)(timer_stop - timer_start)/10000);
	Serial.println(" us");
}

void loop()
{
}

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


skp 08

skp 08

const int switchPin = 8;
unsigned long previousTime = 0;
int led = 2;
long interval = 3000; //3 secondi

void setup() {
  for (int x = 2; x < 8; x++) {
    pinMode(x, OUTPUT);
  }
  pinMode(switchPin, INPUT);
}

void loop() {
  unsigned long currentTime = millis();

  //solo se tengo premuto pulsante
  if (digitalRead(switchPin) == HIGH) {
    if (currentTime - previousTime > interval) {
      previousTime = currentTime;
      digitalWrite(led, HIGH);
      led ++;
      if (led == 8) {
        //clessidra FINITA. Lampeggio
        for (int y = 1; y < 4; y++) {
          for (int x = 2; x < 8; x++) {
            digitalWrite(x, HIGH);
          }
          delay(1000);
          for (int x = 2; x < 8; x++) {
            digitalWrite(x, LOW);
          }
          delay(1000);
        }
        led = 2;
        previousTime = currentTime;
      }
    }
  } else {
    //spengo tutto
    for (int x = 2; x < 8; x++) {
      digitalWrite(x, LOW);
    }
    led = 2;
    previousTime = currentTime;
  }
}

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


fix bug in watchlights() time comparison

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/cwilkens/helioscope-lamp.git/'


JL & LG: Adding the main aquario.ino file

// Aquario
// DS3231 Library Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/

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

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

// Define OneWire pin
#define ONE_WIRE_BUS 8

// Init OneWire
OneWire oneWire(ONE_WIRE_BUS);

// Pass OneWire to DallasTemp
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

// Init a Time-data structure
Time  t;

// Define Relay Digital I/O pin number
#define RELAY_ON 1
#define RELAY_OFF 0

#define Relay_1  2
#define Relay_2  3
#define Relay_3  4
#define Relay_4  5

// set temp
float temp = 30;

// set upper temp variance
float upperTempVariance = 2;

// set lower temp variance
float lowerTempVariance = 5;

int waittime; // Delay between changes

void tempSensorsSetup() {
  // Start up the DallasTemp library
  sensors.begin();

  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");
}

float getSetTemp() {
  return temp;
}

void setSetTemp(float temp) {
  temp = temp;
}

float getUpperTempVariance() {
  return upperTempVariance;
}

void setUpperTempVariance(float upperTempVariance) {
  upperTempVariance = upperTempVariance;
}

float getLowerTempVariance() {
  return lowerTempVariance;
}

void setLowerTempVariance(float lowerTempVariance) {
  lowerTempVariance = lowerTempVariance;
}

// declare upperTempLimit and lowerTempLimit
float upperTempLimit = getSetTemp() + getUpperTempVariance();
float lowerTempLimit = getSetTemp() - getLowerTempVariance();

void setup() {
  // Setup Serial connection
  Serial.begin(9600);

  // Initialize the rtc object
  rtc.begin();

  // The following lines can be uncommented to set the date and time
  //rtc.setDOW(WEDNESDAY);     // Set Day-of-Week to SUNDAY
  rtc.setTime(10, 0, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(1, 1, 2014);   // Set the date to January 1st, 2014

  waittime = 100;
//-------( Initialize Pins so relays are inactive at reset)----
  digitalWrite(Relay_1, RELAY_OFF);
  digitalWrite(Relay_2, RELAY_OFF);
  digitalWrite(Relay_3, RELAY_OFF);
  digitalWrite(Relay_4, RELAY_OFF);

//set digital pins as outputs
  pinMode(Relay_1, OUTPUT);
  pinMode(Relay_2, OUTPUT);
  pinMode(Relay_3, OUTPUT);
  pinMode(Relay_4, OUTPUT);
  delay(4000); //Check that all relays are inactive at

  // temp setup
  tempSensorsSetup();
}

void loop() {
  // Get data from the DS3231
  t = rtc.getTime();

 /* // Send date over serial connection
  Serial.print("Today is the ");
  Serial.print(t.date, DEC);
  Serial.print(". day of ");
  Serial.print(rtc.getMonthStr());
  Serial.print(" in the year ");
  Serial.print(t.year, DEC);
  Serial.println(".");

  // Send Day-of-Week and time
  Serial.print("It is the ");
  Serial.print(t.dow, DEC);
  Serial.print(". day of the week (counting monday as the 1th), and it has passed ");
  Serial.print(t.hour, DEC);
  Serial.print(" hour(s), ");
  Serial.print(t.min, DEC);
  Serial.print(" minute(s) and ");
  Serial.print(t.sec, DEC);
  Serial.println(" second(s) since midnight.");

  // Send a divider for readability
  Serial.println("  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -");*/

//  // Send Day-of-Week
//  Serial.print(rtc.getDOWStr());
//  Serial.print(" ");
//
//  // Send date
//  Serial.print(rtc.getDateStr());
//  Serial.print(" -- ");
//
//  // Send time
//  Serial.println(rtc.getTimeStr());
//
//if(t.hour == 10 && t.min == 00 && t.sec == 15) {
//  turnRelayOnAndOff(Relay_1);
//}
//
//if(t.hour == 10 && t.min == 00 && t.sec == 30) {
//  turnRelayOnAndOff(Relay_2);
//}
//
//if(t.hour == 10 && t.min == 00 && t.sec == 45) {
//  turnRelayOnAndOff(Relay_3);
//}
//
//if(t.hour == 10 && t.min == 01 && t.sec == 00) {
//  turnRelayOnAndOff(Relay_4);
//}

  // Wait one second before repeating :)
  delay (1000);

  // Method 1:
  // check each address individually for an alarm condition
  checkTemp(insideThermometer);

}

void checkTemp(DeviceAddress deviceAddress) {
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println(sensors.getTempCByIndex(0));
  if (sensors.getTempCByIndex(0) >= upperTempLimit) {
    Serial.print("ALARM!! turning relay off: ");
    turnRelayOff(Relay_1, "Heater relay");
  } else if (sensors.getTempCByIndex(0) <= lowerTempLimit) {
    Serial.print("ALARM!! turning relay on: ");
    turnRelayOn(Relay_1, "Heater relay");
  }
}

void turnRelayOn(int relay_num, String relay_name) {
  Serial.print(relay_name + " ON");
  Serial.println("");
  digitalWrite(relay_num, RELAY_ON);// set the Relay ON
}

void turnRelayOff(int relay_num, String relay_name) {
  digitalWrite(relay_num, RELAY_OFF);// set the Relay OFF
  Serial.print(relay_name + " OFF");
  Serial.println("");
}

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


Add Send Values example

Add Send Values example

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

#define TOKEN "your token here"

TheThings thing(TOKEN);

void setup() {
    // Start Serial for debugging on the Serial Monitor
    Serial.begin(9600);

    // Start Ethernet on Arduino
    startEthernet();
}

void loop() {
    Ethernet.maintain();

    delay(1000);
    thing.addValue("A0", "ON");
    thing.send();
    delay(1000);
    thing.addValue("A0", "OFF");
    thing.send();
}

void startEthernet() {
    Serial.println("Connecting Arduino to network...");

    // Local Network Settings
    byte mac[] = { 0xD4, 0x28, 0xB2, 0xFF, 0xA0, 0xA1 }; // Must be unique on local network

    // Connect to network amd obtain an IP address using DHCP
    while (Ethernet.begin(mac) == 0)
        Serial.println("DHCP Failed, retrying");
    Serial.println("Arduino connected to network using DHCP");
}

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


Added a timer that should prevent the compressor starting within 5 mins from last shutdown

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/fbatta/wbox-nodejs.git/'


Added a simple spi_in example for future ref

#include <SPI.h>

////Pin connected to DS of 74HC595
const int dataPin = 12;
const int clockPin = 13;
const int latchPin = 10;

byte stat;
byte stat2;

byte shiftInSPI() {
    SPI.begin();
    //set clockDivider to SPI_CLOCK_DIV2 by default which is 8MHz
    const int clockDivider = SPI_CLOCK_DIV8;
    SPI.setClockDivider(clockDivider);

    //set data mode to SPI_MODE0 by default
    const int dataMode = SPI_MODE0;
    SPI.setDataMode(dataMode);

    //set bitOrder to MSBFIRST by default
    const int bitOrder = MSBFIRST;
    SPI.setBitOrder(bitOrder);

    byte input = SPI.transfer(0x00);

    SPI.end();

    return input;
}

byte shiftIn() {
  digitalWrite(latchPin, LOW);    // Switch to parallel mode: digital inputs are read into shift register
  delayMicroseconds(10);
  digitalWrite(latchPin, HIGH);   // Switch to serial mode: one data bit is output on each clock falling edge

  byte result;

  for(int i = 0; i < 8; ++i) {           // Iteration over both 8 bit registers
    digitalWrite(clockPin, LOW);         // Generate clock falling edge
    delayMicroseconds(10);

    int r = digitalRead(dataPin);
    if (r) result |= (1 << i);
    digitalWrite(clockPin, HIGH);        // Generate clock rising edge
    delayMicroseconds(10);
  }

  for(int i = 0; i < 8; ++i) {           // Iteration over both 8 bit registers
    digitalWrite(clockPin, LOW);         // Generate clock falling edge
    delayMicroseconds(10);

    int r = digitalRead(dataPin);
    if (r) result |= (1 << i);
    digitalWrite(clockPin, HIGH);        // Generate clock rising edge
    delayMicroseconds(10);
  }
  return result;
}

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, INPUT);

  stat = 0;
  stat2 = 0;

  Serial.begin(9600);
}

void loop() {
  digitalWrite(latchPin, LOW);
  delayMicroseconds(10);
  digitalWrite(latchPin, HIGH);
  delayMicroseconds(10);

  digitalWrite(latchPin, LOW);    // Switch to parallel mode: digital inputs are read into shift register
  delayMicroseconds(10);
  digitalWrite(latchPin, HIGH);
  stat = shiftInSPI();
  stat |= shiftInSPI();

  //stat = shiftIn();
  //stat2 = shiftIn();

  if (stat != 0) {
    Serial.println(stat);
  }
  /*(if (stat2 != 0) {
    Serial.println(stat2);
  }*/

  delay(100);
  //Serial.print('x');
}

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


Added ColorTemperature example demo

Added ColorTemperature example demo

#include <FastLED.h>

#define LED_PIN     3

// Information about the LED strip itself
#define NUM_LEDS    60
#define CHIPSET     WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define BRIGHTNESS  128

// FastLED v2.1 provides two color-management controls:
//   (1) color correction settings for each LED strip, and
//   (2) master control of the overall output 'color temperature'
//
// THIS EXAMPLE demonstrates the second, "color temperature" control.
// It shows a simple rainbow animation first with one temperature profile,
// and a few seconds later, with a different temperature profile.
//
// The first pixel of the strip will show the color temperature.
//
// HELPFUL HINTS for "seeing" the effect in this demo:
// * Don't look directly at the LED pixels.  Shine the LEDs aganst
//   a white wall, table, or piece of paper, and look at the reflected light.
//
// * If you watch it for a bit, and then walk away, and then come back
//   to it, you'll probably be able to "see" whether it's currently using
//   the 'redder' or the 'bluer' temperature profile, even not counting
//   the lowest 'indicator' pixel.
//
//
// FastLED provides these pre-conigured incandescent color profiles:
//     Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc,
//     HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky,
// FastLED provides these pre-configured gaseous-light color profiles:
//     WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent,
//     FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent,
//     MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium,
// FastLED also provides an "Uncorrected temperature" profile
//    UncorrectedTemperature;

#define TEMPERATURE_1 Tungsten100W
#define TEMPERATURE_2 OvercastSky

// How many seconds to show each temperature before switching
#define DISPLAYTIME 20
// How many seconds to show black between switches
#define BLACKTIME   3

void loop()
{
  // draw a generic, no-name rainbow
  static uint8_t starthue = 0;
  fill_rainbow( leds + 5, NUM_LEDS - 5, --starthue, 20);

  // Choose which 'color temperature' profile to enable.
  uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2);
  if( secs < DISPLAYTIME) {
    FastLED.setTemperature( TEMPERATURE_1 ); // first temperature
    leds[0] = TEMPERATURE_1; // show indicator pixel
  } else {
    FastLED.setTemperature( TEMPERATURE_2 ); // second temperature
    leds[0] = TEMPERATURE_2; // show indicator pixel
  }

  // Black out the LEDs for a few secnds between color changes
  // to let the eyes and brains adjust
  if( (secs % DISPLAYTIME) < BLACKTIME) {
    memset8( leds, 0, NUM_LEDS * sizeof(CRGB));
  }

  FastLED.show();
  FastLED.delay(8);
}

void setup() {
  delay( 3000 ); // power-up safety delay
  // It's important to set the color correction for your LED strip here,
  // so that colors can be more accurately rendered through the 'temperature' profiles
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalSMD5050 );
  FastLED.setBrightness( BRIGHTNESS );
}

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


Added files via upload

Added files via upload

//Comunicacion i2c
//1-manager
//2 diana inferior izqda 3 diana inferior central 4 diana inferior dcha
//5 diana superior medio 6 diana superior alta

#include <Wire.h>

String inSerial;
const int buttonPinStop = 2;
const int buttonPinStart = 3;
const int ledPin =  13;      // the number of the LED pin
int buttonState = 0;
int inByte;
char MessageReceived;
int Shoots = 0;
String texto;
String SerialString;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  pinMode(ledPin, OUTPUT);
  pinMode(buttonPinStop, INPUT);
  pinMode(buttonPinStart, INPUT);
  Wire.begin(1); // join i2c bus (address optional for master)
  Wire.onReceive(receiveEvent); // register event

}

void loop() {

  buttonState = digitalRead(buttonPinStart);

  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);

    // Now listen on the second port

    Serial.println("Comienza Partida");
    Wire.beginTransmission(2); // transmit to device #0 means broadcast
    Wire.write("go");
    Wire.endTransmission();    // stop transmitting

    Wire.beginTransmission(3);
    Wire.write("go");
    Wire.endTransmission();

       Wire.beginTransmission(4);
    Wire.write("go");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("go");
    Wire.endTransmission();

    Wire.beginTransmission(6);
    Wire.write("go");
    Wire.endTransmission();
    delay (500);

  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }

  buttonState = digitalRead(buttonPinStop);

  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);

    Wire.beginTransmission(2);
    Wire.write("end");
    Wire.endTransmission();

    Wire.beginTransmission(3);
    Wire.write("end");
    Wire.endTransmission();

        Wire.beginTransmission(4);
    Wire.write("end");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("end");
    Wire.endTransmission();

        Wire.beginTransmission(6);
    Wire.write("end");
    Wire.endTransmission();
    delay (500);
    Shoots = 0;

  }
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }

  if (texto != "")
  {
    Serial.println (texto);
    texto = "";

  }

  getSerialData ();
    WorkWithReceivedData ();

    SerialString = "";

  // int x = Wire.read();    // receive byte as an integer
  //  Serial.println(x);         // print the integer

}

void receiveEvent(int howMany) {
  while ( Wire.available()) { // loop through all but the last
    char c = Wire.read(); // receive byte as a character
    texto = texto + c;
    //Serial.print(c);         // print the character

  }

}

void getSerialData ()
{

  while (Serial.available())
  {
    delay(3);  //delay to allow buffer to fill

    if (Serial.available() > 0) {
      char c = Serial.read();  //gets one byte from serial buffer
      //Serial.print (c); //makes the string readString
      SerialString += c;

    }

  }

}
void WorkWithReceivedData ()
{

  if ((SerialString[0] == '1'))
  {
    Wire.beginTransmission(2); // transmit to device #0 means broadcast
    Wire.write("go");
    Wire.endTransmission();    // stop transmitting

    Wire.beginTransmission(3);
    Wire.write("go");
    Wire.endTransmission();

        Wire.beginTransmission(4);
    Wire.write("go");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("go");
    Wire.endTransmission();

        Wire.beginTransmission(6);
    Wire.write("go");
    Wire.endTransmission();
    delay (500);
  }
  if ((SerialString[0] == '2'))
  {
    Wire.beginTransmission(2); // transmit to device #0 means broadcast
    Wire.write("end");
    Wire.endTransmission();    // stop transmitting

    Wire.beginTransmission(3);
    Wire.write("end");
    Wire.endTransmission();

        Wire.beginTransmission(4);
    Wire.write("end");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("end");
    Wire.endTransmission();

        Wire.beginTransmission(6);
    Wire.write("end");
    Wire.endTransmission();
    delay (500);
  }
  if ((SerialString[0] == '3'))
  {
    Wire.beginTransmission(2); // transmit to device #0 means broadcast
    Wire.write("gup");
    Wire.endTransmission();    // stop transmitting

    Wire.beginTransmission(3);
    Wire.write("gup");
    Wire.endTransmission();

        Wire.beginTransmission(4);
    Wire.write("gup");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("gup");
    Wire.endTransmission();

        Wire.beginTransmission(6);
    Wire.write("gup");
    Wire.endTransmission();
    delay (500);
  }
  if ((SerialString[0] == '4'))
  {
    Wire.beginTransmission(2); // transmit to device #0 means broadcast
    Wire.write("gdo");
    Wire.endTransmission();    // stop transmitting

    Wire.beginTransmission(3);
    Wire.write("gdo");
    Wire.endTransmission();

        Wire.beginTransmission(4);
    Wire.write("gdo");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("gdo");
    Wire.endTransmission();

       Wire.beginTransmission(6);
    Wire.write("gdo");
    Wire.endTransmission();
    delay (500);
  }
  if ((SerialString[0] == '5'))
  {
    Wire.beginTransmission(2); // transmit to device #0 means broadcast
    Wire.write("gme");
    Wire.endTransmission();    // stop transmitting

    Wire.beginTransmission(3);
    Wire.write("gme");
    Wire.endTransmission();

        Wire.beginTransmission(4);
    Wire.write("gme");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("gme");
    Wire.endTransmission();

       Wire.beginTransmission(6);
    Wire.write("gme");
    Wire.endTransmission();
    delay (500);
  }
  if ((SerialString[0] == '6'))
  {
    Wire.beginTransmission(2); // transmit to device #0 means broadcast
    Wire.write("rst");
    Wire.endTransmission();    // stop transmitting

    Wire.beginTransmission(3);
    Wire.write("rst");
    Wire.endTransmission();

        Wire.beginTransmission(4);
    Wire.write("rst");
    Wire.endTransmission();

    Wire.beginTransmission(5);
    Wire.write("rst");
    Wire.endTransmission();

        Wire.beginTransmission(6);
    Wire.write("rst");
    Wire.endTransmission();
    delay (500);
  }
}

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


better command parsing

better command parsing

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


BME280 raw & compensated ADC values are good


ready for tmr leaderboard

ready for tmr leaderboard

exploration use IR sensor to turn/src/main.ino

error: pathspec 'exploration' did not match any file(s) known to git
error: pathspec 'use' did not match any file(s) known to git
error: pathspec 'IR' did not match any file(s) known to git
error: pathspec 'sensor' did not match any file(s) known to git
error: pathspec 'to' did not match any file(s) known to git
error: pathspec 'turn/src/main.ino' did not match any file(s) known to git


tests: add basic peripherals sketch

tests: add basic peripherals sketch

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

void loop() {
  Bean.getAcceleration();
  Bean.setLed(0, 255, 255);
}

error: pathspec 'tests/resources/test_sketches/basic_peripherals.ino' did not match any file(s) known to git


Add Serial1 example

Add Serial1 example

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/neojou/arduino-ameba.git/'


ESP8266 Blink example for the blue LED on the ESP-01 module

/*
 ESP8266 Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain
*/

const int ledPin =  1;         // The blue LED on the ESP-01 module is connected to GPIO1
                               // (which is also the TXD pin; so we cannot use
                               // Serial.print() at the same time

void setup() {
  pinMode(ledPin, OUTPUT);     // Initialize the ledPin as an output
  ESP.wdtDisable();            // Disable the watchdog timer built into the ESP8266
                               // otherwise the ESP8266 reboots during the "delay(1000);"
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(ledPin, LOW);   // turn the LED on (Note that LOW is the voltage level
                               // but actually the LED is on; this is because
                               // it is acive low on the ESP-01)
  delay(1000);                 // Wait for a second
  digitalWrite(ledPin, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                 // Wait for two seconds (to demonstrate the active low LED)
}

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


Delete explorer-robot-v2.ino

Delete explorer-robot-v2.ino

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


I think this works. Going to test now.

I think this works. Going to test now.

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


Modified a bit during testing. Now looking at output and measured (oscilloscope) data...


Create web-stepper.ino

Create web-stepper.ino

Particle sketch for browser control of stepper motor.

//////////////////////////////////////////////////
// Spice machine stepper motor web control v1.0 //
//////////////////////////////////////////////////

// Justin Ashton
// (c) J. Ashton & Company, Inc., 2016
//
// Hardware setup: Particle Photon, Easy Driver v4.5, NEMA 17, 12v power
//
// This sketch is designed to be controlled by the file:
// "spice machine web control v1.0.hmtl". Please make sure to
// update your Photon keys and access token in the html file.

int steps = 0;
int dly = 1000; //default delay in uSecs for speed control
int rotateSteps(String numSteps);
int changeDelay(String newDelay);

//Declare pin mapping
int dir = D0;
int stp = D1;

void setup()
{
  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
  digitalWrite(dir, LOW);
  digitalWrite(stp, LOW);
  Serial.begin(9600); //Open Serial connection for debugging
  Serial.println("Starting up the Spice Machine web control...");
  Serial.println();
  Particle.function("numsteps", rotateSteps); //cloud function to update then drive # steps
  Particle.function("uSecsDelay", changeDelay); //cloud function to update delay (rot speed)

}

void loop()
{
}

int rotateSteps(String numSteps)
{
    steps = numSteps.toInt();
    Serial.print("updated steps: ");
    Serial.println(steps);
    if(steps > 0 && steps < 6401){
        for(int i=0; i < steps; i++){
            digitalWrite(stp, HIGH);
            delayMicroseconds(dly);
            digitalWrite(stp, LOW);
            delayMicroseconds(dly);
            }
            return 1;
            } else {
                Serial.println("Steps out of range 1-6400");
                return -1;
                }
}

int changeDelay(String newDelay)
{
    int temp = newDelay.toInt();
    Serial.print("updated delay: ");
    Serial.println(temp);
    if(temp > 99 && temp < 1001){
        dly = temp;
        return 1;
    } else {
        Serial.println("Delay out of range 100-1000 microSecs");
        return -1;

    }

}

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


Created Arduino control code

Created Arduino control code

Authored code to detect states from the RC controller. This will be
read in using I2C from the Raspberry Pi.

#define uint  unsigned int
#define ulong unsigned long
#include <Servo.h>
#include <EEPROM.h>
#include <Wire.h>

#include <math.h>

#define PIN_SWITCH      2     // Digital 2
#define PIN_SERVO       3     // Digital 3
#define PIN_WINCH       4     // Digital 4

int switchSignal;
int servoSignal;
int winchSignal;

//=======================================================
// Initialize
//=======================================================
void setup() {
    Serial.begin(9600);
    Wire.begin(2); // Join i2c bus with address #2
    Wire.onRequest(requestEvent); // Register event
    Wire.onReceive(receiveEvent); // Register event
}

//=======================================================
// Main loop.
//=======================================================
void loop() {

    // 20 reads per second
    delay(50);

    switchSignal = readPulse(PIN_SWITCH);
    servoSignal = readPulse(PIN_SERVO);
    winchSignal = readPulse(PIN_WINCH);
}

int readPulse(int pin) {
    return pulseIn(pin, HIGH);
}

// Data to send to I2C Master
void requestEvent() {
    static uint8_t buff[1];
    buff[0] = switchSignal;
    buff[1] = servoSignal;
    buff[2] = winchSignal;
    Wire.write(buff, 3); // Respond with message of 6 bytes as expected by master

    /*
    Serial.println(switchSignal);
    Serial.println(servoSignal);
    Serial.println(winchSignal);
    */
}

// Data to receive from I2C Master
void receiveEvent(int howMany) {
    int b;
    while (Wire.available() > 0) {
        b = Wire.read();
        Serial.println(b);
    }
}

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


Sumobot initial

Sumobot initial

#include <Servo.h>

Servo Rservo; // create servo object to control a Right servo
Servo Lservo; // create servo object to control a Left servo
Servo ScanHead; // create servo object to control a ScanHead servo
int HeadPos; // Variable for holding scan head position
int HeadAdj; // Variable for holding scan head changes

void setup() {
    delay(3000); // Chunk of time to let go of the bot
    Rservo.attach(0); // attaches the servo on pin 0 to the servo object
    Lservo.attach(1); // attaches the servo on pin 1 to the servo object
    ScanHead.attach(12); // attaches the servo on pin 12 to the servo object
    Serial.begin(9600); // initialize serial communication at 9600 bits per second:
    HeadPos = 1500; //Start Scan head in the middle
    HeadAdj = 25; // Set the scan speed
}

void loop() {
    if (HeadPos < 1000) // Set the far left position
    {
        HeadAdj = 25; // Determines speed and direction of Scanhead rotation
    }
    if (HeadPos > 1900) // Set the far right position
    {
        HeadAdj = -25; // Determines speed and direction of Scanhead rotation
    }
    HeadPos = HeadPos + HeadAdj; //Set the scan head position
    ScanHead.write(HeadPos); // move the Scan Head

    int senValue0 = analogRead(A0); // read the input on analog pin 0:
    Serial.print("Sen1 = ");
    Serial.println(senValue0);
    int LsenValue = analogRead(A1); // read the input on analog pin 1:
    Serial.print("L Sen = ");
    Serial.println(LsenValue);
    int RsenValue = analogRead(A2); // read the input on analog pin 2:
    Serial.print("R Sen = ");
    Serial.println(RsenValue);

    // Turn to face opponent if to one side
    if (HeadPos < 1200) {
        if (senValue0 > 350) //Set the distance..bigger is closer
        {
            for (int dur = 10; dur >= 2; dur--) // set the distance the robot turns
            {
                Rservo.writeMicroseconds(1000); // sets the servo position to 1ms
                Lservo.writeMicroseconds(1000); // sets the servo position to 1ms
                delay(10);
            }
        }
    }
    // Turn to face opponent if to the other side
    if (HeadPos > 1700) {
        if (senValue0 > 350) //Set the distance..bigger is closer
        {
            for (int dur = 10; dur >= 2; dur--) {
                Rservo.writeMicroseconds(2000); // sets the servo position to 2ms
                Lservo.writeMicroseconds(2000); // sets the servo position to 2ms
                delay(10);
            }
        }
    }

    if (LsenValue < 500) //go forward if on white
    {
        Rservo.writeMicroseconds(1000); // sets the servo position to 1ms
        Lservo.writeMicroseconds(2000); // sets the servo position to 2ms
        delay(10);
    }
    if (RsenValue < 500) //go forward if on white
    {
        Rservo.writeMicroseconds(1000); // sets the servo position to 1ms
        Lservo.writeMicroseconds(2000); // sets the servo position to 2ms
        delay(10);
    }

    if (LsenValue > 500) //turn away if on black
    {
        for (int dur = 50; dur >= 2; dur--) {
            Rservo.writeMicroseconds(2000); // sets the servo position to 1ms
            Lservo.writeMicroseconds(2000); // sets the servo position to 2ms
            delay(10);
        }
    }
    if (RsenValue > 500) //turn away if on black
    {
        for (int dur = 30; dur >= 2; dur--) {
            Rservo.writeMicroseconds(1000); // sets the servo position to 1ms
            Lservo.writeMicroseconds(1000); // sets the servo position to 2ms
            delay(10);
        }
    }

}

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


Ejemplo con background

Ejemplo con background

// scrolltext demo for Adafruit RGBmatrixPanel library.
// Demonstrates double-buffered animation on our 16x32 RGB LED matrix:
// http://www.adafruit.com/products/420

// Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
// for Adafruit Industries.
// BSD license, all text above must be included in any redistribution.

#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library

// Similar to F(), but for PROGMEM string pointers rather than literals
#define F2(progmem_ptr) (const __FlashStringHelper *)progmem_ptr

#define CLK 11  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A   A0
#define B   A1
#define C   A2
// Last parameter = 'true' enables double-buffering, for flicker-free,
// buttery smooth animation.  Note that NOTHING WILL SHOW ON THE DISPLAY
// until the first call to swapBuffers().  This is normal.
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true);
// Double-buffered mode consumes nearly all the RAM available on the
// Arduino Uno -- only a handful of free bytes remain.  Even the
// following string needs to go in PROGMEM:

//char str[] PROGMEM = "Adafruit 16x32 RGB LED Matrix";
int  textX   = matrix.width();
int  textMin = 0 * -12;
int  hue     = 0;

char string0[50];
//char string1[8];
int posicion=0;
int posicion2=0;
int borrar=0;
int fila=0;

int velocity=1;

int8_t ball[3][4] = {
  {  3,  0,  1,  1 }, // Initial X,Y pos & velocity for 3 bouncy balls
  { 17, 15,  1, -1 },
  { 27,  4, -1,  1 }
};
static const uint16_t PROGMEM ballcolor[3] = {
  0x0080, // Green=1
  0x0002, // Blue=1
  0x1000  // Red=1
};

void setup() {
  matrix.begin();
  matrix.setTextWrap(false); // Allow text to run off right edge
  matrix.setTextSize(2);
  Serial.begin(14400);
}

void loop() {
  byte i;

  matrix.fillScreen(0);

  // Bounce three balls around
  for(i=0; i<3; i++) {
    // Draw 'ball'
    matrix.fillCircle(ball[i][0], ball[i][1], 5, pgm_read_word(&ballcolor[i]));
    // Update X, Y position
    ball[i][0] += ball[i][2];
    ball[i][1] += ball[i][3];
    // Bounce off edges
    if((ball[i][0] == 0) || (ball[i][0] == (matrix.width() - 1)))
      ball[i][2] *= -1;
    if((ball[i][1] == 0) || (ball[i][1] == (matrix.height() - 1)))
      ball[i][3] *= -1;
  }

  if (Serial.available()){
    int incomingByte = Serial.read();

    if(incomingByte == '\n') {
        // ------
    }else if(incomingByte == '#') {
      matrix.fillScreen(0);
      borrar=1;
      posicion=0;
    }else{
      borrar=0;
      string0[posicion++]=(char)incomingByte;
    }
  }

 if(borrar==1){
   matrix.fillScreen(0);
 }

 for(int j=0;j<posicion;j++){
   matrix.print(string0[j]);
 }

  textMin =  posicion * -12;
  Serial.print(textX);
  Serial.print(" <=> ");
  Serial.println(textMin);

  if((--textX) < textMin) textX = matrix.width();

  matrix.setCursor(textX, 1);
  matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));
  hue += 7;
  if(hue >= 1536) hue -= 1536;
  delay(10);

  // Update display
  matrix.swapBuffers(false);
}

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


setting gpio via javascript

setting gpio via javascript

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/zikalino/droplet-x1.git/'


nie pamientam

nie pamientam

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


Add BLE Link example

Add BLE Link example

/**************************************************************
 *
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social groups:              http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to use The AirBoard + BLE-Link
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 * 1. plug in the BLE-Link shield to your AirBoard and
 *    the USB BLE-Link dongle to your computer
 *
 * 2. Optional, but recommended.
 *    Connect additional USB-serial adapter to see the prints.
 *
 * 3. Edit auth token and upload this sketch.
 *
 * 4. Run the script (script located in "scripts" folder of library root,
 *    e.g. 'blynk-library/scripts') for redirecting traffic to server:
 *
 *      for Windows:         scripts/blynk-ser.bat
 *      for Linux and OSX:   ./scripts/blynk-ser.sh (may need to run with sudo)
 *
 *    You can specify port, baud rate, and server endpoint like this
 *    (you may skip server parameters when running local):
 *      ./blynk-ser.sh -c <serial port> -b <baud rate> -s <server address> -p <server port>
 *
 *    For instance :
 *      ./blynk-ser.sh -c /dev/tty.usbmodem621 -b 9600 -s cloud.blynk.cc -p 8442
 *
 *    Be sure to select the right serial port (there may be multiple) when prompted:
 *       Select serial port [  ]: <serial_port>
 *
 *    Run blynk-ser.sh -h for more information
 *
 *    Attention!
 *        Arduino IDE may complain with "programmer is not responding".
 *        You need to terminate script before uploading new sketch.
 *
 * 5. To start, drag and drop a single D5 button to control the pin 5 green LED
 *    as shown in this video: https://www.youtube.com/watch?v=cAP668GF3_8
 *
 *    Don't forget to connect your smartphone to your WiFi network
 *
 **************************************************************/

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(10, 11);
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerial.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

void setup()
{
  DebugSerial.begin(9600);
  Blynk.begin(auth, 9600); // BLE-Link uses baud rate 9600
}

void loop()
{
  Blynk.run();
}

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


initial push of ALARM

initial push of ALARM

#include "MqttConnection.h"
MqttConnection * myMqtt;

/************************* WiFi Access Point *********************************/

#define WLAN_SSID       "SFR_34A8"
#define WLAN_PASS       "ab4ingrograstanstorc"

#define SENSOR_ID "ALARM1"

#define ALARM_RELAY_PIN        D6

/************************* MQTT *********************************/

#define MQTT_SERVER  "192.168.1.27"
#define MQTT_PORT 1883

//Constants
const char TV_STATE_OFF = 1;
const char TV_STATE_ON  = 2;
const char ALARM_ON  =  '2';
const char ALARM_OFF =  '1';

void processAlarmStateMsg(char* topic, byte* payload, unsigned int length)
{

  Serial.print("Checking if state topic");
  if(String(topic) == "ALARM1/cmd"){
	  Serial.println("Received Alarm change message");
       if ((char)payload[0] == ALARM_ON){
		    Serial.println("ALARM ON received");

			  switchAlarmOn();

	     }
       else if ((char)payload[0] == ALARM_OFF){
        Serial.println("ALARM OFF received");

        switchAlarmOff();

       }
		 else {
		    Serial.print("Unknown payload : ");
			Serial.println((char)payload[0]);
		 }

  }
}

void setup() {
  Serial.begin(115200);
  pinMode(ALARM_RELAY_PIN, OUTPUT);
  digitalWrite(ALARM_RELAY_PIN, HIGH);

  delay(10);

  myMqtt = new MqttConnection(SENSOR_ID, WLAN_SSID, WLAN_PASS, MQTT_SERVER, MQTT_PORT);
  myMqtt->registerCustomProcessing(&processAlarmStateMsg);
  myMqtt->addSubscription("cmd");

}

void switchAlarmOn(){

  Serial.println("Switching Alarm ON");
  digitalWrite(ALARM_RELAY_PIN, LOW);

}
void switchAlarmOff(){

  Serial.println("Switching Alarm OFF");
  digitalWrite(ALARM_RELAY_PIN, HIGH);

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

  if (!myMqtt->connected()) {
    myMqtt->reconnect();
  }
  myMqtt->loop();

  delay(10);

}

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


Create fadeToBlackBy_example.ino

Create fadeToBlackBy_example.ino

//***************************************************************
// Example showing how fadeToBlackBy works.
// Open the serial monitor to see r,g,b values.
//
// Each time fadeToBlackBy(X) is called it will fade a pixel's
// r,g,b values by a certain percentage.  Calling it repeatedly
// will eventually fade to black (where r,g,b = 0,0,0).
//
// Note that the specified number is a *percentage* out of 255,
// so for example, using 64 would be 64/255 = 25%, and using
// 10 would be 10/255 = 4%.  0 would be no fading.
//
// It can be used to fade all leds of a CRGB array like:
//   fadeToBlackBy(leds, NUM_LEDS, 128);  // 128/255 = 50%
//
// Or can be used to fade a specific pixel.
//   leds[i].fadeToBlackBy(128);  // fade by 50%
//
//
// Marc Miller, Oct 2020
//***************************************************************

#include "FastLED.h"
#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
#define COLOR_ORDER GRB
#define MASTER_BRIGHTNESS 255

CRGB leds[NUM_LEDS];

//---------------------------------------------------------------
void setup() {
  Serial.begin(115200);  // Allows serial monitor output (check baud rate)
  delay(2500);  // Startup delay
  FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(MASTER_BRIGHTNESS);

  // In this exmaple we will start out by filling the strip with this redish color
  fill_solid(leds, NUM_LEDS, CRGB(255,128,64));

  FastLED.show();  // Update the display
  printPixelInfo(0);  // Print out the r,g,b values in the serial monitor
}

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

  // Reduce this 250 ms to something smaller to change
  // how often the fade is called.
  EVERY_N_MILLISECONDS(250) {

    // Try different fade values here and note how it changes the look.
    //fadeToBlackBy(leds, NUM_LEDS, 10);  // 10/255 = 4%
    fadeToBlackBy(leds, NUM_LEDS, 64);  // 64/255 = 25%
    //fadeToBlackBy(leds, NUM_LEDS, 128);  // 128/255 = 50%
    //fadeToBlackBy(leds, NUM_LEDS, 200);  // 200/255 = 78%

    FastLED.show();  // Update the pixel display
    printPixelInfo(0);  // Print out the r,g,b values in the serial monitor

    // Check if we have gone all the way to black (off).
    // If true, then pick a new random color to fade.
    if ( leds[0] == CRGB(0,0,0) ) {
      delay(2000);
      fill_solid(leds, NUM_LEDS, CHSV(random8(), random8(128,255), 255));

      FastLED.show();
      Serial.println(" ");
      printPixelInfo(0);

    }

  }  // end every_N

}  // end main loop

// Try experimenting with different fade values and different values
// for EVERY_N_MILLISECONDS above to see how it effects things.

//---------------------------------------------------------------
// Function to print out r,g,b info for specified pixel number
void printPixelInfo(uint16_t i) {
  Serial.print("  leds["); Serial.print(i); Serial.print("] ");
  Serial.print("\tr: "); Serial.print(leds[i].r);
  Serial.print("\tg: "); Serial.print(leds[i].g);
  Serial.print("\tb: "); Serial.println(leds[i].b);
}

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


Arduino code

Arduino code

//call the library and define the rx and tx pins for send and receive
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(10,11);  //RX,TX

//char used to read the input
char data=0;

//put a led in pin 5 in arduino
int led = 5;

//pot setup and value
int potPin=A0;
int potValue=0;

//temp setup and value
int tempPin=A1;
float readValue , realValue;
int finalValue;

//ldr setup and value
int ldrPin=A2;
int ldrValue;

//button setup
int button =6;
int button_state=0;

int flag=0;

int leds=3;

void setup() {

//intainalize the Serial and the bluetooth with 9600 boot rat
Serial.begin(9600);
bluetooth.begin(9600);

//define the input and the output for the arduio
pinMode(led,OUTPUT);
pinMode(potPin,INPUT);
pinMode(tempPin,INPUT);
pinMode(ldrPin,INPUT);
pinMode(leds,OUTPUT);
pinMode(button,INPUT);

}

void loop() {

//read the value from the pot
potValue =analogRead(potPin);

//read the value from the temp
readValue=analogRead(tempPin);
realValue = readValue*5 /1023;
finalValue = realValue*100;

//read value from LDR
ldrValue=analogRead(ldrPin);

button_state=digitalRead(button);

sendAndroidValues();

    if(bluetooth.available()){
      data = bluetooth.read();
      if(data == 'o'){
        digitalWrite(led,HIGH);
        }
        else if(data == 'f'){
          digitalWrite(led,LOW);
          }
      }
}

//send the value from the sensor over serial to BT module
void sendAndroidValues()
{
  //put # before the value so that the app know that new data send
  bluetooth.print('#');

  bluetooth.print(finalValue);
  bluetooth.print('+');

  bluetooth.print(ldrValue);
  bluetooth.print('+');

 //put the sensors value
  bluetooth.print(potValue);
  bluetooth.print('+');

  //put the button state
  bluetooth.print(button_state);
  bluetooth.print('+');

  //used to end the transimssion
  bluetooth.print('~');
  bluetooth.println();
  //add delay to eliminate missed data
  delay(150);
  }

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