Added string reference class test

Added string reference class test

#include <Arduino.h>
#include <ArduinoUnit.h>
#include <Arduino_FreeRTOS.h>
#include <StandardCplusplus.h>
#include <RabirdToolkit.h>
#include <RAbstractStringRef.h>
#include <string.h>

class BasicStringRef: public RAbstractStringRef
{
public:
  BasicStringRef(const char * str);
  ~BasicStringRef();

  unsigned int
  length(void) const
  {
    return static_cast<unsigned int>(mLength);
  }

  char
  charAt(unsigned int index) const
  {
    if((NULL == mStr) || (index >= length()))
    {
      return '\0';
    }

    return mStr[index];
  }

private:
  const char * mStr;
  rnumber_t    mLength;
};

BasicStringRef::BasicStringRef(const char * str): RAbstractStringRef(), mStr(str), mLength(0)
{
  if(NULL != str)
  {
    mLength = rSignedCast(strlen(str));
  }
}

BasicStringRef::~BasicStringRef()
{
}

test(TestAbstractStringRef)
{
  const char * normalString0 = "";
  const char * normalString1 = "a";
  const char * normalString2 = "ab";
  const char * normalString3 = "abc";
  const char * normalString4 = "AbC";

  // length
  assertEqual(BasicStringRef(normalString0).length(), strlen(normalString0));
  assertEqual(BasicStringRef(normalString1).length(), strlen(normalString1));
  assertEqual(BasicStringRef(normalString2).length(), strlen(normalString2));
  assertEqual(BasicStringRef(normalString3).length(), strlen(normalString3));

  // compareTo
  assertEqual(BasicStringRef(normalString3).compareTo(BasicStringRef(normalString3)), 0);
  assertMore(BasicStringRef(normalString3).compareTo(BasicStringRef(normalString2)), 0);
  assertMore(BasicStringRef(normalString3).compareTo(BasicStringRef(normalString1)), 0);
  assertMore(BasicStringRef(normalString3).compareTo(BasicStringRef(normalString0)), 0);

  assertLess(BasicStringRef(normalString0).compareTo(BasicStringRef(normalString3)), 0);
  assertLess(BasicStringRef(normalString0).compareTo(BasicStringRef(normalString2)), 0);
  assertLess(BasicStringRef(normalString0).compareTo(BasicStringRef(normalString1)), 0);
  assertLess(BasicStringRef(normalString0).compareTo(BasicStringRef(normalString0)), 0);

  assertEqual(BasicStringRef(normalString3).compareTo((normalString3)), 0);
  assertMore(BasicStringRef(normalString3).compareTo((normalString2)), 0);
  assertMore(BasicStringRef(normalString3).compareTo((normalString1)), 0);
  assertMore(BasicStringRef(normalString3).compareTo((normalString0)), 0);

  assertLess(BasicStringRef(normalString0).compareTo((normalString3)), 0);
  assertLess(BasicStringRef(normalString0).compareTo((normalString2)), 0);
  assertLess(BasicStringRef(normalString0).compareTo((normalString1)), 0);
  assertLess(BasicStringRef(normalString0).compareTo((normalString0)), 0);

  // equals
  assertTrue(BasicStringRef(normalString3).equals(BasicStringRef(normalString3)));
  assertTrue(BasicStringRef(normalString3).equals((normalString3)));

  // equalsIgnoreCase
  assertTrue(BasicStringRef(normalString3).equalsIgnoreCase(BasicStringRef(normalString4)));
  assertTrue(BasicStringRef(normalString3).equalsIgnoreCase(BasicStringRef(normalString3)));
  assertFalse(BasicStringRef(normalString3).equalsIgnoreCase(BasicStringRef(normalString2)));
  assertFalse(BasicStringRef(normalString3).equalsIgnoreCase(BasicStringRef(normalString0)));

  // startsWith
  assertTrue(BasicStringRef(normalString3).startsWith(BasicStringRef(normalString3)));
  assertTrue(BasicStringRef(normalString3).startsWith(BasicStringRef(normalString2)));
  assertTrue(BasicStringRef(normalString3).startsWith(BasicStringRef(normalString1)));
  assertFalse(BasicStringRef(normalString3).startsWith(BasicStringRef(normalString0)));

  // endsWith
  assertTrue(BasicStringRef(normalString3).endsWith(BasicStringRef("c")));
  assertTrue(BasicStringRef(normalString3).endsWith(BasicStringRef("bc")));
  assertTrue(BasicStringRef(normalString3).endsWith(BasicStringRef("abc")));
  assertFalse(BasicStringRef(normalString3).endsWith(BasicStringRef("")));

  // charAt
  assertTrue(BasicStringRef(normalString3).charAt(0) == 'a');
  assertTrue(BasicStringRef(normalString3).charAt(1) == 'b');
  assertTrue(BasicStringRef(normalString3).charAt(2) == 'c');
  assertTrue(BasicStringRef(normalString3).charAt(3) == '\0');

  // operator ==
  assertTrue(BasicStringRef(normalString3) == BasicStringRef(normalString3));
  assertTrue(BasicStringRef(normalString3) == normalString3);

  // operator !=
  assertTrue(BasicStringRef(normalString3) != BasicStringRef(normalString3));
  assertTrue(BasicStringRef(normalString3) != BasicStringRef(normalString0));

  // operator >
  assertTrue(BasicStringRef(normalString3) > BasicStringRef(normalString2));
  assertTrue(BasicStringRef(normalString3) > BasicStringRef(normalString0));

  // operator <
  assertTrue(BasicStringRef(normalString1) < BasicStringRef(normalString3));
  assertTrue(BasicStringRef(normalString1) < BasicStringRef(normalString2));

  // operator <=
  assertTrue(BasicStringRef(normalString2) <= BasicStringRef(normalString3));
  assertTrue(BasicStringRef(normalString2) <= BasicStringRef(normalString2));
  assertTrue(BasicStringRef(normalString2) <= BasicStringRef(normalString1));
  assertFalse(BasicStringRef(normalString2) <= BasicStringRef(normalString0));

  // operator >=
  assertFalse(BasicStringRef(normalString2) >= BasicStringRef(normalString3));
  assertTrue(BasicStringRef(normalString2) >= BasicStringRef(normalString2));
  assertTrue(BasicStringRef(normalString2) >= BasicStringRef(normalString1));
  assertTrue(BasicStringRef(normalString2) >= BasicStringRef(normalString0));
}

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

void loop()
{
  Test::run();
}

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


Vijay - 2017/06/10 - adding arduino java serialport examples

#define LED_RED           2
#define LED_GREEN         3
#define LED_YELLOW        4

unsigned char LR=0;
unsigned char LG=0;
unsigned char LY=0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(LED_RED,   OUTPUT);
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_YELLOW,  OUTPUT);

  digitalWrite(LED_RED,   LOW);
  digitalWrite(LED_GREEN, LOW);
  digitalWrite(LED_YELLOW,  LOW);
}

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

}

void serialEvent() {
    int ind=0;
    char buff[11];
    if(Serial.available()){
        delay(10);
        while(Serial.available()){
            char c = (char)Serial.read();
            if(ind<10){
              buff[ind++] = c;
            }
        }
        buff[ind]=0;

        if      (strcmp(buff, "red")==0)  { LR = 1-LR; digitalWrite(LED_RED, LR);
        }else if(strcmp(buff, "green")==0){ LG = 1-LG; digitalWrite(LED_GREEN, LG);
        }else if(strcmp(buff, "yellow")==0) { LY = 1-LY; digitalWrite(LED_YELLOW, LY);
        }
    }
}

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


added arduino controller firmware

added arduino controller firmware

//Ethernet to WS2811 bridge for max et

#include "FastLED.h"
#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#define NUM_LEDS 1010
//#define DATA_PIN 2
//#define CLOCK_PIN 3

#define magicNum 603

char headerBL[3];
//char lt0[900] = {0}; //temp buffers for packets
//char lt1[900] = {0};
//char lt2[900] = {0};
//char lt3[900];

//Teensy 3.1
//#define DATA_PIN    7
//#define CLOCK_PIN   14

//megatemp
//#define DATA_PIN 4
//#define CLOCK_PIN 5

//teesny bitbang
#define DATA_PIN 21
#define CLOCK_PIN 20

#define COLOR_ORDER BGR
#define CHIPSET     APA102

#define UDP_TX_PACKET_MAX_SIZE 700

CRGB leds[NUM_LEDS];

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
//byte mac[] = {
//  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte mac[] = {
  0xA0, 0xAF, 0xB4, 0xAF, 0x0b, 0x03
};
IPAddress ip(192, 168, 1, 210);

//IPAddress ip(10,4,2,10);

unsigned int localPort = 6038;      // local port to listen on

EthernetUDP Udp;

// buffers for receiving and sending data
//char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet

void setup() {
  // start the Ethernet and UDP:

  Ethernet.begin(mac, ip);
  Udp.begin(localPort);

  // FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  // FastLED.addLeds<CHIPSET, DATA_PIN,CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  // FastLED.addLeds<CHIPSET,DATA_PIN,CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.addLeds<CHIPSET, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

FastLED.setBrightness(16);

  for (int i = 0; i < NUM_LEDS; i = i + 20) {
    // Set the i'th led to red
    leds[i] = CRGB::Blue;
    // Show the leds
    FastLED.show();
    // now that we've shown the leds, reset the i'th led to black
    leds[i] = CRGB::Black;
    // Wait a little bit before we loop around and do it again
  }
  //
  Serial.begin(115200);
  Serial.println("enetNeoPixel finished setup 210");
  //Serial.println(IPAddress);
  //Serial.println(char(mac));
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  //  if(Udp.parsePacket())
  if (packetSize)
  {
    Udp.read(headerBL, 3);
    int shift = int(headerBL[0]);
    Serial.println(shift);
   // headerBL[0]=uint8_t(headerBL[0]);

    Udp.read( (char*)(leds + shift * 200), 600);

  }
FastLED.show();
 Serial.println(LEDS.getFPS());
}

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


