Added sensors and actuators implementation for arduino

Jira issue: WP-595

error: pathspec 'webinos/platform/arduino/api/sensors_actuators_driver/sensors_actuators_driver.ino' did not match any file(s) known to git

--- webinos/platform/arduino/api/sensors_actuators_driver/sensors_actuators_driver.ino
+++ webinos/platform/arduino/api/sensors_actuators_driver/sensors_actuators_driver.ino
@@ -0,0 +1,296 @@
+#include <aJSON.h>
+#include <SPI.h>
+#include <Ethernet.h>
+
+#define NUM_ELEMENTS   2
+
+#define BOARD_ID         "00001"
+//#define BOARD_LANGUAGE "webinos"
+//#define BOARD_PROTOCOL "HTTP"
+//#define BOARD_NAME     "ARDUINO_UNO"
+#define BOARD_IP         192,168,1,120
+#define BOARD_PORT       80
+
+#define PZP_IP           192,168,1,130
+#define PZP_PORT         1984
+
+//NB sa -> 0=sensor, 1=actuator
+//NB ad -> 0=analog, 1=digital
+#define ELEMENTS_RES "{\"bid\":\"00001\",\"cmd\":\"ele\",\"elements\":[{\"id\":\"00001_000\", \"element\": {\"sa\":\"0\",\"maximumRange\":\"0.1\",\"minDelay\":\"500\",\"power\":\"0.02\",\"resolution\":\"0.001\",\"type\":\"temperature\",\"vendor\":\"apple_temp\",\"version\":\"1\"}},{\"id\":\"00001_001\", \"element\":{\"sa\":\"0\",\"maximumRange\":\"0.1\",\"minDelay\":\"500\",\"power\":\"0.02\",\"resolution\":\"0.001\",\"type\":\"proximity\",\"vendor\":\"apple_prox\",\"version\":\"1\"}}]}"
+#define HELLO_REQ "GET /newboard?jsondata={\"id\":\"00001\",\"protocol\":\"HTTP\",\"name\":\"ARDUINO_UNO\",\"ip\":\"192.168.1.120\",\"port\":\"80\"} HTTP/1.0"
+
+
+typedef struct {
+  char* id;
+  bool sa;
+  bool ad;
+  int pin;
+  bool active;
+  long rate;
+  long lastConnectionTime;
+  } IOElement;
+
+IOElement * elements[NUM_ELEMENTS];
+
+
+//Ethernet stuff
+byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
+IPAddress pzp_ip(PZP_IP);
+IPAddress arduino_ip(BOARD_IP);
+EthernetClient client;
+EthernetServer server(BOARD_PORT);
+
+boolean boardconnected = false;
+
+void setup(){
+  Serial.begin(9600);
+
+  elements[0] = new IOElement();
+  elements[0]->id = "00001_000";
+  elements[0]->sa = 0;
+  elements[0]->ad = 0;
+  elements[0]->pin = 0;
+  elements[0]->active = 0;
+  elements[0]->rate = 1000;
+
+  elements[1] = new IOElement();
+  elements[1]->id = "00001_001";
+  elements[1]->sa = 0;
+  elements[1]->ad = 1;
+  elements[1]->pin = 1;
+  elements[1]->active = 0;
+  elements[1]->rate = 3500;
+
+  //start Ethernet
+  Ethernet.begin(mac, arduino_ip);
+}
+
+//hell function
+String getValueFromSensor(bool ad, int pin){
+  int value = -1;
+  if(ad == 0){ //analog sensor
+    value = analogRead(pin);
+  }
+  else{ //digital sensor
+    value = digitalRead(pin);
+  }
+  return String(value);
+}
+
+void sendDataToAPI(int id_ele){
+//  Serial.print("Send data id : ");
+//  Serial.println(id_ele);
+  if (client.connect(pzp_ip, PZP_PORT)) {
+    client.print("POST /sensor?id=");
+    client.print(elements[id_ele]->id);
+    client.print("&data=");
+    client.print(getValueFromSensor(elements[id_ele]->ad, elements[id_ele]->pin));
+    client.println("\0 HTTP/1.0");
+    client.println();
+    client.stop();
+    elements[id_ele]->lastConnectionTime = millis();
+  }
+}
+
+void loop(){
+  if(!boardconnected){
+    Serial.println("Try connecting to PZP");
+    if (client.connect(pzp_ip, PZP_PORT)) {
+      client.println(HELLO_REQ);
+      client.println();
+
+      String s;
+      bool nextisbody = false;
+      delay(1000);
+
+      char vet[19];
+      int i=0;
+      int num_spaces=0;
+      while(client.available() > 0){
+        char c = client.read();
+
+//      // Not work! test it!
+//        if(num_spaces==2){
+//          vet[i++] = c;
+//          if(i==19){
+//            vet[i] = '/0';
+//            if(strcmp(vet, "{\"ack\":\"newboard\"}") == 0)
+//              Serial.println("new board");
+//            else
+//              Serial.println("error");
+//
+//            boardconnected=true;
+//            break;
+//          }
+//          else
+//            Serial.print(c);
+//        }
+//        else{
+//          if(c == '\n')
+//            num_spaces++;
+//          else
+//            num_spaces=0;
+//        }
+
+        s += c;
+        if(c == '\n'){
+          if(nextisbody){
+            Serial.println(s);
+            char json_char[s.length()];
+            s.toCharArray(json_char, s.length());
+            aJsonObject* jsonObject = aJson.parse(json_char);
+            aJsonObject* ack = aJson.getObjectItem(jsonObject, "ack");
+            if(strcmp(ack->valuestring,"newboard")==0){
+//            if(s.equals("{\"ack\":\"newboard\"}")){
+              delete jsonObject;
+              delete ack;
+              free(&json_char);
+              free(&s);
+              boardconnected=true;
+              server.begin();
+            }
+//            else
+//              Serial.println("PZP refused my req");
+            break;
+
+          }
+          if(s.equals("\r\n")){
+            nextisbody = true;
+          }
+          s = "";
+        }
+
+      }
+      client.stop();
+    }
+    else {
+     // Serial.println("PZP unavailable");
+      delay(2000);
+    }
+  }
+  else{ // boardisconnected == true
+    EthernetClient client = server.available();
+    if (client) {
+      // an http request ends with a blank line
+      boolean currentLineIsBlank = true;
+      char cmd[4];
+      char pin[4];
+      char dat[30];
+      int counter=1;
+      int i=0,j=0,z=0;
+      bool finish = false;
+
+      while (client.connected()) {
+        if (client.available()) {
+          char c = client.read();
+          // GET /?cmd=get&pin=012&dat=.....\n
+          if(counter>10 && counter<14)
+            cmd[i++] = c;
+          if(counter>18 && counter<22)
+            pin[j++] = c;
+          if(counter > 26){
+            dat[z++] = c;
+            if(c == '\ ')
+              finish=true;
+          }
+          if(finish){
+            cmd[i] = '\0';
+            pin[j] = '\0';
+            dat[z-1] = '\0';
+
+            Serial.println(cmd);
+            Serial.println(pin);
+            Serial.println(dat);
+            client.println("HTTP/1.1 200 OK");
+            client.println("Content-Type: application/json");
+            client.println("Connnection: keep-alive");
+            client.println();
+
+            if(strcmp(cmd,"ele")==0){
+              client.println(ELEMENTS_RES);
+            }
+            else if(strcmp(cmd,"get")==0){
+              int ipin = atoi(pin);
+              int value = analogRead(ipin);
+              client.print("{\"cmd\":\"get\",\"eid\":\"");
+              client.print(BOARD_ID);
+              client.print("_");
+              client.print(ipin);
+              client.print("\",\"dat\":\"");
+              client.print(value);
+              client.println("\"}");
+            }
+            else if(strcmp(cmd,"str")==0 || strcmp(cmd,"stp")==0){
+
+              Serial.print(pin);
+              Serial.print(" mode : ");
+              Serial.println(dat);
+
+              int len = strlen(BOARD_ID) + 1 + strlen(pin);  // BOARD_ID + _ + pin
+              Serial.println(len);
+
+              char eid[len+1];
+              strcpy(eid,BOARD_ID);
+              strcat(eid,"_");
+              strcat(eid,pin);
+              strcat(eid,'\0');
+//              Serial.println(eid);
+
+              if(strcmp(cmd,"str")==0){
+                client.print("{\"cmd\":\"str\",");
+                client.print("\"id\":\"");
+                client.print(eid);
+                client.println("\"}");
+                Serial.print("starting sensor ");
+                Serial.println(eid);
+
+                for(int i=0; i<NUM_ELEMENTS; i++){
+                  if(strcmp(elements[i]->id, eid) == 0)
+                    elements[i]->active = true;
+                }
+              }
+              else{ //if(strcmp(cmd,"stp")==0){
+                client.println("{\"cmd\":\"stp\"}");
+                Serial.println("stopping sensor ");
+                for(int i=0; i<NUM_ELEMENTS; i++){
+                  if(strcmp(elements[i]->id, eid) == 0)
+                    elements[i]->active = false;
+                }
+              }
+            }
+            break;
+          }
+          counter++;
+        }
+      }
+      // give the web browser time to receive the data
+      delay(1);
+      client.stop();
+    }
+
+    for(int i=0; i<NUM_ELEMENTS; i++){
+      if(elements[i]->active && (millis() - elements[i]->lastConnectionTime > elements[i]->rate)){
+        sendDataToAPI(i);
+      }
+    }
+
+//    for(int i=0; i<NUM_ELEMENTS; i++){
+//      if(elements[i]->active && ( time*mindelay % elements[i]->rate == 0) ){
+//        Serial.print("Read from sensor ");
+//        Serial.println(elements[i]->id);
+//        if (client.connect(pzp_ip, PZP_PORT)) {
+//          client.print("POST /sensor?id=");
+//          client.print(elements[i]->id);
+//          client.print("&data=");
+//          client.print(getValueFromSensor(elements[i]->ad, elements[i]->pin));
+//          client.println("\0 HTTP/1.0");
+//          client.println();
+//          client.stop();
+//        }
+//      }
+//    }
+//    time++;
+//    delay(mindelay);
+
+  }
+}


Add bluetooth

Add bluetooth

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


Added failure tone and matched timing of opening tone to original game.

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/tonyczeh/arduino-repeat.git/'


Some stray calls to ipToString.

Some stray calls to ipToString.

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

--- examples/WebServerSketch1/WebServerSketch1.ino
+++ examples/WebServerSketch1/WebServerSketch1.ino
@@ -0,0 +1,45 @@
+
+/*
+ * 2016-11-26 dvb
+ * Work on OmServer, so that its messages tend to
+ * help a new user bootstrap to it.
+ */
+#include "Arduino.h"
+#include "OmBlinker.h"
+#include "OmWebServer.h"
+#include <OmEspHelpers.h>
+
+// These includes arent used in this file, but tells Arduino IDE that this project uses them.
+#include <ESP8266WebServer.h>
+#include <ESP8266WiFi.h>
+
+OmBlinker ob(-1);
+OmWebServer w;
+OmWebPages p;
+
+void setup()
+{
+  Serial.begin(115200);
+  Serial.printf("\n\n\nWelcome to the Sketch\n\n");
+
+  ob.addNumber(1234);
+
+  w.addWifi("noope", "haha");
+  w.addWifi("omino warp", "0123456789");
+
+  w.setHandler(p);
+}
+
+int ticks = 0;
+void loop()
+{
+  delay(10);
+  ob.tick();
+  w.tick();
+
+  ticks++;
+  if(ticks % 1000 == 0)
+  {
+    ob.addInterjection(10, 2);
+  }
+}


Improved Style

Improved Style

Improved Code Layout impending a rewrite.

--- nRF51822-BLEMIDI/nRF51822-BLEMIDI.ino
+++ nRF51822-BLEMIDI/nRF51822-BLEMIDI.ino
@@ -68,8 +68,7 @@
 static int rx_buf_num, rx_state = 0;
 static uint8_t rx_temp_buf[20];

-
-// TXRX Service & UDIDs
+// TXRX Service & UDIDs
 static const uint8_t uart_base_uuid[] = {0x03, 0xB8, 0x0E, 0x5A, 0xED, 0xE8, 0x4B, 0x33, 0xA7, 0x51, 0x6C, 0xE3, 0x4E, 0xC4, 0xC7, 0};
 static const uint8_t uart_tx_uuid[]   = {0x77, 0x72, 0xE5, 0xDB, 0x38, 0x68, 0x41, 0x12, 0xA1, 0xA9, 0xF2, 0x66, 0x9D, 0x10, 0x6B, 0xF3};
 static const uint8_t uart_rx_uuid[]   = {0x77, 0x72, 0xE5, 0xDB, 0x38, 0x68, 0x41, 0x12, 0xA1, 0xA9, 0xF2, 0x66, 0x9D, 0x10, 0x6B, 0xF3};
