Add new starting payload program

Add new starting payload program

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

--- payload/my-payload.ino
+++ payload/my-payload.ino
@@ -0,0 +1,65 @@
+#include <Wire.h>
+#include "Adafruit_BMP085.h"
+
+/*
+ * BMP180 setup instructions:
+ * ----------------------------------------
+ * Connect BMP180 V-in   to 3.3V (NOT 5.0V)
+ * Connect BMP180 GND    to Ground
+ * Connect BMP180 SCL    to Analog 5
+ * Connect BMP180 SDA    to Analog 4
+ * ----------------------------------------
+*/
+
+Adafruit_BMP085 barometer;
+
+void setup() {
+  Serial.begin(9600); // 9600 bits/second
+  if (!barometer.begin()) {
+  	Serial.println("No BMP085 sensor found.");
+  	while (1) { /* Trap the thread. */ }
+  }
+}
+
+void printBaroData() {
+
+    // Get temperature.
+    Serial.print("Temperature = ");
+    Serial.print(barometer.readTemperature());
+    Serial.println(" *C");
+
+    // Get pressure at sensor.
+    Serial.print("Pressure = ");
+    Serial.print(barometer.readPressure());
+    Serial.println(" Pa");
+
+    // Calculate pressure at 0 MSL. (0 meters mean sea-level)
+    Serial.print("Calculated pressure at 0 MSL = ");
+    Serial.print(barometer.readSealevelPressure());
+    Serial.println(" Pa");
+
+    // Get pressure altitude:
+    // altitude with (default) altimeter setting at 101325 Pascals == 1013.25 millibars
+    // == 29.92 inches mercury (i.e., std. pressure)
+    Serial.print("Pressure altitude = ");
+    Serial.print(barometer.readAltitude());
+    Serial.println(" meters");
+
+    // TODO:
+    // Density altitude: pressure altitude corrected for nonstandard temperature
+    // High density altitude (High, Hot, and Humid) means decreased performance.
+
+    // Get indicated altitude:
+    // pressure altitude corrected for non-standard pressure, with altimeter
+    // setting 1015 millibars == 101500 Pascals
+    // For pressure conversions, visit NOAA at: https://www.weather.gov/media/epz/wxcalc/pressureConversion.pdf.
+    Serial.print("Indicated altitude = ");
+    Serial.print(barometer.readAltitude(101500));
+    Serial.println(" meters");
+
+    Serial.println();
+}
+void loop() {
+    printBaroData();
+    delay(350);
+}


LED blink and analog read

LED blink and analog read

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

--- LED_blink/LED_blink.ino
+++ LED_blink/LED_blink.ino
@@ -0,0 +1,39 @@
+/*
+  LED Blink (now with Analog Read)
+  Turns on the two LEDs on for one second, then off for one second, repeatedly.
+  Reads from the analog input pin and prints out to serial at 9600 baud
+  Note that HIGH is OFF and LOW is ON
+
+  modified Oct 2016
+  by Nancy Ouyang
+*/
+
+
+#define LED_PIN D0
+#define LED_PIN_2 D4
+#define ANALOG_PIN A0
+int sensorValue = 999;
+
+void setup() {
+  pinMode(LED_PIN, OUTPUT);
+  pinMode(LED_PIN_2, OUTPUT);
+  pinMode(ANALOG_PIN, INPUT);
+  Serial.begin(9600);
+}
+
+void loop() {
+  digitalWrite(LED_PIN, HIGH);
+  digitalWrite(LED_PIN_2, LOW);
+  sensorValue = analogRead(ANALOG_PIN);
+  Serial.println(sensorValue);
+
+  delay(300);
+
+  digitalWrite(LED_PIN, LOW);
+  digitalWrite(LED_PIN_2, HIGH);
+  sensorValue = analogRead(ANALOG_PIN);
+  Serial.println(sensorValue);
+
+  delay(300);
+
+}


dsp7s04_demo.ino

dsp7s04_demo.ino

Test program for DSP7S04

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

--- dsp7s04_demo.ino
+++ dsp7s04_demo.ino
@@ -0,0 +1,123 @@
+/*
+Copyright (c) 2015, Embedded Adventures
+All rights reserved.
+Contact us at source [at] embeddedadventures.com
+www.embeddedadventures.com
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in the
+  documentation and/or other materials provided with the distribution.
+- Neither the name of Embedded Adventures nor the names of its contributors
+  may be used to endorse or promote products derived from this software
+  without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+//DSP7S04 7-Segment display demo
+//Written originally by Embedded Adventures
+
+#include <dsp7s04.h>
+
+/*pin configurations for this demo*/
+#define CLK 12
+#define MOSI 11
+#define LAT 5
+#define PW 6
+
+void setup() {
+  dsp7s04.init(CLK, MOSI, LAT, PW);
+  Serial.begin(115200);
+  Serial.println("Initializing...");
+}
+
+void loop() {
+  demoBrightness();
+  dsp7s04.clearAll();
+  demoDots();
+  demoNumbers();
+}
+
+void demoNumbers() {
+  Serial.println("Run through 0-9 on all digits");
+  for (int i = 0; i < 10; i++){
+    int demoInt = i*1000 + i*100 + i*10 + i;
+    demoInt = i*1000 + i*100 + i*10 + i;
+    dsp7s04.write(demoInt);
+    delay(500);
+    dsp7s04.clearAll();
+    delay(500);
+  }
+  Serial.println("Second form of write(), using two ints");
+  dsp7s04.write(20, 15);
+  delay(500);
+  dsp7s04.clearAll();
+  Serial.println("Third form of write(), specifiying a digit and a number to write as a char");
+  dsp7s04.write('1', 3);
+  delay(500);
+  dsp7s04.write('3', 2);
+  delay(500);
+  dsp7s04.write('5', 1);
+  delay(500);
+  dsp7s04.write('7', 0);
+  delay(500);
+  dsp7s04.clearAll();
+}
+
+void demoDots() {
+  Serial.println("Demo of dots");
+  for (int i = 3; i >= 0; i--){
+    if (i != 3) {
+      dsp7s04.clearDot(i+1);
+    }
+    dsp7s04.setDot(i);
+    delay(500);
+  }
+   Serial.println("Blinking all dots");
+   for (int i = 3; i >= 0; i--){
+    dsp7s04.setDot(0);
+    dsp7s04.setDot(1);
+    dsp7s04.setDot(2);
+    dsp7s04.setDot(3);
+    delay(500);
+    dsp7s04.clearAll();
+    delay(500);
+  }
+}
+
+void demoBrightness() {
+  dsp7s04.turnOn();
+  dsp7s04.setBrightness(0);
+  Serial.println("Setting brightness level at 100%");
+  delay(1000);
+  dsp7s04.setBrightness(75);
+  Serial.println("Setting brightness level at 75%");
+  delay(1000);
+  dsp7s04.setBrightness(50);
+  Serial.println("Setting brightness level at 50%");
+  delay(1000);
+  dsp7s04.setBrightness(25);
+  Serial.println("Setting brightness level at 25%");
+  delay(1000);
+  dsp7s04.setBrightness(0);
+  Serial.println("Setting brightness level at 0%");
+  delay(1000);
+
+  for (int i = 10; i < 100; i+=10){
+    dsp7s04.setBrightness(i);
+    delay(500);
+  }
+}


arduino code shockbox

arduino code shockbox

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


new example of producer/consumer module

new example of producer/consumer module

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

--- examples/merg_servo_ir/merg_servo_ir.ino
+++ examples/merg_servo_ir/merg_servo_ir.ino
@@ -0,0 +1,329 @@
+/*
+This example implements a ir sensor controller to detect block occupancy.
+It drives 16 ir. Can be more in arduino Mega, but it just an example.
+The module produces ON/OFF events.
+The vents can be toogled by the first 2 node variables. 0 means ON when train enters, OFF when trains leaves.
+1 means the oposit. Each bit of the 2 bytes are to ser togle or not.
+Usim FLIM mode teach on/off events.
+It implements all automatic configuration, including learning events.
+It does not handle DCC messages, but you can do it on your user function.
+You can change the ports to fit to your arduino.
+This node uses 500 bytes of EPROM to store events and the other information.
+See MemoryManagement.h for memory configuration
+To clear the memory, press pushbutton1 while reseting the arduino
+
+*/
+
+
+
+#include <Arduino.h>
+#include <SPI.h> //required by the library
+#include <TimerOne.h>
+#include <MergCBUS.h>
+#include <Message.h>
+#include <EEPROM.h> //required by the library
+#include <VarSpeedServo.h>
+
+//Module definitions servo
+#define NUM_SERVOS 8      //number of servos
+// first byte is to indicate which servo is on.
+// 1 byte to indicate to togle.
+// 2 for start and end angle in % of 360 grad
+#define VAR_PER_SERVO 6       //variables per servo
+#define SPEED 50              //servo speed
+#define SERVO_START 0         //servo start angle
+#define SERVO_END 180         //servo end angle
+//pins where the servos are attached
+//pins 9,10 and 15 don't work for many servos. servo library limitation
+byte servopins[]={1,2,3,4,5,6,7,8};
+VarSpeedServo servos[NUM_SERVOS];
+byte active_servo;
+byte togle_servo;
+
+//Module definitions sensor
+#define NUMSENSORS 8
+#define TLIMIT 500
+#define RLIMIT 25
+struct SENSOR {
+  int port;
+  int state;
+  unsigned long time;
+  unsigned long resets;
+};
+byte togle_ir;
+
+struct SENSOR sensors[NUMSENSORS];
+int sensorport[NUMSENSORS]={A0, A1 ,A2 ,A3, A4 ,A5, A6,A7};
+
+//first 2 are to indicate which servo is on. 2 bytes to indicate to togle. 2 for start and end angle
+#define VAR_PER_SENSOR 1  //variables per servo. used as reserve. it is mostly used by consumers
+
+//CBUS definitions
+#define GREEN_LED 27                            //merg green led port
+#define YELLOW_LED 26                           //merg yellow led port
+#define PUSH_BUTTON 25                          //std merg push button
+#define PUSH_BUTTON1 28                         //debug push button
+#define NODE_VARS 4                             //2 for togle events, 2 for spare
+#define NODE_EVENTS 30                          //max number of events
+#define EVENTS_VARS VAR_PER_SENSOR              //number of variables per event
+#define DEVICE_NUMBERS NUMSENSORS+NUM_SERVOS   //number of device numbers. each servo can be a device
+
+
+#define EVENTS_VARS VAR_PER_SERVO   //number of variables per event
+#define DEVICE_NUMBERS NUM_SERVOS   //number of device numbers. each servo can be a device
+#define TOGLE_IR_VAR       1
+#define TOGLE_SERVO_VAR    2
+#define ACTIVE_SERVO_VAR   3
+#define START_ANGLE_VAR    4          //var index for the start angle
+#define END_ANGLE_VAR      5            //var index for the end angle
+
+//arduino mega has 4K, so it is ok.
+
+
+//create the merg object
+MergCBUS cbus=MergCBUS(NODE_VARS,NODE_EVENTS,EVENTS_VARS,DEVICE_NUMBERS);
+
+void setup(){
+
+  pinMode(PUSH_BUTTON1,INPUT_PULLUP);//debug push button
+  Serial.begin(115200);
+
+  //Configuration data for the node
+  cbus.getNodeId()->setNodeName("MSERVOIR",8);  //node name
+  cbus.getNodeId()->setModuleId(58);            //module number
+  cbus.getNodeId()->setManufacturerId(0xA5);    //merg code
+  cbus.getNodeId()->setMinCodeVersion(1);       //Version 1
+  cbus.getNodeId()->setMaxCodeVersion(0);
+  cbus.getNodeId()->setProducerNode(true);
+  cbus.getNodeId()->setConsumerNode(true);
+  cbus.setStdNN(999); //standard node number
+
+  if (digitalRead(PUSH_BUTTON1)==LOW){
+    //Serial.println("Setup new memory");
+    cbus.setUpNewMemory();
+    cbus.setSlimMode();
+    cbus.saveNodeFlags();
+  }
+  cbus.setLeds(GREEN_LED,YELLOW_LED);//set the led ports
+  cbus.setPushButton(PUSH_BUTTON);//set the push button ports
+  cbus.setUserHandlerFunction(&myUserFunc);//function that implements the node logic
+  cbus.initCanBus(53);  //initiate the transport layer. pin=53, rate=125Kbps,10 tries,200 millis between each try
+
+  //create the servos object
+  setupSensors();
+  setUpServos();
+  //Serial.println("Setup finished");
+}
+
+void loop (){
+  cbus.cbusRead();
+  cbus.run();//do all logic
+
+  if (cbus.getNodeState()==NORMAL){
+    checkSensors();
+  }
+
+  //debug memory
+  if (digitalRead(PUSH_BUTTON1)==LOW){
+    cbus.dumpMemory();
+  }
+}
+
+//user defined function. contains the module logic.called every time run() is called.
+void myUserFunc(Message *msg,MergCBUS *mcbus){
+  boolean onEvent;
+  unsigned int converted_speed;
+  int varidx=0;
+
+  byte servo_start,servo_end;
+  if (mcbus->eventMatch()){
+     onEvent=mcbus->isAccOn();
+     getServosArray(msg,mcbus);
+     Serial.println("event match");
+     servo_start=mcbus->getEventVar(msg,START_ANGLE_VAR);
+     servo_end=mcbus->getEventVar(msg,END_ANGLE_VAR);
+     Serial.println(servo_start);
+     Serial.println(servo_end);
+      //get the events var and control the servos
+      for (int i=0;i<NUM_SERVOS;i++){
+
+        if (isServoActive(i)){
+          moveServo(onEvent,i,servo_start,servo_end);
+        }
+      }
+  }
+  else{
+    //feedback messages
+
+
+  }
+}
+
+void checkSensors(){
+  int state;
+  int i;
+  unsigned long actime;
+  //int s=7;
+
+  for (i=0;i<NUMSENSORS;i++){
+    state=getSensorState(i);
+    //Serial.println(state);
+    actime=millis();
+    if (state==LOW){
+      if (sensors[i].state==HIGH){
+        //if (i==s){
+        /*
+        Serial.print("Sensor ");
+        Serial.print(i);
+        Serial.println(" ON");
+        */
+        //}
+        sendMessage(true,i);
+        sensors[i].state=LOW;
+      }
+      sensors[i].state=LOW;
+      sensors[i].time=actime;
+      sensors[i].resets++;
+    }
+    else{
+      if (actime-sensors[i].time>TLIMIT){
+        if (sensors[i].resets<RLIMIT){
+          //give extra time
+          sensors[i].time=actime;
+        }
+       else {
+          if (sensors[i].state==LOW){
+          //    if (i==s){
+          /*
+              Serial.print("Sensor ");
+              Serial.print(i);
+              Serial.print(" OFF time: ");
+              Serial.print(actime-sensors[i].time);
+              Serial.print(" resets:");
+              Serial.println(sensors[i].resets);
+            */
+              sendMessage(false,i) ;
+            //  }
+            sensors[i].state=HIGH;
+            sensors[i].resets=0;
+          }
+       }
+      }
+    }
+  }
+}
+
+//send the can message
+void sendMessage(bool state,unsigned int sensor){
+   unsigned int event;
+   bool onEvent=true;
+   event=sensor;
+   if (togleSensor(sensor)){
+     onEvent=false;
+   }
+   if (onEvent){
+     cbus.sendOnEvent(true,event);
+   }
+   else{
+     cbus.sendOffEvent(true,event);
+   }
+}
+//check if we have to togle the event
+bool togleSensor(int sensor){
+  byte first,second;
+  bool resp=false;
+  first=cbus.getNodeVar(0);
+  second=cbus.getNodeVar(1);
+  //check if the bit is set
+  if (sensor>0 && sensor<9){
+    if (bitRead(first,sensor)==1){
+      resp=true;
+    }
+  }
+  else if (sensor>8 && sensor<17){
+     if (bitRead(second,sensor)==1){
+      resp=true;
+    }
+  }
+  return resp;
+}
+//configure the sensors
+void setupSensors(){
+  int i=0;
+  for (i=0;i<NUMSENSORS;i++)  {
+    sensors[i].state=HIGH;
+    sensors[i].port=sensorport[i];
+    pinMode(sensors[i].port,INPUT);
+  }
+}
+//read the sensor state
+int getSensorState(int i){
+  //return digitalRead(sensors[i].port);
+
+  int j;
+  float ntimes;
+  ntimes=30;
+  for (j=0;j<ntimes;j++){
+    if (digitalRead(sensors[i].port)==0){
+      return 0;
+    }
+  }
+  return 1;
+
+}
+
+void moveServo(boolean event,byte servoidx,byte servo_start,byte servo_end){
+    if (event){
+      if (isServoToTogle(servoidx)){
+        servos[servoidx].write(servo_start,SPEED);
+      }
+      else {
+        Serial.println("moving servo");
+        servos[servoidx].write(servo_end,SPEED);
+      }
+    }
+    else{
+      if (isServoToTogle(servoidx)){
+        servos[servoidx].write(servo_end,SPEED);
+      }
+      else {
+        servos[servoidx].write(servo_start,SPEED);
+      }
+    }
+}
+
+//create the objects for each servo
+void setUpServos(){
+  for (int i=0;i<NUM_SERVOS;i++){
+    servos[i].attach(servopins[i]);
+    servos[i].write(0,127);
+  }
+}
+//is the servo to be activated or not
+boolean isServoActive(int index){
+
+  if (bitRead(active_servo,index)==1){
+    return true;
+  }
+  else{
+     return false;
+  }
+}
+//is the servo by index to togle or not
+boolean isServoToTogle(int index){
+  if (bitRead(togle_servo,index)==1){
+    return true;
+  }
+  else{
+     return false;
+  }
+}
+
+//
+//get the events vars for activate servos and to togle the servos:invert behaviour on on/off events
+void getServosArray(Message *msg,MergCBUS *mcbus){
+  active_servo=mcbus->getEventVar(msg,2);
+  togle_servo=mcbus->getEventVar(msg,1);
+  togle_ir=mcbus->getEventVar(msg,0);
+}
+