example-1 Pin

example-1 Pin

/**
 * example-1
 *
 * 这个样例将指引您正确使用Pin类
 * 以高效使用针脚(Pin)
 *
 * 本样例包含了Pin类的基本用法
 * 至于高级膜法请参考Pin.h
 */

#include <kjArduino.h>

//在setup()的外面声明一个针脚,而不是在它里面(必须)
//至于为什么非得在外面,这涉及到Arduino源码编译原理,此处不细讲
Pin led = Pin(13, OUTPUT);

//也允许只声明针脚却不声明用途,但最好之后在setup()中初始化
Pin button = Pin(D1);

//声明一个呼吸灯
Pin breath = Pin(9, OUTPUT);

void setup(){
    button.setMode(INPUT_PULLUP); //声明button这个针脚的用途
}

void loop(){
    if(button.isHigh()){ //如果按钮所在针脚为高电平
        led.setHigh(); //将LED的电平设置为高
    }else{
        led.setLow(); //将LED的电平设置为低
    }

    breath.fade(0, 255, 10, 1); //让呼吸灯开始呼吸,后两个参数不是必须值,参考Pin.h内的doc以了解更多
    breath.fade(255, 0);

    breath.set(233); //设置呼吸灯所在针脚的模拟值为233

    button.waitTillHigh(); //让按钮锁死程序,直到按钮按下使得按钮所在针脚变为高电平

    button.waitTillLow(); //让按钮锁死程序,直到松开按钮使得按钮所在针脚变为低电平
}

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


Example for 2 MSGEQ7 graphic equilizer .ino file

/*Editor: Earl R. Watkins II Title: ERW_MSGEQ7_example Date: 11/04/2015
 * Datasheet: http://www.mix-sig.com/images/datasheets/MSGEQ7.pdf
 * Use to hook up pins properly, Also contains a recomended circuit.
 * 7 Bands: 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, and 16kHz
 * notes: TIP=Left, Ring = Right, Sleeve = GND.
 * This example requires 2 MSGEQ7 ICs.
 * leftRead = Tip= Analog Input
 * rightRead = Ring = Analog Input
 * Strobe = Digital Output
 * Reset = Digital Output
  */
//Libraries
#include <ERW_MSGEQ7.h> // Add Earl's MSGEQ7 library.
//Definitions
#define leftRead A0 // Define analog pin to read from left MSGEQ7.
#define rightRead A1 // Define analog pin to read from right MSGEQ7.
#define Strobe 3 // Define output pin to strobe MSGEQ7 for Frequencies.
#define Reset 2 // Define output pin to reset MSGEQ7 to read
int leftAmplitudes[7]; //The Library modifies an left channel array.
int rightAmplitudes[7]; // The Library modifies the right channel array.
const unsigned long timeStep = 1000; // 1000ms is 1 second. This controls the sample rate.
unsigned long Timer; // Timer to do math instead of delay
//Objects
ERW_MSGEQ7 VU; // Rename object

void setup() // Setup -------------------------------------------------------------
{
  Serial.begin(9600); //Begin Serial interface
  VU.begin(leftRead, rightRead, Strobe, Reset); //Begin graphic equilizer for stereo.
           //Requires 2 analog read pins and 2 digital write pins.
  Serial.println("MSGEQ7 started"); //User info.
  Serial.print("Left: "); // Print Channel indicator.
  Serial.println("\t\t\t\t\t\t\t\t\t\t\t\t\t\tRight: "); // Print Channel indicator.
  Timer=millis(); // Start timer.
}

void loop() // Pete & repete ------------------------------------------------------
{
  if(millis()-Timer>=timeStep)
  {
    VU.getAmplitudes(leftAmplitudes, rightAmplitudes); // Gets amplitudes of stereo.
                      // Must pass the name of two arrays.
                      // One left and one right.
    for(int i=0; i<7; i++) // Loop through all values of array.
    {
      printHz(i); // Print the Frequency of the value.
      Serial.print(leftAmplitudes[i]); // Print value(0-1023).
    }
    for(int i=6; i>=0; i--) // Loop through all values of array.
    {
      printHz(i); // Print the Frequency of the value.
      Serial.print(rightAmplitudes[i]); // Print value(0-1023).
    }
    Serial.println(); // New Line.
    Timer+=timeStep; // Update timer.
  }
}

void printHz(int sw) // Print the Frequency of the value.
{
  //7 Bands: 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, and 16kHz
  switch (sw)
  {
    case 1:
      Serial.print("\t160Hz: "); //Print the current frequency
      break;
    case 2:
      Serial.print("\t400Hz: "); //Print the current frequency
      break;
    case 3:
      Serial.print("\t1kHz: "); //Print the current frequency
      break;
    case 4:
      Serial.print("\t2.5kHz: "); //Print the current frequency
      break;
    case 5:
      Serial.print("\t6.25kHz: "); //Print the current frequency
      break;
    case 6:
      Serial.print("\t16kHz: "); //Print the current frequency
      break;
    default:
      Serial.print("63Hz: "); //Print the current frequency
    break;
  }
}

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


added destination signaling

added destination signaling

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


Added files via upload

Added files via upload

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

// Receptor - Seria la diana de la feria
#include <IRremote.h>
#include <Servo.h>
#include <Wire.h>

const int ledPin =  13;
int RECV_PIN = 11;
Servo myservo;
int pos = 15;
boolean Playing;
IRrecv irrecv(RECV_PIN);
char MessageReceived;
unsigned long timer = millis();
unsigned long time_between_target = 7;
int randNumber = 0;
int UpDegrees = 160;  //Grados a los que la diana esta vertical
int Shoots = 0; //Guardaremos el numero de diana y en función de ella modificaremos la dificultad
boolean TargetUp;

int DownDegrees = 15;  //Grados a los que la diana esta vertical
int ShootAvailableDegrees = 82; //Grados a los que la diana esperará el tiro.
boolean DirectionRightToLeft = true;
String texto;
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  myservo.attach(9);
  //Serial.println ("Comenzamos...");
  myservo.write(DownDegrees);
  delay(15);
  Playing = false;
  pinMode(ledPin, OUTPUT);
  Wire.begin(5);                // join i2c bus with address #2
  Wire.onReceive(receiveEvent); // register event
  //Serial.println (millis());ç
  //Manager.begin(9600);
  Playing = false;
  //TargetUp = true;

}

void (* resetFunc) (void) = 0;