@@ -94,7 +93,6 @@
 uint8_t usbstate;
 uint8_t laststate;
 uint8_t rcode;
-//uint8_t buf[sizeof(USB_DEVICE_DESCRIPTOR)];
 USB_DEVICE_DESCRIPTOR buf;

 void MIDI_poll();
@@ -112,40 +110,41 @@
 static uint8_t midiOut_buff[MAX_TX_BUFF];
 static uint8_t midiOut_buff_len = 0;

-
-
 /*******************************************************************************
 * Send MIDI data to BLE Stack
 *
 * BLE Packet is capped to 17 bytes (2 bytes prefix + 3 bytes MIDI + 3 * 4 bytes)
 *
 * Right now this is periodically called by the app_timer, to make sure the buffer clears
-* out fast enough as calling this through MIDI_poll() caused more delay.
+* out fast enough as calling this through MIDI_poll() caused more delay.
 * TO DO: Use MIDI Structs instead of byte array
 *
 *******************************************************************************/
 void m_uart_rx_handle(void * p_context)
 {
-  if(rx_buf_num > 0 && isConnected) {
- int bufInc = 0;
-
- // with every ticker-call to this function we take 17 bytes off the buffer and send it out to BLE
- if (rx_buf_num < 17) {
-    bufInc = rx_buf_num % 17;
-  }
- else {
-    bufInc = 17;
- }
-  ble.updateCharacteristicValue(txCharacteristic.getHandle(), rx_buf, bufInc);
-  memmove(rx_buf, rx_buf+bufInc, rx_buf_num-bufInc); // probably not best practice, needs to be fixed
-  rx_buf_num -= bufInc;
-  rx_state = 0;
-  }
+if(rx_buf_num > 0 && isConnected)
+{
+	 int bufInc = 0;
+
+	 // with every ticker-call to this function we take 17 bytes off the buffer and send it out to BLE
+	 if (rx_buf_num < 17)
+	 {
+	    bufInc = rx_buf_num % 17;
+	 }
+	 else
+	 {
+		 bufInc = 17;
+	 }
+	  ble.updateCharacteristicValue(txCharacteristic.getHandle(), rx_buf, bufInc);
+	  memmove(rx_buf, rx_buf+bufInc, rx_buf_num-bufInc); // probably not best practice, needs to be fixed
+	  rx_buf_num -= bufInc;
+	  rx_state = 0;
+}
 }

 /*******************************************************************************
 * Connection callback
-*
+*
 *  TO DO:
 * - Probably doesnt need Serial.Read() here since we dont do any reading
 *
@@ -174,7 +173,8 @@
   Usb.Task();
   usbstate = Usb.getUsbTaskState();

-  if (usbstate != laststate) {
+  if (usbstate != laststate)
+	{
     laststate = usbstate;

     switch (usbstate) {
@@ -197,12 +197,12 @@
         E_Notify(PSTR("\r\nGetting device descriptor"), 0x80);
         rcode = Usb.getDevDescr(1, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*) & buf);

-        if (rcode) {
+        if (rcode)
+				{
           E_Notify(PSTR("\r\nError reading device descriptor. Error code "), 0x80);
-          // print_hex(rcode, 8);
         }
-        else {
-
+        else
+				{
           E_Notify(PSTR("\r\nDescriptor Length:\t"), 0x80);
           print_hex(buf.bLength, 8);
           E_Notify(PSTR("\r\nDescriptor type:\t"), 0x80);
@@ -245,8 +245,7 @@

   if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
   {
-
-    MIDI_poll();
+		MIDI_poll();
   }

 }
@@ -260,16 +259,15 @@
   ble.startAdvertising();
 }

-void connectionCallback(void) {
- isConnected = true;
- uint32_t err_code = NRF_SUCCESS;
+void connectionCallback(void)
+{
+ 	isConnected = true;
+ 	uint32_t err_code = NRF_SUCCESS;
   err_code = app_timer_create(&m_uart_rx_id, APP_TIMER_MODE_REPEATED, m_uart_rx_handle);
   APP_ERROR_CHECK(err_code);

   err_code = app_timer_start(m_uart_rx_id, STATUS_CHECK_TIME, NULL);
   APP_ERROR_CHECK(err_code);
-
-
 }

@@ -283,8 +281,7 @@
 {
   uint8_t buf[TXRX_BUF_LEN];
   uint16_t bytesRead;
- Serial.println("Something");
-
+	Serial.println("Something");
   if ( charHandle == txCharacteristic.getHandle() )
   {
     ble.readCharacteristicValue(txCharacteristic.getHandle(), buf, &bytesRead);
@@ -300,8 +297,7 @@
   uint32_t err_code = NRF_SUCCESS;
   uart_callback_t uart_cb;
   Serial.begin(9600);
-  // while (!Serial); // activate to wait for attached serial
-
+
   //Workaround for non UHS2.0 Shield
   pinMode(10, OUTPUT);
   digitalWrite(10, HIGH);
@@ -333,7 +329,7 @@

   ble.startAdvertising();
  // err_code = app_timer_create(&m_uart_rx_id, APP_TIMER_MODE_SINGLE_SHOT, m_uart_rx_handle);
-
+
   err_code = app_timer_create(&m_status_check_id, APP_TIMER_MODE_REPEATED, m_status_check_handle);
   APP_ERROR_CHECK(err_code);

@@ -381,7 +377,7 @@
  * Convert MIDI BLE to MIDI USB
  *
  * Pleas check the experimental branch for MIDI BLE to MIDI USB
- *
+ *
  *******************************************************************************/
 void parseBLEtoMIDI(uint8_t *dataptr, uint16_t bytesRead)
 {
@@ -394,7 +390,7 @@
 /*******************************************************************************
  * Convert MIDI Data to MIDI-BLE Packets
  *
- * TO DO:
+ * TO DO:
  * - Jitter / Time Coding is not yet implemented
  * - 1 Byte between MIDI Packet is time-offset currently ignored
  * - Move this to proper MIDI Parsing (e.g. SysEx)
@@ -428,11 +424,11 @@
         rx_buf[rx_buf_num] = 0x80;
         rx_buf_num++;
       }
-
+
       for (int i = 0; i < size; i++)
       {
         rx_buf[rx_buf_num] = outBuf[i];
-        rx_buf_num++;
+        rx_buf_num++;
       }
   }
 }


Fixed credentials  : UNDO RESET: on sample

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/TheBeachMaster/AfricasTalkingIOT.git/'


add PushButtonNode as SerialApi 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/electronicplayground/ep-arduino.git/'


hmm letting the queue run dry is not htat hard …

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


Added encoders support

Added encoders support

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

--- arduino/AStarRPiSlaveRPB202.ino
+++ arduino/AStarRPiSlaveRPB202.ino
@@ -0,0 +1,135 @@
+#include <Servo.h>
+#include <AStar32U4.h>
+#include <PololuRPiSlave.h>
+#include <FastGPIO.h>
+
+/* This example program shows how to make the A-Star 32U4 Robot
+ * Controller into a Raspberry Pi I2C slave.  The RPi and A-Star can
+ * exchange data bidirectionally, allowing each device to do what it
+ * does best: high-level programming can be handled in a language such
+ * as Python on the RPi, while the A-Star takes charge of motor
+ * control, analog inputs, and other low-level I/O.
+ *
+ * The example and libraries are available for download at:
+ *
+ * https://github.com/pololu/pololu-rpi-slave-arduino-library
+ *
+ * You will need the corresponding Raspberry Pi code, which is
+ * available in that repository under the pi/ subfolder.  The Pi code
+ * sets up a simple Python-based web application as a control panel
+ * for your Raspberry Pi robot.
+ */
+
+// Custom data structure that we will use for interpreting the buffer.
+// We recommend keeping this under 64 bytes total.  If you change the
+// data format, make sure to update the corresponding code in
+// a_star.py on the Raspberry Pi.
+
+struct Data
+{
+  bool yellow, green, red;
+  bool buttonA, buttonB, buttonC;
+
+  int16_t leftMotor, rightMotor;
+  uint16_t batteryMillivolts;
+  uint16_t analog[6];
+
+  bool resetEncoders;
+
+  int16_t encoderLCount, encoderRCount;
+
+  bool playNotes;
+  char notes[14];
+};
+
+PololuRPiSlave<struct Data,0> slave;
+PololuBuzzer buzzer;
+AStar32U4Motors motors;
+AStar32U4ButtonA buttonA;
+AStar32U4ButtonB buttonB;
+AStar32U4ButtonC buttonC;
+
+// Encoders variables
+const byte encoderLeftPin = 8;
+const byte encoderRightPin = 7;
+volatile uint16_t encoderLeftCount;
+volatile uint16_t encoderRightCount;
+
+// ISRs
+// ISR for left encoder (PCINT)
+ISR(PCINT0_vect)
+{
+  encoderLeftCount++;
+}
+
+// ISR for right encoder (INT)
+static void rightISR()
+{
+  encoderRightCount++;
+}
+
+void setup()
+{
+  // Set up the slave at I2C address 20.
+  slave.init(20);
+
+  // Play startup sound.
+  buzzer.play("v10>>g16>>>c16");
+
+  // Setup encoders pins and attach ISRs
+  FastGPIO::Pin<encoderLeftPin>::setInputPulledUp();
+  FastGPIO::Pin<encoderRightPin>::setInputPulledUp();
+  PCICR = (1 << PCIE0);
+  PCMSK0 = (1 << PCINT4);
+  PCIFR = (1 << PCIF0);
+  attachInterrupt(digitalPinToInterrupt(encoderRightPin), rightISR, CHANGE);
+}
+
+void loop()
+{
+  // Call updateBuffer() before using the buffer, to get the latest
+  // data including recent master writes.
+  slave.updateBuffer();
+
+  // Write various values into the data structure.
+  slave.buffer.buttonA = buttonA.isPressed();
+  slave.buffer.buttonB = buttonB.isPressed();
+  slave.buffer.buttonC = buttonC.isPressed();
+
+  // Change this to readBatteryMillivoltsLV() for the LV model.
+  slave.buffer.batteryMillivolts = readBatteryMillivoltsSV();
+
+  for(uint8_t i=0; i<6; i++)
+  {
+    slave.buffer.analog[i] = analogRead(i);
+  }
+
+  // Read encoders
+  slave.buffer.encoderLCount = encoderLeftCount;
+  slave.buffer.encoderRCount = encoderRightCount;
+  if (slave.buffer.resetEncoders)
+  {
+    slave.buffer.resetEncoders = 0;
+    encoderLeftCount = 0;
+    encoderRightCount = 0;
+  }
+
+  // READING the buffer is allowed before or after finishWrites().
+  ledYellow(slave.buffer.yellow);
+  ledGreen(slave.buffer.green);
+  ledRed(slave.buffer.red);
+  motors.setSpeeds(slave.buffer.leftMotor, slave.buffer.rightMotor);
+
+  // Playing music involves both reading and writing, since we only
+  // want to do it once.
+  if(slave.buffer.playNotes)
+  {
+    buzzer.play(slave.buffer.notes);
+    while(buzzer.isPlaying());
+    slave.buffer.playNotes = false;
+  }
+
+  // When you are done WRITING, call finalizeWrites() to make modified
+  // data available to I2C master.
+  slave.finalizeWrites();
+}


uploading arduino code from last semester

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

--- bluetooth_init.ino
+++ bluetooth_init.ino
@@ -0,0 +1,332 @@
+/*
+ David Spruill, 2014
+
+ This code is designed to control the Bblr Bubble Display made as a capstone final project
+ in Duke's ECE 459 Embedded Systems course taught by Dr. John Board.
+
+ This code currently deals with both time keeping, bluetooth phone connections for picture
+ reception, and bubble (pixel) compensation planning.
+ */
+
+#include <TimerOne.h>
+#include <Time.h>
+
+//Image
+#define rails 24 // number of rails
+#define height 5 // maximum number of bubbles that can fit in the board
+#define charHeight 5
+#define charWidth 3
+#define allowedHeight 100//max allowed height of a schedule
+
+//Timing
+#define pixelPitch 330 // distance between the pixels
+#define blockPitch 1000 // distance between letters/blocks
+#define compensation 10 // compensation time
+#define pixelDuration 8
+#define initialDelay 3000
+#define calibrationBubbleSize 40
+
+boolean PixelDelay[rails] = {
+  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
+
+int counterOffset = 0;
+byte mode = 0;
+boolean currTime = 0;
+boolean phoneSetTime = false;
+
+int currRails = 24;
+int currRowLimit = 5;
+
+boolean setSchedule = false;
+boolean startPrint = false;
+
+boolean schedule[rails][allowedHeight];
+
+unsigned long lastWrite = 0;
+int currRow = 0;
+
+// Alphanumeric lib
+boolean alphabet[26][3][5] = {
+    {{1, 1, 1, 1, 1},{1, 0, 1, 0, 0},{1, 1, 1, 1, 1}},  //A
+    {{1, 1, 1, 1, 1},{1, 0, 1, 0, 1},{0, 1, 0, 1, 0}},  //B
+    {{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{1, 0, 0, 0, 1}},  //C
+    {{1, 1, 1, 1, 1},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}},  //D
+    {{1, 1, 1, 1, 1},{1, 0, 1, 0, 1},{1, 0, 0, 0, 1}},  //E
+    {{1, 1, 1, 1, 1},{1, 0, 1, 0, 0},{1, 0, 0, 0, 0}},  //F
+    {{0, 1, 1, 1, 0},{1, 0, 1, 0, 1},{1, 0, 0, 1, 0}},  //G ~ looks funny
+    {{1, 1, 1, 1, 1},{0, 0, 1, 0, 0},{1, 1, 1, 1, 1}},  //H
+    {{1, 0, 0, 0, 1},{1, 1, 1, 1, 1},{1, 0, 0, 0, 1}},  //I
+    {{0, 0, 0, 1, 0},{1, 0, 0, 0, 1},{1, 1, 1, 1, 0}},  //J
+    {{1, 1, 1, 1, 1},{0, 1, 0, 1, 0},{1, 0, 0, 0, 1}},  //K
+    {{1, 1, 1, 1, 1},{0, 0, 0, 0, 1},{0, 0, 0, 0, 1}},  //L
+    {{1, 1, 1, 1, 1},{0, 1, 1, 0, 0},{1, 1, 1, 1, 1}},  //M
+    {{1, 1, 1, 1, 1},{0, 1, 1, 1, 0},{1, 1, 1, 1, 1}},  //N
+    {{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}},  //O
+    {{1, 1, 1, 1, 1},{1, 0, 1, 0, 0},{0, 1, 0, 0, 0}},  //P
+    {{0, 1, 1, 1, 0},{1, 0, 0, 1, 1},{0, 1, 1, 1, 1}},  //Q ~ good be better
+    {{1, 1, 1, 1, 1},{1, 0, 1, 1, 0},{0, 1, 0, 0, 1}},  //R
+    {{0, 1, 0, 0, 1},{1, 0, 1, 0, 1},{1, 0, 0, 1, 0}},  //S
+    {{1, 0, 0, 0, 0},{1, 1, 1, 1, 1},{1, 0, 0, 0, 0}},  //T
+    {{1, 1, 1, 1, 0},{0, 0, 0, 0, 1},{1, 1, 1, 1, 0}},  //U
+    {{1, 1, 1, 0, 0},{0, 0, 0, 1, 1},{1, 1, 1, 0, 0}},  //V
+    {{1, 1, 1, 1, 1},{0, 0, 0, 1, 0},{1, 1, 1, 1, 1}},  //W
+    {{1, 1, 0, 1, 1},{0, 0, 1, 0, 0},{1, 1, 0, 1, 1}},  //X
+    {{1, 1, 0, 0, 0},{0, 0, 1, 1, 1},{1, 1, 0, 0, 0}},  //Y
+    {{1, 0, 0, 1, 1},{1, 0, 1, 0, 1},{1, 1, 0, 0, 1}}}; //Z
+
+boolean numbers[10][3][5] =  {
+    {{0, 1, 1, 1, 0},{1, 0, 0, 0, 1},{0, 1, 1, 1, 0}},  //0
+    {{0, 1, 0, 0, 1},{1, 1, 1, 1, 1},{0, 0, 0, 0, 1}},  //1
+    {{1, 0, 1, 1, 1},{1, 0, 1, 0, 1},{1, 1, 1, 0, 1}},  //2
+    {{1, 0, 0, 0, 1},{1, 0, 1, 0, 1},{1, 1, 1, 1, 1}},  //3
+    {{1, 1, 1, 0, 0},{0, 0, 1, 0, 0},{1, 1, 1, 1, 1}},  //4
+    {{1, 1, 1, 0, 0},{1, 0, 1, 0, 1},{1, 0, 1, 1, 1}},  //5
+    {{1, 1, 1, 1, 1},{1, 0, 1, 0, 1},{1, 0, 1, 1, 1}},  //6
+    {{1, 0, 0, 1, 1},{1, 0, 1, 0, 0},{1, 1, 0, 0, 0}},  //7
+    {{1, 1, 1, 1, 1},{1, 0, 1, 0, 1},{1, 1, 1, 1, 1}},  //8
+    {{1, 1, 1, 0, 0},{1, 0, 1, 0, 0},{1, 1, 1, 1, 1}}}; //9    These last several could use some straightening out
+
+void setup()
+{
+  pinMode(13,OUTPUT);
+  Serial.begin(9600);  // Begin the serial monitor at 9600bps
+
+  Serial1.begin(115200);  // The Bluetooth Mate defaults to 115200bps
+  Serial1.print("$");  // Print three times individually
+  Serial1.print("$");
+  Serial1.print("$");  // Enter command mode
+  delay(100);  // Short delay, wait for the Mate to send back CMD
+
+  Serial.println("configuring");
+  Serial1.println("U,9600,E");  // Change the baudrate to 9600, even parity
+  Serial1.println("---");
+  Serial1.end();
+  Serial1.begin(9600);  // Start bluetooth serial at 9600
+
+  Timer1.initialize(1000000); // set a timer of length 100000 microseconds (or 0.1 sec - or 10Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)
+  Timer1.attachInterrupt( timerInt ); // attach the service routine here
+  setTime(0);
+}
+
+void loop()
+{
+  if(Serial1.available())  // If the bluetooth sent any characters
+  {
+    // Send any characters the bluetooth prints to the serial monitor
+    char currByte = Serial1.read();
+    switch(currByte){
+    case 0xFE:
+      updateTime();
+      break;
+    case 0xFD:
+      getImage();
+      break;
+    case 0xFC:
+      stopDisplay();
+      break;
+    case 0xFB:
+      startClock();
+      break;
+    case 0xFA:
+      getText();
+      break;
+    }
+  }
+  if(startPrint){
+    //begin printing
+    if(millis() - lastWrite > pixelPitch){
+      for(int i = 0; i < rails; i++){
+        Serial.print(String(schedule[i][currRow],DEC));
+         //here we would turn on the solenoids
+      }
+      Serial.print("\n");
+      delay(pixelDuration);
+      for(int i =0; i < rails; i++){
+         //here we would turn off the solenoids
+      }
+      lastWrite = millis();
+      currRow++;
+      if(currRow >= currRowLimit) {
+        stopDisplay(); // appropriately stop printing & clear schedule
+        currRow = 0;
+        Serial.print("\n");
+      }
+    }
+    else {
+      for(int i = 0; i < rails; i++){
+        //Serial.print("0"); //this else isn't actually needed, just for testing
+      }
+
+    }
+  }
+}
+
+void getText(){
+
+}
+
+void getImage() {
+  digitalWrite(13,HIGH);
+  char received[10] = {
+    0,0,0,0,0,0,0,0,0,0          };
+  int receivedCount = Serial1.readBytesUntil(0xA0,received,10);
+  if(receivedCount < 2) return;
+
+  int imageRails = received[0];
+  if(imageRails > rails) return;
+
+  currRowLimit = received[1];
+  Serial.println("rails: "+String(imageRails) + " rows: "+String(currRowLimit));
+  char *image = new char[imageRails*currRowLimit+10];
+  int pixelsReceived = Serial1.readBytesUntil(0xFF,image,imageRails*currRowLimit);
+  Serial.print("Data: ");
+  for(int i = 0; i < imageRails*currRowLimit+10; i++){Serial.print(String(image[i],DEC) + " "); if(i%(imageRails)==0)Serial.print("\n");}
+  Serial.println();
+
+  int leftSide = (rails - imageRails) / 2;  if(leftSide < 0) leftSide = 0;
+
+  for(int i = 0; i < rails; i++){
+    for(int j = 0; j < currRowLimit; j++){
+     if(i>=leftSide&&i<(leftSide+imageRails)){
+      schedule[i][j] = image[(i-leftSide)+j*(imageRails)-8] == 0x01;
+     }
+     else schedule[i][j] = 0;
+    }
+  }
+  startPrint = true;
+  setSchedule = true;
+}
+
+void stopDisplay() { //stop printing and clear the schedule
+  startPrint = false;
+  for(int i = 0; i < rails; i++){
+   for(int j = 0; j < allowedHeight; j++){
+    schedule[i][j] = 0;
+   }
+  }
+}
+
+void startClock() {
+
+}
+
+void updateTime(){
+  while(Serial1.available() < 5) {
+  }
+  char received[10] = {
+    0,0,0,0,0,0,0,0,0,0          };
+  int receivedCount = Serial1.readBytesUntil(0xFF,received,10);
+  Serial.println();
+  setTime((unsigned char)received[0],(unsigned char)received[1],(unsigned char)received[2],
+  (unsigned char)received[3],(unsigned char)received[4],(word)(((unsigned) received[5])<<8) + (word)((unsigned)received[6]));
+  phoneSetTime = true;
+}
+
+void timerInt()
+{
+  if(++counterOffset == 30 & !startPrint){
+    counterOffset = 0;
+    if(phoneSetTime){
+      digitalWrite(13,digitalRead(13)^1);
+      if(mode == 0){
+        if(currTime)  WriteCurrTime();
+        if(!currTime) WriteCurrDate();
+        currTime = !currTime;
+      }
+    }
+  }
+}
+
+void WriteCurrTime(){
+  currRowLimit = 5;
+  if(rails < 24) return;
+  for(int i = 0; i < currRowLimit; i++){
+     int currHour = hour();
+     char AorP = 'A';
+     if(currHour > 12) {currHour-=12; AorP = 'P';}
+     schedule[0][i]  = numbers[currHour/10][0][i];
+     schedule[1][i]  = numbers[currHour/10][1][i];
+     schedule[2][i]  = numbers[currHour/10][2][i];
+
+     schedule[3][i]  = false;
+
+     schedule[4][i]  = numbers[currHour%10][0][i];
+     schedule[5][i]  = numbers[currHour%10][1][i];
+     schedule[6][i]  = numbers[currHour%10][2][i];
+
+     schedule[7][i]  = (i%2)-1==0 && i>0; //colons
+
+     schedule[8][i]  = numbers[minute()/10][0][i];
+     schedule[9][i]  = numbers[minute()/10][1][i];
+     schedule[10][i] = numbers[minute()/10][2][i];
+
+     schedule[11][i] = false;
+
+     schedule[12][i] = numbers[minute()%10][0][i];
+     schedule[13][i] = numbers[minute()%10][1][i];
+     schedule[14][i] = numbers[minute()%10][2][i];
+
+     schedule[15][i] = false;
+
+     schedule[16][i] = alphabet[AorP-65][0][i];
+     schedule[17][i] = alphabet[AorP-65][1][i];
+     schedule[18][i] = alphabet[AorP-65][2][i];
+
+     schedule[19][i] = false;
+
+     schedule[20][i] = alphabet['M'-65][0][i];
+     schedule[21][i] = alphabet['M'-65][1][i];
+     schedule[22][i] = alphabet['M'-65][2][i];
+
+     schedule[23][i] = false;
+  }
+  startPrint = true;
+  setSchedule = true;
+}
+void WriteCurrDate(){
+  currRowLimit = 5;
+  if(rails < 24) return;
+  for(int i = 0; i < currRowLimit; i++){
+     schedule[0][i]  = numbers[month()/10][0][i];
+     schedule[1][i]  = numbers[month()/10][1][i];
+     schedule[2][i]  = numbers[month()/10][2][i];
+
+     schedule[3][i]  = false;
+
+     schedule[4][i]  = numbers[month()%10][0][i];
+     schedule[5][i]  = numbers[month()%10][1][i];
+     schedule[6][i]  = numbers[month()%10][2][i];
+
+     schedule[7][i]  = false;
+
+     schedule[8][i]  = numbers[day()/10][0][i];
+     schedule[9][i]  = numbers[day()/10][1][i];
+     schedule[10][i] = numbers[day()/10][2][i];
+
+     schedule[11][i] = false;
+
+     schedule[12][i] = numbers[day()%10][0][i];
+     schedule[13][i] = numbers[day()%10][1][i];
+     schedule[14][i] = numbers[day()%10][2][i];
+
+     schedule[15][i] = false;
+
+     schedule[16][i] = numbers[(year()%100)/10][0][i];
+     schedule[17][i] = numbers[(year()%100)/10][1][i];
+     schedule[18][i] = numbers[(year()%100)/10][2][i];
+
+     schedule[19][i] = false;
+
+     schedule[20][i] = numbers[(year()%100)%10][0][i];
+     schedule[21][i] = numbers[(year()%100)%10][1][i];
+     schedule[22][i] = numbers[(year()%100)%10][2][i];
+
+     schedule[23][i] = false;
+  }
+  startPrint = true;
+  setSchedule = true;
+}
+
+
+
+


Optimise data types

Optimise data types

fatal: remote error: upload-pack: not our ref 3b0409b09357730b4c54a4b6dac30ede0f3141bc
fatal: the remote end hung up unexpectedly


Update ProbeCube_pp_099b0224.ino

Update ProbeCube_pp_099b0224.ino

error: pathspec 'Arduino' did not match any file(s) known to git
error: pathspec 'with' did not match any file(s) known to git
error: pathspec 'cc3000wifi' did not match any file(s) known to git
error: pathspec 'based/Code/ProbeCube_pp_099b0224.ino' did not match any file(s) known to git


create Thunder Watcher sketch.

create Thunder Watcher sketch.

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

--- src/ThunderWatcher/ThunderWatcher.ino
+++ src/ThunderWatcher/ThunderWatcher.ino
@@ -0,0 +1,336 @@
+
+//AS3935 SCL = A5
+//AS3935 SDA = A4
+//AS3935 IRQ = D5
+//AQM1602 SCL = A5
+//AQM1602 SDA = A4
+//USE 5V PWR
+
+#include <ST7032.h> // LCD library
+#include <Wire.h>
+#include <FreqCounter.h>
+
+#define AS3935_ADRS 0x00
+#define LCD_ADRS 0x3E
+
+#define AFE_GB  0x1F  // ANALOG FRONT END GAIN BOOST = 12(Indoor) 0x00 to 0x1F
+#define NF_LEV  0x02  // NOIS FLOOR LEVEL 0x00 to 0x07
+#define WDTH    0x02  // WATCH DOG THRESHOLD 0x00 to 0x0F
+
+ST7032 lcd;
+
+String LCD_STRING;
+byte reg0,reg1,reg2,reg3,reg4,reg5,reg6,reg7,reg8,reg3A,reg3B,reg3C,reg3D,regDUMMY;
+unsigned long enargy;
+unsigned int distance;
+long int freq;
+long int OLD_BUFFER = 10000;
+long int NOW_BUFFER = 0;
+int C;
+long int F;
+byte CAP_RESULT;
+
+// Thunder mark character
+byte Lightning[8] = {
+	0b00010,
+	0b00100,
+	0b01100,
+	0b11111,
+	0b00110,
+	0b00100,
+	0b01000,
+	0b10000
+};
+
+void ByteWrite(byte reg, byte data)
+{
+  Wire.beginTransmission(AS3935_ADRS);
+  Wire.write(reg);
+  Wire.write(data);
+  Wire.endTransmission();
+  delay(50);
+}
+
+byte ByteRead(byte reg)
+{
+  byte data = 0;
+  Wire.beginTransmission(AS3935_ADRS);
+  Wire.write(reg);
+  Wire.endTransmission(false);
+  Wire.requestFrom(AS3935_ADRS,1);
+  data = Wire.read();      // Receive 1 byte
+  return data;
+}
+
+void resistorRead(void)
+{
+  Wire.beginTransmission(AS3935_ADRS);
+  Wire.write(0);
+  Wire.endTransmission(false);
+  Wire.requestFrom(AS3935_ADRS,9);
+  reg0 = Wire.read();
+  reg1 = Wire.read();
+  reg2 = Wire.read();
+  reg3 = Wire.read();
+  reg4 = Wire.read();
+  reg5 = Wire.read();
+  reg6 = Wire.read();
+  reg7 = Wire.read();
+  reg8 = Wire.read();
+  Wire.beginTransmission(AS3935_ADRS);
+  Wire.write(0x3A);
+  Wire.endTransmission(false);
+  Wire.requestFrom(AS3935_ADRS,4);
+  reg3A = Wire.read();
+  reg3B = Wire.read();
+  reg3C = Wire.read();
+  reg3D = Wire.read();
+
+}
+
+void setup()
+{
+  pinMode(2,INPUT);
+
+  Wire.begin();
+  Serial.begin(9600);          // start serial communication at 9600bps
+  Serial.println("READY");   // print the reading
+  // create a new character
+  lcd.createChar(5, Lightning);
+
+  INIT_LCD();
+  DISP_OPENNING();
+  INIT_AS3935();
+}
+
+void loop()
+{
+  writeCommand(0x01); // Clear Display
+  while(1)
+  {
+  if (digitalRead(5)== HIGH) INT_DETECTS();
+  }
+}
+
+void INT_DETECTS(void)
+{
+  digitalWrite(4, HIGH);  // LED ON
+  byte reg3buffer;
+  delay(4);
+  resistorRead();
+  reg3buffer = reg3 & 0x0F;
+  if (reg3buffer == 0x01) INT_NH();
+  if (reg3buffer == 0x04) INT_D();
+  if (reg3buffer == 0x08) INT_L();
+  digitalWrite(4, LOW);  // LED OFF
+}
+
+void INT_NH(void)  //noise level too high
+{
+  writeCommand(0x01); // Clear Display
+  LCD_STRING = "Nois Level High ";
+  LCD_DISP_16_1();
+  LCD_STRING = "el High ";
+  LCD_DISP_16_2();
+  delay(700);
+  writeCommand(0x01); // Clear Display
+  LCD_STRING = "Watching........ ";
+  LCD_DISP_16_1();
+}
+
+void INT_D(void)  //disturber detected
+{
+  writeCommand(0x01); // Clear Display
+  LCD_STRING = "Disturbe";
+  LCD_DISP_16_1();
+  LCD_STRING = "r DETect";
+  LCD_DISP_16_2();
+  delay(1500);
+  writeCommand(0x01); // Clear Display
+  LCD_STRING = "Watching........";
+  LCD_DISP_16_1();
+}
+
+void INT_L(void)  //lightning interrupt
+{
+  writeCommand(0x01); // Clear Display
+  enargy = (((reg6 & 0x0F) * 65536)+ (reg5 * 256)+ (reg4)) & 0x0FFFFF;
+  distance = (reg7 );
+  lcd.setCursor(0, 0);
+  lcd.write(5);
+  LCD_STRING = "E=" + String(enargy) ;
+  lcd.setCursor(1, 0);
+  LCD_DISP_16_1();
+  LCD_STRING = "D=" + String(distance) + "km";
+
+  if(reg7 == 0x01)  LCD_STRING = "E=" + String(enargy) + " OvrHed";
+  if(reg7 == 0x3F)  LCD_STRING = "E=" + String(enargy) + " OutRng";
+  LCD_DISP_16_2();
+  serialDisplay();
+  delay(5000);
+  writeCommand(0x01); // Clear Display
+  LCD_STRING = "Watching........";
+  LCD_DISP_16_1();
+}
+
+void INIT_AS3935(void)
+{
+  ByteWrite(0x3C,0x96);
+  ByteWrite(0x3D,0x96);
+  ByteWrite(0x00,(AFE_GB << 1));  // SET ANALOG FRONT END GAIN BOOST
+  ByteWrite(0x01,((NF_LEV << 4) | WDTH));
+  ByteWrite(0x03,0x00);           // FRQ DIV RATIO = 1/16
+  CALIB_LCO();
+}
+
+void CALIB_LCO(void)
+{
+  writeCommand(0x01); // Clear Display
+  delay(20);
+  LCD_STRING = "NOW CALIBRATION ";
+  LCD_DISP_16_1();
+  LCD_STRING = "C=000pF F=500000";
+  LCD_DISP_16_2();
+  FREQ_COUNT();    //DUMMY
+  for ( byte b = 0; b < 0x10 ; b++)
+  {
+    ByteWrite(0x08,(0x80 | b));
+    delay(50);
+    FREQ_COUNT();
+    NOW_BUFFER = abs(freq - 3125);
+    if(OLD_BUFFER > NOW_BUFFER) CAP_RESULT = b;
+    OLD_BUFFER = NOW_BUFFER;
+    Serial.print("CAP = ");
+    Serial.print(b,DEC);
+    Serial.print(" freq = ");
+    Serial.println((freq * 16 * 10 ),DEC );
+    LCD_STRING = String(b * 8);
+    writeCommand(0x40+0x82);
+    for(int i = 0; i < 3; i++)
+    {
+      writeData(LCD_STRING[i]);
+    }
+    LCD_STRING = String(freq * 16 * 10);
+    writeCommand(0x40+0x8A);
+    for(int i = 0; i < 7 ; i++)
+    {
+      writeData(LCD_STRING[i]);
+    }
+    delay(300);
+  }
+  writeCommand(0x01); // Clear Display
+  Serial.print("CAP_RESULT=");
+  Serial.print(CAP_RESULT);
+  Serial.print("   ");
+  Serial.print(CAP_RESULT * 8);
+  Serial.println("pF");
+  ByteWrite(0x08,(0x80 | CAP_RESULT));
+  delay(100);
+  FREQ_COUNT();
+  LCD_STRING = "CALIBRATION DONE";
+  LCD_DISP_16_1();
+  LCD_STRING = "pF 5000000Hz    ";
+  LCD_DISP_16_2();
+  LCD_STRING = String(CAP_RESULT * 8);
+  writeCommand(0x40+0x80);
+  for (int i = 0; i < 3; i++)
+  {
+    writeData(LCD_STRING[i]);
+  }
+  LCD_STRING = String(freq * 16 * 10);
+  writeCommand(0x40+0x87);
+  for (int i = 0; i < 7; i++)
+  {
+    writeData(LCD_STRING[i]);
+  }
+  ByteWrite(0x08,CAP_RESULT);
+  delay(3000);
+}
+
+void  FREQ_COUNT(void)
+{
+    FreqCounter::f_comp = 10;
+    FreqCounter::start(100);
+    while (FreqCounter::f_ready == 0);
+    freq = FreqCounter::f_freq;
+}
+
+void DISP_OPENNING(void)
+{
+  LCD_STRING = "Lightning Sensor";
+  LCD_DISP_16_1();
+  writeCommand(0x40+0x80);
+  LCD_STRING = "   AS3935 DEMO  ";
+  LCD_DISP_16_2();
+  delay(2000);
+}
+
+//Write Data
+void writeData(byte t_data)
+{
+  Wire.beginTransmission(LCD_ADRS);
+  Wire.write(0x40);
+  Wire.write(t_data);
+  Wire.endTransmission();
+delay(1);
+}
+//Write Command
+void writeCommand(byte t_command)
+{
+  Wire.beginTransmission(LCD_ADRS);
+  Wire.write(0x00);
+  Wire.write(t_command);
+  Wire.endTransmission();
+delay(10);
+}
+
+//Initialize LCD
+void INIT_LCD()
+{
+    lcd.begin(8, 2);      // LCD range
+    lcd.setContrast(30);  // Contrast setting
+    lcd.setCursor(0, 0);  // Cursor position
+}
+
+void LCD_DISP_16_1(void)
+{
+  for(int i = 0; i < 16; i++)
+  {
+    writeData(LCD_STRING[i]);
+  }
+}
+
+void LCD_DISP_16_2(void)
+{
+  writeCommand(0x40+0x80);
+  for(int i = 0; i < 16; i++)
+  {
+    writeData(LCD_STRING[i]);
+  }
+}
+
+
+void serialDisplay(void)
+{
+  Serial.print(LCD_STRING);
+  Serial.print(" reg0=");
+  Serial.print(reg0,HEX);
+  Serial.print(" reg1=");
+  Serial.print(reg1,HEX);
+  Serial.print(" reg2=");
+  Serial.print(reg2,HEX);
+  Serial.print(" reg3=");
+  Serial.print(reg3,HEX);
+  Serial.print(" reg4=");
+  Serial.print(reg4,HEX);
+  Serial.print(" reg5=");
+  Serial.print(reg5,HEX);
+  Serial.print(" reg6=");
+  Serial.print(reg6,HEX);
+  Serial.print(" reg7=");
+  Serial.print(reg7,HEX);
+  Serial.print(" reg8=");
+  Serial.println(reg8,HEX);
+}
+
+


Bluetooth control of 2 LEDs

Bluetooth control of 2 LEDs

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

--- src/bluetooth_LEDs/bluetooth_LEDs.ino
+++ src/bluetooth_LEDs/bluetooth_LEDs.ino
@@ -0,0 +1,39 @@
+int ledPin = 13;
+int state = 0;
+int flag = 0;
+
+void setup() {
+  pinMode(ledPin, OUTPUT);
+  digitalWrite(ledPin, LOW);
+  Serial.begin(9600);
+}
+
+void loop() {
+  if (Serial.available() > 0)
+  {
+    state = Serial.read();
+    Serial.print("State: ");
+    Serial.println(state);
+    flag = 0;
+  }
+
+  if (state == '0')
+  {
+    digitalWrite(ledPin, LOW);
+    if (flag == 0)
+    {
+      Serial.println("LED: off");
+      flag = 1;
+    }
+  }
+
+  if (state == '1')
+  {
+    digitalWrite(ledPin, HIGH);
+    if (flag == 0)
+    {
+      Serial.println("LED: on");
+      flag = 1;
+    }
+  }
+}


implementado botão um-clique com debounce

error: pathspec 'EMP-B-Due.ino' did not match any file(s) known to git

--- EMP-B-Due.ino
+++ EMP-B-Due.ino
@@ -0,0 +1,104 @@
+/*
+ EMP-B Due
+ V0.1 © 03/08/2014 William Koch
+
+ Controlador de Empacotadeira com Arduino Due.
+*/
+
+// Constantes de Entradas
+const byte botao_geral = 22;
+int estado_botao_geral;
+int estado_botao_geral_anterior = HIGH;
+long atraso_geral_anterior = 0;
+
+const byte indicador_geral = 25;
+int estado_indicador_geral = LOW;
+
+
+const byte botao_dosador = 26;
+int estado_botao_dosador;
+int estado_botao_dosador_anterior = HIGH;
+long atraso_dosador_anterior = 0;
+
+const byte indicador_dosador = 29;
+int estado_indicador_dosador = LOW;
+
+
+
+long atraso = 50;
+
+void setup() {
+  pinMode(botao_geral, INPUT_PULLUP);
+  pinMode(botao_dosador, INPUT_PULLUP);
+
+  pinMode(indicador_geral, OUTPUT);
+  pinMode(indicador_dosador, OUTPUT);
+
+  // set initial LED state
+  digitalWrite(indicador_geral, estado_indicador_geral);
+  digitalWrite(indicador_dosador, estado_indicador_dosador);
+}
+
+
+void loop() {
+  botao_um_clique(botao_geral, &estado_botao_geral, &estado_botao_geral_anterior, &atraso_geral_anterior, indicador_geral, &estado_indicador_geral);
+  botao_um_clique(botao_dosador, &estado_botao_dosador, &estado_botao_dosador_anterior, &atraso_dosador_anterior, indicador_dosador, &estado_indicador_dosador);
+}
+
+
+void botao_um_clique(byte botao, int *estado, int *estado_anterior, long *atraso_anterior, byte saida, int *estado_saida ){
+  int reading = digitalRead(botao);
+  if (reading != *estado_anterior) {
+    *atraso_anterior = millis();
+  }
+
+  if ((millis() - *atraso_anterior) > atraso) {
+    if (reading != *estado) {
+      *estado = reading;
+      if (*estado == LOW) {
+        *estado_saida = !*estado_saida;
+      }
+    }
+  }
+  digitalWrite(saida, *estado_saida);
+  *estado_anterior = reading;
+}
+
+
+
+// void botao_maquina(){
+//   // read the state of the switch into a local variable:
+//   int reading = digitalRead(buttonPin);
+
+//   // check to see if you just pressed the button
+//   // (i.e. the input went from LOW to HIGH),  and you've waited
+//   // long enough since the last press to ignore any noise:
+
+//   // If the switch changed, due to noise or pressing:
+//   if (reading != lastButtonState) {
+//     // reset the debouncing timer
+//     lastDebounceTime = millis();
+//   }
+
+//   if ((millis() - lastDebounceTime) > debounceDelay) {
+//     // whatever the reading is at, it's been there for longer
+//     // than the debounce delay, so take it as the actual current state:
+
+//     // if the button state has changed:
+//     if (reading != buttonState) {
+//       buttonState = reading;
+
+//       // only toggle the LED if the new button state is HIGH
+//       if (buttonState == LOW) {
+//         ledState = !ledState;
+//       }
+//     }
+//   }
+
+//   // set the LED:
+//   digitalWrite(ledPin, ledState);
+
+//   // save the reading.  Next time through the loop,
+//   // it'll be the lastButtonState:
+//   lastButtonState = reading;
+// }


Altitude Control Servo code

Altitude Control Servo code

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

--- Altitude/alt_control/alt_control.ino
+++ Altitude/alt_control/alt_control.ino
@@ -0,0 +1,46 @@
+Servo servo;
+int t = 0;
+int timeStop = 0;
+bool valveClosed = true;
+bool isCrusing = false;
+bool manueverDone = false;
+int altDiff = 0; //avg difference between last 5 readings of alt
+int tCruise = 0;
+void setup() {
+  servo.attach(0);
+
+}
+
+void loop() {
+  if (alt >= 50000 && valveClosed) {
+    t = millis() + 9000;
+    servo.write(180);
+    valveClosed = false;
+  }
+  if (55000 <= alt && !valveClosed) {
+    t = millis() + 9000;
+    servo.write(0);
+    valveClosed = true;
+    manueverDone = true;
+  }
+  if (millis() > t) {
+    servo.write(90);
+  }
+  if (altDiff < 100 && manueverDone) {
+    isCruising = true;
+    tCruise = millis() + 300000;
+  }
+  if (millis() > tCruise && isCruising) {
+    t = millis() + 216_000_000;
+    servo.write(180);
+    valveClosed = false;
+    isCruising = false;
+  }
+  if (millis() > (t + 60000) && !isCruising && manueverDone) {
+    t = millis() + 216_000_000;
+    servo.write(180);
+    valveClosed = false;
+    isCruising = false;
+  }
+
+}


Depuracion de archivos antiguos, actualizacion del sensor de energia

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

--- Arduino/SensordeEnergia/SensorEnergia.ino
+++ Arduino/SensordeEnergia/SensorEnergia.ino
@@ -0,0 +1,518 @@
+/**
+  * Description: This code has been only tested in Intel Galileo Gen 1 and gets the readings of the next sensors:
+        * SCT-013-000 - Electric current sensor
+    Then it calls the python scripts to send the data to the server via MQTT. All readings are writen to a file
+    located in the SD card, located by default in '/media/mmcblk0p1/'. The SD functions were taken from:
+    https://gist.github.com/carlynorama/9316252, we only override writing methods so it could support multiple
+    data types.
+
+  * Author:       Gustavo Adrián Jiménez González (Ruxaxup)
+  * Date:         03 - 27 - 2017
+  * Version:      1.0.0
+  * Contact:      gustavo.jim.gonz@gmail.com
+**/
+
+#include <Wire.h>
+#include <SD.h>
+#include "EmonLib.h"
+
+#define POTENCIA1 0X20
+#define POTENCIA 0X40
+
+#define ALL_CONNECTED 48
+#define DEBUG 0
+
+//FRECUENCIA DE MUESTREO
+#define SECOND         			1000
+#define CONNECTION_DELAY        SECOND *1 		// 1 second
+#define TIME_POTENCIA 			1              	//min
+#define TIME_DISC       		SECOND * 2     	//Time for connecting sensors
+//LEDS
+#define LED_ERROR 13
+#define LED_WARNING 12
+#define LED_OK 11
+
+//SENSOR LEYENDO
+#define LED_SENS_1 10
+#define LED_SENS_2 9
+#define LED_SENS_3 8
+
+
+//CANTIDAD DE SENSORES DE ENERGIA
+#define ENERGY_COUNT  3
+
+//VALOR DE CALIBRACION DE SENSORES DE ENERGIA
+#define ENERGY_CAL    116 //504
+
+byte readingFlag = 0x0;
+
+byte warningFlag = 0x0;
+
+byte estatus_sensores, estatus_anterior;
+
+typedef struct {  /*S2*/
+  double power[ENERGY_COUNT];   /*S2*/
+} Mediciones;
+
+enum states {
+  start,
+  idle,
+  readSensors,
+  sendMetadata,
+  sendDataMQTT,
+  error,
+  checkRanges,
+  connectSensors,
+  idleIterator
+};
+
+states state = start;
+
+//Energy sensors
+EnergyMonitor energySensors[ENERGY_COUNT];  /*S2*/
+//Energy IN array
+int energyPINS[] = {A1, A2, A3};
+Mediciones m;
+
+
+/////////////   MQTT    ///////////////
+
+
+
+
+void blinkERRORLed(int times)
+{
+  for (int i = 0; i < times; i++) {
+    digitalWrite(LED_ERROR, HIGH);
+    delay(250);
+    digitalWrite(LED_ERROR, LOW);
+    delay(250);
+  }
+}
+
+void blinkConnectionLEDS(int times)
+{
+  for (int i = 0; i < times; i++) {
+    digitalWrite (LED_SENS_1, HIGH);
+    digitalWrite (LED_SENS_2, HIGH);
+    digitalWrite (LED_SENS_3, HIGH);
+    delay(100);
+    digitalWrite (LED_SENS_1, LOW);
+    digitalWrite (LED_SENS_2, LOW);
+    digitalWrite (LED_SENS_3, LOW);
+    delay(100);
+    digitalWrite (LED_ERROR,  HIGH);
+    digitalWrite (LED_WARNING, HIGH);
+    digitalWrite (LED_OK, HIGH);
+    delay(100);
+    digitalWrite (LED_ERROR, LOW);
+    digitalWrite (LED_WARNING, LOW);
+    digitalWrite (LED_OK, LOW);
+    delay(100);
+  }
+}
+
+void _sendMetaData(String status) {
+  char data[30];
+
+  String path = String("python /home/root/PythonMQTT/sendMetadata.py " + status + " " + estatus_sensores);
+  char command [path.length() + 1  ];
+  path.toCharArray(command, sizeof(command));
+  if (DEBUG == 1) Serial.println(command);
+  system(command);
+}
+
+
+void _sendDataMQTT(String tipoLectura, String status, int energyIndex) {
+  char data[25];
+  String path = String("python /home/root/PythonMQTT/sendDataMQTTEnergy.py " + tipoLectura + energyIndex + " " + status);
+  galileoCreateFile("values.txt");
+  if (DEBUG == 1) Serial.println(tipoLectura);
+  if (tipoLectura.equals("power")) {
+    addValueToFile("values.txt", m.power[energyIndex]*127); // VALOR MODIFICADO - CALIBRACIÓN NUEVA
+  }                                                                                /*S2*/
+  char command [path.length() + 1  ];
+  path.toCharArray(command, sizeof(command));
+  if (DEBUG == 1) Serial.println(command);
+  system(command);
+  blinkERRORLed(5);
+}
+
+////////////    MQTT    ///////////////
+
+
+void clearData()
+{
+  for(int i = 0; i < ENERGY_COUNT; i++)
+  {
+    m.power[i] = 0.0;
+  }
+
+}
+
+////////////////////////////////////
+boolean getCurrent(EnergyMonitor em, int index)
+{
+  //Calcula a corrente
+  //I = 0.28, P = 25 kW
+  double Irms = em.calcIrms(1480);
+  m.power[index] = Irms;
+  return true;
+
+}
+//////////// Rangos ////////////////
+
+void turnOnStatusLeds(byte sensor)
+{
+  switch (sensor) {
+    case POTENCIA:
+      if ((warningFlag & POTENCIA) == POTENCIA) {
+        digitalWrite (LED_WARNING, HIGH);
+        digitalWrite (LED_OK, LOW);
+        digitalWrite (LED_ERROR, LOW);
+      }
+      else {
+        digitalWrite(LED_WARNING, LOW);
+        digitalWrite (LED_ERROR, LOW);
+        digitalWrite(LED_OK, HIGH);
+
+      }
+      break;
+      case POTENCIA1:
+      if ((warningFlag & POTENCIA1) == POTENCIA1) {
+        digitalWrite (LED_WARNING, HIGH);
+        digitalWrite (LED_OK, LOW);
+        digitalWrite (LED_ERROR, LOW);
+      }
+      else {
+        digitalWrite(LED_WARNING, LOW);
+        digitalWrite (LED_ERROR, LOW);
+        digitalWrite(LED_OK, HIGH);
+
+      }
+      break;
+  }
+}
+
+void turnOnSensorLeds(byte sensor)
+{
+  switch (sensor) {
+    case POTENCIA:
+      digitalWrite (LED_SENS_1, HIGH);
+      digitalWrite (LED_SENS_2, HIGH);
+      digitalWrite (LED_SENS_3, HIGH);
+
+      break;
+      case POTENCIA1:
+      digitalWrite (LED_SENS_1, HIGH);
+      digitalWrite (LED_SENS_2, HIGH);
+      digitalWrite (LED_SENS_3, HIGH);
+
+      break;
+  }
+
+}
+
+void resetLeds()
+{
+  delay(SECOND);
+  digitalWrite (LED_SENS_1, LOW);
+  digitalWrite (LED_SENS_2, LOW);
+  digitalWrite (LED_SENS_3, LOW);
+  digitalWrite(LED_WARNING, LOW);
+  digitalWrite (LED_ERROR, LOW);
+  digitalWrite(LED_OK, LOW);
+
+}
+
+
+void check_ranges()
+{
+  warningFlag = 0;
+  if ( (estatus_sensores & POTENCIA) == POTENCIA ) {
+
+  }
+}
+
+void check_sensors()
+
+{
+  estatus_anterior = estatus_sensores;
+  estatus_sensores = 0;
+  if (getCurrent(energySensors[0], 0)) {
+    estatus_sensores = estatus_sensores | POTENCIA;
+  }
+  else {
+    if (DEBUG == 1)Serial.println("Sensor de potencia1 desconectado");
+  }
+}
+
+void calibrateCurrentSensor(EnergyMonitor *em)
+{
+  em->calcIrms(5860);
+  em->calcIrms(5860);
+  em->calcIrms(5860);
+  em->calcIrms(5860);
+  em->calcIrms(5860);
+}
+
+void setup(void)
+{
+
+  Serial.begin(9600);
+  //Current
+  //Pino, calibracao - Cur Const= Ratio/BurdenR. 1800/62 = 29.
+  for(int i = 0; i < ENERGY_COUNT; i++)
+  {
+    energySensors[i].current(energyPINS[i], ENERGY_CAL);
+    calibrateCurrentSensor(&energySensors[i]);
+  }
+
+  pinMode(LED_ERROR, OUTPUT);
+  digitalWrite(LED_ERROR, LOW);
+  pinMode(LED_WARNING, OUTPUT);
+  digitalWrite(LED_WARNING, LOW);
+  pinMode(LED_OK, OUTPUT);
+  digitalWrite(LED_OK, LOW);
+  pinMode(LED_SENS_1, OUTPUT);
+  digitalWrite(LED_SENS_1, LOW);
+  pinMode(LED_SENS_2, OUTPUT);
+  digitalWrite(LED_SENS_2, LOW);
+  pinMode(LED_SENS_3, OUTPUT);
+  digitalWrite(LED_SENS_3, LOW);
+
+  //Indicador de arranque
+  turnOnSensorLeds(POTENCIA);
+  resetLeds();
+  turnOnSensorLeds(POTENCIA);
+  resetLeds();
+
+  turnOnSensorLeds(POTENCIA1);
+  resetLeds();
+  turnOnSensorLeds(POTENCIA1);
+  resetLeds();
+
+  estatus_sensores = 0;
+}
+
+/******************************** SD **********************************/
+//SD.open retrieves the file in append more.
+void addValueToFile(String fileName, float content) {
+  char charFileName[fileName.length() + 1];
+  fileName.toCharArray(charFileName, sizeof(charFileName));
+
+  if (SD.exists(charFileName)) {
+    File targetFile = SD.open(charFileName, FILE_WRITE);
+    targetFile.print(content);
+    targetFile.print("\n");
+    targetFile.close();
+  }
+}
+
+void addValueToFile(String fileName, double content) {
+  char charFileName[fileName.length() + 1];
+  fileName.toCharArray(charFileName, sizeof(charFileName));
+
+  if (SD.exists(charFileName)) {
+    File targetFile = SD.open(charFileName, FILE_WRITE);
+    targetFile.print(content);
+    targetFile.print("\n");
+    targetFile.close();
+  }
+}
+
+void addValueToFile(String fileName, uint32_t content) {
+  char charFileName[fileName.length() + 1];
+  fileName.toCharArray(charFileName, sizeof(charFileName));
+
+  if (SD.exists(charFileName)) {
+    File targetFile = SD.open(charFileName, FILE_WRITE);
+    targetFile.print(content);
+  }
+}
+
+void galileoCreateFile(String fileName) {
+  String status_message = String();
+  status_message = fileName;
+  char charFileName[fileName.length() + 1];
+  fileName.toCharArray(charFileName, sizeof(charFileName));
+
+  if (SD.exists(charFileName)) {
+    status_message += " exists already.";
+    if (DEBUG == 1) Serial.println("existe");
+  }
+  else {
+    if (DEBUG == 1) Serial.println("no existe");
+    char system_message[256];
+    char directory[] = "/media/realroot";
+    sprintf(system_message, "touch %s/%s", directory, charFileName);
+    SD.open(charFileName,FILE_WRITE);
+    system(system_message);
+    if (SD.exists(charFileName)) {
+      status_message += " created.";
+    }
+    else {
+      status_message += " creation tried and failed.";
+    }
+  }
+}
+
+/**********************************************************************/
+
+int cont_current = 0;
+int cont_disconnected = 0;
+
+void loop(void)
+{
+  String tipoLectura = String();
+
+  switch (state) {
+
+    case start:
+      check_sensors();
+      if (estatus_sensores == 0) {
+        state = error;
+      } else {
+        if (estatus_sensores != estatus_anterior) {
+          if (DEBUG == 1) Serial.println("Hubo cambios");
+          state = sendMetadata;
+        } else {
+          if (DEBUG == 1) Serial.println("No hubo cambios");
+          state = idle;
+        }
+      }
+
+
+      break;
+
+    case idle:
+      if (DEBUG == 1) Serial.println("state:Duermo 1 min");
+      delay(SECOND * 60);
+      if ( (estatus_sensores & POTENCIA) == POTENCIA ) {
+        cont_current++;
+      } else {
+        cont_current = 0;
+      }
+
+      if (DEBUG == 1) {
+        Serial.print("cont_current = ");
+        Serial.println(cont_current);
+      }
+      if (DEBUG == 1) Serial.println("state:Idle");
+
+      if (cont_current >= TIME_POTENCIA) {
+        readingFlag = readingFlag | POTENCIA;
+      }
+
+      if (readingFlag != 0x00) {
+        state = readSensors;
+      }
+
+      break;
+
+    case sendMetadata:
+      if (DEBUG == 1) Serial.println("state:sendMetadata");
+      _sendMetaData("S");
+      state = idle;
+      break;
+
+    case sendDataMQTT:
+      if (DEBUG == 1) Serial.println("state:sendDataMQTT");
+
+      if ( (readingFlag & POTENCIA) == POTENCIA) {
+        for(int i = 0; i < ENERGY_COUNT; i++)
+        {
+          if(DEBUG == 1)
+          {
+            Serial.print("Enviando POTENCIA ");
+            Serial.print(i);
+            Serial.print(":");
+            Serial.print(m.power[i] * 127);
+            Serial.println(" W");
+            Serial.print("***CORRIENTE electrica: ");
+            Serial.print(m.power[i]);
+            Serial.println(" A");
+          }
+          _sendDataMQTT("power", ((warningFlag & POTENCIA) == POTENCIA) ? "W" : "K", i);
+        }
+
+        cont_current = 0;
+        turnOnSensorLeds(POTENCIA);
+        turnOnStatusLeds(POTENCIA);
+        resetLeds();
+        readingFlag = readingFlag ^ POTENCIA;
+      }
+
+      clearData();
+      if (DEBUG == 1)Serial.print("SENSORS STATUS: ");
+      if (DEBUG == 1)Serial.println(estatus_sensores);
+      if (false) {
+        if (DEBUG == 1)Serial.println("CONNECT SENSOR");
+        state = connectSensors;
+      } else {
+        state = start;
+      }
+
+      break;
+
+    case readSensors:
+      if (DEBUG == 1) Serial.println("state:readSensors");
+      if( (readingFlag & POTENCIA) == POTENCIA)
+      {
+
+          if(DEBUG == 1) Serial.println("ENERGY SENSORS");
+          for(int i = 0; i < ENERGY_COUNT; i++)
+          {
+            getCurrent(energySensors[i],i);
+            if(DEBUG == 1)
+            {
+              Serial.print(i+1);
+              Serial.print(" Sensor: ");
+              Serial.println(m.power[i]);
+            }
+          }
+
+      }
+      state = checkRanges;
+      break;
+
+    case checkRanges:
+      check_ranges();
+      state = sendDataMQTT;
+      break;
+
+    case error:
+      if (DEBUG == 1) Serial.println("state:Error");
+      blinkERRORLed(10);
+      cont_disconnected++;
+      if (cont_disconnected == TIME_DISC) {
+        cont_disconnected = 0;
+        state = start;
+      } else {
+        delay(CONNECTION_DELAY);
+      }
+
+      break;
+
+    case connectSensors:
+      blinkConnectionLEDS(5);
+      cont_disconnected++;
+      if (cont_disconnected == TIME_DISC) {
+        cont_disconnected = 0;
+        state = start;
+      } else {
+        delay(CONNECTION_DELAY);
+      }
+      break;
+
+    case idleIterator:
+
+      break;
+
+    default:
+      if (DEBUG == 1) Serial.println("state:Default");
+      break;
+  }
+
+}
+


Add first Arduino example - blinky with delay function.

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

--- arduino/uno/001_blinky_with_delay_function/001_blinky_with_delay_function.ino
+++ arduino/uno/001_blinky_with_delay_function/001_blinky_with_delay_function.ino
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) 2019, Łukasz Marcin Podkalicki <lpodkalicki@gmail.com>
+ * ArduinoUno/001
+ * Blinky with delay function.
+ */
+
+#define LED_PIN (13)
+
+void setup() {
+  pinMode(LED_PIN, OUTPUT);
+}
+
+void loop() {
+  digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Toggle LED pin
+  delay(500); // wait 0.5s
+}
+


Simultaneus code. Unknown functionality

Simultaneus code. Unknown functionality

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

--- code/arduino/all/all.ino
+++ code/arduino/all/all.ino
@@ -0,0 +1,146 @@
+// FLIP-FLAP
+// Arduino code for Maker Faire Rome
+// October 2014
+// by John Rees
+
+// Declare the display not calibrated
+boolean calibrated = false;
+
+// Declare array strings for the 4 units
+String s0 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+String s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+String s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+String s3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:e ";
+
+// Define pin numbers
+int STEP_0 = 8;
+int STEP_1 = 6;
+int STEP_2 = 10;
+int STEP_3 = 12;
+
+int DIR_0 = 9;
+int DIR_1 = 7;
+int DIR_2 = 11;
+int DIR_3 = 13;
+
+
+
+//int limit = 10000;
+//int counter = 0;
+
+char serialdata[4];
+
+void setup() {
+
+  // Init Serial
+  Serial.begin(9600);
+  Keyboard.begin();
+  while (!Serial) {
+    ; // wait for serial port to connect. Needed for Leonardo only
+  }
+
+
+  // Init stepper pins
+  pinMode(DIR_3, OUTPUT);
+  pinMode(STEP_3, OUTPUT);
+  digitalWrite(DIR_3, HIGH);
+  digitalWrite(STEP_3, LOW);
+
+  pinMode(DIR_2, OUTPUT);
+  pinMode(STEP_2, OUTPUT);
+  digitalWrite(DIR_2, HIGH);
+  digitalWrite(STEP_2, LOW);
+
+  pinMode(DIR_0, OUTPUT);
+  pinMode(STEP_0, OUTPUT);
+  digitalWrite(DIR_0, HIGH);
+  digitalWrite(STEP_0, LOW);
+
+  pinMode(DIR_1, OUTPUT);
+  pinMode(STEP_1, OUTPUT);
+  digitalWrite(DIR_1, HIGH);
+  digitalWrite(STEP_1, LOW);
+
+
+  // Display Message
+  Serial.println("Flip-Flap Ready!");
+  Serial.println("Enter the 4 characters that the flipflap is displaying:");
+
+}
+
+int p0;
+int p1;
+int p2;
+int p3;
+
+void loop() {
+
+  if (Serial.available() > 0) {
+
+    Serial.readBytesUntil(10, serialdata, 4);
+
+    p0 = s0.indexOf(0);
+    p1 = s1.indexOf(1);
+    p2 = s2.indexOf(2);
+    p3 = s3.indexOf(3);
+
+    if(!calibrated) {
+      s0 = s0.substring(p0) + s0.substring(0,p0);
+      s1 = s1.substring(p1) + s1.substring(0,p1);
+      s2 = s2.substring(p2) + s2.substring(0,p2);
+      s3 = s3.substring(p2) + s3.substring(0,p3);
+      calibrated = true;
+    }
+    else {
+
+      p0 *= 480;
+      p1 *= 480;
+      p2 *= 480;
+      p3 *= 480;
+
+
+      // Obtaining max of p0,p1,p2,p3
+      int maxp=max(p0,p1);
+      maxp=max(maxp,p2);
+      maxp=max(maxp,p3);
+
+
+      // Put all steps in the same common loop
+      for(int i = 0; i < maxp; i++) {
+
+        if (i < p0) {
+          digitalWrite(STEP_0, HIGH);}
+        if (i < p1) {
+          digitalWrite(STEP_1, HIGH);}
+        if (i < p2) {
+          digitalWrite(STEP_2, HIGH);}
+        if (i < p3)  {
+          digitalWrite(STEP_3, HIGH);}
+
+        delayMicroseconds(100);
+
+        if (i < p0) {
+          digitalWrite(STEP_0, LOW);}
+        if (i < p1) {
+          digitalWrite(STEP_1, LOW);}
+        if (i < p2) {
+          digitalWrite(STEP_2, LOW);}
+        if (i < p3)  {
+          digitalWrite(STEP_3, LOW);}
+      }
+
+     // Shift strings
+     s0 = s0.substring(p0) + s0.substring(0,p0);
+     s1 = s1.substring(p1) + s1.substring(0,p1);
+     s2 = s2.substring(p2) + s2.substring(0,p2);
+     s3 = s3.substring(p3) + s3.substring(0,p3);
+     Serial.println("Done!");
+
+    }
+  }
+
+
+
+}
+
+


Create mega2560_Modbusmaster.ino

Create mega2560_Modbusmaster.ino

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

--- rr/mega2560_Modbusmaster.ino
+++ rr/mega2560_Modbusmaster.ino
@@ -0,0 +1,47 @@
+#include <SimpleModbusMaster.h>
+
+
+#define baud 9600
+#define timeout 1000
+#define polling 200
+#define retry_count 10
+
+
+#define TxEnablePin 2
+
+long randNumber;
+#define TOTAL_NO_OF_REGISTERS 1
+
+
+enum
+{
+  PACKET1,
+  PACKET2,
+  TOTAL_NO_OF_PACKETS
+};
+
+
+Packet packets[TOTAL_NO_OF_PACKETS];
+
+
+unsigned int regs[TOTAL_NO_OF_REGISTERS];
+
+void setup()
+{
+
+  modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0, 1, 0);
+  modbus_construct(&packets[PACKET2], 1, PRESET_MULTIPLE_REGISTERS, 1, 1, 0);
+
+
+  modbus_configure(&Serial3, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
+
+
+}
+
+void loop()
+{randNumber = random(10, 30);
+  modbus_update();
+
+  regs[0] = randNumber;
+
+}


Untested Arduino receiver code.

Untested Arduino receiver code.

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

--- SensorSeed/Arduino/ArduinoIndoorReceiverI2cSlave/ArduinoIndoorReceiverI2cSlave.ino
+++ SensorSeed/Arduino/ArduinoIndoorReceiverI2cSlave/ArduinoIndoorReceiverI2cSlave.ino
@@ -0,0 +1,148 @@
+#include <TinyWireM.h>
+#include <USI_TWI_Master.h>
+#include <Wire.h>
+#include <RFM69.h>
+#include <SPI.h>
+#include <stdlib.h>
+
+volatile byte* Float1ArrayPtr;
+double dataToSend;
+unsigned long lastReceivedMillis = millis();
+unsigned long lastSentMillis = millis();
+char radiopacket[150];
+
+// Settings for the Adafruit RFM69HCW radio
+#define NETWORKID     81
+#define NODEID        1
+#define FREQUENCY     RF69_915MHZ
+#define ENCRYPTKEY    "eq^YkQ3n7HvC#9c$"
+#define IS_RFM69HCW   true
+
+// Pins for the Adafruit RFM69HCW radio
+#define RFM69_CS      10
+#define RFM69_IRQ     2
+#define RFM69_IRQN    0  // IRQ 0
+#define RFM69_RST     9
+
+#define LED           13
+
+#define SERIAL_BAUD   9600
+
+// Setup the radio library
+RFM69 radio = RFM69(RFM69_CS, RFM69_IRQ, IS_RFM69HCW, RFM69_IRQN);
+
+void setupRadio() {
+  // Hard Reset the RFM module
+  pinMode(RFM69_RST, OUTPUT);
+  digitalWrite(RFM69_RST, HIGH);
+  delay(100);
+  digitalWrite(RFM69_RST, LOW);
+  delay(100);
+// Initialize radio
+  radio.initialize(FREQUENCY,NODEID,NETWORKID);
+  if (IS_RFM69HCW) {
+    radio.setHighPower();    // Only for RFM69HCW & HW!
+  }
+  radio.setPowerLevel(31); // power output ranges from 0 (5dBm) to 31 (20dBm)
+
+  radio.encrypt(ENCRYPTKEY);
+
+  pinMode(LED, OUTPUT);
+  Serial.print("\nListening at ");
+  Serial.print(FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
+  Serial.println(" MHz");
+}
+
+
+void setup() {
+  Serial.begin(SERIAL_BAUD);
+  Serial.println("Starting Arduino Metro weather station I2C master, radio receiver...");
+  setupRadio();
+
+ Wire.begin(7);
+ Wire.onRequest(requestEvent);
+ Wire.onReceive(receiveEvent);
+  Serial.println("Setup complete");
+}
+
+void loop() {
+  //check if something was received (could be an interrupt from the radio)
+  if (radio.receiveDone())
+  {
+    //print message received to serial
+    Serial.print('[');Serial.print(radio.SENDERID);Serial.print("] ");
+    Serial.print((char*)radio.DATA);
+    Serial.print("   [RX_RSSI:");Serial.print(radio.RSSI);Serial.print("]");
+
+    lastReceivedMillis = millis();
+
+    //check if sender wanted an ACK
+    if (radio.ACKRequested())
+    {
+      radio.sendACK();
+      Serial.println(" - ACK sent");
+    }
+  }
+
+  radio.receiveDone(); //put radio in RX mode
+  Serial.flush(); //make sure all serial data is clocked out before sleeping the MCU
+}
+
+double isDataNew() {
+  unsigned long difference = lastReceivedMillis -  lastSentMillis;
+  if(difference > 0) {
+    return 1;
+  } else {
+    return 0;
+  }
+}
+
+
+
+void requestEvent(){
+  // char frame[30];
+ //sprintf(frame, "%8.2", dataToSend);
+
+   //String data = String(dataToSend, DEC);
+   //dataToSend = 123456.78;
+
+
+  if(dataToSend == 3) {
+    //String data = String(radiopacket);
+    lastSentMillis = millis();
+    Wire.write(radiopacket);
+  } else {
+   char temp1[10];
+   dtostrf(dataToSend, 10, 2, temp1);
+   String data = String(temp1);
+   Wire.write(temp1);
+  }
+
+  //Wire.write(frame, 30);
+  //Wire.write("abcd");
+  //Serial.print("Sent: ");
+  //Serial.println(data);
+  //Serial.println("-----");
+}
+
+
+void receiveEvent(int howMany){
+  int c;
+  c = Wire.read(); // receive byte as a character
+  //Serial.print("Got: ");
+  //Serial.println(c);
+  if(c == 1) { // Is there new data?
+    dataToSend = isDataNew();
+    //dataToSend = 1.2;
+  } else if(c == 2) { // What is the data?
+     // dataToSend = 3.4;
+    dataToSend = 3;
+  }
+}
+
+
+
+
+
+
+


Fix typos and incorrect LED assignment

Fix typos and incorrect LED assignment

error: pathspec 'Sounds' did not match any file(s) known to git
error: pathspec 'and' did not match any file(s) known to git
error: pathspec 'Senses/analog_range/analog_range.ino' did not match any file(s) known to git


Initial commit for shu_timer

Initial commit for shu_timer

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

--- shu_timer/shu_timer.ino
+++ shu_timer/shu_timer.ino
@@ -0,0 +1,124 @@
+/*
+  Shu Timer
+
+  A Timer app with for Shu-chan to limit his TV/Gaming time.
+  Runs on littleBits + Arduino.
+ */
+
+// consts
+const int START_BTN = 0; // timer start button input at D0
+const int STOP_BTN = A0; // timer stop button input at A0
+const int RESET_BTN = A1; // timer reset button input at A1
+const int BLINKER_LED = 1; // blinker LED output at D1
+const int COUNTER_LED = 5; // counter 7-seg LED output at D5
+const int CLOUDBIT = 9; // cloudBit output at D9
+
+const int START_VAL = 20 * 60; // the unit amount for starting timer in seconds
+const int MAX_VAL = 99 * 60; // max amount of timer in seconds
+
+// states
+int timerValue = 0;
+unsigned long lastTick = 0;
+boolean isStopped = false;
+int startBtnPrev = LOW;
+int stopBtnPrev = 0;
+int timerValuePrev = 0;
+
+// setup
+void setup() {
+  pinMode(BLINKER_LED, OUTPUT);
+  pinMode(COUNTER_LED, OUTPUT);
+  pinMode(CLOUDBIT, OUTPUT);
+  analogWrite(CLOUDBIT, 0);
+}
+
+// main loop
+void loop() {
+  delay(100);
+  ticking();
+  checkResetButton();
+  checkStartButton();
+  checkStopButton();
+  outputCloudBit();
+  displayBlinker();
+  displayCounter();
+}
+
+// decrease timerValue every one sec if timer is not stopped
+void ticking() {
+  if (lastTick == 0 || millis() - lastTick > 1000) {
+    lastTick = millis();
+    timerValuePrev = timerValue;
+    if (timerValue > 0 && !isStopped) {
+      timerValue--;
+    }
+  }
+}
+
+// if reset button is pressed, clear all the states
+void checkResetButton() {
+  if (digitalRead(RESET_BTN) == HIGH) {
+    lastTick = 0;
+    timerValue = 0;
+    timerValuePrev = 0;
+    isStopped = false;
+  }
+}
+
+// if start button is pressed, increase timerValue by START_VAL
+void checkStartButton() {
+  boolean startBtn = digitalRead(START_BTN);
+  if (startBtn == HIGH && startBtnPrev == LOW) {
+    timerValue = min(timerValue + START_VAL, MAX_VAL);
+  }
+  startBtnPrev = startBtn;
+}
+
+// if stop button is pressed, flip isStopped flag
+void checkStopButton() {
+  int stopBtn = analogRead(STOP_BTN);
+  if (stopBtn > 90 && stopBtnPrev == 0 && timerValue > 0) {
+    isStopped = !isStopped;
+  }
+  stopBtnPrev = stopBtn;
+}
+
+// output to blinker LED
+void displayBlinker() {
+
+  // if timer is not working, turn off
+  if (timerValue == 0) {
+      digitalWrite(BLINKER_LED, LOW);
+      return;
+  }
+
+  // if timer is stopped, turn on
+  if (isStopped) {
+      digitalWrite(BLINKER_LED, HIGH);
+      return;
+  }
+
+  // if timer is ticking, blink it
+  int blinkerValue = LOW;
+  if(timerValue % 2 == 0) {
+    blinkerValue = LOW;
+  } else {
+    blinkerValue = HIGH;
+  }
+  digitalWrite(BLINKER_LED, blinkerValue);
+}
+
+// output to counter 7seg LED
+void displayCounter() {
+  int counterValue = counterValue = map(timerValue, 0, 5999, 0, 255); // maps 6000 sec to 100 minutes on littleBits LED
+  analogWrite(COUNTER_LED, counterValue);
+}
+
+// output to cloutBit when timer counting is finished
+void outputCloudBit() {
+  if (timerValue == 0 && timerValuePrev == 1) {
+    analogWrite(CLOUDBIT, 255);
+    delay(500);
+    analogWrite(CLOUDBIT, 0);
+  }
+}


quad ultrasonic sensor code optimization

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


PWM reader

PWM reader

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

--- TimerTest/TimerTest.ino
+++ TimerTest/TimerTest.ino
@@ -0,0 +1,90 @@
+#include <LiquidCrystal.h>
+
+#define LED_PIN 13
+#define READ_PIN 2
+#define PWM_PIN 3
+
+#define POT_PIN 0
+
+volatile long timeSinceLast = 0;
+volatile long period = 0;
+volatile long pilseLength = 0;
+
+ISR(INT0_vect) {
+  int currentTime = TCNT1;
+  if (digitalRead(READ_PIN) == HIGH) {
+    timeSinceLast = currentTime;
+    period = pilseLength + currentTime;
+  } else {
+    TCNT1 = 0;
+    pilseLength = currentTime - timeSinceLast;
+  }
+}
+
+int currState = LOW;
+LiquidCrystal lcd(5, 6, 8, 9, 10, 11);
+
+void setup()
+{
+  pinMode(LED_PIN, OUTPUT);
+  pinMode(READ_PIN, INPUT);
+  pinMode(PWM_PIN, OUTPUT);
+
+
+  lcd.begin(16, 2);
+  lcd.print("hello, world!");
+  Serial.begin(9600);
+  TCCR1A = 0;    // set timer1 operation mode to normal
+  //TIFR1 |= _BV(OCF1A);     // clear any pending interrupts;
+  //TIMSK1 |=  _BV(OCIE1A) ; // enable the output compare interrupt
+
+  EICRA |= (1 << ISC00); // ext.int. any logic change
+  EIMSK |= (1 << INT0);  // enable INT0
+  TCCR1B = 2; // set prescaler 8
+  // change timer2 prescaler. Timer2 controls PWM no pin 3
+  TCCR2B &= 0xF8;  // clear prescaler bits
+  TCCR2B |= 5;     // set 1024 prescaler
+
+  Serial.println(TCCR0B);
+  Serial.println(TCCR1B);
+  Serial.println(TCCR2B);
+}
+
+void loop()
+{
+  blink();
+
+  byte potValue = analogRead(POT_PIN)/4;
+  analogWrite(PWM_PIN, potValue);
+
+  lcd.setCursor(0, 0);
+  lcd.print("Pulse(ms): ");
+  lcd.print(1000.0 / (double)(F_CPU / (pilseLength * 8)));
+  lcd.setCursor(0, 1);
+  lcd.print("Period(ms): ");
+  lcd.print(1000.0 / (double)(F_CPU / (period * 8)));
+
+  Serial.print("Pulse(ms): ");
+  Serial.print(1000.0 / (double)(F_CPU / (pilseLength * 8)));
+  Serial.print(" Period(ms): ");
+  Serial.print(1000.0 / (double)(F_CPU / (period * 8)));
+  Serial.print(" PotValue: ");
+  Serial.println(potValue);
+ //Serial.println(TCNT1);
+
+ //char str[255];
+ //sprintf(str, "qwe %i", 555);
+ //Serial.println(str);
+
+ delay(10);
+}
+
+void blink() {
+   digitalWrite(LED_PIN, currState);
+     if (currState == LOW)
+      currState = HIGH;
+    else
+      currState = LOW;
+}
+
+


Create load-cell-calibration.ino

Create load-cell-calibration.ino

Use this sketch to calculate the calibration parameter to output mass in human readable quantities

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

--- firmware/load-cell-calibration.ino
+++ firmware/load-cell-calibration.ino
@@ -0,0 +1,85 @@
+//////////////////////////////////////////
+// Particle Photon load cell scale v1.0 //
+//////////////////////////////////////////
+
+// Justin Ashton
+// (c) J. Ashton & Company, Inc., 2016
+//
+// Borrowed code from: https://github.com/juano2310/HX711ADC
+//
+// Hardware setup: Particle Photon, HX711 load cell amp from SparkFun, load cell strain gauge
+//
+// This sketch is designed to help you calibrate your load cell scale.
+// Run this sketch and open a serial port for input/output. The first time you run this
+// sketch, enter the number "1" to reset any existing calibration. Then type "2" to
+// zero out the scale (tare). Place a known weight on the scale, then type "3" to measure
+// and output the weight on the scale. The calibration parameter needed in .set_scale() is
+// equal to the value output in step #3 divided by the mass of the known weight. Enter it
+// inside the parentheses of the scale.set_scale() function under void setup().
+
+// This #include statement was automatically added by the Particle IDE.
+#include "application.h"
+#include "HX711ADC/HX711ADC.h"
+
+char user_input;
+
+//HX711ADC(byte dout, byte pd_sck, byte gain = 128);
+HX711ADC scale(D3, D2); //D3 to DAT and D2 to CLK pin on SparkFun load cell amp board
+
+
+void setup() {
+  Serial.begin(9600);
+  scale.set_scale(1610.f); // to calibrate scale, change this parameter and be sure to add ".f" after
+  Serial.println("HX711ADC Calibration Sketch");
+  Serial.println("Menu: Enter number");
+  Serial.println("m. List menu.");
+  Serial.println("1. Reset scale calibration.");
+  Serial.println("2. Zero out scale.");
+  Serial.println("3. Weigh scale.");
+  Serial.println();
+
+}
+
+void loop() {
+
+  while(Serial.available()){
+      user_input = Serial.read(); //Read user input and trigger appropriate action
+      switch (user_input){
+          case '1':
+          Serial.println("1. Reset scale calibration."); //uses function .set_scale to reset the calibration value
+          scale.set_scale();
+          Serial.println("Initialized");
+          delay(250);
+          break;
+
+          case '2':
+          Serial.println("2.Zero out scale."); //use function .tare to zero out scale
+          scale.tare();
+          Serial.println("Zeroed.");
+          delay(250);
+          break;
+
+          case '3':
+          Serial.println("3. Weigh scale."); // reads and outputs an average value of weight.
+          Serial.println(scale.get_units(10));
+          delay(250);
+          break;
+
+          case 'm':
+          Serial.println("Menu: Enter number");
+          Serial.println("m. List menu.");
+          Serial.println("1. Reset scale calibration.");
+          Serial.println("2. Zero out scale.");
+          Serial.println("3. Weigh scale.");
+          Serial.println();
+          delay(250);
+          break;
+
+          default:
+          Serial.println("Invalid option entered.");
+          }
+
+          }
+}
+
+


Use strcmp instead of == (c# habits die hard)

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


add arduino program to read animation from SD and sending to 3D8

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

--- SDAnimation.ino
+++ SDAnimation.ino
@@ -0,0 +1,79 @@
+#include "SD.h"
+#include "string.h"
+
+Sd2Card card;
+SdVolume volume;
+const int chipSelect = 4;
+File root;
+
+void setup()
+{
+	Serial.begin(57600);
+
+	pinMode(10, OUTPUT); // change this to 53 on a mega
+
+	bool sd_ok = SD.begin(9);
+
+	if (!sd_ok)
+	{
+		Serial.println("failed.");
+		return;
+	}
+
+	root = SD.open("/");
+}
+
+void sendAnimation(byte *data)
+{
+	Serial.write(0xf3);
+	Serial.write(data[1]);
+
+	Serial.write(0xf4);
+	Serial.write(data[2]);
+
+	Serial.write(0xf5);
+	Serial.write(data[3]);
+
+	Serial.write(0xf2);
+	for (byte i = 8; i < 72; i++)
+	{
+		Serial.write(data[i]);
+	}
+
+	delayMicroseconds(makeWord(data[4], data[5]));
+	delay(makeWord(data[6], data[7]));
+}
+
+void readAnimation(File & file)
+{
+	byte data[72];
+	while (file.available())
+	{
+		file.read(data, 72);
+//		for (byte i = 0; i < 72; i++)
+//			Serial.write(data[i]);
+
+		sendAnimation(data);
+	}
+}
+
+void loop(void)
+{
+	File file = root.openNextFile();
+	if (file)
+	{
+		char *p = file.name();
+		char *p_dot = strchr(p, '.');
+
+		if (p_dot != NULL && strcmp(p_dot, ".DAT") == 0)
+		{
+			readAnimation(file);
+		}
+
+		file.close();
+	}
+	else
+		root.rewindDirectory();
+}
+
+


add audio-menu and extra playmode

add audio-menu and extra playmode

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/andydrop/klampfinator.git/'


Asservissement:  mise en forme code asservissement vitesse

error: pathspec 'Module' did not match any file(s) known to git
error: pathspec 'Moteur/Software/Asservissement/Asservissement' did not match any file(s) known to git
error: pathspec 'vitesse/src/application.ino' did not match any file(s) known to git


Change 128x64 life to use tiny screen

Change 128x64 life to use tiny screen

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


Stuff

Stuff

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/markwatneyy/ttt_arduino.git/'


SoundBuzzer

SoundBuzzer

updated the last note!

error: pathspec 'Action' did not match any file(s) known to git
error: pathspec 'Modules/Piano' did not match any file(s) known to git
error: pathspec 'Synthesizer/PianoSynthesizerATtiny/PianoSynthesizerATtiny.ino' did not match any file(s) known to git


Change control topic to, well, "control"


Create palette_example2.ino

Create palette_example2.ino

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

--- palette_example2.ino
+++ palette_example2.ino
@@ -0,0 +1,89 @@
+//***************************************************************
+// Gradient palette that can have colors or anchor points updated on the fly.
+// This is based on some code from Mike Brown.
+// https://plus.google.com/u/0/102054795236178256184/posts/UWbQBcmKDdU?cfem=1
+//
+// Randomly picks start and end colors.  Colors in middle remain
+// constant, but for fun their anchor points are randomly picked.
+//
+// More info on gradient palettes here:
+// https://github.com/FastLED/FastLED/wiki/Gradient-color-palettes
+//
+// Marc Miller, May 2017
+//***************************************************************
+
+#include "FastLED.h"
+#if FASTLED_VERSION < 3001000
+#error "Requires FastLED 3.1 or later; check github for latest code."
+#endif
+
+#define LED_TYPE LPD8806
+#define DATA_PIN 11
+#define CLOCK_PIN 13
+#define NUM_LEDS 32
+#define COLOR_ORDER GRB
+CRGB leds[NUM_LEDS];
+#define BRIGHTNESS  255
+
+CRGBPalette256 currentPalette;
+CHSV hsv;
+CRGB rgb;
+
+//---------------------------------------------------------------
+void setup() {
+  Serial.begin(115200);
+  delay(500);  // startup delay
+  //FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
+  FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
+  FastLED.setBrightness(BRIGHTNESS);
+}
+
+//---------------------------------------------------------------
+void loop () {
+  EVERY_N_SECONDS(2){
+    newGradientPalette();
+  }
+  FastLED.show();
+  FastLED.delay(100);
+}
+
+
+//---------------------------------------------------------------
+void newGradientPalette(){
+  uint8_t xyz[16];  // Needs to be 4 times however many colors are being used.
+                    // 3 colors = 12, 4 colors = 16, etc.
+
+  hsv = CHSV(random8(), 255, 255);  // pick random hue
+  hsv2rgb_rainbow( hsv, rgb);  // convert to R,G,B
+
+  xyz[0] = 0;  // anchor of first color - must be zero
+  xyz[1] = rgb.r;
+  xyz[2] = rgb.g;
+  xyz[3] = rgb.b;
+
+  xyz[4] = random8(48,118);  // random anchor point for second color
+  xyz[5] = 255;
+  xyz[6] = 0;
+  xyz[7] = 0;
+
+  xyz[8] = random8(138,225);  // random anchor point for third color
+  xyz[9] = 0,
+  xyz[10] = 255;
+  xyz[11] = 0;
+
+  hsv = CHSV(random8(), 255, 255);  // pick random hue
+  hsv2rgb_rainbow( hsv, rgb);  // convert to R,G,B
+
+  xyz[12] = 255;  // anchor of last color - must be 255
+  xyz[13] = rgb.r;
+  xyz[14] = rgb.g;
+  xyz[15] = rgb.b;
+
+  currentPalette = xyz;
+
+  for (int p = 0; p < NUM_LEDS; p++) {
+    leds[p] = ColorFromPalette(currentPalette, p*255/(NUM_LEDS-1), BRIGHTNESS, NOBLEND);
+  }
+
+}
+