Fix NTP client example on boards with small serial buffer

On boards with small serial buffer (e.g. Arduino Uno with 64 B)
the packet would get lost if not read as soon as it starts
arriving due to buffer overflow

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/PaoloP74/WiFiESP.git/'


Add HTTP POST for Arduino Yun.

Add HTTP POST for Arduino Yun.

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

--- vor-arduino/YunClient/YunClient.ino
+++ vor-arduino/YunClient/YunClient.ino
@@ -0,0 +1,55 @@
+/*
+  Yún HTTP Client
+
+ This example for the Arduino Yún shows how create a basic
+ HTTP client that connects to the internet and downloads
+ content. In this case, you'll connect to the Arduino
+ website and download a version of the logo as ASCII text.
+
+ created by Tom igoe
+ May 2013
+
+ This example code is in the public domain.
+
+ http://www.arduino.cc/en/Tutorial/HttpClient
+
+ */
+
+#include <Bridge.h>
+#include <HttpClient.h>
+
+const char* msg = "{\"id\":\"1\",\"type\":\"room\",\"reserved\":false,\"temperature\":10,\"light\":10,\"dioxide\":10,\"noise\":10}";
+
+void setup() {
+  // Bridge takes about two seconds to start up
+  // it can be helpful to use the on-board LED
+  // as an indicator for when it has initialized
+  pinMode(13, OUTPUT);
+  digitalWrite(13, LOW);
+  Bridge.begin();
+  digitalWrite(13, HIGH);
+
+  Serial.begin(9600);
+
+  while (!Serial); // wait for a serial connection
+}
+
+void loop() {
+  // Initialize the client library
+  HttpClient client;
+  client.setHeader("Content-Type: text/plain");
+  // Make a HTTP request:
+  client.post("rubix.futurice.com/messages", msg);
+
+  // if there are incoming bytes available
+  // from the server, read them and print them:
+  while (client.available()) {
+    char c = client.read();
+    Serial.print(c);
+  }
+  Serial.flush();
+
+  delay(5000);
+}
+
+


UniversalFirmware for Arduino

UniversalFirmware for Arduino

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

--- Arduio/ArduinoUniFirmware/ArduinoUniFirmware.ino
+++ Arduio/ArduinoUniFirmware/ArduinoUniFirmware.ino
@@ -0,0 +1,80 @@
+const int MaxAnalogPin = 5; //Magic number for Arduino Uno
+const int MaxDigitalPin = 13; //Magic number for Arduino Uno
+int del = 3000; //Delay between data packets
+int prevtime;  //Time of prev data packet
+String line = ""; //Line from pc is stored here
+
+void setup() {
+  Serial.begin(1200);
+  prevtime = millis();
+}
+void loop() {
+  sendData();
+  receiveData();
+}
+
+void sendData()
+{
+  int curtime = millis();
+  int diff = curtime - prevtime;
+  if (diff<0)
+  {
+    diff = curtime;
+    prevtime = 0;
+  }
+  if (diff > del)
+  {
+    for(int i = 0; i <= MaxAnalogPin; i++)
+    {
+      int sensorValue = analogRead(i);
+      Serial.print("A");
+      Serial.print(i);
+      Serial.print(":");
+      Serial.print(sensorValue);
+      Serial.print("\n");
+    }
+    for(int i = 0; i <= MaxDigitalPin; i++)
+    {
+      int sensorValue = digitalRead(i);
+      Serial.print(i);
+      Serial.print(":");
+      Serial.print(sensorValue);
+      Serial.print("\n");
+    }
+    prevtime = curtime;
+  }
+}
+
+void receiveData()
+{
+  if(getLine() != -1)
+  {
+    int div_index = line.indexOf(':');
+    int pin = line.substring(0, div_index).toInt();
+    int value = line.substring(div_index + 1).toInt();
+    pinMode(pin, OUTPUT);
+    if(value == 0)
+    {
+      digitalWrite(pin, LOW);
+    }
+    else
+    {
+      digitalWrite(pin, HIGH);
+    }
+  }
+}
+
+int getLine()
+{
+  while(Serial.peek()!=-1)
+  {
+    int inbyte = Serial.read();
+    if(inbyte == '\n')
+    {
+      return line.length();
+    }
+    line += inbyte;
+  }
+  return -1;
+}
+


Added example

Added example

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

--- examples/simulatedCar/simulatedCar.ino
+++ examples/simulatedCar/simulatedCar.ino
@@ -0,0 +1,30 @@
+void loop(){
+  char phoneme = voice.getPhoneme();
+  if( phoneme != ‘h’){
+			collvoice = denoise(phoneme,collvoice);
+  }
+  else {
+    int i[3],j,min,x;
+    i[0] = umatch(collvoice,”sop”); //stop
+    i[1] = umatch(collvoice,”ez”); //left
+    i[2] = umatch(collvoice,”i”); //right
+    //find the lowest number
+    while(j<0){
+	if(i[j]<min){
+		x = j;
+		min = i[j];
+	}
+	j++;
+    }
+    if(x == 0){
+	stop();
+    }
+    if(x == 1){
+	left();
+    }
+    if(x == 2){
+	right();
+    }
+    }
+  }
+}


debug beautification

debug beautification

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


* removed debug values for button and auxmod. should not be needed anymore since the feature is working well

error: pathspec 'Main' did not match any file(s) known to git
error: pathspec 'Module/Code_MainModule/multiplexer_4051.ino' did not match any file(s) known to git


Initial upload to fix things

Initial upload to fix things

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