void loop() {

  if (Playing)
  {

    if ((timer < millis()) && (!TargetUp))
    { //levantamos la diana transcurrido un tiempo aleatorio desde el ultimo blanco
      Wire.beginTransmission(1); // transmit to device #1
      Wire.write("go004");              // sends one byte
      Wire.endTransmission();    // stop transmitting
      if (DirectionRightToLeft)
      { //Serial.println ("pos1");
        for (pos = DownDegrees; pos <= ShootAvailableDegrees; pos += 1) // goes from 0 degrees to 180 degrees
        { // in steps of 1 degree
          myservo.write(pos);              // tell servo to go to position in variable 'pos'
          delay(5);                       // waits 5ms for the servo to reach the position
        }
      }
      else
      {
        for (pos = UpDegrees; pos >= ShootAvailableDegrees; pos -= 1)
        {
          myservo.write(pos);
          delay(5);
        }
      }
      TargetUp = true;
      //Serial.println (pos);
      //bajaremos la diana en 1-5 segundos depende de la dificultad

      switch (Shoots) {
        case  2:
          time_between_target = 5;
          //Serial.println (time_between_target);
          break;
        case  3:
          time_between_target = 4;
          //Serial.println (time_between_target);
          break;

        case  5:
          time_between_target = 3;
          //Serial.println (time_between_target);
          break;

        case  7:
          time_between_target = 1;
          //Serial.println (time_between_target);
          break;
      }
    }

    if (timer + (time_between_target * 1000) < millis() && TargetUp) //Si ha pasado el tiempo marcado desde el ultimo tiro, la nave continua
    {
      //      Serial.println (timer);
      //      Serial.println (time_between_target * 1000);
      //      Serial.println (timer + (time_between_target * 1000) );
      //      Serial.println (millis());
      //      Serial.println ("Aqui2");
      Wire.beginTransmission(1); // transmit to device #1
      Wire.write("nok004");              // sends one byte
      Wire.endTransmission();    // stop transmitting
      if (DirectionRightToLeft)
      { //Serial.println ("pos2");
        for (pos = ShootAvailableDegrees; pos <= UpDegrees; pos += 1)
        {
          myservo.write(pos);
          delay(5);
        }
      }
      else
      {
        for (pos = ShootAvailableDegrees ; pos >= DownDegrees; pos -= 1)
        {
          myservo.write(pos);
          delay(5);
        }
      }
      DirectionRightToLeft = !DirectionRightToLeft;
      TargetUp = false;
      randNumber = random(2, time_between_target);
      //Serial.println (randNumber);
      timer = randNumber * 1000 + millis();
      randomSeed(analogRead(0));

      //      Serial.println (timer);
      //      Serial.println (millis());
      //      Serial.println ("Aqui3");
      irrecv.resume(); // Receive the next value
    }

    //delay (200);
    if (irrecv.decode(&results) && TargetUp) {
      //Serial.println(results.value, DEC);
      irrecv.resume(); // Receive the next value
      //Serial.print (millis());
      if (results.value == 2704)  //valor que dispara el emisor de infrarrojos (apagado de tele sony)
      {
        Serial.print ("Blanco: ");
        //Serial.print (millis());
        //Manager.listen();
        Wire.beginTransmission(1); // transmit to device #1
        Wire.write("ok004");              // sends one byte
        Wire.endTransmission();    // stop transmitting

        Shoots = Shoots + 1;
        randNumber = random(2, time_between_target);
        //Serial.println (randNumber);
        timer = randNumber * 1000 + millis();
        randomSeed(analogRead(0));
        //Serial.println (timer);
        //Serial.println (millis());
        if (DirectionRightToLeft)
        {
          //Serial.println ("Aqui 1");
          myservo.write(ShootAvailableDegrees - 20);
          delay(1500);
          for (pos = ShootAvailableDegrees - 10 ; pos >= DownDegrees; pos -= 1)
          {
            myservo.write(pos);
            delay(2);
            //Serial.println ("Aqui 2");
          }
        }
        else
        { //Serial.println ("Aqui 3");
          myservo.write(ShootAvailableDegrees + 20);
          delay(1500);
          for (pos = ShootAvailableDegrees + 10; pos <= UpDegrees; pos += 1)
          {
            myservo.write(pos);
            delay(2);
            //Serial.println ("Aqui 4");
          }
        }
        delay (500);
        TargetUp = false;
        irrecv.resume();
        //Serial.println (pos);
        //delay(300);
      }
    }

  }

}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
  while ( Wire.available()) { // loop through all but the last
    char c = Wire.read(); // receive byte as a character
    texto = texto + c;
    Serial.print(c);         // print the character
  }

  if (texto == "rst")
  {
    resetFunc();
  }
  if (texto == "go")
  {
    Playing = true;
    Serial.println ("Comienza la partida!!");
    //    randomSeed(analogRead(0));
    //    for (pos = 0; pos <= UpDegrees; pos += 1) // goes from 0 degrees to 180 degrees
    //    { // in steps of 1 degree
    //      myservo.write(pos);              // tell servo to go to position in variable 'pos'
    //      delay(5);                       // waits 15ms for the servo to reach the position
    //      time_between_target = 7;
    //      Shoots = 0;
    //
    //
    //    }
    digitalWrite(ledPin, HIGH);
    TargetUp = false;
    timer = millis();
    DirectionRightToLeft = true;
    myservo.write(DownDegrees);              // tell servo to go to position in variable 'pos'
    delay(300);                       // waits 5ms for the servo to reach the position
  }
  if (texto == "end")
  {
    Playing = false;
    Serial.println ("Fin de la partida!!");
    //    for (pos = UpDegrees; pos >= 0; pos -= 1) // goes from 180 degrees to 0 degrees
    //    {
    myservo.write(DownDegrees);              // tell servo to go to position in variable 'pos'
    delay(300);                       // waits 5ms for the servo to reach the position
    //    }
    TargetUp = false;
    Shoots = 0;
    time_between_target = 7;
    digitalWrite(ledPin, LOW);

  }
  if (texto == "gup")
  {

    myservo.write(UpDegrees);
  }
  if (texto == "gdo")
  {

    myservo.write(DownDegrees);
  }
  if (texto == "gme")
  {

    myservo.write(ShootAvailableDegrees);
  }
  texto = "";

}

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


ok, let's start to move twice as far …

ok, let's start to move twice as far …

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


[chg] projeto de led blink do proprio arduino

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/kaiocesar/karduino.git/'


this should set all those nifty set positions a bit better


particle code

particle code

// This #include statement was automatically added by the Particle IDE.
#include <HttpClient.h>

// This #include statement was automatically added by the Particle IDE.
#include "application.h"
#include <HttpClient.h>

int tempPin = A0;
unsigned int nextTime = 0;    // Next time to contact the server
char publishString[60];
int led1 = D0;
int led2 = D7;

HttpClient http;
http_request_t request;
http_response_t response;

// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
     { "Content-Type", "application/json" },
    //  { "Accept" , "application/json" },
    // { "Accept" , "*/*"},
    { "Accept" , "*/*"},
    { "User-agent", "Particle HttpClient"},
    { NULL, NULL } // NOTE: Always terminate headers will NULL
};

void setup() {
  Serial.begin(9600);
  request.hostname = "picky-home.herokuapp.com";
  request.port = 80;
  request.path = "/readings";
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
   Particle.function("led",ledToggle);

   digitalWrite(led1, LOW);
}

unsigned long lasttime;
int mesPow,mesPow2;

void loop() {
  static unsigned long tracktime;
  static unsigned long tracktime2;
  if(millis()>tracktime) {
      tracktime = millis()+2000;
      routine();
  }
  if(digitalRead(D1)==LOW) {
      unsigned long thistime = millis();
      if(thistime-lasttime>100) { // Start of the sequence
          mesPow = 0;
          unsigned long tracktime3 = millis();
          int increment = 45;  // first slice
          while(millis()<tracktime3+7*80+30) { // sequence length
            if(millis()>tracktime) {
              tracktime = millis()+2000;
              routine();
            }
            if(millis()>tracktime3+increment) {
                increment+=80;
                bool val = digitalRead(D1);
                mesPow |= val<<increment/80;
            }
          }
          mesPow2 = mesPow;
          Serial.println(mesPow2);
      }
      lasttime = thistime;
  }
}

void routine() {
  int tempReading = analogRead(tempPin);
  float tempVolts = tempReading * 3.3 / 4095.0;
  float tempC = (tempVolts - 0.5) * 100.0;
  float tempF = tempC * 9.0 / 5.0 + 32.0;
  sprintf(publishString, "{\"temp\":%f, \"energy\":%f}", tempF, tempF);
  request.body = publishString;
  http.post(request, response, headers);
//   Serial.println(response.status);
//   Serial.println(request.body);
}

int ledToggle(String command) {

    if (command=="on") {
        tone(led1,37900);
        delay(200);
        noTone(led1);
        delay(200);
        tone(led1,37900,20);
        digitalWrite(led2,HIGH);
        return 1;
    }
    else if (command=="off") {
        tone(led1,37900);
        delay(20);
        noTone(led1);
        delay(40);
        tone(led1,37900,20);
        digitalWrite(led2,LOW);
        return 0;
    }
    else {
        return -1;
    }
}

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


this is probably the final iteration

this is probably the final iteration

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/rosalindfdt/huzzahbadge.git/'


Added example of stetting a single bit in a defined byte to 0 or 1

// Used to set each bit with a bitwise or
unsigned char hex[8]= {0x01  ,0x02  ,0x04  ,0x08  ,0x10  ,0x20  ,0x40  ,0x80};

#include "Wire.h"
void setup()
{
 Wire.begin(); // wake up I2C bus
 SetPortA2Outputs();
}

void loop()
{
  byte sendByte = B11111111;
  SetPinsOnPortA(SetBitInByte(sendByte,0,0));
  delay(1000);
  SetPinsOnPortA(sendByte);
  delay(1000);
}

void SetPortA2Outputs()
{
 Wire.beginTransmission(0x20);
 Wire.write(0x00); // IODIRA register
 Wire.write(0x00); // set all of port A to outputs
 Wire.endTransmission();
}

void SetPinsOnPortA(int a)
{
 Wire.beginTransmission(0x20);
 Wire.write(0x12); // GPIOA
 Wire.write(a); // port A
 Wire.endTransmission();
}

byte SetBitInByte(byte inByte,int bitToSet, bool bitValue)
{
  if(bitValue)
  {
    // Set the bit - or
    return inByte|hex[bitToSet];
  }
  else
  {
    // clear the bit - and (Alos need to invert hex for & to get the bit to be set. example 11111110 instead of 00000001)
    return inByte & InvertByte(hex[bitToSet]);
  }
}

byte InvertByte(byte inByte)
{
  return ~inByte;
}

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


Add message checksum, avoid interrupt races

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


update

update

#define trigger 9
#define echo 10
#define motor 4

long tempoTotal = 0;
int distancia;

float ultrassonic();
void controlarMotor();

void setup() {
  pinMode(trigger,OUTPUT);
  pinMode(echo,INPUT);
  pinMode(motor,OUTPUT);

  Serial.begin(9600);
  digitalWrite(trigger,LOW);
  digitalWrite(motor,LOW);
}

void loop() {
  distancia = ultrassonic();
  controlarMotor();
  Serial.println(distancia);       // print as an ASCII-encoded decima
  delay(10);
}

float ultrassonic(){
  digitalWrite(trigger, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigger, LOW);
  tempoTotal = pulseIn(echo,HIGH);
  distancia = tempoTotal*0.034/2; // velocidade do som = 340m/s
  return distancia;
}

void controlarMotor(){
  digitalWrite(motor,HIGH);
}

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


Create AM2321Example.ino

Create AM2321Example.ino

/****************************************************************
  This is the Spark Core example of using the library of the
  AM2321 Humidity and Temperature sensor
  This sensor uses custom I2C communication and supports 2 wires
  and one wire configuration.

  This example assumed a 2 wires configuration.

  Written by Ed Wios.
  Oct 2014
 ***************************************************************/

#include "AM2321.h"

#include "application.h"