--- src/sketch_feb18a/sketch_feb18a.ino
+++ src/sketch_feb18a/sketch_feb18a.ino
@@ -0,0 +1,184 @@
+//IMU + AnalogRead logging to SD over SPI.
+#include <SD.h>
+#include <SPI.h>
+#include <Wire.h>
+#include <SparkFunLSM9DS1.h>
+
+// Use the LSM9DS1 class to create an object. [imu] can be
+// named anything, we'll refer to that throught the sketch.
+LSM9DS1 imu;
+
+// SDO_XM and SDO_G are both pulled high, so our addresses are:
+#define LSM9DS1_M   0x1E // Would be 0x1C if SDO_M is LOW
+#define LSM9DS1_AG  0x6B // Would be 0x6A if SDO_AG is LOW
+
+////////////////////////////
+// Sketch Output Settings //
+////////////////////////////
+#define PRINT_CALCULATED
+//#define PRINT_RAW
+#define PRINT_SPEED 250 // 250 ms between prints
+static unsigned long lastPrint = 0; // Keep track of print time
+
+// Earth's magnetic field varies by location. Add or subtract
+// a declination to get a more accurate heading. Calculate
+// your's here:
+// http://www.ngdc.noaa.gov/geomag-web/#declination
+#define DECLINATION 12.1 // Declination (degrees) in LA.
+
+//the hardware CS pin (10 on most Arduino boards,
+// 53 on the Mega) must be left as an output or the SD
+// library functions will not work.
+const int CSpin = 10;
+String dataString =""; // holds the data to be written to the SD card
+float sensorReading1 = 0.00; // value read from your first sensor
+float sensorReading2 = 0.00; // value read from your second sensor
+float sensorReading3 = 0.00; // value read from your third sensor
+float sensorReading4 = 0.00;
+float sensorReading5 = 0.00;
+float sensorReading6 = 0.00;
+float sensorReading7 = 0.00;
+float sensorReading8 = 0.00;
+File sensorData;
+
+void setup()
+{
+  // Open serial communications
+  Serial.begin(115200);
+  Serial.print("Initializing SD card...\n");
+  pinMode(CSpin, OUTPUT);
+  digitalWrite(10, HIGH);
+  //
+  // see if the card is present and can be initialized:
+  if (!SD.begin(CSpin)) {
+    Serial.println("Card failed");
+    // don't do anything more:
+    Serial.println("WTF\n");
+    return;
+  }
+  sensorData = SD.open("data.csv", FILE_WRITE);
+  sensorData.close();
+  Serial.println("card initialized.");
+  Serial.println("Beginning IMU initialization.");
+  // Before initializing the IMU, there are a few settings
+  // we may need to adjust. Use the settings struct to set
+  // the device's communication mode and addresses:
+  imu.settings.device.commInterface = IMU_MODE_I2C;
+  imu.settings.device.mAddress = LSM9DS1_M;
+  imu.settings.device.agAddress = LSM9DS1_AG;
+  // The above lines will only take effect AFTER calling
+  // imu.begin(), which verifies communication with the IMU
+  // and turns it on.
+  if (!imu.begin())
+  {
+    Serial.println("Failed to communicate with LSM9DS1.");
+    Serial.println("Double-check wiring.");
+    Serial.println("Default settings in this sketch will " \
+                  "work for an out of the box LSM9DS1 " \
+                  "Breakout, but may need to be modified " \
+                  "if the board jumpers are.");
+    while (1)
+      ;
+  }
+}
+
+// Calculate pitch, roll, and heading.
+// Pitch/roll calculations take from this app note:
+// http://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf?fpsp=1
+// Heading calculations taken from this app note:
+// http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/Magnetic__Literature_Application_notes-documents/AN203_Compass_Heading_Using_Magnetometers.pdf
+void printAttitude(float ax, float ay, float az, float mx, float my, float mz)
+{
+  float roll = atan2(ay, az);
+  float pitch = atan2(-ax, sqrt(ay * ay + az * az));
+
+  float heading;
+  if (my == 0)
+    heading = (mx < 0) ? PI : 0;
+  else
+    heading = atan2(mx, my);
+
+  heading -= DECLINATION * PI / 180;
+
+  if (heading > PI) heading -= (2 * PI);
+  else if (heading < -PI) heading += (2 * PI);
+  else if (heading < 0) heading += 2 * PI;
+
+  // Convert everything from radians to degrees:
+  heading *= 180.0 / PI;
+  pitch *= 180.0 / PI;
+  roll  *= 180.0 / PI;
+
+  Serial.print("Pitch, Roll: ");
+  Serial.print(pitch, 2);
+  Serial.print(", ");
+  Serial.println(roll, 2);
+  Serial.print("Heading: "); Serial.println(heading, 2);
+}
+
+void loop(){
+  //These two reads are just raw voltage as a float from A0 and A1.
+  int A0 = analogRead(0);
+  sensorReading1 = A0;
+  sensorReading1 = (sensorReading1 * 5.0) / 1023.0;
+
+  int A1 = analogRead(1);
+  sensorReading2 = A1;
+  sensorReading2 = (sensorReading2 * 5.0) / 1023.0;
+
+    //Begin IMU data collection
+    // Update the sensor values whenever new data is available
+  if ( imu.gyroAvailable() )
+  {
+    // To read from the gyroscope,  first call the
+    // readGyro() function. When it exits, it'll update the
+    // gx, gy, and gz variables with the most current data.
+    imu.readGyro();
+  }
+  if ( imu.accelAvailable() )
+  {
+    // To read from the accelerometer, first call the
+    // readAccel() function. When it exits, it'll update the
+    // ax, ay, and az variables with the most current data.
+    imu.readAccel();
+  }
+  if ( imu.magAvailable() )
+  {
+    // To read from the magnetometer, first call the
+    // readMag() function. When it exits, it'll update the
+    // mx, my, and mz variables with the most current data.
+    imu.readMag();
+  }
+
+  if ((lastPrint + PRINT_SPEED) < millis())
+  {
+    sensorReading3 = imu.calcGyro(imu.gx);
+    sensorReading4 = imu.calcGyro(imu.gy);
+    sensorReading5 = imu.calcGyro(imu.gz);
+    //accel readings
+    sensorReading6 = imu.calcAccel(imu.ax);
+    sensorReading7 = imu.calcAccel(imu.ay);
+    sensorReading8 = imu.calcAccel(imu.az);
+
+
+    lastPrint = millis(); // Update lastPrint time
+  }
+  // build the data string
+  dataString = String(sensorReading1) + "," + String(sensorReading2) + "," + String(sensorReading3) + "," + String(sensorReading4) + "," + String(sensorReading5) + "," + String(sensorReading6) + "," + String(sensorReading7) + "," + String(sensorReading8) + ","; // convert to CSV
+  saveData(); // save to SD card
+  //delay(60000); // delay before next write to SD Card, adjust as required
+}
+
+void saveData(){
+  if(SD.exists("data.csv")){ // check the card is still there
+    // now append new data file
+    sensorData = SD.open("data.csv", FILE_WRITE);
+    if (sensorData){
+      sensorData.println(dataString);
+      sensorData.close(); // close the file
+    }
+  }
+  else{
+    Serial.println("Error writing to file !");
+  }
+}


Rom Id Finder for OneWire bus

Rom Id Finder for OneWire bus

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

--- examples/OWromFinder/OWromFinder.ino
+++ examples/OWromFinder/OWromFinder.ino
@@ -0,0 +1,46 @@
+/**
+ * \file OWromFinder.ino
+ * \brief Connect a single 1-Wire component. This program prints its ROM unique
+ * id. We assume that the 1-wire pin of the component is connected to Arduino
+ * 2. Change \c OWPIN macro if you prefer to connect it to another pin.
+ * \author Enrico Formenti
+ * \version 0.1
+ * \date 2012-2013
+ * \warning The author is not responsible for any damage or...
+ * caused by this software. Use it at your own risk.
+ * \copyright BSD license. See license.txt for more details.
+ * All text above must be included in any redistribution.
+ */
+
+#include <OWcomponent.h>
+#include <Serial.h>
+
+#define OWPIN 2
+
+OWcomponent ow(OWPIN);
+
+void setup()
+{
+  Serial.begin(9600);
+}
+
+void loop(){
+
+  uint8_t ROM[8], i;
+
+  ow.search(ROM, CMD_GENERIC_SEARCH);
+
+  Serial.print("Family id: ");
+  Serial.println(ROM[0]);
+
+  Serial.print("Component id:");
+  for(i=1;i<7;i++) {
+    Serial.print(" ");
+    Serial.print(ROM[i]);
+  }
+  Serial.println();
+
+  Serial.print("CRC: ");
+  Serial.println(ROM[7]);
+}
+


test PIR

test PIR

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

--- electro/Exemple/testPIR/testPIR.ino
+++ electro/Exemple/testPIR/testPIR.ino
@@ -0,0 +1,44 @@
+//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
+int calibrationTime = 30;
+
+int ledPin = 13;                // choose the pin for the LED
+int inputPin = 2;               // choose the input pin (for PIR sensor)
+int pirState = LOW;             // we start, assuming no motion detected
+int val = 0;                    // variable for reading the pin status
+
+void setup() {
+  pinMode(ledPin, OUTPUT);      // declare LED as output
+  pinMode(inputPin, INPUT);     // declare sensor as input
+  Serial.begin(9600);
+
+  Serial.print("calibrating sensor ");
+  for(int i = 0; i < calibrationTime; i++){
+    Serial.print(".");
+    delay(1000);
+  }
+}
+
+void loop(){
+  val = digitalRead(inputPin);  // read input value
+  Serial.println(val);
+  if (val == HIGH) { // check if the input is HIGH
+    digitalWrite(ledPin, HIGH);  // turn LED ON
+    delay(150);
+
+    if (pirState == LOW) {
+      // we have just turned on
+      Serial.println("Motion detected!");
+      // We only want to print on the output change, not state
+      pirState = HIGH;
+    }
+  } else {
+    digitalWrite(ledPin, LOW); // turn LED OFF
+    delay(300);
+    if (pirState == HIGH){
+      // we have just turned of
+      Serial.println("Motion ended!");
+      // We only want to print on the output change, not state
+      pirState = LOW;
+    }
+  }
+}


sprout controller

sprout controller

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

--- chitil-conroller.ino
+++ chitil-conroller.ino
@@ -0,0 +1,77 @@
+// atlas cinetific & Adafruit code
+
+#include "DHT.h"
+#define DHTPIN 3
+#define HeatPad 13
+#define DCCooler  12
+#define DHTTYPE DHT11   // DHT 11
+DHT dht(DHTPIN, DHTTYPE);
+float temp;
+
+
+void setup() {
+  Serial.begin(9600);
+  pinMode(2, OUTPUT);
+  pinMode(HeatPad,OUTPUT);
+    pinMode(DCCooler,OUTPUT);
+  dht.begin();
+}
+
+void loop() {
+  temp = read_temp();
+  delay(12000);
+
+  float h = dht.readHumidity();
+  float t = dht.readTemperature();
+  float f = dht.readTemperature(true);
+
+  if (isnan(h) || isnan(t) || isnan(f)) {
+    Serial.println("Failed to read from DHT sensor!");
+    return;
+  }
+
+  float hif = dht.computeHeatIndex(f, h);
+  float hic = dht.computeHeatIndex(t, h, false);
+
+  Serial.print("Humidity: ");
+  Serial.print(h);
+  Serial.print(" %\t");
+  Serial.print("Micro Climat Temp: ");
+  Serial.print(t);
+  Serial.print(" *C\t");
+  Serial.print("plant root Temp: ");
+  Serial.print(temp);
+  Serial.println(" *C");
+
+  ///////
+
+if (temp >27) {
+		digitalWrite(HeatPad, LOW);
+	} else {
+		digitalWrite(HeatPad, HIGH);
+	}
+
+
+
+if (h > 75) {
+  digitalWrite(DCCooler, HIGH);
+ } else {
+  digitalWrite(DCCooler, LOW );
+ }
+
+}
+
+
+float read_temp(void){
+float v_out;
+float temp;
+digitalWrite(A0, LOW);
+digitalWrite(2, HIGH);
+delay(2);
+v_out = analogRead(0);
+digitalWrite(2, LOW);
+v_out*=.0048;
+v_out*=1000;
+temp= 0.0512 * v_out -20.5128;
+return temp;
+}


added opmode

added opmode

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

--- op.ino
+++ op.ino
@@ -0,0 +1,61 @@
+#include <Audio.h>
+#include <Wire.h>
+#include <SPI.h>
+#include <SD.h>
+#include <SerialFlash.h>
+
+// GUItool: begin automatically generated code
+AudioInputAnalog         adc1;           //xy=82,93
+AudioInputAnalog         adc2;           //xy=82,143
+AudioAnalyzePeak         peak1;          //xy=243,26
+AudioFilterStateVariable filter1;        //xy=249,97
+AudioFilterStateVariable filter2;        //xy=250,163
+AudioAnalyzePeak         peak2;          //xy=252,230
+AudioAnalyzeFFT1024      fft1024_1;      //xy=433,86
+AudioAnalyzeFFT1024      fft1024_2;      //xy=437,167
+AudioConnection          patchCord1(adc1, peak1);
+AudioConnection          patchCord2(adc1, 0, filter1, 0);
+AudioConnection          patchCord3(adc2, peak2);
+AudioConnection          patchCord4(adc2, 0, filter2, 0);
+AudioConnection          patchCord5(filter1, 0, fft1024_1, 0);
+AudioConnection          patchCord6(filter2, 0, fft1024_2, 0);
+// GUItool: end automatically generated code
+
+// ** question for PJRC
+// *  question for Michael
+//    question for me
+
+double scale_factor_1;
+const double margin = 0.1;
+
+void setup() {
+
+	AudioMemory(12); // ** how do I choose how much audio memory?
+
+	fft1024_1.WindowFunction(AudioWindowHanning1024); // which window?
+	fft1024_2.WindowFunction(AudioWindowHanning1024); // http://electronicdesign.com/analog/choose-right-fft-window-function-when-evaluating-precision-adcs
+
+	scale_factor_1 = 0;
+
+	filter1.frequency(1000);
+	filter2.frequency(1000);
+
+}
+
+void loop() {
+
+	// FIRST: SCALE PEAKS
+	if (peak1.available() && peak2.available()) {
+		scale_factor_1 *= (peak1.read() / peak2.read());
+	}
+
+	if (fft1024_1.available() && fft1024_2.available()) {
+		for(int i = 0; i <= 511; i++){
+			if ( abs( fft1024_1.read(i) * scale_factor_1 + fft1024_2.read(i) ) > 0.1 ) { // replace .01 with "SIGNIFICANT" defined static var.
+				// something! // here's the "GPS and coordinate system" stuff
+				//https://www.pjrc.com/teensy/td_libs_TinyGPS.html
+				//https://forum.pjrc.com/threads/24979-Teensy-3-1-Ultimate-GPS-code
+			}
+		}
+	}
+}


Fixing a terrible written phrase. I guess I was drunk.

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


Adding empty file

Adding empty file

error: pathspec 'Mpe/Prototype/TempGuard/Atmega8TempGuard/Atmega8TempGuard.ino' did not match any file(s) known to git

--- Mpe/Prototype/TempGuard/Atmega8TempGuard/Atmega8TempGuard.ino
+++ Mpe/Prototype/TempGuard/Atmega8TempGuard/Atmega8TempGuard.ino
@@ -0,0 +1 @@
+


Initial Arduino with Onboard Server for Choose_Video

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

--- server/pusher/choose_video.ino
+++ server/pusher/choose_video.ino
@@ -0,0 +1,172 @@
+#include <PusherClient.h>
+#include <Ethernet.h>
+#include <SPI.h>
+
+char subscribe[] = "choose_video";
+char receive_channel[] = "choose_video";
+String pusher_channel = "choose_video";
+String pusher_event_register = "arduino_event_register";
+String fact[] = {"a", "b","c", "JacobHanshaw"};
+int fact_delays[] = { 4000, 4000, 4000, 4000};
+int facts = 4;
+
+EthernetClient arisClient;
+PusherClient pusherClient;
+
+byte mac[] = {
+  0x90, 0xA2, 0xDA, 0x0C, 0x00, 0x83 };
+byte aris[] = {
+  50, 56, 80, 147 };
+
+const int relayPin1 = 2;
+const int relayPin2 = 3;
+const int video_over = 6;
+
+int video1Votes = 0;
+int video2Votes = 0;
+int members = 0;
+
+void setup() {
+  //Serial.begin(9600);
+  Serial.println("Setup...");
+  Ethernet.begin(mac); //,ip
+  delay(1000); //Give time to initialize before connecting
+
+  pinMode(relayPin1, OUTPUT);
+  pinMode(relayPin2, OUTPUT);
+  //pinMode(video_over, INPUT);
+
+  while(!pusherClient.connect("7fe26fe9f55d4b78ea02")){}
+  while(!pushMessage(pusher_channel, pusher_event_register, "success")) {}
+  pusherClient.bind("Member_Added", memberAdd);
+  pusherClient.bind("Member_Removed", memberRemove);
+  pusherClient.bind("Cast_Vote", eventHandler);
+  //  pusherClient.bindAll(eventHandler);
+  //  pusherClient.bind(subscribe, eventHandler);
+  pusherClient.subscribe(receive_channel);
+  Serial.println("Pusher Connect Success!");
+}
+
+
+void loop() {
+  pusherClient.monitor();
+  if(members > 0){
+    //Begin the login time
+    long startTime = millis();
+    while((millis() -startTime) <= 15000){
+      pusherClient.monitor();
+      int time = (millis()-startTime);
+      if(time % 1000 <= 10){
+        String output = (String)time;
+        while(!pushMessage(pusher_channel, "Clock_Time", output)) { }
+      }
+    }
+    //Begin Voting
+    while(!pushMessage(pusher_channel, "Begin_Voting", "")) { }
+    startTime = millis();
+    while((millis() -startTime) <= 30000 && members != (video1Votes + video2Votes)){
+      pusherClient.monitor();
+    }
+    //Voting Complete, trigger the pin
+    if(video1Votes >= video2Votes){
+      digitalWrite(relayPin1, HIGH);
+      delay(500);
+      digitalWrite(relayPin1, LOW);
+      Serial.println("Video 1 Wins!");
+    }
+    else{
+      digitalWrite(relayPin2, HIGH);
+      delay(500);
+      digitalWrite(relayPin2, LOW);
+      Serial.println("Video 2 Wins!");
+    }
+    video1Votes = 0;
+    video2Votes = 0;
+
+    //Tell clients, Voting is complete
+    while(!pushMessage(pusher_channel, "Done_Voting", "")) {
+    }
+    delay(2000);
+    for(int i = 0; i < facts; i++){
+       while(!pushMessage(pusher_channel, "Message", fact[i])) { }
+       delay(fact_delays[i]);
+    }
+    //while(digitalRead(video_over) == LOW) { }
+    while(!pushMessage(pusher_channel, "Video_Over", "")) {
+    }
+  }
+}
+
+void memberAdd(String data) {
+  members++;
+ // Serial.println("Members: ");
+ // Serial.println(members);
+}
+
+void memberRemove(String data) {
+  if(members-1>=0){
+    members--;
+  }
+//  Serial.println("Members: ");
+//  Serial.println(members);
+}
+
+void eventHandler(String data) {
+  //Serial.println(data);
+  int firstColon = data.indexOf(':');
+  int secondColon = data.indexOf(':', firstColon + 1 );
+  int start = secondColon + 4;
+  int endQuote = data.indexOf('"', start);
+  int endofData = endQuote -1;
+  String importantData = data.substring(start, endofData);
+ // Serial.println(importantData);
+  if(importantData.charAt(0) == 'v'){
+    importantData = importantData.substring(1);
+    char pointer[importantData.length()];
+    for(int i = 0; i < importantData.length(); i++){
+      pointer[i] = importantData.charAt(i);
+    }
+    int vote = atoi(pointer);
+    if(vote == 1){
+    //  Serial.println("1");
+      video1Votes++;
+      String votes = (String)video1Votes;
+      votes += "^";
+      votes += video2Votes;
+      Serial.println(votes);
+      while(!pushMessage(pusher_channel, "Vote", votes)) {
+      }
+    }
+    else if(vote == 2){
+  //    Serial.println("2");
+      video2Votes++;
+      String votes = (String)video1Votes;
+      votes += "^";
+      votes += video2Votes;
+      Serial.println(votes);
+      while(!pushMessage(pusher_channel, "Vote", votes)) {
+      }
+    }
+  }
+  else{
+  //  Serial.println("ERROR: " + data);
+  }
+}
+
+boolean pushMessage(String channel, String event, String data){
+  if(arisClient.connect(aris, 80)){
+    String request = "GET /server/pusher/public_send.php?channel="; //change when updated
+    request += channel;
+    request += "&event=";
+    request += event;
+    request += "&data=";
+    request += data;
+    request += " HTTP/1.0";
+    arisClient.println(request);
+    arisClient.println();
+    arisClient.stop();
+    return true;
+  }
+  return false;
+}
+


Add minimal example

Add minimal example

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

--- firmware/lm-matrix-minimal/lm-matrix-minimal.ino
+++ firmware/lm-matrix-minimal/lm-matrix-minimal.ino
@@ -0,0 +1,51 @@
+//
+//  LedMatrix
+//  part of Let's make series
+//
+//  The Cave, 2017
+//  https://thecave.cz
+//
+//  Licensed under MIT License (see LICENSE file for details)
+//
+
+// Pin definitions. If you change something in hardware, change it here too
+#define PIN_DATA A2
+#define PIN_CLK A0
+#define PIN_LOAD A1
+#define PIN_BUTTON 2
+
+uint8_t data[] = {0b00111100, 0b01000010, 0b10101001, 0b10000101, 0b10000101, 0b10101001, 0b01000010, 0b00111100};
+
+void setup() {
+  pinMode(PIN_DATA, OUTPUT);
+  pinMode(PIN_CLK, OUTPUT);
+  pinMode(PIN_LOAD, OUTPUT);
+  digitalWrite(PIN_LOAD, HIGH);
+
+  displaySend(15, 0); // disable display test mode
+  displaySend(11, 7); // set maximum scanlimit (8 rows)
+  displaySend(9, 0); // disable BCD decoding (only for 7-seg displays)
+  displaySetBrightness(8); // set initial brightness
+  displaySend(12, 1); // enable display
+
+  for (uint8_t i = 0; i < 8; i++) {
+    displaySend(i+1, data[i]);
+  }
+}
+
+void loop() {
+}
+
+void displaySetBrightness(int8_t val) {
+  displaySend(10, constrain(val, 0, 15));
+}
+
+// this is actually sending data to display
+void displaySend(uint8_t command, uint8_t data) {
+  digitalWrite(PIN_LOAD, LOW);
+  shiftOut(PIN_DATA, PIN_CLK, MSBFIRST, command);
+  shiftOut(PIN_DATA, PIN_CLK, MSBFIRST, data);
+  digitalWrite(PIN_LOAD, HIGH);
+}
+
+


Nested while loop added

Nested while loop added

we observed that the speed of the motors was really less as compared when plugged to a battery supply. The motor drivers were fine too. The reduction of speed was only observed when the motors were run according to image processing.
•	We then observed that the camera from which the video was being captured had a frame rate of 100fps. Whereas the Baud rate set for PySerial and Arduino was 9600. This meant that out of 9600 times a second the date was sent by PySerial to Arduino, only 100 of them had the actual information. It therefore unknowingly created PWM with a DC average 1/96th time of the maximum DC output.
•	We therefore found out that since we had used ‘if loop’ in the Arduino code, the relevant signal was only passed if there was an incoming byte from PySerial. So, we inserted a nested ‘while loop’ in the ‘if loop’. And things got fine! 

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


Nuit Blanche 2015

Nuit Blanche 2015

Snapshot of code for Rhys

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

--- SoMoV5/SoMoV5_Glove/SoMoV5_Glove.ino
+++ SoMoV5/SoMoV5_Glove/SoMoV5_Glove.ino
@@ -0,0 +1,229 @@
+// MaxMSP SensorBox demonstration sketch for SoMo V5
+//
+// This sketch reads the IMU, scales values to the range 0-1024,
+// and sends them to MAX using the SensorBox protocol
+// ( https://cycling74.com/toolbox/sensorbox/ )
+//
+// To program, ensure the Arduino IDE is set to "Arduino Leonardo" under Tools->Board
+//
+// This version used at Nuit Blanche 2015 - modded by Rhys and Leif
+
+
+/*This code sits on the remote devices (what the dancers will wear)
+  in a multiple dancer setup with XBee Series 1 Radios.
+  Unit ID for each remote device needs to be set using the keys below:
+    Unit 1: 0x01
+    Unit 2: 0x02
+    Unit 3: 0x03
+    Unit 4: 0x04
+    Unit 5: 0x05
+    Unit 6: 0x06
+    Unit 7: 0x07
+    Unit 8: 0x08
+    Unit 9: 0x09
+*/
+
+byte unitID = 0x01;  //Unit ID
+
+#include <SoftwareSerial.h>
+#include <Wire.h>
+#include <I2Cdev.h>
+#include <MPU6050.h>
+
+MPU6050 accelgyro;
+
+int16_t ax, ay, az;
+int16_t gx, gy, gz;
+int16_t mx, my, mz;
+
+#define POWER 1
+#define RX    8   //  Use 17 for SoMo V4
+#define TX    4
+#define glove 9
+
+SoftwareSerial xbSerial(RX, TX); // RX, TX of the XBee
+
+char analogValue[20]; //array of analog values *in byte format for MAX* plus some buffer
+int digVal=0;         //digital pins bits are packed into a single variable
+int pointer=0;        //global variable used by packValue__()
+int gloveRead=0;      //global variable to read the voltage when the thumb connects with another pad
+byte imask = 0x80;    //index bytes start with 1
+byte theEnd = 0xFF;   //byte to signal message end to Max patch
+
+void setup()
+{
+  // Configure serial ports
+  Serial.begin(9600);      // USB
+  xbSerial.begin(9600);    // XBee
+
+  // initialize device
+  Serial.println("Initializing I2C devices...");
+  Wire.begin();
+  accelgyro.initialize();
+
+  // verify connection
+  Serial.println("Testing device connections...");
+  Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
+
+  // setup digital inputs
+  pinMode(glove, INPUT);
+
+  // Turn on SoMo Power LED
+  pinMode(POWER, OUTPUT);
+  digitalWrite(POWER, HIGH);
+}
+
+void loop()
+{
+  // Read raw accel/gyro measurements from device
+  accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);
+  //Read glove contact pins
+  gloveRead = analogRead(glove);
+
+/*
+  // Debugging only:  Display tab-separated accel/gyro x/y/z values
+  Serial.print(ax); Serial.print("\t");
+  Serial.print(ay); Serial.print("\t");
+  Serial.print(az); Serial.print("\t");
+  Serial.print(gx); Serial.print("\t");
+  Serial.print(gy); Serial.print("\t");
+  Serial.print(gz); Serial.print("\t");
+  Serial.print(mx); Serial.print("\t");
+  Serial.print(my); Serial.print("\t");
+  Serial.println(mz);
+*/
+
+  // scale inputs to 0-1024 for backwards compatibility with old SensorBox code using pure analog inputs
+  int scaled_ax = ScaleMAX(ax);
+  int scaled_ay = ScaleMAX(ay);
+  int scaled_az = ScaleMAX(az);
+  int scaled_gx = ScaleMAX(gx);
+  int scaled_gy = ScaleMAX(gy);
+  int scaled_gz = ScaleMAX(gz);
+  int scaled_mx = ScaleMAX_mag(mx);
+  int scaled_my = ScaleMAX_mag(my);
+  int scaled_mz = ScaleMAX_mag(mz);
+
+
+  // Debugging only: display SCALED tab-separated accel/gyro x/y/z values & glove reading
+  Serial.print("Scaled:\t");
+  Serial.print(scaled_ax);
+  Serial.print("\t");
+  Serial.print(scaled_ay);
+  Serial.print("\t");
+  Serial.print(scaled_az);
+  Serial.print("\t");
+  Serial.print(scaled_gx);
+  Serial.print("\t");
+  Serial.print(scaled_gy);
+  Serial.print("\t");
+  Serial.print(scaled_gz);
+  Serial.print("\t");
+  Serial.print(scaled_mx);
+  Serial.print("\t");
+  Serial.print(scaled_my);
+  Serial.print("\t");
+  Serial.print(scaled_mz);
+  Serial.print("\t");
+  Serial.println(gloveRead);
+
+  // pack the data from the MPU9150 into the SensorBox numbers to transmit
+  pointer=0;
+
+  packValueMPU9150(scaled_ax);
+  packValueMPU9150(scaled_ay);
+  packValueMPU9150(scaled_az);
+  packValueMPU9150(scaled_mx);
+  packValueMPU9150(scaled_my);
+  packValueMPU9150(scaled_mz);
+  packValueMPU9150(scaled_gx);
+  packValueMPU9150(scaled_gy);
+  packValueMPU9150(scaled_gz);
+  packValueMPU9150(gloveRead);
+
+  /*
+  // Read Digital values
+  digVal =  0;
+  digVal |= digitalRead(9)*0x01;
+  digVal |= digitalRead(10)*0x02;
+  */
+
+  // Send the message
+  sendMessage();
+  delay(10);
+}
+
+void packValueMPU9150(int16_t value)
+{
+  int16_t tempA = value;
+  analogValue[pointer] = tempA & 127;
+  pointer++;
+  analogValue[pointer] = (tempA >> 7);
+  pointer++;
+}
+
+// Scale the inputs
+int ScaleMAX(int raw)
+{
+   float temp = Scale(raw, -16000, 16000);
+   return temp*1024;
+}
+
+// Scale the inputs for magnetometer only
+int ScaleMAX_mag(int raw)
+{
+   float temp = Scale(raw, -32000, 32000);
+   return temp*1024;
+}
+
+// Scale one of the inputs to between 0.0 and 1.0
+float Scale(long in, long smin, long smax)
+{
+  // Bound
+  if (in > smax) in=smax;
+  if (in < smin) in=smin;
+
+  // Change zero-offset
+  in = in-smin;
+
+  // Scale between 0.0 and 1.0 (0.5 would be halfway)
+  float temp = (float)in/((float)smax-(float)smin);
+  return temp;
+}
+
+//Calculates the checksum and sends the message
+void sendMessage()
+{
+  // Send the Unit ID
+  //xbSerial.write(unitID);
+  // Send analog values in the format 0x81 a1 a2.....0xFF
+  // Max wants 81 (start), FF is the end of the message
+  xbSerial.write(imask|1); //this is 0x81
+
+
+  //xbSerial.write((const uint8_t*)analogValue, sizeof(analogValue));
+
+   for (int i = 0;i<pointer;i++)
+   {
+    xbSerial.write(analogValue[i]);
+  }
+
+
+//  xbSerial.write((imask|2));
+//  xbSerial.write((digVal&127));
+//  xbSerial.write(digVal>>7);
+  xbSerial.write(theEnd);     //ends digital message with 255
+
+/*
+  //Print the packet we are sending (debug purposes)
+  Serial.print('\n');
+  for (pointer = 0; pointer != 37; pointer++) {
+    if (data[pointer] < 0x10) {
+      Serial.print("0");
+    }
+    Serial.print(data[pointer], HEX);
+  }
+   Serial.print('\n');
+*/
+
+}