extern char* itoa(int a, char* buffer, unsigned char radix);

AM2321 am2321;

char str[8];

void setup()
{
    am2321.begin();
    Serial.begin(BAUD);
}

void loop()
{
	float temp, humi;
	unsigned int amID;

	amID = am2321.readID();
	delay(2000);
	temp = am2321.readTemperature();
	delay(2000);
	humi = am2321.readHumidity();

	Serial.print("ID: ");
	Serial.print(amID);
	Serial.print(", Temp: ");
	Serial.print(temp);
	Serial.print(", Humi: ");
	Serial.println(humi);
	delay(2000);
}

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


check list almost finish

check list almost finish

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


sensor

sensor

#include <SFE_BMP180.h>
#include <Wire.h>

unsigned long prevTime;
int tickInterval = 1000 * 5;
unsigned long currentTicks = 0;
String reqId = "";
int errorState = 0;
bool high = false;
bool conf = false;

int redPin = A7;
int yellowPin = A9;
int greenPin = A10;

int tempStatus = 1;
int strike = 0;

// BMP-180 variables
SFE_BMP180 bmp;
double pressureBaseline = 0;
double temp = 0;
double pressure = 0;
double altitude = 0;

String appName = "PlantIT";

bool nextTick(){
  unsigned long currTime = millis();
  if ((currTime - prevTime) > tickInterval){
    prevTime = currTime;
    return true;
  }

  return false;
}

void changeStatus(int s){
  if (s == 2){
    analogWrite(greenPin, 0);
    analogWrite(yellowPin, 255);
  } else if (s == 3){
    analogWrite(yellowPin, 0);
    analogWrite(redPin,255);
  }
}

void resetSerial() {
  Serial1.end();
  Serial1.begin(9600);
}

void buildResponse(String &res) {
  res = res + "#";
  res = res + "@" + temp + "$";
}

double readBMP180Values()
{
  char status;
  status = bmp.startTemperature();

  if (status != 0)
  {
    delay(status);
    status = bmp.getTemperature(temp);

    if (status != 0)
    {
      status = bmp.startPressure(3);

      if (status != 0)
      {
        delay(status);
        status = bmp.getPressure(pressure, temp);

        if (status != 0)
        {
          altitude = bmp.altitude(pressure, pressureBaseline + 5.6);
          return pressure;
        }
        else Serial1.println("error retrieving pressure measurement\n");
      }
      else Serial1.println("error starting pressure measurement\n");
    }
    else Serial1.println("error retrieving temperature measurement\n");
  }
  else Serial1.println("error starting temperature measurement\n");
}

void readValues() {
  readBMP180Values();
}

void setupBMP180() {
  if (!bmp.begin()) {
    Serial1.println("Error");
    while (1);
  }

  pressureBaseline = readBMP180Values();
}

void setup() {
  Serial1.begin(9600);
  Serial.begin(19200);
  setupBMP180();
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);

  analogWrite(greenPin, 255);

  prevTime = millis();

}

void sendResponse(String &res) {
  Serial1.print(res);
}

void checkForOperation() {
  char operation = '0';

  if (Serial1.available()) {
    operation = char(Serial1.read());

    if (operation == 'd'){
      sendData();
    } else if (operation == 'n'){
      sendName();
    } else if (operation == 'c'){
      conf = true;
    } else if (conf){
      reqId = String(operation);
    }
  }
}

void sendName(){
  Serial1.print("#" + appName + "$");
}

void sendData() {
  readValues();
  String res = String("");
  buildResponse(res);
  Serial1.print(res);
}

void loop() {
  if (nextTick()){
    readValues();
   // Serial.println("next tick");
    //Serial.println(errorState);
    if (errorState != 3){
      errorState = checkRequirements();
      changeStatus(errorState);
      //Serial.println(errorState);
    }
  }

  checkForOperation();
}

//########################  Check values ##############################

int above(double value, double threshold){
  if (value > threshold){
    return 3;
  } else if (value > threshold*0.9){
    return 2;
  } else {
    return 1;
  }
}

int isFreeze(double value){
   if (value < 0){
      return 3;
   } else if (value < 2) {
    return 2;
   } else {
    return 1;
   }
}

int combine(int state1, int state2){
  if (state1 == 3 || state2 == 3){
    return 3;
  } else if (state1 == 2 || state2 == 2){
    return 2;
  } else {
    return 1;
  }
}

int complexCheck(double d1, double d2){
  if (!high){
    int res = above(temp, 30);
    if (res == 3){
      high = true;
      return checkRequirements();
    }
    return combine(res, noMore(d1));
  }

  return combine(above(temp, 30), noMore(d2));
}

int noMore(int numberOfTicks){
  if (currentTicks > numberOfTicks){
    return 3;
  } else if (currentTicks > numberOfTicks * 0.9){
    return 2;
  } else {
    return 1;
  }
}

int checkRequirements(){
  if (reqId == "A"){
    return complexCheck(10, 7);
  } else if (reqId == "B"){
    return complexCheck(8, 6);
  } else if (reqId == "C"){
    return complexCheck(14,11);
  } else if (reqId == "D"){
    return above(temp, 34);
  } else if (reqId == "E"){
    return isFreeze(temp);
  } else if (reqId == "F"){
    return above(temp, 8);
  } else if (reqId == "0"){
    return above(temp, 8);
  } else if (reqId == "25"){
     return above(temp, 25);
  } else if (reqId == "0F"){
    return combine(above(temp,8), isFreeze(temp));
  } else if (reqId == "AF"){
    return combine(complexCheck(3,2), isFreeze(temp));
  } else if (reqId == "BF"){
    return combine(complexCheck(8,6), isFreeze(temp));
  } else if (reqId == "CF"){
    return combine(complexCheck(14, 11), isFreeze(temp));
  } else {
    return 0;
  }
}

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


[arduino] Speeds up sending of energy to erpi1.

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/bassjansson/vera.git/'


Added pong

Added pong

// Define pins used by potentiometer knobs
#define paddle_l 22
#define paddle_r 21

// Define pins used by buttons
#define button_l 4
#define button_r 5
#define button_m 6

// Define pins used by SPI to communicate with LCD display
#define cs   10
#define dc   9
#define rst  8  // you can also connect this to the Arduino reset

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

// Initialize the display object with the pins we chose
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);

#define ANALOG_MAX 1024
#define WIDTH 126
#define HEIGHT 158

#define PADDLE_SIZE 30

int player1_pos = 0, player1_score = 0;
int player2_pos = 0, player2_score = 0;

float ball_x, ball_y;
float ball_xdir, ball_ydir;

void draw_paddle(int x, int y, int color) {
  tft.drawFastVLine(x-1, y-PADDLE_SIZE/2+2, PADDLE_SIZE-4, color);
  tft.drawFastVLine(x+0, y-PADDLE_SIZE/2, PADDLE_SIZE, color);
  tft.drawFastVLine(x+1, y-PADDLE_SIZE/2+2, PADDLE_SIZE-4, color);
}

void draw_ball(int x, int y, int color) {
  tft.fillCircle(x, y, 4, color);
}

void draw_score(int player, int value, int color) {
  tft.setTextColor(color);
  if (player == 1)
    tft.setCursor(7, 0);
  if (player == 2)
    tft.setCursor(WIDTH-10, 0);
  tft.print(value);
}

void reset_ball() {
  ball_x = WIDTH/2;
  ball_y = HEIGHT/2;
  ball_xdir = 2.5;
  if(random(2) == 0) ball_xdir *= -1;
  ball_ydir = random(0, 5)/2;
}

void setup(void) {
  randomSeed(analogRead(0));

  pinMode(button_l, INPUT);
  pinMode(button_r, INPUT);
  pinMode(button_m, INPUT);

  tft.initR(INITR_REDTAB);   // alternative: INITR_GREENTAB
  tft.fillScreen(ST7735_BLACK);
  delay(500);

  tft.setTextSize(1);

  reset_ball();
}

void loop() {
  draw_ball(ball_x, ball_y, ST7735_BLACK);
  draw_paddle(4, player1_pos, ST7735_BLACK);
  draw_paddle(WIDTH-4, player2_pos, ST7735_BLACK);

  draw_score(1, player1_score, ST7735_BLACK);
  draw_score(2, player2_score, ST7735_BLACK);

  player1_pos = HEIGHT - (analogRead(paddle_l) * HEIGHT / ANALOG_MAX);
  player2_pos = HEIGHT - (analogRead(paddle_r) * HEIGHT / ANALOG_MAX);

  // If ball goes to top or bottom, just bounce
  if (ball_y < 4 || ball_y > HEIGHT-4) {
    ball_ydir *= -1;
  }

  // If ball hits player 1's paddle, bounce
  if (ball_x > 4 && ball_x < 8 &&
      ball_y > (player1_pos - PADDLE_SIZE/2) &&
      ball_y < (player1_pos + PADDLE_SIZE/2)) {
    ball_xdir *= -1;
    ball_ydir += (ball_y - player1_pos) / PADDLE_SIZE * 2.5;
  }

  // If ball hits player 2's paddle, bounce
  if (ball_x > WIDTH-8 && ball_x < WIDTH-4 &&
      ball_y > (player2_pos - PADDLE_SIZE/2) &&
      ball_y < (player2_pos + PADDLE_SIZE/2)) {
    ball_xdir *= -1;
    ball_ydir += (ball_y - player2_pos) / PADDLE_SIZE * 2.5;
  }

  ball_x += ball_xdir;
  ball_y += ball_ydir;
  // If ball gets behind either player, it's gone
  if (ball_x < 0) {
    player2_score++;
    reset_ball();
  }
  if (ball_x > WIDTH) {
    player1_score++;
    reset_ball();
  }

  draw_ball(ball_x, ball_y, ST7735_BLUE);
  draw_paddle(4, player1_pos, ST7735_WHITE);
  draw_paddle(WIDTH-4, player2_pos, ST7735_WHITE);

  draw_score(1, player1_score, ST7735_RED);
  draw_score(2, player2_score, ST7735_RED);

  delay(30);
}

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


prepare for relay support

prepare for relay support

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/janiversen/SolarPower.git/'


first version

first version

SW-420 is a motion sensor. Soldered on a Grove protoshield, together
with a LED which light on when motion/shock is triggered.

verdiepingslessen/SW-420 Motion Sensor Vibration/MotionSensor-basic/MotionSensor-basic.ino

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


keep reading until u_X_dis reach good range


added arduino nano firmware

added arduino nano firmware

#include <SPI.h>
#include <ros.h>
#include <std_msgs/String.h>
#include <std_msgs/Bool.h>
#include <std_msgs/Float64.h>
#include <std_msgs/Int16.h>
#include <Servo.h>

unsigned long int temp_raw, pres_raw;
signed long int t_fine;

uint16_t dig_T1;
int16_t dig_T2;
int16_t dig_T3;
uint16_t dig_P1;
int16_t dig_P2;
int16_t dig_P3;
int16_t dig_P4;
int16_t dig_P5;
int16_t dig_P6;
int16_t dig_P7;
int16_t dig_P8;
int16_t dig_P9;
int8_t  dig_H1;
int16_t dig_H2;
int8_t  dig_H3;
int16_t dig_H4;
int16_t dig_H5;
int8_t  dig_H6;

ros::NodeHandle nh; //write with IDE
// ros::NodeHandle_<ArduinoHardware, 1, 2, 512, 512> nh;

std_msgs::Float64 float_msg;
std_msgs::Bool bool_msg;

ros::Publisher pressure_pub("vacuum_gripper/limb/right/pressure", &float_msg);
ros::Publisher state_pub("gripper_grabbed/limb/right/state", &bool_msg);

unsigned long  publisher_timer = 0;

Servo myservo;

void servoCb(const std_msgs::Int16& angle_msg)
{
    myservo.write(angle_msg.data);
}

ros::Subscriber<std_msgs::Int16> servo_sub("vacuum_gripper/limb/right/servo", &servoCb);

void setup() {
    init_servo();
    pinMode(SS, OUTPUT);
    digitalWrite(SS, HIGH);
    nh.getHardware()->setBaud(57600);
    nh.initNode();
    nh.subscribe(servo_sub);
    nh.advertise(pressure_pub);
    nh.advertise(state_pub);

    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV8);
    initBME();
    readTrim();
}

void loop() {
    float temp_act = 0.0, press_act = 0.0;
    unsigned long int press_cal, temp_cal;

    if (millis() > publisher_timer) {
        readData();
        temp_cal = calibration_T(temp_raw);
        press_cal = calibration_P(pres_raw);
        temp_act = (float)temp_cal / 100.0;
        press_act = (float)press_cal / 100.0;

        bool_msg.data = (press_act < 900);
        float_msg.data = press_act;

        state_pub.publish(&bool_msg);
        pressure_pub.publish(&float_msg);

        publisher_timer = millis() + 100;
    }
    nh.spinOnce();
}

void init_servo()
{
    myservo.attach(9);
}

void initBME()
{
    digitalWrite(SS, LOW);
    SPI.transfer((0xF5 & 0x7F));
    SPI.transfer(0xA0);
    SPI.transfer((0xF4 & 0x7F));
    SPI.transfer(0x27);
    digitalWrite(SS, HIGH);
}

void readTrim()
{
    uint8_t data[32];
    int i;
    digitalWrite(SS, LOW);
    SPI.transfer((0x88 | 0x80));
    for (i = 0; i < 24; i++) {
        data[i] = SPI.transfer(0);
    }
    digitalWrite(SS, HIGH);
    delay(1);
    digitalWrite(SS, LOW);
    SPI.transfer((0xA1 | 0x80));
    data[24] = SPI.transfer(0);
    digitalWrite(SS, HIGH);
    delay(1);
    digitalWrite(SS, LOW);
    SPI.transfer((0xE1 | 0x80));
    for (i = 25; i < 32; i++) {
        data[i] = SPI.transfer(0);
    }
    digitalWrite(SS, HIGH);

    dig_T1 = (data[1] << 8) | data[0];
    dig_T2 = (data[3] << 8) | data[2];
    dig_T3 = (data[5] << 8) | data[4];
    dig_P1 = (data[7] << 8) | data[6];
    dig_P2 = (data[9] << 8) | data[8];
    dig_P3 = (data[11] << 8) | data[10];
    dig_P4 = (data[13] << 8) | data[12];
    dig_P5 = (data[15] << 8) | data[14];
    dig_P6 = (data[17] << 8) | data[16];
    dig_P7 = (data[19] << 8) | data[18];
    dig_P8 = (data[21] << 8) | data[20];
    dig_P9 = (data[23] << 8) | data[22];
    dig_H1 = data[24];
    dig_H2 = (data[26] << 8) | data[25];
    dig_H3 = data[27];
    dig_H4 = (data[28] << 4) | (0x0F & data[29]);
    dig_H5 = (data[30] << 4) | ((data[29] >> 4) & 0x0F);
    dig_H6 = data[31];
}

void readData()
{
    uint32_t data[8];
    int i;
    digitalWrite(SS, LOW);
    SPI.transfer((0xF7 | 0x80));
    for (i = 0; i < 8; i++) {
        data[i] = SPI.transfer(0x00);
    }
    digitalWrite(SS, HIGH);
    pres_raw = (data[0] << 12) | (data[1] << 4) | (data[2] >> 4);
    temp_raw = (data[3] << 12) | (data[4] << 4) | (data[5] >> 4);
}

signed long int calibration_T(signed long int adc_T)
{

    signed long int var1, var2, T;
    var1 = ((((adc_T >> 3) - ((signed long int)dig_T1 << 1))) * ((signed long int)dig_T2)) >> 11;
    var2 = (((((adc_T >> 4) - ((signed long int)dig_T1)) * ((adc_T >> 4) - ((signed long int)dig_T1))) >> 12) * ((signed long int)dig_T3)) >> 14;

    t_fine = var1 + var2;
    T = (t_fine * 5 + 128) >> 8;
    return T;
}

unsigned long int calibration_P(signed long int adc_P)
{
    signed long int var1, var2;
    unsigned long int P;
    var1 = (((signed long int)t_fine) >> 1) - (signed long int)64000;
    var2 = (((var1 >> 2) * (var1 >> 2)) >> 11) * ((signed long int)dig_P6);
    var2 = var2 + ((var1 * ((signed long int)dig_P5)) << 1);
    var2 = (var2 >> 2) + (((signed long int)dig_P4) << 16);
    var1 = (((dig_P3 * (((var1 >> 2) * (var1 >> 2)) >> 13)) >> 3) + ((((signed long int)dig_P2) * var1) >> 1)) >> 18;
    var1 = ((((32768 + var1)) * ((signed long int)dig_P1)) >> 15);
    if (var1 == 0)
    {
        return 0;
    }
    P = (((unsigned long int)(((signed long int)1048576) - adc_P) - (var2 >> 12))) * 3125;
    if (P < 0x80000000)
    {
        P = (P << 1) / ((unsigned long int) var1);
    }
    else
    {
        P = (P / (unsigned long int)var1) * 2;
    }
    var1 = (((signed long int)dig_P9) * ((signed long int)(((P >> 3) * (P >> 3)) >> 13))) >> 12;
    var2 = (((signed long int)(P >> 2)) * ((signed long int)dig_P8)) >> 13;
    P = (unsigned long int)((signed long int)P + ((var1 + var2 + dig_P7) >> 4));
    return P;
}

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


Move WiFi connect debug messages

Move WiFi connect debug messages

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


Added the code for the compass.ino and accelerometer.ino files.

We still will need to ensure that we can integrate these systems.

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


added rtc example.

added rtc example.

error: pathspec 'arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10.' did not match any file(s) known to git
error: pathspec 'Etc/rtc_time/rtc_time.ino' did not match any file(s) known to git


Add ShowInfo script from internet that shows timings

// -----------------------------------------------------
// Arduino ShowInfo
// Show what the Arduino has to tell you.
//
// 10 April 2012: Extra speed tests,
//                and a few other additions.
// 17 April 2012: The name 'ADCW' is preferred over 'ADC'.
// 23 April 2012: Changed PB5 into PORTB5.
// 1 July 2012  : Added i2c_scanner.
//                More speed tests.
// 21 July 2012 : Added divide speed tests.
// 25 July 2012 : Added sketchSize.
// 26 July 2012 : Changed sketchSize for more than 64kB.
//                Also show sketchSize in percentage.
//                Added processor defines.
//                Arduino Mega compatible (not tested).
// 5 November 2014 : Tested on Arduino Mega 2560
//                Added Arduino version "ARDUINO".
//                Replaced "double" with "float".
//                The i2c scanner scans now 1 up to 126,
//                  it was 0 up to 127.
//                Added UTF-8 test.
//                The delayMicroseconds(1) replaced by
//                  2 micro seconds. I think one micro second
//                  was not called.
//                The analogReference() timing removed,
//                  I think it was not called.
// 4 December 2014 : Delay to allow the Serial.print to be printed.
//                More floating point and 32-bit integer tests.
//                Tested with Arduino 1.0.6 and Leonardo and Uno.
// -----------------------------------------------------