First arduino project files commit

First arduino project files commit

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

--- arduinoCode/LCDDisplayandArduino.ino
+++ arduinoCode/LCDDisplayandArduino.ino
@@ -0,0 +1,82 @@
+//  _ ___ _______     ___ ___ ___  ___ _   _ ___ _____ ___
+// / |_  )__ /   \   / __|_ _| _ \/ __| | | |_ _|_   _/ __|
+// | |/ / |_ \ |) | | (__ | ||   / (__| |_| || |  | | \__ \
+// |_/___|___/___/   \___|___|_|_\\___|\___/|___| |_| |___/
+//
+// LCD Display and Arduino
+//
+// Made by Hino Hau
+// License: Public Domain
+// Downloaded from: https://123d.circuits.io/circuits/1355136-lcd-display-and-arduino
+
+#include <LiquidCrystal.h>
+
+// initialize the library with the numbers of the interface pins
+LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
+
+int button = 2 ;
+int led = 5 ;
+int value ;
+
+void setup() {
+  pinMode (button , INPUT );
+  pinMode (led , OUTPUT );
+
+  // set up the LCD's number of columns and rows:
+  lcd.begin(16, 2);
+  // Print a message to the LCD.
+  lcd.print("Welcome to MON");
+  delay(5000);
+}
+
+void loop() {
+
+  value = digitalRead (button);
+  int buttonPressed = 0
+
+  lcd.clear();
+  char s1[ ] = "Name:";
+  char s2[ ] = "Kwok Hin Hau";
+  char s3[ ] = "Status:";
+  char s4[ ] = "Available";
+  char s5[ ] = "ID:";
+  char s6[ ] = "463473584";
+  char s7[ ] = "Age:";
+  char s8[ ] = "20";
+
+  lcd.setCursor(0, 0);
+  lcd.print(s1);
+  lcd.setCursor(0, 1);
+  lcd.print(s2);
+  delay(5000);
+  if (value == HIGH)
+    if (buttonPressed == 0)
+    buttonPressed = 1;
+    else
+    buttonPressed = 0;
+
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print(s3);
+  lcd.setCursor(0, 1);
+  lcd.print(s4);
+  delay(5000);
+
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print(s5);
+  lcd.setCursor(0, 1);
+  lcd.print(s6);
+  delay(5000);
+
+  lcd.clear();
+  lcd.setCursor(0, 0);
+  lcd.print(s7);
+  lcd.setCursor(0, 1);
+  lcd.print(s8);
+  delay(5000);
+
+
+
+
+  }


adding first prototype of display

adding first prototype of display

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

--- githubCommits.ino
+++ githubCommits.ino
@@ -0,0 +1,76 @@
+/***************************************************
+  This is a library for our I2C LED Backpacks
+
+  Designed specifically to work with the Adafruit LED Matrix backpacks
+  ----> http://www.adafruit.com/products/872
+  ----> http://www.adafruit.com/products/871
+  ----> http://www.adafruit.com/products/870
+
+  These displays use I2C to communicate, 2 pins are required to
+  interface. There are multiple selectable I2C addresses. For backpacks
+  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
+  with 3 Address Select pins: 0x70 thru 0x77
+
+  Adafruit invests time and resources providing this open source code,
+  please support Adafruit and open-source hardware by purchasing
+  products from Adafruit!
+
+  Written by Limor Fried/Ladyada for Adafruit Industries.
+  BSD license, all text above must be included in any redistribution
+ ****************************************************/
+
+#include <Wire.h>
+#include "Adafruit_LEDBackpack.h"
+#include "Adafruit_GFX.h"
+
+Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
+
+static uint8_t __attribute__ ((progmem)) smile_bmp[]={0x3C, 0x42, 0x95, 0xA1, 0xA1, 0x95, 0x42, 0x3C};
+static uint8_t __attribute__ ((progmem)) frown_bmp[]={0x3C, 0x42, 0xA5, 0x91, 0x91, 0xA5, 0x42, 0x3C};
+static uint8_t __attribute__ ((progmem)) neutral_bmp[]={0x3C, 0x42, 0x95, 0x91, 0x91, 0x95, 0x42, 0x3C};
+
+const int colors[3] = { LED_GREEN, LED_YELLOW, LED_RED };
+
+int count = 0;
+
+int commits[] = { 0,0,0,8,10,3,0,0,1,2,2,6,1,0,0,2,1,1,4,5,0,13,4,0,0,2,3,0,8,3,7,3,6,7,2,1,9,4,1,0,0,0,0,0,0,0,2,4,0,0,0,0,0,0,0,0 };
+
+void setup() {
+  Serial.begin(9600);
+  Serial.println("8x8 LED Matrix Test");
+
+  matrix.begin(0x70);  // pass in the address
+
+  matrix.setBrightness(5);
+
+  matrix.setRotation(3);
+
+  int count = 0;
+  int numCommits = 0;
+
+  matrix.clear();
+
+  for(int x = 0; x < 8; x++) {
+    for(int y = 0; y < 7; y++) {
+      if(commits[count] > 0) {
+        if(commits[count] > 6) {
+          numCommits = 0;
+        } else if (commits[count] > 3) {
+          numCommits = 1;
+        } else {
+          numCommits = 2;
+        }
+
+        matrix.drawPixel(x, y, colors[numCommits]);
+      }
+
+      count++;
+    }
+  }
+
+  matrix.writeDisplay();
+}
+
+void loop() {
+  // nothing to do here
+}


Added basic example

Added basic example

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

--- examples/BasicNode/BasicNode.ino
+++ examples/BasicNode/BasicNode.ino
@@ -0,0 +1,83 @@
+#include "FastLED.h"
+#include <SPI.h>
+#include <Ethernet.h>
+#include <ArtNode.h>
+
+#define VERSION_HI 0
+#define VERSION_LO 1
+
+////////////////////////////////////////////////////////////
+ArtConfig config = {
+  {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}, // MAC - last 3 bytes set by Teensy
+  {2, 0, 0, 1},                         // IP
+  {255, 0, 0, 0},                       // Subnet mask
+  0x1936,                               // UDP port
+  false,                                // DHCP
+
+  // These fields get overwritten by loadConfig:
+  0, 0,                                 // Net (0-127) and subnet (0-15)
+  "ArtNode",                            // Short name
+  "ArtNode",                            // Long name
+  4,                                    // Number of ports
+  {PortTypeDmx | PortTypeOutput, PortTypeDmx | PortTypeOutput, PortTypeDmx | PortTypeOutput, PortTypeDmx | PortTypeOutput}, // Port types
+  {0, 0, 0, 0},                         // Port input universes (0-15)
+  {0, 1, 2, 3},                         // Port output universes (0-15)
+  VERSION_HI,
+  VERSION_LO
+};
+////////////////////////////////////////////////////////////
+IPAddress gateway(config.ip[0], 0, 0, 1);
+EthernetUDP udp;
+byte buffer[600];
+ArtNode node = ArtNode(config, sizeof(buffer), buffer);
+
+////////////////////////////////////////////////////////////
+void setup() {
+
+  Ethernet.begin(config.mac, config.ip,  gateway, gateway, config.subnet);
+  udp.begin(config.udpPort);
+}
+
+////////////////////////////////////////////////////////////
+void loop() {
+
+  while (udp.parsePacket()) {
+
+    int n = udp.read(buffer, sizeof(ArtHeader));
+    if (n >= sizeof(ArtHeader)) {
+
+      ArtHeader* header = (ArtHeader*)buffer;
+      if (memcmp(header->ID, "Art-Net", 8) == 0) {
+
+        // Read the rest of the packet
+        udp.read(buffer + sizeof(ArtHeader), udp.available());
+
+        // Package Op-Code determines type of packet
+        switch (header->OpCode) {
+
+          // Poll packet. Send poll reply.
+          case OpPoll:
+            node.createPollReply();
+            artnetSend(buffer, sizeof(ArtPollReply));
+            break;
+
+          // DMX packet
+          case OpDmx: {
+              ArtDmx* dmx = (ArtDmx*)buffer;
+              int port = node.getPort(dmx->SubUni, dmx->Net);
+          } break;
+
+          default:
+            break;
+        }
+      }
+    }
+  }
+}
+
+////////////////////////////////////////////////////////////
+void artnetSend(byte* buffer, int length) {
+  udp.beginPacket(node.broadcastIP(), config.udpPort);
+  udp.write(buffer, length);
+  udp.endPacket();
+}


Add files via upload

Add files via upload

Temperature measurement with TMP36 sensor on LoRa Node w/ Dragino LoRa Shield and Arduino Uno

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