#include <avr/boot.h>
#include <Wire.h>

void setup()
{
  // The system led is present on most Arduino boards.
  pinMode(13,OUTPUT);

  Serial.begin(9600);

#if defined (__AVR_ATmega32U4__)
  while(!Serial);        // For Leonardo, wait for serial port
#endif

  Serial.println(F("Arduino ShowInfo"));
  Serial.println(F("Show what the Arduino has to tell you."));

  ShowMenu();
}

void loop()
{
  int incomingByte, i, n;

  if (Serial.available() > 0)
  {
    incomingByte = Serial.read();

    switch (incomingByte)
    {
#if !defined (__AVR_ATmega32U4__)
      case '0':
        Serial.println(F("System LED off"));
        digitalWrite(13,LOW);
        Serial.println(F("-----------"));
        break;
      case '1':
        Serial.println(F("System LED on"));
        digitalWrite(13,HIGH);
        Serial.println(F("-----------"));
        break;
      case '2':
        i2c_scanner();
        break;
#endif
      case 'i':
        Information();
        break;
      case 'r':
        Serial.println(F("Test serial communcation"));
        Serial.println(F("Will your terminal program send characters immediately?"));
        Serial.println(F("Enter characters, followed by Enter"));
        for (i=0; i<25; i++)
        {
          Serial.print(F("Serial.available() = "));
          n = Serial.available();
          Serial.print(n,DEC);
          Serial.print(F("    Serial.peek() = "));
          n = Serial.peek();
          Serial.println(n,DEC);
          delay(500);
        }
        // empty the buffer of incoming data
        while (Serial.available() > 0)
          Serial.read();
        Serial.println(F("-----------"));
        break;
      case 's':
        SpeedTest();
        break;
#if !defined (__AVR_ATmega32U4__)
      case 't':
        TimerRegisterDump();
        break;
#endif
      case 'h':
      case '?':
        ShowMenu();
        break;
      // Ignore some characters, like the carriage return and line feed.
      case '\'':
      case '\r':
      case '\n':
        break;
      default:
        Serial.print(F("Unknown command: 0x"));
        Serial.println(incomingByte,HEX);
        Serial.println(F("Type '?' followed by Enter"));
        // Something could be wrong, delete incoming data in buffer
        while (Serial.available() > 0)
          Serial.read();
        Serial.println(F("-----------"));
        break;
    }
  }
}

void ShowMenu(void)
{
  Serial.println(F(""));
  Serial.println(F("Menu"));
  Serial.println(F("-----------"));
#if !defined (__AVR_ATmega32U4__)
  Serial.println(F("0 = System LED off"));
  Serial.println(F("1 = System LED on"));
  Serial.println(F("2 = i2c_scanner"));
#endif
  Serial.println(F("i = Show information"));
  Serial.println(F("h = Show menu"));
  Serial.println(F("r = Test serial communication"));
  Serial.println(F("s = Speed tests"));
#if !defined (__AVR_ATmega32U4__)
  Serial.println(F("t = Timer Register Dump"));
#endif
  Serial.println(F("? = Show menu"));
  Serial.println(F(""));
  Serial.println(F("Type command, followed by Enter"));
}

float GetTemp(void)
{
  unsigned int wADC;
  float t;

  // The internal temperature has to be used
  // with the internal reference of 1.1V.
  // Channel 8 can not be selected with
  // the analogRead function yet.

  // This code is not valid for the Arduino Mega,
  // and the Arduino Mega 2560.

#ifdef THIS_MIGHT_BE_VALID_IN_THE_FUTURE
  analogReference (INTERNAL);
  delay(20);            // wait for voltages to become stable.
  wADC = analogRead(8); // Channel 8 is temperature sensor.
#else
  // Set the internal reference and mux.
  ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
  ADCSRA |= _BV(ADEN);  // enable the ADC

  delay(20);            // wait for voltages to become stable.

  ADCSRA |= _BV(ADSC);  // Start the ADC

  // Detect end-of-conversion
  while (bit_is_set(ADCSRA,ADSC));

  // Reading register "ADCW" takes care of how to read ADCL and ADCH.
#if defined (__AVR_ATmega32U4__)
  wADC = ADC;      // For Arduino Leonardo
#else
  wADC = ADCW;     // 'ADCW' is preferred over 'ADC'
#endif
#endif

  // The offset of 337.0 could be wrong. It is just an indication.
  t = (wADC - 337.0 ) / 1.22;

  return (t);
}

// Helper function for free ram.
//   With use of http://playground.arduino.cc/Code/AvailableMemory
//
int freeRam(void)
{
  extern unsigned int __heap_start;
  extern void *__brkval;

  int free_memory;
  int stack_here;

  if (__brkval == 0)
    free_memory = (int) &stack_here - (int) &__heap_start;
  else
    free_memory = (int) &stack_here - (int) __brkval;

  return (free_memory);
}

// Helper function for sketch size.
// The sketch size is runtime calculated.
// From user "Coding Badly" in his post:
//   http://arduino.cc/forum/index.php/topic,115870.msg872309.html#msg872309
// Changed into unsigned long for code size larger than 64kB.
//
// This function returns the sketch size
// for a size between 0 and 32k. If the code
// size is larger (for example with an Arduino Mega),
// the return value is not valid.
//
unsigned long sketchSize(void)
{
  extern int _etext;
  extern int _edata;

  return ((unsigned long)(&_etext) + ((unsigned long)(&_edata) - 256L));
}

void Information(void)
{
  int i,j;
  int data1,data2,data3,data4;
  unsigned long ul;
  float percentage;

  Serial.println(F(""));
#if !defined (__AVR_ATmega32U4__)
  Serial.println(F("Information"));
  Serial.println(F("-----------"));

  Serial.print(F("sketch Size = "));
  ul = sketchSize();
  Serial.print(ul,DEC);
  Serial.print(F(" ("));
  percentage = (float) ul / ((float) FLASHEND + 1.0) * 100.0;
  Serial.print(percentage,0);
  Serial.println(F("%)"));

  Serial.print(F("free RAM    = "));
  i = freeRam();
  Serial.println(i,DEC);
  Serial.print(F("RAM used    = "));
  j = (RAMEND + 1) - i;
  Serial.print(j, DEC);
  Serial.print(F(" ("));
  percentage = (float) j / ((float) RAMEND + 1.0) * 100.0;
  Serial.print(percentage,0);
  Serial.println(F("%)"));
#endif

  Serial.print(F("ARDUINO = "));
  Serial.print(ARDUINO);
  Serial.print(F(" (Arduino version "));
  Serial.print( (float) ARDUINO / 100.0, 2);
  Serial.println(F(")"));

  Serial.print(F("__VERSION__ = "));
  Serial.println(F(__VERSION__));

  Serial.print(F("__DATE__    = "));
  Serial.println(F(__DATE__));

  Serial.print(F("__TIME__    = "));
  Serial.println(F(__TIME__));

  Serial.print(F("__AVR_LIBC_VERSION_STRING__ = "));
  Serial.println(F(__AVR_LIBC_VERSION_STRING__));

  Serial.print(F("__FILE__    = "));
  Serial.println(F(__FILE__));

  Serial.print(F("__STDC__    = "));
  Serial.println(__STDC__,DEC);

#if !defined (__AVR_ATmega32U4__)
  Serial.print(F("OSCCAL = "));
  Serial.println(OSCCAL,DEC);

  Serial.print(F("GPIOR0 = 0x"));
  Serial.println(GPIOR0,HEX);

  Serial.print(F("GPIOR1 = 0x"));
  Serial.println(GPIOR1,HEX);

  Serial.print(F("GPIOR1 = 0x"));
  Serial.println(GPIOR1,HEX);
#endif

  Serial.print(F("RAMEND   = 0x"));
  Serial.println(RAMEND,HEX);

  Serial.print(F("XRAMEND  = 0x"));
  Serial.println(XRAMEND,HEX);

  Serial.print(F("E2END    = 0x"));
  Serial.println(E2END,HEX);

  Serial.print(F("FLASHEND = 0x"));
  Serial.println(FLASHEND,HEX);

  cli();
  data1 = boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS);
  data2 = boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS);
  data3 = boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS);
  data4 = boot_lock_fuse_bits_get(GET_LOCK_BITS);
  sei();

  Serial.print(F("LOW FUSE      = 0x"));
  Serial.println(data1,HEX);

  Serial.print(F("HIGH FUSE     = 0x"));
  Serial.println(data2,HEX);

  Serial.print(F("EXTENDED FUSE = 0x"));
  Serial.println(data3,HEX);

  Serial.print(F("LOCK BITS     = 0x"));
  Serial.println(data4,HEX);

  Serial.print(F("Processor according to compiler = "));
#if defined (__AVR_ATtiny45__)
  Serial.println(F("__AVR_ATtiny45__"));
#elif defined (__AVR_ATtiny85__)
  Serial.println(F("__AVR_ATtiny85__"));
#elif defined (__AVR_ATtiny2313__)
  Serial.println(F("__AVR_ATtiny2313__"));
#elif defined (__AVR_ATtiny2313A__)
  Serial.println(F("__AVR_ATtiny2313A__"));
#elif defined (__AVR_ATmega48__)
  Serial.println(F("__AVR_ATmega48__"));
#elif defined (__AVR_ATmega48A__)
  Serial.println(F("__AVR_ATmega48A__"));
#elif defined (__AVR_ATmega48P__)
  Serial.println(F("__AVR_ATmega48P__"));
#elif defined (__AVR_ATmega8__)
  Serial.println(F("__AVR_ATmega8__"));
#elif defined (__AVR_ATmega8U2__)
  Serial.println(F("__AVR_ATmega8U2__"));
#elif defined (__AVR_ATmega88__)
  Serial.println(F("__AVR_ATmega88__"));
#elif defined (__AVR_ATmega88A__)
  Serial.println(F("__AVR_ATmega88A__"));
#elif defined (__AVR_ATmega88P__)
  Serial.println(F("__AVR_ATmega88P__"));
#elif defined (__AVR_ATmega88PA__)
  Serial.println(F("__AVR_ATmega88PA__"));
#elif defined (__AVR_ATmega16__)
  Serial.println(F("__AVR_ATmega16__"));
#elif defined (__AVR_ATmega168__)
  Serial.println(F("__AVR_ATmega168__"));
#elif defined (__AVR_ATmega168A__)
  Serial.println(F("__AVR_ATmega168A__"));
#elif defined (__AVR_ATmega168P__)
  Serial.println(F("__AVR_ATmega168P__"));
#elif defined (__AVR_ATmega32__)
  Serial.println(F("__AVR_ATmega32__"));
#elif defined (__AVR_ATmega328__)
  Serial.println(F("__AVR_ATmega328__"));
#elif defined (__AVR_ATmega328P__)
  Serial.println(F("__AVR_ATmega328P__"));
#elif defined (__AVR_ATmega32U2__)
  Serial.println(F("__AVR_ATmega32U2__"));
#elif defined (__AVR_ATmega32U4__)
  Serial.println(F("__AVR_ATmega32U4__"));
#elif defined (__AVR_ATmega32U6__)
  Serial.println(F("__AVR_ATmega32U6__"));
#elif defined (__AVR_ATmega128__)
  Serial.println(F("__AVR_ATmega128__"));
#elif defined (__AVR_ATmega1280__)
  Serial.println(F("__AVR_ATmega1280__"));
#elif defined (__AVR_ATmega2560__)
  Serial.println(F("__AVR_ATmega2560__"));
#endif

#ifdef SIGRD
  Serial.print(F("SIGRD = "));
  Serial.println(SIGRD,DEC);
#else
  Serial.println(F("SIGRD : not defined (let's make it 5 and see what happens)."));
#define SIGRD 5
#endif

  Serial.print(F("Signature = 0x"));

  data1 = boot_signature_byte_get(0x00);
  data2 = boot_signature_byte_get(0x02);
  data3 = boot_signature_byte_get(0x04);
  data4 = boot_signature_byte_get(0x01);

  Serial.print(data1,HEX);
  Serial.print(F(", 0x"));
  Serial.print(data2,HEX);
  Serial.print(F(", 0x"));
  Serial.println(data3,HEX);

  Serial.print(F("calibration = "));
  Serial.println(data3,DEC);

#if !defined (__AVR_ATmega32U4__)
  Serial.print(F("Number of seconds since start = "));
  Serial.println(millis()/1000L,DEC);
#endif

#if defined (__AVR_ATmega328P__)
  Serial.print(F("Internal Temperature = "));
  Serial.print(GetTemp(),1);
  Serial.println(F(" Celsius   (the offset could be wrong)."));
#endif

  Serial.println(F("UTF-8 test:"));
  Serial.println(F("    Micro µ µ µ µ µ µ µ µ µ µ"));
  Serial.println(F("    Euro  € € € € € € € € € €"));
  Serial.println(F("    (c)   © © © © © © © © © ©"));

  Serial.println(F("-----------"));
}

#if !defined (__AVR_ATmega32U4__)
void TimerRegisterDump(void)
{
  Serial.println(F("Timer Register dump:"));
  Serial.print(F("TIMER0 TCCR0A = 0x")); Serial.println(TCCR0A,HEX);
  Serial.print(F("TIMER0 TCCR0B = 0x")); Serial.println(TCCR0B,HEX);
  Serial.print(F("TIMER0 OCR0A  = 0x")); Serial.println(OCR0A,HEX);
  Serial.print(F("TIMER0 OCR0B  = 0x")); Serial.println(OCR0B,HEX);
  Serial.print(F("TIMER0 TIMSK0 = 0x")); Serial.println(TIMSK0,HEX);
  Serial.print(F("TIMER0 TCNT0  = 0x")); Serial.println(TCNT0,HEX);
  Serial.print(F("TIMER0 TIFR0  = 0x")); Serial.println(TIFR0,HEX);

  Serial.print(F("TIMER1 TCCR1A = 0x")); Serial.println(TCCR1A,HEX);
  Serial.print(F("TIMER1 TCCR1B = 0x")); Serial.println(TCCR1B,HEX);
  Serial.print(F("TIMER1 TCCR1C = 0x")); Serial.println(TCCR1C,HEX);
  Serial.print(F("TIMER1 OCR1A  = 0x")); Serial.println(OCR1A,HEX);
  Serial.print(F("TIMER1 OCR1B  = 0x")); Serial.println(OCR1B,HEX);
  Serial.print(F("TIMER1 TIMSK1 = 0x")); Serial.println(TIMSK1,HEX);
  Serial.print(F("TIMER1 TCNT1  = 0x")); Serial.println(TCNT1,HEX);
  Serial.print(F("TIMER1 ICR1   = 0x")); Serial.println(ICR1,HEX);
  Serial.print(F("TIMER1 TIFR1  = 0x")); Serial.println(TIFR1,HEX);

  Serial.print(F("TIMER2 TCCR2A = 0x")); Serial.println(TCCR2A,HEX);
  Serial.print(F("TIMER2 TCCR2B = 0x")); Serial.println(TCCR2B,HEX);
  Serial.print(F("TIMER2 OCR2A  = 0x")); Serial.println(OCR2A,HEX);
  Serial.print(F("TIMER2 OCR2B  = 0x")); Serial.println(OCR2B,HEX);
  Serial.print(F("TIMER2 TIMSK2 = 0x")); Serial.println(TIMSK2,HEX);
  Serial.print(F("TIMER2 TCNT2  = 0x")); Serial.println(TCNT2,HEX);
  Serial.print(F("TIMER2 TIFR2  = 0x")); Serial.println(TIFR2,HEX);
  Serial.print(F("TIMER2 ASSR   = 0x")); Serial.println(ASSR,HEX);
  Serial.print(F("TIMERn GTCCR  = 0x")); Serial.println(GTCCR,HEX);

  Serial.println(F("-----------"));
}
#endif

#if !defined (__AVR_ATmega32U4__)
void i2c_scanner(void)
{
  byte error, address;
  int nDevices;

  Serial.println(F(""));
  Serial.println(F("i2c_scanner"));
  Serial.println(F("Scanning..."));

  Wire.begin();

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print(F("I2C device found at address 0x"));
      if (address<16)
        Serial.print(F("0"));
      Serial.print(address,HEX);
      Serial.println(F(" !"));

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print(F("Unknow error at address 0x"));
      if (address<16)
        Serial.print(F("0"));
      Serial.println(address,HEX);
    }
  }
  if (nDevices == 0)
    Serial.println(F("No I2C devices found."));
  else
    Serial.println(F("Done."));

  Serial.println(F("-----------"));
}
#endif