--- lora_shield_ttn_tempC.ino
+++ lora_shield_ttn_tempC.ino
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
+ *
+ * Permission is hereby granted, free of charge, to anyone
+ * obtaining a copy of this document and accompanying files,
+ * to do whatever they want with them without any restriction,
+ * including, but not limited to, copying, modification and redistribution.
+ * NO WARRANTY OF ANY KIND IS PROVIDED.
+ *
+ * This example sends a valid LoRaWAN packet with payload "Hello,
+ * world!", using frequency and encryption settings matching those of
+ * the (early prototype version of) The Things Network.
+ *
+ * Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in g1,
+ *  0.1% in g2).
+ *
+ * Change DEVADDR to a unique address!
+ * See http://thethingsnetwork.org/wiki/AddressSpace
+ *
+ * Do not forget to define the radio type correctly in config.h.
+ *
+ *******************************************************************************/
+#include <stdlib.h>
+#include <lmic.h>
+#include <hal/hal.h>
+#include <SPI.h>
+
+// LoRaWAN NwkSKey, network session key
+// This is the default Semtech key, which is used by the prototype TTN
+// network initially.
+static const PROGMEM u1_t NWKSKEY[16] = { 0xEA, 0xD6, 0xB1, 0xA4, 0xD0, 0xBA, 0x8C, 0xEE, 0x84, 0x11, 0x38, 0xF6, 0xC1, 0xB7, 0xDC, 0x63 }; //{ 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
+
+// LoRaWAN AppSKey, application session key
+// This is the default Semtech key, which is used by the prototype TTN
+// network initially.
+static const u1_t PROGMEM APPSKEY[16] = { 0x1E, 0xBF, 0xD7, 0xE8, 0x3B, 0x5A, 0x0B, 0xCA, 0x84, 0x92, 0xA4, 0x18, 0x64, 0xA5, 0x67, 0xA5 }; // { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C };
+
+// LoRaWAN end-device address (DevAddr)
+// See http://thethingsnetwork.org/wiki/AddressSpace
+static const u4_t DEVADDR = 0xFB3E1760; // from TTN device registration   09984507 ; // <-- Change this address for every node!
+
+// These callbacks are only used in over-the-air activation, so they are
+// left empty here (we cannot leave them out completely unless
+// DISABLE_JOIN is set in config.h, otherwise the linker will complain).
+void os_getArtEui (u1_t* buf) { }
+void os_getDevEui (u1_t* buf) { }
+void os_getDevKey (u1_t* buf) { }
+
+static uint8_t mydata[] = "0123456789";
+//char mydata[] = "";
+static osjob_t sendjob;
+
+// Schedule TX every this many seconds (might become longer due to duty
+// cycle limitations).
+const unsigned TX_INTERVAL = 60;
+
+// Pin mapping
+const lmic_pinmap lmic_pins = {
+    .nss = 10,
+    .rxtx = LMIC_UNUSED_PIN,
+    .rst = 9,
+    .dio = {2, 6, 7},
+};
+
+const int sensorPin = 0;  // TMP36 connected to Pin A0
+
+void onEvent (ev_t ev) {
+    Serial.print(os_getTime());
+    Serial.print(": ");
+    switch(ev) {
+        case EV_SCAN_TIMEOUT:
+            Serial.println(F("EV_SCAN_TIMEOUT"));
+            break;
+        case EV_BEACON_FOUND:
+            Serial.println(F("EV_BEACON_FOUND"));
+            break;
+        case EV_BEACON_MISSED:
+            Serial.println(F("EV_BEACON_MISSED"));
+            break;
+        case EV_BEACON_TRACKED:
+            Serial.println(F("EV_BEACON_TRACKED"));
+            break;
+        case EV_JOINING:
+            Serial.println(F("EV_JOINING"));
+            break;
+        case EV_JOINED:
+            Serial.println(F("EV_JOINED"));
+            break;
+        case EV_RFU1:
+            Serial.println(F("EV_RFU1"));
+            break;
+        case EV_JOIN_FAILED:
+            Serial.println(F("EV_JOIN_FAILED"));
+            break;
+        case EV_REJOIN_FAILED:
+            Serial.println(F("EV_REJOIN_FAILED"));
+            break;
+            break;
+        case EV_TXCOMPLETE:
+            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
+            if(LMIC.dataLen) {
+                // data received in rx slot after tx
+                Serial.print(F("Data Received: "));
+                Serial.write(LMIC.frame+LMIC.dataBeg, LMIC.dataLen);
+                Serial.println();
+            }
+            // Schedule next transmission
+            os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
+            break;
+        case EV_LOST_TSYNC:
+            Serial.println(F("EV_LOST_TSYNC"));
+            break;
+        case EV_RESET:
+            Serial.println(F("EV_RESET"));
+            break;
+        case EV_RXCOMPLETE:
+            // data received in ping slot
+            Serial.println(F("EV_RXCOMPLETE"));
+            break;
+        case EV_LINK_DEAD:
+            Serial.println(F("EV_LINK_DEAD"));
+            break;
+        case EV_LINK_ALIVE:
+            Serial.println(F("EV_LINK_ALIVE"));
+            break;
+         default:
+            Serial.println(F("Unknown event"));
+            break;
+    }
+}
+
+void do_send(osjob_t* j){
+    // Check if there is not a current TX/RX job running
+    if (LMIC.opmode & OP_TXRXPEND) {
+        Serial.println(F("OP_TXRXPEND, not sending"));
+    } else
+    {
+        getTemperature();
+        // Prepare upstream data transmission at the next possible time.
+        LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
+        Serial.println(F("Packet queued"));
+    }
+    // Next TX is scheduled after TX_COMPLETE event.
+}
+
+void getTemperature()
+{
+  int reading = analogRead(sensorPin);
+  float voltage = reading * 5.0 /1024;
+  float temperatureC = (voltage - 0.5) * 100;
+  dtostrf(temperatureC, 7, 2, mydata);
+  Serial.print("Measured temperature = ");
+  Serial.print(temperatureC);
+  Serial.println(" *C");
+}
+
+void setup() {
+    Serial.begin(115200);
+    Serial.println(F("Starting"));
+
+    #ifdef VCC_ENABLE
+    // For Pinoccio Scout boards
+    pinMode(VCC_ENABLE, OUTPUT);
+    digitalWrite(VCC_ENABLE, HIGH);
+    delay(1000);
+    #endif
+
+    // LMIC init
+    os_init();
+    // Reset the MAC state. Session and pending data transfers will be discarded.
+    LMIC_reset();
+
+    // Set static session parameters. Instead of dynamically establishing a session
+    // by joining the network, precomputed session parameters are be provided.
+    #ifdef PROGMEM
+    // On AVR, these values are stored in flash and only copied to RAM
+    // once. Copy them to a temporary buffer here, LMIC_setSession will
+    // copy them into a buffer of its own again.
+    uint8_t appskey[sizeof(APPSKEY)];
+    uint8_t nwkskey[sizeof(NWKSKEY)];
+    memcpy_P(appskey, APPSKEY, sizeof(APPSKEY));
+    memcpy_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));
+    LMIC_setSession (0x1, DEVADDR, nwkskey, appskey);
+    #else
+    // If not running an AVR with PROGMEM, just use the arrays directly
+    LMIC_setSession (0x1, DEVADDR, NWKSKEY, APPSKEY);
+    #endif
+
+    // Set up the channels used by the Things Network, which corresponds
+    // to the defaults of most gateways. Without this, only three base
+    // channels from the LoRaWAN specification are used, which certainly
+    // works, so it is good for debugging, but can overload those
+    // frequencies, so be sure to configure the full frequency range of
+    // your network here (unless your network autoconfigures them).
+    // Setting up channels should happen after LMIC_setSession, as that
+    // configures the minimal channel set.
+    LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
+    LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);      // g-band
+    LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
+    LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
+    LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
+    LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
+    LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
+    LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band
+    LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI);      // g2-band
+    // TTN defines an additional channel at 869.525Mhz using SF9 for class B
+    // devices' ping slots. LMIC does not have an easy way to define set this
+    // frequency and support for class B is spotty and untested, so this
+    // frequency is not configured here.
+
+    // Disable link check validation
+    LMIC_setLinkCheckMode(0);
+
+    // Set data rate and transmit power (note: txpow seems to be ignored by the library)
+    LMIC_setDrTxpow(DR_SF7,14);
+
+    // Start job
+    do_send(&sendjob);
+}
+
+void loop() {
+    os_runloop_once();
+}


Deleted arduino_shutter_code

Deleted arduino_shutter_code

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


Update ProbeCube_pp_099b0223.ino

Update ProbeCube_pp_099b0223.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_099b0223.ino' did not match any file(s) known to git


add arduino funksteckdosen script

add arduino funksteckdosen script

error: pathspec 'arduino/rc-switch/funksteckdosen.ino' did not match any file(s) known to git

--- arduino/rc-switch/funksteckdosen.ino
+++ arduino/rc-switch/funksteckdosen.ino
@@ -0,0 +1,71 @@
+#include <SPI.h>
+#include <Ethernet.h>
+#include <EthernetUdp.h>
+#include <RCSwitch.h>
+
+RCSwitch mySwitch = RCSwitch();
+
+byte mac[] = {
+  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
+};
+IPAddress ip(192, 168, 2, 190);
+
+unsigned int localPort = 8888;      // local port to listen on
+
+// buffers for receiving and sending data
+char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
+
+// An EthernetUDP instance to let us send and receive packets over UDP
+EthernetUDP Udp;
+
+void setup() {
+  // start the Ethernet and UDP:
+  Ethernet.begin(mac, ip);
+  Udp.begin(localPort);
+
+  Serial.begin(9600);
+
+  mySwitch.enableTransmit(9);
+}
+
+char *cmd, *group, *id;
+void loop() {
+  // if there's data available, read a packet
+  int packetSize = Udp.parsePacket();
+  if (packetSize)
+  {
+    Serial.print("Received packet of size ");
+    Serial.print(packetSize);
+    Serial.print(" with content: ");
+
+    // read the packet into packetBufffer
+    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
+
+    packetBuffer[strlen(packetBuffer)-1] = '\0';
+
+    Serial.println(packetBuffer);
+
+    cmd = strtok(packetBuffer, " ");
+    group = strtok(NULL, " ");
+    id = strtok(NULL, " ");
+
+    Serial.print("cmd: ");
+    Serial.print(cmd);
+    Serial.print(", group: ");
+    Serial.print(group);
+    Serial.print(", id: ");
+    Serial.println(id);
+
+    if(String(cmd).equals("on")) {
+      mySwitch.switchOn(group, id);
+    } else if(String(cmd).equals("off")) {
+      mySwitch.switchOff(group, id);
+    }
+
+    cmd = NULL;
+    group = NULL;
+    id = NULL;
+  }
+  delay(10);
+}
+


Removing trailing whitespace

Removing trailing whitespace

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/tomwagner1999/SmartHome.git/'


Added in arduino loader code.

Added in arduino loader code.

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

--- src/pong_loader/arduino_code/loader_arduino/loader_arduino.ino
+++ src/pong_loader/arduino_code/loader_arduino/loader_arduino.ino
@@ -0,0 +1,95 @@
+/*
+ * Purpose: Loads a ball into a hopper.
+            Designed to run on a teensie 3.1.
+            The pwm controlled motor does nothing until
+              it receives a ros message telling motor to spin.
+            Motor spins until a sensor switch is hit.
+
+   Date: 4/29/15
+   Author: Kory Kraft
+ */
+
+#include <ros.h>
+#include <std_msgs/String.h>
+#include <std_msgs/Bool.h>
+
+
+ros::NodeHandle nh;
+
+std_msgs::String state_msg;
+ros::Publisher pub_state("loader/state", &state_msg);
+
+const int switch_pin = 5;
+const int led_pin = 13;
+const int motor_pin = 9;
+
+const int motor_speed = 50;
+
+//bool last_reading;
+//long last_debounce_time=0;
+//long debounce_delay=50;
+//bool published = true;
+
+void run_motor(int motor_speed){
+  analogWrite(motor_pin, motor_speed);
+}
+
+void stop_motor(){
+  analogWrite(motor_pin, 0);
+}
+
+void load_ball(){
+  // While we haven't seen the switch be high,
+  //   run the motor
+
+  while(digitalRead(switch_pin) != HIGH){
+    run_motor(motor_speed);
+
+
+    delay(10);
+    break; // put this in here to test, don't want to kill the motor
+  }
+
+  stop_motor();
+
+}
+
+void load_cmd_cb(const std_msgs::Bool& cmd_msg){
+
+  if (cmd_msg.data == true){
+    // load ball
+    state_msg.data = "loading";
+    pub_state.publish(&state_msg);
+    digitalWrite(led_pin, HIGH);
+
+
+    load_ball();
+
+    state_msg.data = "loaded";
+    pub_state.publish(&state_msg);
+    digitalWrite(led_pin,LOW);
+
+  }
+
+}
+
+ros::Subscriber<std_msgs::Bool> load_sub("load_cmd", load_cmd_cb);
+
+void setup()
+{
+  nh.initNode();
+  nh.advertise(pub_state);
+
+  //initialize an LED output pin for status purposes
+  //init input pin for switch input and motor control pin
+  pinMode(led_pin, OUTPUT);
+  pinMode(switch_pin, INPUT);
+  pinMode(motor_pin, OUTPUT);
+
+}
+
+void loop()
+{
+  nh.spinOnce();
+  delay(1);
+}


Issue #2, added sample for CRC Motors module.

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

--- examples/Ex03_Motors/Ex03_Motors.ino
+++ examples/Ex03_Motors/Ex03_Motors.ino
@@ -0,0 +1,57 @@
+/***************************************************
+This file is designed for the Simula project by Chicago Robotics Corp.
+http://www.chicagorobotics.net/products
+
+Copyright (c) 2016, Chicago Robotics Corp.
+See README.md for license details
+****************************************************/
+
+#include "CRC_Hardware.h"
+#include "CRC_Motor.h"
+
+/** Start Instantiate all CRC Modules here **/
+CRC_HardwareClass hardware;
+CRC_Motor motorLeft(hardware.enc1A, hardware.enc1B, hardware.mtr1Enable, hardware.mtr1In1, hardware.mtr1In2);
+CRC_Motor motorRight(hardware.enc2A, hardware.enc2B, hardware.mtr2Enable, hardware.mtr2In1, hardware.mtr2In2);
+CRC_Motors motors;
+/** End Instantiate all CRC Modules here **/
+
+void setup()
+{
+  // You can use the Serial Monitor to see these message
+  Serial.begin(115200);
+  Serial.println(F("Setting up Hardware."));
+
+  // Set up the Simula Board
+  hardware.init();
+
+  // Configure the motors with left/right motor/encoders
+  motors.initialize(&motorLeft, &motorRight);
+
+  Serial.println(F("Motors Ready to go"));
+}
+
+
+void loop()
+{
+  Serial.println(F("Fowards at full Power"));
+  motors.setPower(255, 255); // Forwards
+  delay(1000);
+
+  Serial.println(F("Backwards at full Power"));
+  motors.setPower(-255, -255); // Backwards
+  delay(1000);
+
+  Serial.println(F("Spin Right"));
+  motors.setPower(255, -255); // Spin right
+  delay(1000);
+
+  Serial.println(F("Spin Left"));
+  motors.setPower(-255, 255);  // Spin left
+  delay(1000);
+
+  Serial.println(F("Stop"));
+  motors.allStop();  // All Stop, this is the same as  motors.setPower(0, 0);
+  delay(1000);
+}
+