void SpeedTest(void)
{
  register int i,j;
  volatile unsigned char c1,c2;
  volatile int v;
  volatile long l1,l2;
  volatile float f1,f2;
  int p,q,r;
  unsigned long m,n;
  float d, overhead;
  char buffer[30];

  Serial.println(F(""));
  Serial.println(F("Speed test"));
  Serial.println(F("----------"));

  Serial.print(F("F_CPU = "));
  Serial.print(F_CPU,DEC);
  Serial.println(F(" Hz"));
  Serial.print(F("1/F_CPU = "));
  Serial.print((1000000.0/(float)F_CPU),4);
  Serial.println(F(" us"));

#if !defined (__AVR_ATmega32U4__)
  Serial.println(F("The next tests are runtime compensated for overhead"));
  Serial.println(F("Interrupts are still enabled, because millis() is used for timing"));
#endif
  delay(800);    // Allow the Serial text to be transmitted

  Serial.print(F("  nop                       : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<100; i++)
  {
    for (j=0; j<10000; j++)
    {
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
      asm volatile ("nop");
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;           // in micro seconds
  // Calculate overhead with 'nop' instruction per loop in microseconds
  overhead = d - (20.0 * (1000000.0/(float)F_CPU));
  d -= overhead;
  d /= 20.0;             // per instruction
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  avr gcc I/O               : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<50; i++)
  {
    for (j=0; j<10000; j++)
    {
      // Use system led
      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);

      PORTB |= _BV(PORTB5);
      PORTB &= ~_BV(PORTB5);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  Arduino digitalRead       : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<10000; j++)
    {
      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);

      digitalRead(13);
      digitalRead(13);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  Arduino digitalWrite      : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<10000; j++)
    {
      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);

      digitalWrite(13, HIGH);
      digitalWrite(13, LOW);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  pinMode                   : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<10000; j++)
    {
      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);

      pinMode(13, INPUT);
      pinMode(13, OUTPUT);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  multiply byte             : "));
  c1 = 2;
  c2 = 3;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<20; i++)
  {
    for (j=0; j<10000; j++)
    {
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
      c1 *= c2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  divide byte               : "));
  c1 = 253;
  c2 = 3;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<10000; j++)
    {
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
      c1 /= c2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  add byte                  : "));
  c1 = 1;
  c2 = 2;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<20; i++)
  {
    for (j=0; j<10000; j++)
    {
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
      c1 += c2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  multiply integer          : "));
  volatile int x,y;
  x = 2;
  y = 3;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<10; i++)
  {
    for (j=0; j<10000; j++)
    {
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
      x *= y;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  divide integer            : "));
  x = 31415;
  y = 3;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<10000; j++)
    {
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
      x /= y;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  add integer               : "));
  x = 1;
  y = 3;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<10; i++)
  {
    for (j=0; j<10000; j++)
    {
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
      x += y;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  multiply long             : "));
  l1 = 2;
  l2 = 3;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<10000; j++)
    {
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
      l1 *= l2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  divide long               : "));
  l1 = 2000000000L;
  l2 = 3;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<2000; j++)
    {
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
      l1 /= l2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  add long                  : "));
  l1 = 500000000L;
  l2 = 123;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<4; i++)
  {
    for (j=0; j<10000; j++)
    {
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
      l1 += l2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  multiply float            : "));
  f1 = 3.24;
  f2 = 1.25;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<10000; j++)
    {
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
      f1 *= f2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  divide float              : "));
  f1 = 312645.24;
  f2 = 1.21;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<2000; j++)
    {
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
      f1 /= f2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  add float                 : "));
  f1 = 9876.54;
  f2 = 1.23;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<10000; j++)
    {
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
      f1 += f2;
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  itoa()                    : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<10000; j++)
    {
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
      itoa(i,buffer,10);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  long int l = 314159L;
  Serial.print(F("  ltoa()                    : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<500; j++)
    {
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
      ltoa(l,buffer,10);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  dtostrf()                 : "));
  float d3;
  d3 = 3.14159265;
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<1000; j++)
    {
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
      dtostrf (d3, 6, 2, buffer);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  random()                  : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<2; i++)
  {
    for (j=0; j<1000; j++)
    {
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
      r=random();
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  y |= (1<<x)               : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<20; i++)
  {
    for (j=0; j<10000; j++)
    {
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
      v |= _BV(12);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  bitSet()                  : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<20; i++)
  {
    for (j=0; j<10000; j++)
    {
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
      bitSet (v, 12);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

// #define ENABLE_ANALOGREFERENCE_TIMING
#ifdef ENABLE_ANALOGREFERENCE_TIMING
  Serial.print(F("  analogReference()         : "));
#if defined (__AVR_ATmega1280__) || defined (__AVR_ATmega2560__)
  #define _NOT_DEFAULT_ INTERNAL1V1
#else
  #define _NOT_DEFAULT_ INTERNAL
#endif
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<20; i++)
  {
    for (j=0; j<10000; j++)
    {
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
      analogReference (_NOT_DEFAULT_);
      analogReference (DEFAULT);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));
#endif

  Serial.print(F("  analogRead()              : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<1000; j++)
    {
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
      analogRead (0);
      analogRead (1);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  analogWrite() PWM         : "));
  // Using pin 13 (system led) for output.
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<10000; j++)
    {
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
      analogWrite (13, 100);
      analogWrite (13, 200);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  delay(1)                  : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<100; j++)
    {
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
      delay(1);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  delay(100)                : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<2; j++)
    {
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
      delay(100);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  delayMicroseconds(2)      : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<20; i++)
  {
    for (j=0; j<10000; j++)
    {
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
      delayMicroseconds(2);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  delayMicroseconds(5)      : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<5; i++)
  {
    for (j=0; j<10000; j++)
    {
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
      delayMicroseconds(5);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.print(F("  delayMicroseconds(100)    : "));
  delay(70);     // Allow the Serial text to be transmitted
  m=millis();
  for (i=0; i<1; i++)
  {
    for (j=0; j<1000; j++)
    {
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
      delayMicroseconds(100);
    }
  }
  n=millis();
  d = ((float)n - (float)m) / ((float)i * (float)j);
  d *= 1000.0;
  d -= overhead;
  d /= 20.0;
  Serial.print (d,3);
  Serial.println (F(" us"));

  Serial.println(F("-----------"));
}

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


updated to send the full reading

updated to send the full reading

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/relayr/Arduino-Bridge-Library.git/'


added utils

added utils

// test LCD screen dimensions with 2 pots connected on A0 and A1 (x, y)

#include <UTFT.h>
#define DEBUG 0

int x, y;

UTFT lcd(CTE32HR,38,39,40,41);

void setup(){
  lcd.InitLCD();
  if(DEBUG)Serial.begin(9600);
  lcd.fillScr(VGA_BLACK);
}

void loop(){
  x = analogRead(A0);
  y = analogRead(A1);

  if(DEBUG){
    Serial.print("x: ");
    Serial.print(x);
    Serial.print(" | y: ");
    Serial.println(y);
  }

//  lcd.fillScr(VGA_BLACK);
  //lcd.clrScr();
  lcd.setColor(VGA_GREEN);
  lcd.fillRect(0, 0, x, y);

  delay(50);
}

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


code

code

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/Wind31/code2things.git/'


Fix bug in ground speed calculation

Fix bug in ground speed calculation

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/UgCS/sagetech-ardu.git/'


Asservissement: rectification pins

Asservissement: rectification pins

Module Moteur/Software/Asservissement/Asservissement vitesse/Asservissement vitesse/asservissementVitesse.ino

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


Added copy-paste implementation for Pro Micro board (untested)

#include "HID-Project.h"
#include "MouseKeyboardDataTypes.h"

#define Y_AXIS_PIN A0
#define X_AXIS_PIN A1
#define BUTTON_PIN A2

#define JOYSTICK_JITTER 1
#define XY_RANGE 5

boolean buttonPressed = false;
uint8_t keyPressed = 0;

int8_t x_zero = 0;
int8_t y_zero = 0;
InputData prev_input = {0};
InputData input = {0};

typedef void (*ProcessInput)(InputData const &);

// Return false if all zeros in current and prev
boolean should_report_input(InputData const & current, InputData const & prev) {
  return (current.x + current.y + current.btn + current.key + prev.x + prev.y + prev.btn + prev.key);
}

void copy_input(InputData const & src, InputData & dst) {
  dst.x = src.x;
  dst.y = src.y;
  dst.btn = src.btn;
  dst.key = src.key;
}

void calibrate_joystick() {
  // Read the zero position of the joystick on startup for calibration
  // Fingers crosses that it's not moved at this time
  x_zero = map(analogRead(X_AXIS_PIN), 0, 1 << 10, -XY_RANGE, XY_RANGE);
  y_zero = map(analogRead(Y_AXIS_PIN), 0, 1 << 10, XY_RANGE, -XY_RANGE);
}

void read_input(InputData & input) {
  input.x = map(analogRead(X_AXIS_PIN), 0, 1 << 10, -XY_RANGE, XY_RANGE) - x_zero;
  input.y = map(analogRead(Y_AXIS_PIN), 0, 1 << 10, XY_RANGE, -XY_RANGE) - y_zero;

  // Zero x and/or y if below the jitter threshold
  if (abs(input.x) <= JOYSTICK_JITTER) {
    input.x = 0;
  }
  if (abs(input.y) <= JOYSTICK_JITTER) {
    input.y = 0;
  }

  input.btn = !digitalRead(BUTTON_PIN);
  // TODO: read actual keys when connected
  input.key = 0;
}

void handle_input(InputData const & input, InputData & prev_input, ProcessInput process) {
  if (should_report_input(input, prev_input)) {
    copy_input(input, prev_input);
    process(input);
  }
}

void on_button_released() {
  Keyboard.write(KEY_S);
  Keyboard.write(KEY_P);
  Keyboard.write(KEY_R);
  Keyboard.write(KEY_E);
  Keyboard.write(KEY_S);
  Keyboard.write(KEY_S);
  Keyboard.write(KEY_SPACE);
  Keyboard.write(KEY_P);
  Keyboard.write(KEY_U);
  Keyboard.write(KEY_L);
  Keyboard.write(KEY_L);
  Keyboard.write(KEY_ENTER);
}

void on_key_pressed(const uint8_t key) {
    // TODO: handle keys
}

void send_usb_input_reports(InputData const & input_) {
    // Release the mouse button if the joystick is released
    if (input_.x == 0 && input_.y == 0) {
      if (Mouse.isPressed(MOUSE_MIDDLE)) {
        Mouse.release(MOUSE_MIDDLE);
        //Serial.println(F("Middle mouse released"));
      }
    } else {
      // Press the middle mouse button if it's not allready
      if (!Mouse.isPressed(MOUSE_MIDDLE)) {
        Mouse.press(MOUSE_MIDDLE);
        //Serial.println(F("Middle mouse pressed"));
      }
      Mouse.move(input_.x, input_.y);
    }

    if (input_.btn) {
      buttonPressed = true;
    } else {
      if (buttonPressed) {
        on_button_released();
        buttonPressed = false;
      }
    }

    if (input_.key) {
      keyPressed = input_.key;
    } else {
      if (keyPressed) {
        on_key_pressed(input_.key);
        keyPressed = 0;
      }
    }
}

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  calibrate_joystick();

  // Sends a clean report to the host. This is important on any Arduino type.
  Keyboard.begin();
  Mouse.begin();
}

void loop() {
  read_input(input);
  handle_input(input, prev_input, send_usb_input_reports);
  delay(5);
}

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