Add: random packets generator example

Add: random packets generator example

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

--- examples/send_random/send_random.ino
+++ examples/send_random/send_random.ino
@@ -0,0 +1,120 @@
+/*
+ * demo: CAN-BUS Shield, send random id/type/data
+ * This code has a little same with linux can-utils 'cangen -mv'
+ *
+ * Copyright (C) 2020 Seeed Technology Co.,Ltd.
+ */
+#include <SPI.h>
+
+/*SAMD core*/
+#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
+    #define SERIAL SerialUSB
+#else
+    #define SERIAL Serial
+#endif
+
+#define CAN_2515
+// #define CAN_2518FD
+
+// the cs pin of the version after v1.1 is default to D9
+// v0.9b and v1.0 is default D10
+
+// Set SPI CS Pin according to your hardware
+// For Wio Terminal w/ MCP2518FD RPi Hat：
+// Channel 0 SPI_CS Pin: BCM 8
+// Channel 1 SPI_CS Pin: BCM 7
+// Interupt Pin: BCM25
+// *****************************************
+// For Arduino MCP2515 Hat:
+// SPI_CS Pin: D9
+
+#ifdef CAN_2518FD
+#include "mcp2518fd_can.h"
+const int SPI_CS_PIN = 9;
+const int CAN_INT_PIN = 2;
+mcp2518fd CAN(SPI_CS_PIN); // Set CS pin
+#define MAX_DATA_SIZE 64
+#endif
+
+#ifdef CAN_2515
+#include "mcp2515_can.h"
+const int SPI_CS_PIN = 9;
+const int CAN_INT_PIN = 2;
+mcp2515_can CAN(SPI_CS_PIN); // Set CS pin
+#define MAX_DATA_SIZE 8
+#endif
+
+void setup() {
+    SERIAL.begin(115200);
+    while(!Serial){};
+
+#ifdef CAN_2518FD
+    while (0 != CAN.begin((byte)CAN_500K_1M)) {            // init can bus : baudrate = 500k
+#else
+    while (CAN_OK != CAN.begin(CAN_500KBPS)) {             // init can bus : baudrate = 500k
+#endif
+        SERIAL.println("CAN BUS Shield init fail");
+        SERIAL.println(" Init CAN BUS Shield again");
+        delay(100);
+    }
+    SERIAL.println("CAN BUS Shield init ok!");
+
+    randomSeed(millis());
+}
+
+uint32_t id;
+uint8_t  type; // bit0: ext, bit1: rtr
+unsigned len;
+byte cdata[MAX_DATA_SIZE] = {0};
+
+void loop() {
+    type = random(4);
+    if (type & 0x1) {
+        // total 29 bits
+        // Arduino AVR only generate up to 16 bits random number
+        id = random(0x1U << 14);
+        id |= (uint32_t)random(0x1U << 15) << 14;
+    } else {
+        id = random(0x1U << 11);
+    }
+    if (type & 0x2) {
+        len = 0;
+        // remote frame could also carry data
+        // but don't do it.
+        // len = random(0, MAX_DATA_SIZE + 1);
+    } else {
+        len = random(0, MAX_DATA_SIZE + 1);
+    }
+
+    int i;
+    for (i = 0; i < len; i++) {
+        cdata[i] = random(0x100);
+    }
+
+    CAN.sendMsgBuf(id, bool(type & 0x1),
+                       bool(type & 0x2),
+                       len, cdata);
+    char prbuf[0x40];
+    int n;
+
+    /* Displayed type:
+     *
+     * 0x00: standard data frame
+     * 0x02: extended data frame
+     * 0x30: standard remote frame
+     * 0x32: extended remote frame
+     */
+    static const byte type2[] = {0x00, 0x02, 0x30, 0x32};
+    n = sprintf(prbuf, "TX: [%08lX](%02X) ", (unsigned long)id, type2[type]);
+    // n = sprintf(prbuf, "TX: [%08lX](%02X) ", id, type);
+
+    for (i = 0; i < len; i++) {
+        n += sprintf(prbuf + n, "%02X ", cdata[i]);
+    }
+    SERIAL.println(prbuf);
+
+    unsigned d = random(30);
+    SERIAL.println(d);
+    delay(d);
+}
+// END FILE


fixed point math is not that hard …

fixed point math is not that 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/'


arduino sketch

arduino sketch

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

--- controle_ventilador_meu_quarto_ATTINY.ino
+++ controle_ventilador_meu_quarto_ATTINY.ino
@@ -0,0 +1,68 @@
+//Anor Batista Esteves Neto
+//  04/01/2015  21:10
+//  Attiny send IR Remote Key with button or clap
+
+#include <attiny85_IR.h>
+
+// defining pins
+#define buttonPin  4    // attiny physical pin 3, button with pull down resistor
+#define ledPin     0      // attiny physical pin 5 , normal led for visual feedback of when we are sending an ir command
+
+//defining constants
+#define TRIGGER 550
+
+
+IRsend irsend; // IR led on physical pin 6 (D1) , the IR output will be always on attiny physical pin 6
+
+// Variables that will change:
+int buttonState;             // the current reading from the input pin
+int lastButtonState = HIGH;   // the previous reading from the input pin
+// the following variables are long's because the time, measured in miliseconds,
+// will quickly overflow an int
+long lastDebounceTime = 0;  // the last time the output pin was toggled
+long debounceDelay = 50;    // the debounce time; increase if the output flickers
+
+void setup() {
+  pinMode(buttonPin, INPUT);
+  digitalWrite(buttonPin,HIGH); //activating internal pull-up on button pin
+  pinMode(ledPin,OUTPUT);
+  digitalWrite(ledPin,LOW);
+}
+
+void loop() {
+  check_button_state();
+ }
+
+
+void check_button_state( void ){
+    // 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;
+      if (buttonState == LOW) send_ir();
+    }
+    // save the reading.  Next time through the loop,
+    // it'll be the lastButtonState:
+    lastButtonState = reading;
+}
+
+void send_ir(){
+    irsend.sendNEC(150468615, 32); // ir code for my fan light
+    digitalWrite(ledPin,HIGH); // just a visual feedback
+    delay(200);
+    digitalWrite(ledPin,LOW);
+}


first upload of 7segment arduino test code.

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

--- arduinoTest/_7segment/_7segment.ino
+++ arduinoTest/_7segment/_7segment.ino
@@ -0,0 +1,52 @@
+//Pin connected to ST_CP of 74HC595
+int latchPin = 8;
+//Pin connected to SH_CP of 74HC595
+int clockPin = 12;
+////Pin connected to DS of 74HC595
+int dataPin = 11;
+
+int digit0 = 0b0;
+int digit1 = 0b00010001;
+int digit2 = 0b01101011;
+int digit3 = 0b00111011;
+int digit4 = 0b00011101;
+int digit5 = 0b00111110;
+int digit6 = 0b01111100;
+int digit7 = 0b00010011;
+int digit8 = 0b01111111;
+int digit9 = 0b00011111;
+// if you want to add in the decimal point simply add 1 to each number
+
+void setup() {
+  //set pins to output so you can control the shift register
+  pinMode(latchPin, OUTPUT);
+  pinMode(clockPin, OUTPUT);
+  pinMode(dataPin, OUTPUT);
+}
+
+void loop() {
+    sendDigit(digit0);
+    sendDigit(digit1);
+    sendDigit(digit2);
+    sendDigit(digit3);
+    sendDigit(digit4);
+    sendDigit(digit5);
+    sendDigit(digit6);
+    sendDigit(digit7);
+    sendDigit(digit8);
+    sendDigit(digit9);
+  }
+}
+
+void sendDigit(int x){
+  // take the latchPin low so
+  // the LEDs don't change while you're sending in bits:
+  digitalWrite(latchPin, LOW);
+  // shift out the bits:
+  shiftOut(dataPin, clockPin, MSBFIRST, x);
+
+  //take the latch pin high so the LEDs will light up:
+  digitalWrite(latchPin, HIGH);
+  // pause before next value:
+  delay(1000);
+}


Arduino example

Arduino example

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

--- arduino_example/arduino_example.ino
+++ arduino_example/arduino_example.ino
@@ -0,0 +1,25 @@
+void setup()
+  {
+    //Setting pins
+    pinMode(0,OUTPUT);
+    pinMode(1,OUTPUT);
+    pinMode(3,INPUT);
+  }
+void loop()
+  {
+    //Read value from sensor 2
+    if (digitalRead(3)==1)
+      {
+        //Turn of motor A
+        digitalWrite(1,LOW);
+        //Turn on motor B
+        digitalWrite(0,HIGH);
+      }
+    else
+      {
+        //Turn of motor B
+        digitalWrite(0,LOW);
+        //Turn on motor A
+        digitalWrite(1,HIGH);
+      }
+  }


Copy from rfid cards with standard authentication

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

--- examples/RFID-Cloner/RFID-Cloner.ino
+++ examples/RFID-Cloner/RFID-Cloner.ino
@@ -0,0 +1,312 @@
+/*
+Copy the RFID card data into variables and then
+scan the second empty card to copy all the date
+ * ----------------------------------------------------------------------------
+ * Example sketch/program which will try the most used default keys listed in
+ * https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys to dump the
+ * block 0 of a MIFARE RFID card using a RFID-RC522 reader.
+ *
+ * Typical pin layout used:
+ * -----------------------------------------------------------------------------------------
+ *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
+ *             Reader/PCD   Uno           Mega      Nano v3    Leonardo/Micro   Pro Micro
+ * Signal      Pin          Pin           Pin       Pin        Pin              Pin
+ * -----------------------------------------------------------------------------------------
+ * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
+ * SPI SS      SDA(SS)      10            53        D10        10               10
+ * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
+ * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
+ * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
+ *
+ */
+
+#include <SPI.h>
+#include <MFRC522.h>
+
+#define RST_PIN         9           // Configurable, see typical pin layout above
+#define SS_PIN          10          // Configurable, see typical pin layout above
+
+MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
+
+byte buffer[18];
+byte block;
+byte waarde[64][16];
+MFRC522::StatusCode status;
+
+MFRC522::MIFARE_Key key;
+
+// Number of known default keys (hard-coded)
+// NOTE: Synchronize the NR_KNOWN_KEYS define with the defaultKeys[] array
+#define NR_KNOWN_KEYS   8
+// Known keys, see: https://code.google.com/p/mfcuk/wiki/MifareClassicDefaultKeys
+byte knownKeys[NR_KNOWN_KEYS][MFRC522::MF_KEY_SIZE] =  {
+    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // FF FF FF FF FF FF = factory default
+    {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5}, // A0 A1 A2 A3 A4 A5
+    {0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5}, // B0 B1 B2 B3 B4 B5
+    {0x4d, 0x3a, 0x99, 0xc3, 0x51, 0xdd}, // 4D 3A 99 C3 51 DD
+    {0x1a, 0x98, 0x2c, 0x7e, 0x45, 0x9a}, // 1A 98 2C 7E 45 9A
+    {0xd3, 0xf7, 0xd3, 0xf7, 0xd3, 0xf7}, // D3 F7 D3 F7 D3 F7
+    {0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}, // AA BB CC DD EE FF
+    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  // 00 00 00 00 00 00
+};
+
+char choice;
+/*
+ * Initialize.
+ */
+void setup() {
+    Serial.begin(9600);         // Initialize serial communications with the PC
+    while (!Serial);            // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
+    SPI.begin();                // Init SPI bus
+    mfrc522.PCD_Init();         // Init MFRC522 card
+    Serial.println(F("Try the most used default keys to print block 0 to 63 of a MIFARE PICC."));
+    Serial.println("1.Read card \n2.Write to card \n3.Copy the data.");
+
+    for (byte i = 0; i < 6; i++) {
+        key.keyByte[i] = 0xFF;
+    }
+}
+
+
+
+ //Via seriele monitor de bytes uitlezen in hexadecimaal
+
+void dump_byte_array(byte *buffer, byte bufferSize) {
+    for (byte i = 0; i < bufferSize; i++) {
+        Serial.print(buffer[i] < 0x10 ? " 0" : " ");
+        Serial.print(buffer[i], HEX);
+    }
+}
+//Via seriele monitor de bytes uitlezen in ASCI
+
+void dump_byte_array1(byte *buffer, byte bufferSize) {
+  for (byte i = 0; i < bufferSize; i++) {
+    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
+    Serial.write(buffer[i]);
+  }
+}
+
+/*
+ * Try using the PICC (the tag/card) with the given key to access block 0 to 63.
+ * On success, it will show the key details, and dump the block data on Serial.
+ *
+ * @return true when the given key worked, false otherwise.
+ */
+
+boolean try_key(MFRC522::MIFARE_Key *key)
+{
+    boolean result = false;
+
+    for(byte block = 0; block < 64; block++){
+
+    // Serial.println(F("Authenticating using key A..."));
+    status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, key, &(mfrc522.uid));
+    if (status != MFRC522::STATUS_OK) {
+        Serial.print(F("PCD_Authenticate() failed: "));
+        Serial.println(mfrc522.GetStatusCodeName(status));
+        return false;
+    }
+
+    // Read block
+    byte byteCount = sizeof(buffer);
+    status = mfrc522.MIFARE_Read(block, buffer, &byteCount);
+    if (status != MFRC522::STATUS_OK) {
+        Serial.print(F("MIFARE_Read() failed: "));
+        Serial.println(mfrc522.GetStatusCodeName(status));
+    }
+    else {
+        // Successful read
+        result = true;
+        Serial.print(F("Success with key:"));
+        dump_byte_array((*key).keyByte, MFRC522::MF_KEY_SIZE);
+        Serial.println();
+
+        // Dump block data
+        Serial.print(F("Block ")); Serial.print(block); Serial.print(F(":"));
+        dump_byte_array1(buffer, 16); //omzetten van hex naar ASCI
+        Serial.println();
+
+        for (int p = 0; p < 16; p++) //De 16 bits uit de block uitlezen
+        {
+          waarde [block][p] = buffer[p];
+          Serial.print(waarde[block][p]);
+          Serial.print(" ");
+        }
+
+        }
+    }
+    Serial.println();
+
+    Serial.println("1.Read card \n2.Write to card \n3.Copy the data.");
+
+    mfrc522.PICC_HaltA();       // Halt PICC
+    mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD
+    return result;
+
+    start();
+}
+
+/*
+ * Main loop.
+ */
+void loop() {
+  start();
+
+}
+
+void start(){
+  choice = Serial.read();
+
+  if(choice == '1')
+  {
+    Serial.println("Read the card");
+    keuze1();
+
+    }
+    else if(choice == '2')
+    {
+      Serial.println("See what is in the variables");
+      keuze2();
+    }
+    else if(choice == '3')
+    {
+      Serial.println("Copying the data on to the new card");
+      keuze3();
+    }
+}
+
+void keuze2(){ //Test waardes in blokken
+
+  for(block = 4; block <= 62; block++){
+    if(block == 7 || block == 11 || block == 15 || block == 19 || block == 23 || block == 27 || block == 31 || block == 35 || block == 39 || block == 43 || block == 47 || block == 51 || block == 55 || block == 59){
+      block ++;
+    }
+
+  Serial.print(F("Writing data into block "));
+  Serial.print(block);
+  Serial.println("\n");
+
+    for(int j = 0; j < 16; j++){
+      Serial.print(waarde[block][j]);
+      Serial.print(" ");
+    }
+    Serial.println("\n");
+
+  }
+
+  Serial.println("1.Read card \n2.Write to card \n3.Copy the data.");
+  start();
+}
+
+void keuze3(){ //Copy the data in the new card
+Serial.println("Insert new card...");
+  // Look for new cards
+    if ( ! mfrc522.PICC_IsNewCardPresent())
+        return;
+
+    // Select one of the cards
+    if ( ! mfrc522.PICC_ReadCardSerial())
+        return;
+
+    // Show some details of the PICC (that is: the tag/card)
+    Serial.print(F("Card UID:"));
+    dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
+    Serial.println();
+    Serial.print(F("PICC type: "));
+    byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
+    Serial.println(mfrc522.PICC_GetTypeName(piccType));
+
+    // Try the known default keys
+    /*MFRC522::MIFARE_Key key;
+    for (byte k = 0; k < NR_KNOWN_KEYS; k++) {
+        // Copy the known key into the MIFARE_Key structure
+        for (byte i = 0; i < MFRC522::MF_KEY_SIZE; i++) {
+            key.keyByte[i] = knownKeys[k][i];
+        }
+    }*/
+    for (byte i = 0; i < 6; i++) {
+        key.keyByte[i] = 0xFF;
+    }
+
+  for(int i = 4; i <= 62; i++){ //De blocken 4 tot 62 kopieren, behalve al deze onderstaande blocken (omdat deze de authenticatie blokken zijn)
+    if(i == 7 || i == 11 || i == 15 || i == 19 || i == 23 || i == 27 || i == 31 || i == 35 || i == 39 || i == 43 || i == 47 || i == 51 || i == 55 || i == 59){
+      i++;
+    }
+    block = i;
+
+      // Authenticate using key A
+    Serial.println(F("Authenticating using key A..."));
+    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid));
+    if (status != MFRC522::STATUS_OK) {
+        Serial.print(F("PCD_Authenticate() failed: "));
+        Serial.println(mfrc522.GetStatusCodeName(status));
+        return;
+    }
+
+    // Authenticate using key B
+    Serial.println(F("Authenticating again using key B..."));
+    status = (MFRC522::StatusCode) mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_B, block, &key, &(mfrc522.uid));
+    if (status != MFRC522::STATUS_OK) {
+        Serial.print(F("PCD_Authenticate() failed: "));
+        Serial.println(mfrc522.GetStatusCodeName(status));
+        return;
+    }
+
+    // Write data to the block
+    Serial.print(F("Writing data into block "));
+    Serial.print(block);
+    Serial.println("\n");
+
+    dump_byte_array(waarde[block], 16);
+
+
+     status = (MFRC522::StatusCode) mfrc522.MIFARE_Write(block, waarde[block], 16);
+      if (status != MFRC522::STATUS_OK) {
+        Serial.print(F("MIFARE_Write() failed: "));
+        Serial.println(mfrc522.GetStatusCodeName(status));
+      }
+
+
+     Serial.println("\n");
+
+  }
+  mfrc522.PICC_HaltA();       // Halt PICC
+  mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD
+
+  Serial.println("1.Read card \n2.Write to card \n3.Copy the data.");
+  start();
+}
+
+void keuze1(){ //Read card
+  Serial.println("Insert card...");
+  // Look for new cards
+    if ( ! mfrc522.PICC_IsNewCardPresent())
+        return;
+
+    // Select one of the cards
+    if ( ! mfrc522.PICC_ReadCardSerial())
+        return;
+
+    // Show some details of the PICC (that is: the tag/card)
+    Serial.print(F("Card UID:"));
+    dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
+    Serial.println();
+    Serial.print(F("PICC type: "));
+    byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
+    Serial.println(mfrc522.PICC_GetTypeName(piccType));
+
+    // Try the known default keys
+    MFRC522::MIFARE_Key key;
+    for (byte k = 0; k < NR_KNOWN_KEYS; k++) {
+        // Copy the known key into the MIFARE_Key structure
+        for (byte i = 0; i < MFRC522::MF_KEY_SIZE; i++) {
+            key.keyByte[i] = knownKeys[k][i];
+        }
+        // Try the key
+        if (try_key(&key)) {
+            // Found and reported on the key and block,
+            // no need to try other keys for this PICC
+            break;
+        }
+    }
+}


added Arduino serial/LCD code

added Arduino serial/LCD code

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

--- LcdSerial/LcdSerial.ino
+++ LcdSerial/LcdSerial.ino
@@ -0,0 +1,208 @@
+#include <stdarg.h>
+
+/*
+
+  The circuit:
+ * LCD RS pin to digital pin 12
+ * LCD Enable pin to digital pin 11
+ * LCD D4 pin to digital pin 5
+ * LCD D5 pin to digital pin 4
+ * LCD D6 pin to digital pin 3
+ * LCD D7 pin to digital pin 2
+ * LCD R/W pin to ground
+ * 10K resistor:
+ * ends to +5V and ground
+ * wiper to LCD VO pin (pin 3)
+
+ Based on the following tu:
+ http://www.arduino.cc/en/Tutorial/LiquidCrystal
+ */
+
+#include <LiquidCrystal.h>
+
+// Set up the data pins
+LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
+
+void setup()
+{
+    // Set up the serial port connection
+    Serial.begin(9600);
+    Serial.flush();
+
+    // set up the LCD's number of columns and rows:
+    lcd.begin(16, 2);
+}
+
+
+// Read bytes from serial port into buffer
+// Return number of bytes read
+
+int readSerialData(char* buffer, int bufsize)
+{
+    int i = 0;
+
+    if (Serial.available())
+    {
+        while (Serial.available() && i < (bufsize-1))
+        {
+            buffer[i++] = Serial.read();
+        }
+    }
+
+    return i;
+}
+
+
+/*
+ * Interpret and run the next command in the buffer
+ *
+ * @return number of characters consumed,
+ *  or -1 if no valid command recognised
+ *
+ * Returns zero if nothing was processed - for example
+ * if the buffer was not ready, or not enough data was
+ * found to supply all of a command's expected arguments
+ */
+int runCommand(const char* buffer, int len)
+{
+    if (len < 1)
+        return 0;
+
+    switch (buffer[0])
+    {
+        /*
+         * CLEAR
+         * Clear the screen - no arguments
+         */
+        case 'c':
+        {
+            lcd.clear();
+            return 1;
+        }
+
+        /*
+         * WRITE
+         * Write string to screen at current position.
+         * Next bytes specify the string until null char is found
+         * Example (writes Hello to the screen):
+         *      wHello
+         */
+        case 'w':
+        {
+            int count = strnlen(++buffer, len-1);
+            if (count != len-1)
+            {
+                lcd.print(buffer);
+                return count + 2;
+            }
+            return 0;
+        }
+
+        /*
+         * MOVE
+         * Move cursor position
+         * Next two bytes specify the column and row
+         *      m<col><row>
+         */
+        case 'm':
+        {
+            if (len >= 3)
+            {
+                lcd.setCursor(buffer[1], buffer[2]);
+                return 3;
+            }
+            return 0;
+        }
+
+        /*
+         * SCROLL LEFT
+         * Scroll cursor left
+         * Next byte specifies number of columns to scroll
+         */
+        case 'l':
+        {
+            if (len >= 2)
+            {
+                for (int i=0; i < buffer[1]; i++) {
+                    lcd.scrollDisplayLeft();
+                    delay(150);
+                }
+                return 2;
+            }
+            return 0;
+        }
+
+        /*
+         * SCROLL RIGHT
+         * Scroll cursor right
+         * Next byte specifies number of columns to scroll
+         */
+        case 'r':
+        {
+            if (len >= 2)
+            {
+                for (int i=0; i < buffer[1]; i++) {
+                    lcd.scrollDisplayRight();
+                    delay(150);
+                }
+                return 2;
+            }
+            return 0;
+        }
+    }
+
+    return -1;
+}
+
+
+/*
+ * Serial protocol consists of single character command code
+ * followed by arguments for that command
+ *
+ * Commands can be concatenated:
+ * e.g. to clear the screen and write Hello on the bottom line:
+ *
+ * >>> s.write('cm\x00\x01wHello\0')
+ *
+ * Commands also may arrive in a fragmented state - the buffer reader takes care of this.
+ */
+
+#define BUF_SIZE 256
+char buffer[BUF_SIZE];
+int buf_len = 0;
+
+void loop()
+{
+    // Read new chunk into the buffer
+    int bytes_read = readSerialData(buffer+buf_len, BUF_SIZE-buf_len-1);
+    buf_len += bytes_read;
+    int start = 0;
+
+    // Process all complete commands found in the buffer
+    while (buf_len > 0)
+    {
+        int processed = runCommand(buffer+start, buf_len-start);
+        if (processed > 0)
+        {
+            start += processed;
+        }
+        else if (processed < 0)
+        {
+            buf_len = 0;
+            return;
+        }
+        else
+        {
+            break;
+        }
+    }
+
+    // Reset buffer to new start position
+    // (this moves the buffer backwards in memory to overwrite used-up commands
+    // and start the next loop iteration from the original position)
+    if (start)
+    {
+        memmove(buffer, buffer+start, buf_len-start);
+        buf_len -= start;
+    }
+}


Motor test

Motor test

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

--- MotorTest/MotorTest.ino
+++ MotorTest/MotorTest.ino
@@ -0,0 +1,29 @@
+
+
+int PIN_THROTTLE = A0;    // select the input pin for the potentiometer
+int PIN_MOTOR = 6;      // select the pin for the LED
+
+
+void setup() {
+ //Serial.begin(115200);
+}
+
+void loop() {
+
+
+  byte pwm = joystickMapValues( analogRead(PIN_THROTTLE), 0, 512, 1024, false );
+  analogWrite(PIN_MOTOR, pwm);
+
+  //Serial.println(pwm);
+  //delay(250);
+}
+
+int joystickMapValues(int val, int lower, int middle, int upper, bool reverse)
+{
+  val = constrain(val, lower, upper);
+  if ( val < middle )
+    val = map(val, lower, middle, 0, 128);
+  else
+    val = map(val, middle, upper, 128, 255);
+  return ( reverse ? 255 - val : val );
+}


Optimise data types

Optimise data types

fatal: remote error: upload-pack: not our ref 06c20350f7bf8bea3f4f5a7c0840d1e66fa740ed
fatal: the remote end hung up unexpectedly