Fix a bad slowdown when browsing missing methods due to missing changes file. Thanks Hernán for the report.

'From Cuis 5.0 of 7 November 2016 [latest update: #3345] on 14 June 2018 at 2:11:19 pm'!

!CompiledMethod methodsFor: 'source code management' stamp: 'jmv 6/14/2018 14:06:32'!
getPreambleFrom: aFileStream at: position
	|  writeStream c p |
	writeStream _ String new writeStream.
	p _ position.
	c _ nil.
	aFileStream position: p.
	aFileStream atEnd ifTrue: [ ^ nil ].
	[ p >= 0 and: [ c ~~ $!! ]] whileTrue: [
		aFileStream position: p.
		c _ aFileStream basicNext.
		p _ p - 1 ].
	[ p >= 0] whileTrue: [
		aFileStream position: p.
		c _ aFileStream basicNext.
		c == $!!
			ifTrue: [^ writeStream contents reverse ]
			ifFalse: [ writeStream nextPut: c ].
		p _ p - 1 ].
	^ nil! !

!RemoteString methodsFor: 'accessing' stamp: 'jmv 6/14/2018 14:11:09'!
string
	"Answer the receiver's string if remote files are enabled."
	| theFile answer |
	(sourceFileNumber == nil or: [(SourceFiles at: sourceFileNumber) == nil]) ifTrue: [^nil].
	theFile _ SourceFiles at: sourceFileNumber.
	theFile position: filePositionHi.
	answer _ theFile nextChunk.
	^answer isEmpty ifTrue: [nil] ifFalse: [answer]! !


Add back AutoComplete wraparound. Apologies, Phil.

'From Cuis 5.0 of 7 November 2016 [latest update: #3153] on 25 August 2017 at 1:01:32 pm'!

!AutoCompleterMorph methodsFor: 'actions' stamp: 'jmv 8/25/2017 13:00:40'!
goDown
	self selected = completer entryCount ifTrue: [
		"Wrap around"
		^ self goHome ].
	self selected: self selected + 1.
	(self selected > self lastVisible
			and: [self selected <= completer entryCount])
		ifTrue: [firstVisible := firstVisible + 1].
	self redrawNeeded! !

!AutoCompleterMorph methodsFor: 'actions' stamp: 'jmv 8/25/2017 13:00:48'!
goUp
	(self selected = 0
			and: [self firstVisible = 1])
		ifTrue: [^ self].
	self selected = 1 ifTrue: [
		"Wrap around"
		^self goToEnd ].
	self selected: self selected - 1.
	self selected < self firstVisible
		ifTrue: [firstVisible := firstVisible - 1].
	self redrawNeeded! !


const int BUFFER_SIZE = 4;
int m_buffer[BUFFER_SIZE];
int m_bufIndex = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int val = readValue();
  //Serial.print("Voltage");
  //Serial.print("\t");
  Serial.println(val);
  delay(5);

  //we're interested in events that happen roughly within 15-20 ms

}

int readValue() {
  m_buffer[m_bufIndex] = analogRead(A0);
  m_bufIndex = (m_bufIndex + 1) % BUFFER_SIZE;
  //test if median is better than avg
  int sum = 0;
  for (int n = 0; n < BUFFER_SIZE; ++n) {
    sum += m_buffer[n];
  }
  return sum / BUFFER_SIZE;
}

Use interrupt for timing the sample read

const int BUFFER_SIZE = 8;
int m_buffer[BUFFER_SIZE];
int m_bufIndex = 0;

unsigned long m_timer = 0;
int m_counter = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  m_timer = millis();

  // Timer0 is already used for millis() - we'll just interrupt somewhere
  // in the middle and call the "Compare A" function below
  OCR0A = 0xAF;
  TIMSK0 |= _BV(OCIE0A);
}

// Interrupt is called once a millisecond (Timer0 frequency)
SIGNAL(TIMER0_COMPA_vect)
{
  int val = readValue();
  //we're interested in events that happen roughly within 15-20 ms
  if (m_counter++ >= 4) {
      Serial.println(val);
      m_counter = 0;
  }
}

void loop() {
}

int readSample() {
  int value = m_buffer[m_bufIndex] = analogRead(A0);
  m_bufIndex = (m_bufIndex + 1) % BUFFER_SIZE;
  return value;
}

int readValue() {
  int value = readSample();
  //TODO: test if median is better than avg
  int sum = 0;
  for (int n = 0; n < BUFFER_SIZE; ++n) {
    sum += m_buffer[n];
  }
  return sum / BUFFER_SIZE;
}


// Interduino is the physical manifestation of cigtee - an arduino sketch designed to take serial commands to make stuff happen IRL

void setup()
{
	Serial.begin(9600);
	pinMode(13, OUTPUT);

}

int pinState[6];

void loop()
{
	if(Serial.available()){
		int ledState = Serial.read();
		if(ledState == 65){
			digitalWrite(13, HIGH);
		}
		if(ledState == 90){
			digitalWrite(13, LOW);
		}
	delay(2000);
	}
}

Change logic for serial commands

// Interduino is the physical manifestation of cigtee - an arduino sketch designed to take serial commands to make stuff happen IRL

void setup()
{
	Serial.begin(9600);
	pinMode(13, OUTPUT);

}

int pinState[6];

void loop()
{
	if(Serial.available()){
		int ledState = Serial.read();
		if(ledState == 65){
			digitalWrite(13, HIGH);
		}
//		if(ledState == 90){
//			digitalWrite(13, LOW);
//		}
	delay(2000);
	digitalWrite(13, LOW);
	}
}


#include <WaveHC.h>
#include <WaveUtil.h>

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the volumes root directory
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

void setupSdReader(SdReader &card) {
  if (!card.init()) Serial.println("Card init failed");
  card.partialBlockRead(true); // Optimization. Disable if having issues
}

void setupFatVolume(FatVolume &vol) {
  uint8_t slot;
  // There are 5 slots to look at.
  for (slot = 0; slot < 5; slot++)
    if (vol.init(card, slot)) break;
  if (slot == 5) Serial.println("No valid FAT partition");
}

void setupFatReader(FatReader &root) {
  if (!root.openRoot(vol)) Serial.println("Can't open root dir");
}

void setup() {
  Serial.begin(9600);
  setupSdReader(card);
  setupFatVolume(vol);
  setupFatReader(root);
}

void loop() {

}

Test out some wave files

#include <WaveHC.h>
#include <WaveUtil.h>

String fileNames[4] = {"BUGS2.WAV", "DAFFY1.WAV", "BUGS1.WAV", "DAFFY2.WAV"};

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the volumes root directory
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

void setupSdReader(SdReader &card) {
  if (!card.init()) Serial.println("Card init failed");
  card.partialBlockRead(true); // Optimization. Disable if having issues
}

void setupFatVolume(FatVolume &vol) {
  uint8_t slot;
  // There are 5 slots to look at.
  for (slot = 0; slot < 5; slot++)
    if (vol.init(card, slot)) break;
  if (slot == 5) Serial.println("No valid FAT partition");
}

void setupFatReader(FatReader &root) {
  if (!root.openRoot(vol)) Serial.println("Can't open root dir");
}

void setup() {
  Serial.begin(9600);
  setupSdReader(card);
  setupFatVolume(vol);
  setupFatReader(root);
}

void loop() {
  root.rewind();
  FatReader file;

  for (int i = 0; i < 4; i++) {
    char fileName[fileNames[i].length() + 1];
    fileNames[i].toCharArray(fileName, fileNames[i].length() + 1);

    file.open(root, fileName);
    wave.create(file);
    wave.play();
    while (wave.isplaying) delay(100);
  }
}


#include "ConfigManager.h"

struct Config {
    char name[20];
    bool enabled;
    int8 hour;
    char password[20];
} config;

struct Metadata {
    int8 version;
} meta;

ConfigManager configManager;

void createCustomRoute(ESP8266WebServer *server) {
    server->on("/custom", HTTPMethod::HTTP_GET, [server](){
        server->send(200, "text/plain", "Hello, World!");
    });
}

void setup() {
    meta.version = 3;

    // Setup config manager
    configManager.setAPName("Demo");
    configManager.setAPFilename("/index.html");
    configManager.addParameter("name", config.name, 20);
    configManager.addParameter("enabled", &config.enabled);
    configManager.addParameter("hour", &config.hour);
    configManager.addParameter("password", config.password, 20, set);
    configManager.addParameter("version", &meta.version, get);
    configManager.begin(config);

    configManager.setAPICallback(createCustomRoute);

    //
}

void loop() {
    configManager.loop();

    // Add your loop code here
}

Move begin down in example

#include "ConfigManager.h"

struct Config {
    char name[20];
    bool enabled;
    int8 hour;
    char password[20];
} config;

struct Metadata {
    int8 version;
} meta;

ConfigManager configManager;

void createCustomRoute(ESP8266WebServer *server) {
    server->on("/custom", HTTPMethod::HTTP_GET, [server](){
        server->send(200, "text/plain", "Hello, World!");
    });
}

void setup() {
    meta.version = 3;

    // Setup config manager
    configManager.setAPName("Demo");
    configManager.setAPFilename("/index.html");
    configManager.addParameter("name", config.name, 20);
    configManager.addParameter("enabled", &config.enabled);
    configManager.addParameter("hour", &config.hour);
    configManager.addParameter("password", config.password, 20, set);
    configManager.addParameter("version", &meta.version, get);
    configManager.setAPICallback(createCustomRoute);
    configManager.begin(config);

    //
}

void loop() {
    configManager.loop();

    // Add your loop code here
}


// Interduino is the physical manifestation of cigtee - an arduino sketch designed to take serial commands to make stuff happen IRL

void setup()
{
	Serial.begin(9600);
	pinMode(13, OUTPUT);

}

int pinState[6];

void loop()
{
	if(Serial.available()){
		int ledState = Serial.read();
		if(ledState == 65){
			digitalWrite(13, HIGH);
		}
		if(ledState == 90){
			digitalWrite(13, LOW);
		}
	}
}

Add main func to stop build from breaking on akira

// Interduino is the physical manifestation of cigtee - an arduino sketch designed to take serial commands to make stuff happen IRL

void setup()
{
	Serial.begin(9600);
	pinMode(13, OUTPUT);

}

int pinState[6];

void loop()
{
	if(Serial.available()){
		int ledState = Serial.read();
		if(ledState == 65){
			digitalWrite(13, HIGH);
		}
		if(ledState == 90){
			digitalWrite(13, LOW);
		}
	}
}

int main()
{
  setup();
  while(true) {
    loop();
  }
  return 0;
}


const int outPinLed = 2;
const int inPinTrigger = 7;
const int inPinDetector = 4;

int triggerPressed = 0;

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

  pinMode(outPinLed, OUTPUT);
  digitalWrite(outPinLed, LOW);

  pinMode(inPinTrigger, INPUT);
  pinMode(inPinDetector, INPUT);

}

void loop() {
  int triggerPrev = triggerPressed;
  triggerPressed = digitalRead(inPinTrigger);
  if (triggerPressed != triggerPrev) {
    Serial.print("Trigger state changed: ");
    Serial.println(triggerPressed);
    if (triggerPressed) {
      int detectorValue = digitalRead(inPinDetector);

      Serial.print("Detector: ");
      Serial.println(detectorValue);
    }
  }

  int ledState = triggerPressed ? HIGH : LOW;
  digitalWrite(outPinLed, ledState);

}

Read detector value to A0

const int outPinLed = 2;
const int inPinTrigger = 7;
const int inPinDetector = A0;

int triggerPressed = 0;
int detectorValue = 1023;

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

  pinMode(outPinLed, OUTPUT);
  digitalWrite(outPinLed, LOW);

  pinMode(inPinTrigger, INPUT_PULLUP);
}

void loop() {
  int triggerPrev = triggerPressed;
  triggerPressed = digitalRead(inPinTrigger);
  if (triggerPressed != triggerPrev) {
    Serial.print("Trigger state changed: ");
    Serial.println(triggerPressed);
    /*if (triggerPressed) {
      int detectorValue = analogRead(inPinDetector);

      Serial.print("Detector: ");
      Serial.println(detectorValue);
    }*/
  }
  if (triggerPressed) {
    int detectorPrev = detectorValue;
    detectorValue = analogRead(inPinDetector);
    Serial.print("     Detector: ");
    Serial.print(detectorValue);
    Serial.print("   diff=");
    Serial.println(detectorValue - detectorPrev);
  }

  int ledState = triggerPressed ? HIGH : LOW;
  digitalWrite(outPinLed, ledState);

}


/*
Arduino based self regulating kitchen garden

 */

// light related setup
int lightSensorPin = 3; // Set to whereever light sensor is connected
int lampRelay = 4; // Set to whereever relay for lamp is connected

// activity led setup
int ledPin = 13; // this is just for checking activity

// Initialize settings
void setup() {
  // Initialize output pins.
  pinMode(ledPin, OUTPUT);

  // Initialize input pins.
  pinMode(lightSensorPin, INPUT);

}

// Main loop
void loop() {
  // Read sensor values
  analogRead(lightSensorPin);

}


/*
 Basic MQTT example with Authentication

  - connects to an MQTT server, providing username
    and password
  - publishes "hello world" to the topic "outTopic"
  - subscribes to the topic "inTopic"
*/

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char *ssid =	"xxxxxxxx";		// cannot be longer than 32 characters!
const char *pass =	"yyyyyyyy";		//

// Update these with values suitable for your network.
IPAddress server(172, 16, 0, 2);

void callback(String topic, byte* payload, unsigned int length) {
  // handle message arrived
}

PubSubClient client(server);

void setup()
{
  // Setup console
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.println();

  client.set_callback(callback);

  WiFi.begin(ssid, pass);

  int retries = 0;
  while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) {
    retries++;
    delay(500);
    Serial.print(".");
  }
  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("");
    Serial.println("WiFi connected");
  }

  client.set_auth("testeruser", "testpass");
  if (client.connect("arduinoClient")) {
    client.publish("outTopic","hello world");
    client.subscribe("inTopic");
  }
}

void loop()
{
  client.loop();
}

Update the authentication example using an MQTT::Connect object directly

/*
 Basic MQTT example with Authentication

  - connects to an MQTT server, providing username
    and password
  - publishes "hello world" to the topic "outTopic"
  - subscribes to the topic "inTopic"
*/

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char *ssid =	"xxxxxxxx";		// cannot be longer than 32 characters!
const char *pass =	"yyyyyyyy";		//

// Update these with values suitable for your network.
IPAddress server(172, 16, 0, 2);

void callback(String topic, byte* payload, unsigned int length) {
  // handle message arrived
}

PubSubClient client(server);

void setup()
{
  // Setup console
  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.println();

  client.set_callback(callback);

  WiFi.begin(ssid, pass);

  int retries = 0;
  while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) {
    retries++;
    delay(500);
    Serial.print(".");
  }
  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("");
    Serial.println("WiFi connected");
  }

  if (client.connect(MQTT::Connect("arduinoClient")
	             .set_auth("testeruser", "testpass"))) {
    client.publish("outTopic","hello world");
    client.subscribe("inTopic");
  }
}

void loop()
{
  client.loop();
}


# 2 "TestSystemInfo.ino"

#include <Arduino.h>
#include <Arduino_FreeRTOS.h>
#include <StandardCplusplus.h>
#include <RabirdToolkit.h>

#include <RTest.h>
#include <RRawPointer.h>
#include <RSharedPointer.h>
#include <RFormatter.h>

RTEST(TestSystemInfo)
{
  RFormatter formatter(manager()->printer());

  formatter("Size of int : %s").arg(sizeof(int));
  formatter("Size of uintptr_t : %s").arg(sizeof(uintptr_t));
  formatter("Size of rsize : %s").arg(sizeof(rsize));
  formatter("Size of rnumber : %s").arg(sizeof(rnumber));
  formatter("Size of ruint : %s").arg(sizeof(ruint));
};

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

  while(!Serial)  // for the Arduino Leonardo/Micro only
  {
  }

  RTestApplication testApp;

  testApp.addTest(&RTEST_INSTANCE(TestSystemInfo));
  testApp.run();
}

void
loop()
{
}

Use assert macro for print out system info

# 2 "TestSystemInfo.ino"

#include <Arduino.h>
#include <Arduino_FreeRTOS.h>
#include <StandardCplusplus.h>
#include <RabirdToolkit.h>

#include <RTest.h>

RTEST(TestSystemInfo)
{
  RASSERT_MORE(sizeof(int), 0);
  RASSERT_MORE(sizeof(uintptr_t), 0);
  RASSERT_MORE(sizeof(rsize), 0);
  RASSERT_MORE(sizeof(rnumber), 0);
  RASSERT_MORE(sizeof(ruint), 0);
};

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

  while(!Serial)  // for the Arduino Leonardo/Micro only
  {
  }

  RTestApplication testApp;

  testApp.addTest(&RTEST_INSTANCE(TestSystemInfo));
  testApp.run();
}

void
loop()
{
}


#include <Arduboy.h>
#include <ArdVoice.h>
#include "voices.h"

Arduboy arduboy;
ArdVoice ardvoice;

void setup() {
	arduboy.begin();
	arduboy.setFrameRate(30);
	ardvoice.playVoice(merry_q6);
}

void loop() {
	if (!(arduboy.nextFrame()))
		return;

	if (arduboy.pressed(B_BUTTON)){
		ardvoice.playVoice(merry_q6);
	}

	if (arduboy.pressed(A_BUTTON)){
		ardvoice.stopVoice();
	}
}

Modify samples to use Arduboy2 library

#include <Arduboy2.h>
#include <ArdVoice.h>
#include "voices.h"

Arduboy2 arduboy;
ArdVoice ardvoice;

void setup() {
	arduboy.begin();
	arduboy.setFrameRate(30);
	ardvoice.playVoice(merry_q6);
}

void loop() {
	if (!(arduboy.nextFrame()))
		return;

	if (arduboy.pressed(B_BUTTON)){
		ardvoice.playVoice(merry_q6);
	}

	if (arduboy.pressed(A_BUTTON)){
		ardvoice.stopVoice();
	}
}


int vinpin = A0;
int voutpin = A1;
int gndpin = A2;
int zpin = A3;
int ypin = A4;
int xpin = A5;

void setup() {
  Serial.begin(9600);
  pinMode(vinpin, OUTPUT); digitalWrite(vinpin, HIGH);
  pinMode(gndpin, OUTPUT); digitalWrite(gndpin, LOW);
  pinMode(voutpin, INPUT);
  pinMode(xpin, INPUT);
  pinMode(ypin, INPUT);
  pinMode(zpin, INPUT);
}

void loop() {
  Serial.print(analogRead(xpin)); Serial.print("\t");
  Serial.print(analogRead(ypin)); Serial.print("\t");
  Serial.print(analogRead(zpin)); Serial.println();
}

Comment out power pins in ADXL example code.

int zpin = A3;
int ypin = A4;
int xpin = A5;

// Uncomment the following lines if you're using an ADXL335 on an
// Adafruit breakout board (https://www.adafruit.com/products/163)
// and want to plug it directly into (and power it from) the analog
// input pins of your Arduino board.
//int vinpin = A0;
//int voutpin = A1;
//int gndpin = A2;

void setup() {
  Serial.begin(9600);
  pinMode(vinpin, OUTPUT); digitalWrite(vinpin, HIGH);
  pinMode(gndpin, OUTPUT); digitalWrite(gndpin, LOW);
  pinMode(voutpin, INPUT);
  pinMode(xpin, INPUT);
  pinMode(ypin, INPUT);
  pinMode(zpin, INPUT);
}

void loop() {
  Serial.print(analogRead(xpin)); Serial.print("\t");
  Serial.print(analogRead(ypin)); Serial.print("\t");
  Serial.print(analogRead(zpin)); Serial.println();
}


#include "display.h"
#include "sensor.h"
#include <LiquidCrystal.h>  // Arduino LCD library
#include <Arduino.h>  // enables use of byte pics

void setup() {
  LCD::setup();
  Sensor::setup();
}

void loop() {
  int temp = Sensor::readTemp();
  LCD::displayTemp(temp);
  delay(5000);
  LCD::clearScreen();
}

Update lcd to display and add loop functionality

#include "display.h"
#include "sensor.h"
#include <LiquidCrystal.h>  // Arduino LCD library
#include <Arduino.h>  // enables use of byte pics

void setup() {
  Display::setup();
  Sensor::setup();
}

void loop() {
  int temp = Sensor::readTemp();
  int hum = Sensor::readHum();
  Display::displayTemp(temp);
  Display::displayHum(hum);
  delay(3000);
}


int motorPin = 9;
int switchPin = 7;
int motorStep = 0;
int maxStep = 200;
int minimumStepDelay = 2;

String motorState = String("off");

void makeStep() {
  digitalWrite(motorPin, HIGH);
  digitalWrite(motorPin, LOW);
  motorStep += 1;
  if (motorStep > maxStep) {
    motorStep = 0;
  }
}

void resetMotor() {
  for (int i = motorStep; i < maxStep; i++) {
    makeStep();
    delay(minimumStepDelay);
  }
}

void setup()  {
  pinMode(switchPin, INPUT);
  pinMode(motorPin, OUTPUT);
  digitalWrite(switchPin, HIGH);

  Serial.begin(9600);
}

void loop()  {
  if(Serial.available() > 0) {
    char command = Serial.read();
    switch (command) {
      case 'd':
        Serial.println(String("Current step: ") + motorStep);
        break;
      case 's':
        makeStep();
        Serial.println(motorStep);
        break;
      case 'r':
        resetMotor();
        Serial.println(String("Motor reset. (Step is ") + motorStep + String(")"));
    }
  }
}

Add correct pinout for all optional pins

int enablePin = 4;
int MS1Pin = 5;
int MS2Pin = 6;
int MS3Pin = 7;
int resetPin = 9;
int sleepPin = 10;
int motorPin = 11;
int directionPin = 12;
int switchPin = 13;

// Stepping: Full, half, quarter, eigth, sixteenth
int[] stepping = {
  B000,
  B100,
  B010,
  B110,
  B111
}

int motorStep = 0;
int maxStep = 200;
int minimumStepDelay = 2;

String motorState = String("off");

void makeStep() {
  digitalWrite(motorPin, HIGH);
  digitalWrite(motorPin, LOW);
  motorStep += 1;
  if (motorStep > maxStep) {
    motorStep = 0;
  }
}

void resetMotor() {
  for (int i = motorStep; i < maxStep; i++) {
    makeStep();
    delay(minimumStepDelay);
  }
}

void setup()  {
  pinMode(switchPin, INPUT);
  pinMode(motorPin, OUTPUT);
  digitalWrite(switchPin, HIGH);

  Serial.begin(9600);
}

void loop()  {
  if(Serial.available() > 0) {
    char command = Serial.read();
    switch (command) {
      case 'd':
        Serial.println(String("Current step: ") + motorStep);
        break;
      case 's':
        makeStep();
        Serial.println(motorStep);
        break;
      case 'r':
        resetMotor();
        Serial.println(String("Motor reset. (Step is ") + motorStep + String(")"));
    }
  }
}


#define DEBUG

#include "TheThingsUno.h"

const byte devAddr[4] = { 0x02, 0xDE, 0xAE, 0x00 };
const byte appSKey[16] = { 0x0D, 0x0E, 0x0A, 0x0D, 0x0B, 0x0E, 0x0E, 0x0F, 0x0C, 0x0A, 0x0F, 0x0E, 0x0B, 0x0A, 0x0B, 0x0E };
const byte nwkSKey[16] = { 0x0D, 0x0E, 0x0A, 0x0D, 0x0B, 0x0E, 0x0E, 0x0F, 0x0C, 0x0A, 0x0F, 0x0E, 0x0B, 0x0A, 0x0B, 0x0E };

#define debugSerial Serial
#define loraSerial Serial1

// These are the input pins of your sensors
#define TEMPSENSOR 0
#define SOILSENSOR 1

TheThingsUno ttu;

void setup()
{
  debugSerial.begin(115200);
  loraSerial.begin(57600);

  ttu.init(loraSerial, debugSerial);
  ttu.reset();
  ttu.personalize(devAddr, nwkSKey, appSKey);

#ifdef DEBUG
  ttu.debugStatus();
#endif

  Serial.println("Setup for The Things Network.");
}

void loop() {
  while (debugSerial.available())
    loraSerial.write((char)debugSerial.read());

  while (loraSerial.available())
    debugSerial.write((char)loraSerial.read());

  delay(1);
}

Remove pre-filled DevAddr and Keys

#define DEBUG

#include "TheThingsUno.h"

const byte devAddr[4] = { /* copy DevAddr here */ };
const byte appSKey[16] = { /* copy AppSKey here */ };
const byte nwkSKey[16] = { /* copy NwkSKey here */ };

#define debugSerial Serial
#define loraSerial Serial1

// These are the input pins of your sensors
#define TEMPSENSOR 0
#define SOILSENSOR 1

TheThingsUno ttu;

void setup()
{
  debugSerial.begin(115200);
  loraSerial.begin(57600);

  ttu.init(loraSerial, debugSerial);
  ttu.reset();
  ttu.personalize(devAddr, nwkSKey, appSKey);

#ifdef DEBUG
  ttu.debugStatus();
#endif

  Serial.println("Setup for The Things Network.");
}

void loop() {
  while (debugSerial.available())
    loraSerial.write((char)debugSerial.read());

  while (loraSerial.available())
    debugSerial.write((char)loraSerial.read());

  delay(1);
}


/*
  TestSuite sketch

  Use this sketch when running the Liberty Arduino Feature test suite.

 */
#include <EEPROM.h>
#include <Liberty.h>

Liberty liberty("TestNode");

boolean ns = false;
int nc = 0;
unsigned long ln;
byte bs[20];

void setup() {
   liberty.sram(sramBytes, 20);
   liberty.invocable("foo", &foo);
   liberty.invocable("bar", &bar);
   liberty.invocable("qaz", &qaz);
   liberty.invocable("times", &times);
   liberty.invocable("start", &nstart);
   liberty.invocable("stop", &nstop);
   liberty.begin();
}
void loop() {
  liberty.update();
  if (ns) {
    unsigned long x = millis();
    if (x - ln > 200) {
       ln = x;
       nc++;
       liberty.notify("testN1", nc);
    }
  }
}
int foo() {
 return bs[0];
}
int bar() {
 return 42;
}
int qaz(int x) {
 return x * 4;
}
int times(int x, int y) {
 return x * y;
}

int nstart() {
  ns = true;
  nc = 0;
  ln = millis();
}

int nstop() {
  ns = false;
  return nc;
}

Fix bug in sram size

/*
  TestSuite sketch

  Use this sketch when running the Liberty Arduino Feature test suite.

 */
#include <EEPROM.h>
#include <Liberty.h>

Liberty liberty("TestNode");

boolean ns = false;
int nc = 0;
unsigned long ln;
byte bs[50];

void setup() {
   liberty.sram(bs, 50);
   liberty.invocable("foo", &foo);
   liberty.invocable("bar", &bar);
   liberty.invocable("qaz", &qaz);
   liberty.invocable("times", &times);
   liberty.invocable("start", &nstart);
   liberty.invocable("stop", &nstop);
   liberty.begin();
}
void loop() {
  liberty.update();
  if (ns) {
    unsigned long x = millis();
    if (x - ln > 200) {
       ln = x;
       nc++;
       liberty.notify("testN1", nc);
    }
  }
}
int foo() {
 return bs[0];
}
int bar() {
 return 42;
}
int qaz(int x) {
 return x * 4;
}
int times(int x, int y) {
 return x * y;
}

int nstart() {
  ns = true;
  nc = 0;
  ln = millis();
}

int nstop() {
  ns = false;
  return nc;
}


// https://github.com/thomasfredericks/Metro-Arduino-Wiring
#include <Metro.h>

const int MOTORPIN = 2;

Metro blink = Metro(400);
bool isVibrationOn = false;
bool isMotorOn = false;
uint32_t now;

void onMotor(void)
{
    digitalWrite(MOTORPIN, HIGH);
    isMotorOn = true;
}

void offMotor(void)
{
    digitalWrite(MOTORPIN, LOW);
    isMotorOn = false;
}

void beginVibration(void)
{
    blink.reset();
    isVibrationOn = true;
}

void endVibration(void)
{
    offMotor();
    isVibrationOn = false;
}

void vibrationLoop(void)
{
    if (!isVibrationOn) {
        return;
    }
    if (blink.check()) {
        if (isMotorOn) {
            offMotor();
        } else {
            onMotor();
        }
    }
}

void parseMessage(char letter)
{
    switch (letter) {
    case 'v':
        beginVibration();
        break;
    case 'V':
        endVibration();
        break;
    default:
        break;
    }
}

void setup()
{
    Serial.begin(115200);
    Mouse.begin();
    pinMode(MOTORPIN, OUTPUT);
}

static void mouseLoop()
{
    // move mouse to avoid screen saver
    static uint32_t mprevms = 0;
    const uint32_t PCLOCKMS = 540000; // 9 [min]
    if (now - mprevms > PCLOCKMS) {
        mprevms = now;
        Mouse.move(1, 0, 0);
        //Serial.write("M");
    }
}

void loop()
{
    now = millis();
    vibrationLoop();
    mouseLoop();
    while (Serial.available()) {
        char letter = Serial.read();
        parseMessage(letter);
    }
}

Use TimerThree library to blink motor

// https://www.pjrc.com/teensy/td_libs_TimerOne.html
#include <TimerThree.h>

const int MOTORPIN = 5;

void parseMessage(int letter)
{
    switch (letter) {
    case 'v':
        Timer3.pwm(MOTORPIN, 512);
        break;
    case 'V':
        Timer3.pwm(MOTORPIN, 0);
        break;
    default:
        break;
    }
}

void setup()
{
    Serial.begin(115200);
    Mouse.begin();
    Timer3.initialize(400000);
}

void loop()
{
    while (Serial.available()) {
        char letter = Serial.read();
        parseMessage(letter);
    }
}


int incomingByte = 0;  // for incoming serial data
int relay1 = 4;
int relay2 = 5;
boolean state1 = false;
boolean state2 = false;

void setup() {
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    if (incomingByte == '1') {
      Serial.println("Toggling light 1");
      if (state1 == false) {
        state1 = true;
      } else {
        state1 = false;
      }
      digitalWrite(led1, state1);
    } else if (incomingByte == '2') {
      Serial.println("Toggling light 2");
      if (state2 == false){
        state2 = true;
      } else {
        state2 = false;
      }
      digitalWrite(led2, state2);
    }
  }
}

Fix variable name bug in Arduino code

int incomingByte = 0;  // for incoming serial data
int relay1 = 4;
int relay2 = 5;
boolean state1 = false;
boolean state2 = false;

void setup() {
  Serial.begin(9600);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    if (incomingByte == '1') {
      Serial.println("Toggling light 1");
      if (state1 == false) {
        state1 = true;
      } else {
        state1 = false;
      }
      digitalWrite(relay1, state1);
    } else if (incomingByte == '2') {
      Serial.println("Toggling light 2");
      if (state2 == false){
        state2 = true;
      } else {
        state2 = false;
      }
      digitalWrite(relay2, state2);
    }
  }
}


/**
 * Wrapper for a thermometer.
 *
 * In this case it's a BMP085 barometric sensor, because that's what I had laying around.
 */

#include <Wire.h>
#include <I2Cdev.h>
#include <BMP085.h>

BMP085 barometer;
boolean hasThermometer;

boolean initThermometer () {
  Serial.print(F("Setting up BMP085 for temperature..."));

  Wire.begin();
  barometer.initialize();

  if (barometer.testConnection()) {
    // request temperature
    barometer.setControl(BMP085_MODE_TEMPERATURE);

    // wait appropriate time for conversion (4.5ms delay)
    int32_t lastMicros = micros();
    while (micros() - lastMicros < barometer.getMeasureDelayMicroseconds());

    Serial.println(F(" done."));
    hasThermometer = true;
  } else {
    Serial.println(F(" error."));
    hasThermometer = false;
  }

  return hasThermometer;
}

float getTemperature () {
  return (hasThermometer) ? barometer.getTemperatureF() : 0.0;
}

Switch to Adafruit's BPM085 library.

/**
 * Wrapper for a thermometer.
 *
 * In this case it's a BMP085 barometric sensor, because that's what I had laying around.
 */

#include <Wire.h>
#include <Adafruit_BMP085.h>

Adafruit_BMP085 barometer;
boolean hasThermometer;

boolean initThermometer () {
  Serial.print(F("Setting up BMP085 for temperature..."));

  if (barometer.begin()) {
    Serial.println(F(" done."));
    hasThermometer = true;
  } else {
    Serial.println(F(" error."));
    hasThermometer = false;
  }

  return hasThermometer;
}

float getTemperature () {
  return (hasThermometer) ? barometer.readTemperature() * 9 / 5 + 32 : 0.0;
}


void setup() {
  // put your setup code here, to run once:

}

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

}

Implement initial setup for Wave Shield

#include <WaveHC.h>
#include <WaveUtil.h>

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the volumes root directory
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

void setupSdReader(SdReader &card) {
  if (!card.init()) Serial.println("Card init failed");
  card.partialBlockRead(true); // Optimization. Disable if having issues
}

void setupFatVolume(FatVolume &vol) {
  uint8_t slot;
  // There are 5 slots to look at.
  for (slot = 0; slot < 5; slot++)
    if (vol.init(card, slot)) break;
  if (slot == 5) Serial.println("No valid FAT partition");
}

void setupFatReader(FatReader &root) {
  if (!root.openRoot(vol)) Serial.println("Can't open root dir");
}

void setup() {
  Serial.begin(9600);
  setupSdReader(card);
  setupFatVolume(vol);
  setupFatReader(root);
}

void loop() {

}


/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Social networks:            http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example shows how to use ESP32 BLE
  to connect your project to Blynk.

  Warning: Bluetooth support is in beta!
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleEsp32_BLE.h>
#include <BLEDevice.h>
#include <BLEServer.h>

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

void setup()
{
  // Debug console
  Serial.begin(9600);

  Serial.println("Waiting for connections...");

  Blynk.begin(auth);
}

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

Add setDeviceName for ESP32 BLE

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Social networks:            http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************
  This example shows how to use ESP32 BLE
  to connect your project to Blynk.

  Warning: Bluetooth support is in beta!
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial

#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleEsp32_BLE.h>
#include <BLEDevice.h>
#include <BLEServer.h>

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

void setup()
{
  // Debug console
  Serial.begin(9600);

  Serial.println("Waiting for connections...");

  Blynk.setDeviceName("Blynk");

  Blynk.begin(auth);
}

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


const int PIN_DATA = 4;
const int PIN_LATCH = 3;
const int PIN_CLOCK = 2;

byte arrivalStatus = 1;

void setup() {
    pinMode(PIN_DATA, OUTPUT);
    pinMode(PIN_CLOCK, OUTPUT);
    pinMode(PIN_LATCH, OUTPUT);
}

void loop() {
    digitalWrite(PIN_LATCH, LOW);
    shiftOut(PIN_DATA, PIN_CLOCK, MSBFIRST, arrivalStatus);
    digitalWrite(PIN_LATCH, HIGH);
    simulate_motion();
}

/**
 * Pretend Update arrivalStatus as if this
 * was a bus that is getting closer to the
 * desired stop
 */
void simulate_motion() {
    arrivalStatus <<= 1;
    if (!arrivalStatus)
        arrivalStatus = 1;
    delay(1000);
}

Read data from serial port

const int PIN_DATA = 4;
const int PIN_LATCH = 3;
const int PIN_CLOCK = 2;

void setup() {
    //Initialize Shift register
    pinMode(PIN_DATA, OUTPUT);
    pinMode(PIN_CLOCK, OUTPUT);
    pinMode(PIN_LATCH, OUTPUT);

    //Initialize Serial Port
    Serial.begin(9600);
}

void loop() {
    //Wait for a single byte
    while (Serial.available() < 1);
    byte arrivalStatus = Serial.read();
    Serial.write(arrivalStatus);

    //Update LEDs
    digitalWrite(PIN_LATCH, LOW);
    shiftOut(PIN_DATA, PIN_CLOCK, MSBFIRST, arrivalStatus);
    digitalWrite(PIN_LATCH, HIGH);
}


const byte SCALE_VALUE[] = { 0b00000100, 0b00001100, 0b00011100, 0b00111100};

int senzor = A0;

void setup() {
  Serial.begin(9600);
  pinMode(senzor, INPUT);
  // porty 2,3,4,5 jako vystup
  DDRD |= 0b00111100;
}

void loop() {
  int light = analogRead(senzor);
  Serial.println(light);

  int scale = map(light, 400, 800, 0, 3);
  Serial.println(scale);

  PORTD = 0b00000000;
  PORTD |= (0b00000100 << scale);
  // PORTD |= SCALE_VALUE[scale];

  delay(200);
}

Update map and bit mask

const byte SCALE_VALUE[] = { 0b00000100, 0b00001100, 0b00011100, 0b00111100};

// fotorezistor - A1, termistor - A0
int senzor = A1;

void setup() {
  Serial.begin(9600);
  pinMode(senzor, INPUT);
  // porty 2,3,4,5 jako vystup
  DDRD |= 0b00111100;
}

void loop() {
  int light = analogRead(senzor);
  Serial.println(light);

  int scale = map(light, 300, 1000, 0, 3);
  Serial.println(scale);

  PORTD &= !0b00111100; // nastaveni vychoziho stavu - zhasnuto
  PORTD |= (0b00000100 << scale);
  // PORTD |= SCALE_VALUE[scale];

  delay(200);
}


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

  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);

  for (int x = 2; x<=13; x++){
    digitalWrite(x, HIGH);
  }
}

void loop() {
  char c;
  char l;
  int pin;
  int state;

  if (Serial.available()) {
    c = Serial.read();
    if (c == 'O') {
      pin = Serial.parseInt();
      l = Serial.read();
      state = Serial.parseInt();

      if (pin == 99) {
        for (int x = 2; x<=13; x++){
          digitalWrite(x, state);
        }
      } else {
        digitalWrite(pin, state);
      }
      Serial.println('r');
    }
  }
}

Change initial state of all pins to LOW for new Relay Module

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

  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);

  for (int x = 2; x<=13; x++){
    digitalWrite(x, LOW);
  }
}

void loop() {
  char c;
  char l;
  int pin;
  int state;

  if (Serial.available()) {
    c = Serial.read();
    if (c == 'O') {
      pin = Serial.parseInt();
      l = Serial.read();
      state = Serial.parseInt();

      if (pin == 99) {
        for (int x = 2; x<=13; x++){
          digitalWrite(x, state);
        }
      } else {
        digitalWrite(pin, state);
      }
      Serial.println('r');
    }
  }
}


#define LED 53
void setup()
{
    pinMode(LED, OUTPUT);
}

void loop()
{
    digitalWrite(LED, HIGH);
    delay(500);
    digitalWrite(LED, LOW);
    delay(500);
}

Add blank line for tuto sample.


void setup() {
  // put your setup code here, to run once:

}

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

}

Revert "make editor folding happy"


#include <MINDS-i-Drone.h>

ServoGenerator::Servo drive, steer;

void setup() {
  drive.attach(12 /* APM pin 1 */);
  steer.attach(11 /* APM pin 2 */);

  ServoGenerator::begin();

  //set the initial throttle/direction for the ESC/servo
  drive.write(90);
  steer.write(90);

  APMRadio::setup();
  Serial.begin(9600);

  //delay 2 seconds for arming
  delay(2000);
}

void loop() {
  static uint32_t timer = micros();
  uint32_t dt = timer+micros();
  timer = -micros();

  int driveSig = APMRadio::get(0);
  int steerSig = APMRadio::get(1);

  Serial.print(dt);
  Serial.print(" ");
  Serial.print(driveSig);
  Serial.print(" ");
  Serial.print(steerSig);
  Serial.println();

  drive.write( driveSig );
  steer.write( steerSig );
}

Add backsteer to drone radio drive

#include <MINDS-i-Drone.h>

ServoGenerator::Servo drive, steer, backsteer;

void setup() {
  drive.attach(12 /* APM pin 1 */);
  steer.attach(11 /* APM pin 2 */);
  backsteer.attach(8 /* APM pin 3 */);

  ServoGenerator::begin();

  //set the initial throttle/direction for the ESC/servo
  drive.write(90);
  steer.write(90);
  backsteer.write(90);

  APMRadio::setup();
  Serial.begin(9600);

  //delay 2 seconds for arming
  delay(2000);
}

void loop() {
  static uint32_t timer = micros();
  uint32_t dt = timer+micros();
  timer = -micros();

  int driveSig = APMRadio::get(0);
  int steerSig = APMRadio::get(1);

  Serial.print(dt);
  Serial.print(" ");
  Serial.print(driveSig);
  Serial.print(" ");
  Serial.print(steerSig);
  Serial.println();

  drive.write( driveSig );
  steer.write( steerSig );
  backsteer.write( 90 - steerSig );
}


/*
Arduino based self regulating kitchen garden

 */

#include <DHT.h>

// temperature related setup
#define DHTPIN 2        // Humidity and temperature sensor pin
#define DHTTYPE DHT22   // Model DHT 22 (AM2302)
DHT airSensor(DHTPIN, DHTTYPE); // setup DHT sensor
float airHumidity;
float airTemperature;

// light related setup
int lightSensorPin = 3; // Set to whereever light sensor is connected
int lampRelay = 4; // Set to whereever relay for lamp is connected

// activity led setup
int ledPin = 13; // this is just for checking activity

// Initialize settings
void setup() {
  // Initialize output pins.
  pinMode(ledPin, OUTPUT);

  // Initialize input pins.
  pinMode(lightSensorPin, INPUT);

  airSensor.begin(); // begin DHT so it is ready for reading

}

// Main loop
void loop() {
  // Read sensor values
  analogRead(lightSensorPin);
  airSensor.readHumidity(); // read humidity from DHT
  airSensor.readTemperature(); // read temperature from DHT

}

Add SHT10 sensor and fix some setup

/*
Arduino based self regulating kitchen garden

 */

#include <SHT1x.h>
#include <DHT.h>

// soil related setup
#define soilDataPin  3
#define soilClockPin 4
SHT1x soilSensor(soilDataPin, soilClockPin);
float soilTemperature;
float soilMoisture;

// air temperature related setup
#define DHTPIN 2        // Humidity and temperature sensor pin
#define DHTTYPE DHT22   // Model DHT 22 (AM2302)
DHT airSensor(DHTPIN, DHTTYPE); // setup DHT sensor
float airHumidity;
float airTemperature;

// light related setup
#define lightSensorPin A0 // Set to whereever light sensor is connected

// activity led setup
int ledPin = 13; // this is just for checking activity

// Initialize settings
void setup() {
  // Initialize output pins.
  pinMode(ledPin, OUTPUT);

  // Initialize input pins.
  pinMode(lightSensorPin, INPUT); // Is this needed? It is analog pin..

  airSensor.begin(); // begin DHT so it is ready for reading

}

// Main loop
void loop() {
  // Read sensor values
  analogRead(lightSensorPin); // read light level from LDR
  airSensor.readHumidity(); // read humidity from DHT
  airSensor.readTemperature(); // read temperature from DHT
  sht1x.readTemperatureC(); // read humidity from SHT10
  sht1x.readHumidity(); // read temperature from SHT10

}


#ifndef BOLTARDUINO
#define BOLTARDUINO

#include "button.h"
#include "led.h"
#include "screen.h"
#include "game.h"
#include "const.h"
#include "clock.h"

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

  //Attach interrupt for 64 button shield
  attachInterrupt(digitalPinToInterrupt(P_BUTTON_INTERRUPT), button_ISR, FALLING);

  //Generate new random seed
  randomSeed(analogRead(0));
}

void loop() {
  screen_display("READY");

  led_set(1, LED_STATE_FLASHING);
  button_wait(1);

  game_start();
}

#endif

Add missing import to main .ino file

#ifndef BOLTARDUINO
#define BOLTARDUINO

#include "button.h"
#include "led.h"
#include "screen.h"
#include "game.h"
#include "const.h"
#include "clock.h"
#include "controller.h"

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

  //Attach interrupt for 64 button shield
  attachInterrupt(digitalPinToInterrupt(P_BUTTON_INTERRUPT), button_ISR, FALLING);

  //Generate new random seed
  randomSeed(analogRead(0));
}

void loop() {
  screen_display("READY");

  led_set(1, LED_STATE_FLASHING);
  button_wait(1);

  game_start();
}

#endif


#include <RunningAverage.h>
#include <HX711.h>

#include "TimerDisplay.h"
#include "GramsDisplay.h"

#define DISP_TIMER_CLK 2
#define DISP_TIMER_DIO 3
#define DISP_SCALE_CLK 8
#define DISP_SCALE_DIO 9
#define SCALE_DT       A2
#define SCALE_SCK      A1

#define FILTER_SIZE 10

#define SCALE_FACTOR 1874
#define SCALE_OFFSET 984550

TimerDisplay         timerDisplay(DISP_TIMER_CLK, DISP_TIMER_DIO);
GramsDisplay         gramsDisplay(DISP_SCALE_CLK, DISP_SCALE_DIO);
HX711                scale;
RunningAverage       filter(FILTER_SIZE);
float                weight_in_grams;

void setup() {
  // Serial comm
  Serial.begin(38400);

  // Load cell
  scale.begin(SCALE_DT, SCALE_SCK);
  scale.set_scale(SCALE_FACTOR);
  scale.set_offset(SCALE_OFFSET);

  // Filter
  filter.clear();
}

void loop() {
  filter.addValue(scale.get_units());
  weight_in_grams = filter.getAverage();
  gramsDisplay.displayGrams(weight_in_grams);

  if (weight_in_grams > 1)
    timerDisplay.start();
  else
    timerDisplay.stop();

  timerDisplay.refresh();
}

Put opening braces on separate line


#include <Bridge.h>

#include "logger.h"

#include "thingspeakReceiver.h"
ThingspeakReceiver thingspeakReceiver;

#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Wire.h>

#define PIN_LED    13

Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  pinMode(PIN_LED, OUTPUT);

  Bridge.begin(); //Yun Bridge
  logger->init();

  // init 7-segments matrix
  matrix.begin(0x70);
  matrix.setBrightness(2);
  displayCounter(0);

  //setup the IoT platforms
  logger->log("Start setup connection with IoT platforms...\n");
  thingspeakReceiver.init();

  //Everything seems to be ok, let's start !
  logger->log("\nBottle Opener up, Let's start to play :) !!!\n");

  //highlight blue led just to prevent everything is OK. Useful when logs are disabled
  digitalWrite(PIN_LED, HIGH);
}

/**
   Arduino Loop
*/
void loop() {
  int counter = thingspeakReceiver.receiveCounter();

  displayCounter(counter);

  delay(500);
}

/**
   Display Counter on è
*/
void displayCounter(int counter) {
  matrix.print(counter);
  matrix.writeDisplay();
}

Use of ShiftrConnector as receiver

#include <Bridge.h>

#include "logger.h"

/////////////////////////////////////////////
// Include of Iot Platform's connectors
#include "thingspeakReceiver.h"
ThingspeakReceiver thingspeakReceiver;
int thingsSpeakCounter = 0;

#include "shiftrConnector.h"
ShiftrConnector shiftrConnector;
int shiftrCounter = 0;
/////////////////////////////////////////////

#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Wire.h>

#define PIN_LED    13

Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  pinMode(PIN_LED, OUTPUT);

  Bridge.begin(); //Yun Bridge
  logger->init();

  // init 7-segments matrix
  matrix.begin(0x70);
  matrix.setBrightness(2);
  displayCounter(0);

  //setup the IoT platforms
  logger->log("Start setup connection with IoT platforms...\n");
  thingspeakReceiver.init();
  shiftrConnector.init();

  //Everything seems to be ok, let's start !
  logger->log("\nBottle Opener up, Let's start to play :) !!!\n");

  //highlight blue led just to prevent everything is OK. Useful when logs are disabled
  digitalWrite(PIN_LED, HIGH);
}

/**
   Arduino Loop
*/
void loop() {
  //need to refresh shiftr API in order to send and receive new messages
  shiftrConnector.loop();

  thingsSpeakCounter = thingspeakReceiver.receiveCounter();
  shiftrCounter = shiftrConnector.receiveMessage();

  //display whatever counter, they should be the same, independently of the platform
  displayCounter(shiftrCounter);

  delay(10);
}

/**
   Display Counter on è
*/
void displayCounter(int counter) {
  matrix.print(counter);
  matrix.writeDisplay();
}


#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

  // initialize the M5Stack object
  M5.begin();

  // Lcd display
  M5.Lcd.println("This is software power off demo");
  M5.Lcd.println("Press the button A to power off.");

  // Set the wakeup button
  M5.Power.setWakeupButton(BUTTON_A_PIN);
}

// the loop routine runs over and over again forever
void loop() {

  if(M5.BtnA.wasPressed()) {
    M5.Power.powerOFF();
  }

  M5.update();
}

Remove settin wakeup button from poserOFF example

#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

  // initialize the M5Stack object
  M5.begin();

  // Lcd display
  M5.Lcd.println("This is software power off demo");
  M5.Lcd.println("Press the button A to power off.");
}

// the loop routine runs over and over again forever
void loop() {

  if(M5.BtnA.wasPressed()) {
    M5.Power.powerOFF();
  }

  M5.update();
}


#include <Bridge.h>

#include "thingspeakReceiver.h"
ThingspeakReceiver thingspeakReceiver;

#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Wire.h>

#define PIN_LED_KO    12
#define PIN_LED_OK    13

Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  pinMode(PIN_LED_KO, OUTPUT);
  pinMode(PIN_LED_OK, OUTPUT);

  _setKO();

  Bridge.begin(); //Yun Bridge
  Serial.begin(9600);
  while (!Serial);

  matrix.begin(0x70);
  matrix.setBrightness(2);
  displayCounter(0);

  thingspeakReceiver.init();

  Serial.println("Counter Up !!!");

  _setOK();

}

void loop() {
  int counter = thingspeakReceiver.receiveCounter();

  displayCounter(counter);

  delay(100);
}

void displayCounter(int counter) {
  matrix.print(counter);
  matrix.writeDisplay();

  Serial.println(counter);
}

void _setOK() {
  digitalWrite(PIN_LED_KO, LOW);
  digitalWrite(PIN_LED_OK, HIGH);
}

void _setKO() {
  digitalWrite(PIN_LED_OK, LOW);
  digitalWrite(PIN_LED_KO, HIGH);
}

Remove non-necessary code for the demo

#include <Bridge.h>

#include "logger.h"

#include "thingspeakReceiver.h"
ThingspeakReceiver thingspeakReceiver;

#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Wire.h>

#define PIN_LED    13

Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  pinMode(PIN_LED, OUTPUT);

  Bridge.begin(); //Yun Bridge
  logger->init();

  // init 7-segments matrix
  matrix.begin(0x70);
  matrix.setBrightness(2);
  displayCounter(0);

  //setup the IoT platforms
  logger->log("Start setup connection with IoT platforms...\n");
  thingspeakReceiver.init();

  //Everything seems to be ok, let's start !
  logger->log("\nBottle Opener up, Let's start to play :) !!!\n");

  //highlight blue led just to prevent everything is OK. Useful when logs are disabled
  digitalWrite(PIN_LED, HIGH);
}

/**
   Arduino Loop
*/
void loop() {
  int counter = thingspeakReceiver.receiveCounter();

  displayCounter(counter);

  delay(500);
}

/**
   Display Counter on è
*/
void displayCounter(int counter) {
  matrix.print(counter);
  matrix.writeDisplay();
}


#include <SPI.h>

#define SPI_READ_CMD 0x03
#define CS_PIN 10

unsigned int num_bytes;
unsigned int i;

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

  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);
  SPI.begin();
}

void read_eeprom(unsigned int num_bytes) {
  unsigned int addr;
  byte resp;

  digitalWrite(CS_PIN, LOW);

  /* transmit read command with 3 byte start address */
  SPI.transfer(SPI_READ_CMD);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  SPI.transfer(0x00);

  for (addr = 0; addr < num_bytes; addr++) {
    resp = SPI.transfer(0xff);
    Serial.write(resp);
  }
  digitalWrite(CS_PIN, HIGH);
}

void loop() {

  /* wait for the integer with the requested number of bytes */
  if (Serial.available() == 4) {
    num_bytes = 0;

    /* merge four bytes to single integer */
    for (i = 0; i < 4; i++)
      num_bytes |=  Serial.read() << (i * 8);

    read_eeprom(num_bytes);
  }
}

Convert global variables to local

#include <SPI.h>

#define SPI_READ_CMD 0x03
#define CS_PIN 10

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

  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);
  SPI.begin();
}

void read_eeprom(unsigned int num_bytes) {
  unsigned int addr;
  byte resp;

  digitalWrite(CS_PIN, LOW);

  /* transmit read command with 3 byte start address */
  SPI.transfer(SPI_READ_CMD);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  SPI.transfer(0x00);

  for (addr = 0; addr < num_bytes; addr++) {
    resp = SPI.transfer(0xff);
    Serial.write(resp);
  }
  digitalWrite(CS_PIN, HIGH);
}

void loop() {
  unsigned int num_bytes;
  unsigned int i;

  /* wait for the integer with the requested number of bytes */
  if (Serial.available() == 4) {
    num_bytes = 0;

    /* merge four bytes to single integer */
    for (i = 0; i < 4; i++)
      num_bytes |=  Serial.read() << (i * 8);

    read_eeprom(num_bytes);
  }
}


#include <Wire.h>
#include <LiquidCrystal_I2C.h>

static constexpr unsigned long TimeChunk = 2 * 1000;

static LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
static unsigned long endTime;
static bool previousPressed;

void setup()
{
	lcd.begin(16,2);
	lcd.backlight();

	pinMode(A0, INPUT_PULLUP);
	delay(10);

	endTime = millis() + 10000 * TimeChunk;
	previousPressed = false;
}

void loop()
{
	lcd.setCursor(0,0);

	unsigned long currentTime = millis();
	if (currentTime >= endTime)
	{
		lcd.print("GAME OVER!");
	}
	else
	{
		bool currentPressed = digitalRead(A0);
		if (currentPressed && !previousPressed)
		{
			endTime += 10 * TimeChunk;
		}
		previousPressed = currentPressed;

		unsigned long remainingChunk = (endTime - currentTime) / TimeChunk;
		char buf[12];
		lcd.print(itoa(remainingChunk, buf, 10));
	}

	delay(10);
}

Fix ghost press at launch

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

static constexpr unsigned long TimeChunk = 2 * 1000;

static LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
static unsigned long endTime;
static bool previousPressed;

void setup()
{
	lcd.begin(16,2);
	lcd.backlight();

	pinMode(A0, INPUT_PULLUP);
	delay(10);

	endTime = millis() + 10000 * TimeChunk;
	previousPressed = HIGH;
}

void loop()
{
	lcd.setCursor(0,0);

	unsigned long currentTime = millis();
	if (currentTime >= endTime)
	{
		lcd.print("GAME OVER!");
	}
	else
	{
		bool currentPressed = digitalRead(A0);
		if (currentPressed && !previousPressed)
		{
			endTime += 10 * TimeChunk;
		}
		previousPressed = currentPressed;

		unsigned long remainingChunk = (endTime - currentTime) / TimeChunk;
		char buf[12];
		lcd.print(itoa(remainingChunk, buf, 10));
	}

	delay(10);
}


#include "pn532_i2c_particle/pn532_i2c_particle.h"
#include "pn532_i2c_particle/PN532.h"
#include "pn532_i2c_particle/NfcAdapter.h"

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);

void setup(void) {
    Serial.begin(9600);
    Serial.println("NDEF Reader");
    nfc.begin();
}

void loop(void) {
    Serial.println("\nScan a NFC tag\n");
    if (nfc.tagPresent())
    {
        NfcTag tag = nfc.read();
        //tag.print();
        if(tag.hasNdefMessage()){
                NdefMessage tagMessage = tag.getNdefMessage();
                int i;
                for (i = 0; i < tagMessage.getRecordCount()   ; i++)  {
                         //
                         NdefRecord tagRecord = tagMessage.getRecord(i);
                         tagRecord.print();

                }
        }
    }
    delay(5000);
}

Update readTag to fetch just the payload from the messages on the tag

#include "pn532_i2c_particle/pn532_i2c_particle.h"
#include "pn532_i2c_particle/PN532.h"
#include "pn532_i2c_particle/NfcAdapter.h"

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);

void setup(void) {
    Serial.begin(9600);
    Serial.println("NDEF Reader");
    nfc.begin();
}

void loop(void) {
    Serial.println("\nScan a NFC tag\n");
    if (nfc.tagPresent())
    {
        NfcTag tag = nfc.read();
        if(tag.hasNdefMessage()){
                NdefMessage tagMessage = tag.getNdefMessage();
                int i;
                for (i = 0; i < tagMessage.getRecordCount()   ; i++)  {
                         //
                         NdefRecord tagRecord = tagMessage.getRecord(i);
                         tagRecord.print();

                }
        }
    }
    delay(5000);
}


#include "Wire.h"
#include "SPI.h"
#include "MINDS-i-Drone.h"
#include "platforms/Quadcopter.h"

void setup(){
    calibrateESCs();
}
void loop(){
    output.stop();
}

Disable the output after calibrating instead of deprecated stop

#include "Wire.h"
#include "SPI.h"
#include "MINDS-i-Drone.h"
#include "platforms/Quadcopter.h"

void setup(){
    calibrateESCs();
    output.disable();
}
void loop(){
}


#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

  // initialize the M5Stack object
  M5.begin();

  // Lcd display
  M5.Lcd.println("This is software power off demo");
  M5.Lcd.println("Press the button A to power off.");

  // Set the wakeup button
  M5.setWakeupButton(BUTTON_A_PIN);
}

// the loop routine runs over and over again forever
void loop() {

  if(M5.BtnA.wasPressed()) {
    M5.powerOFF();
  }

  M5.update();
}

Update poser off example for new api.

#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

  // initialize the M5Stack object
  M5.begin();

  // Lcd display
  M5.Lcd.println("This is software power off demo");
  M5.Lcd.println("Press the button A to power off.");

  // Set the wakeup button
  M5.Power.setWakeupButton(BUTTON_A_PIN);
}

// the loop routine runs over and over again forever
void loop() {

  if(M5.BtnA.wasPressed()) {
    M5.Power.deepSleep();
  }

  M5.update();
}


#include "lcd.h"
#include "sensor.h"

void setup() {
  LCD::setup();
  LCD::helloworld();
  // put your setup code here, to run once:

}

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

}

Remove useless comments from ino

#include "lcd.h"
#include "sensor.h"

void setup() {
  LCD::setup();
  LCD::helloworld();
}

void loop() {
}


#include "receiver.h"

Receiver rx1 = Receiver(2, 3, 4);
Receiver rx2 = Receiver(2, 3, 5);
Receiver rx3 = Receiver(2, 3, 6);
Receiver rx4 = Receiver(2, 3, 7);

void setup() {
    // Wait for modules to settle.
    delay(1000);

    // Set to race frequencies.
    rx1.setFrequency(5665);
    rx2.setFrequency(5745);
    rx3.setFrequency(5885);
    rx4.setFrequency(5945);
}

void loop() {
    // Do nothing.
    delay(1000);
}

Add some delays between setting channels + flash LED

#include "receiver.h"

Receiver rx1 = Receiver(2, 3, 4);
Receiver rx2 = Receiver(2, 3, 5);
Receiver rx3 = Receiver(2, 3, 6);
Receiver rx4 = Receiver(2, 3, 7);

void setup() {
    // Wait for modules to settle.
    delay(2000);

    // Set to race frequencies.
    rx1.setFrequency(5805);
    delay(500);
    rx2.setFrequency(5745);
    delay(500);
    rx3.setFrequency(5885);
    delay(500);
    rx4.setFrequency(5945);
}

void loop() {
    // Flash the LED.
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);
}


#include "button.h"
#include "led.h"
#include "screen.h"
#include "game.h"
#include "clock.h"
#include "const.h"
#include "controller.h"
#include "flasher.h"
#include "logger.h"

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

  //Attach interrupt for 64 button shield
  attachInterrupt(digitalPinToInterrupt(P_BUTTON_INTERRUPT), button_ISR, FALLING);

  //Generate new random seed
  randomSeed(analogRead(0));

  led_setup();
  flasher_setup();
  clock_setup();
  logger(LOGGER_TYPE_INFO, "main", "Setup done");
}

void loop() {
  screen_display("READY");

  led_setState(1, LED_STATE_FLASHING);
  button_wait(1);

  game_start();
}

Change flashing button to 0 from 1

#include "button.h"
#include "led.h"
#include "screen.h"
#include "game.h"
#include "clock.h"
#include "const.h"
#include "controller.h"
#include "flasher.h"
#include "logger.h"

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

  //Attach interrupt for 64 button shield
  attachInterrupt(digitalPinToInterrupt(P_BUTTON_INTERRUPT), button_ISR, FALLING);

  //Generate new random seed
  randomSeed(analogRead(0));

  led_setup();
  flasher_setup();
  clock_setup();
  logger(LOGGER_TYPE_INFO, "main", "Setup done");
}

void loop() {
  screen_display("READY");

  led_setState(0, LED_STATE_FLASHING);
  button_wait(0);

  game_start();
}


#include "button.h"
#include "led.h"
#include "screen.h"
#include "game.h"
#include "timer.h"
#include "const.h"
#include "controller.h"
#include "flasher.h"
#include "logger.h"
#include "helper.h"

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

  //Generate new random seed
  randomSeed(analogRead(0));

  //Setup
  button::setup();
  led::setup();
  flasher::setup();
  timer::setup();
  logger::log(logger::TYPE_INFO, "main", "Setup done");
}

void loop() {
  screen::display("READY");

  //Wait for center button to be pressed
  led::setState(0, led::STATE_FLASHING);
  button::wait(0);
  led::setState(0, led::STATE_OFF);

  //Start game
  game::start();
  helper::waitTime(5000);
}

Move main to setup to not repeat

#include "button.h"
#include "led.h"
#include "screen.h"
#include "game.h"
#include "timer.h"
#include "const.h"
#include "controller.h"
#include "flasher.h"
#include "logger.h"
#include "helper.h"

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

  //Generate new random seed
  randomSeed(analogRead(0));

  //Setup
  button::setup();
  led::setup();
  flasher::setup();
  timer::setup();
  logger::log(logger::TYPE_INFO, "main", "Setup done");

  screen::display("READY");

  //Wait for center button to be pressed
  led::setState(0, led::STATE_FLASHING);
  button::wait(0);
  led::setState(0, led::STATE_OFF);

  //Start game
  game::start();
  helper::waitTime(5000);
}

void loop() {

}


/*
  Author: Andrea Stagi <stagi.andrea@gmail.com>
  Example: ReadAll
  Description: fetch all devices and relative temperatures
  on the wire bus on pin 5 and send them via serial port.
*/

#include <OneWire.h>
#include <DSTemperature.h>

DSTemperature ds(5);  // on pin 5

void setup(void) {
  Serial.begin(9600);
  ds.begin();
}

void sendAddress(DSAddress ds) {
  for(int i = 0 ; i < 8 ; i++) {
    Serial.print(ds.value[i], HEX);
    Serial.print(" ");
  }
  Serial.println();
}

void loop(void) {
  for(int i = 0 ; i < ds.getDeviceCount() ; i++) {
    Serial.println("-------------------------------------------");
    Serial.print("DEVICE ADDRESS:    ");
    sendAddress(ds.getAddressFromIndex(i));
    Serial.print("TEMPERATURE VALUE: ");
    Serial.print(ds.getCelsius(i));
    Serial.println(" C");
  }

  /*
    TODO: try to get index from 28 DA E5 D1 3 0 0 77 and 28 DA 19 0 0 0 20 32
  */
}

Use ds_addr instead of ds

/*
  Author: Andrea Stagi <stagi.andrea@gmail.com>
  Example: ReadAll
  Description: fetch all devices and relative temperatures
  on the wire bus on pin 5 and send them via serial port.
*/

#include <OneWire.h>
#include <DSTemperature.h>

DSTemperature ds(5);  // on pin 5

void setup(void) {
  Serial.begin(9600);
  ds.begin();
}

void sendAddress(DSAddress ds_addr) {
  for(int i = 0 ; i < 8 ; i++) {
    Serial.print(ds_addr.value[i], HEX);
    Serial.print(" ");
  }
  Serial.println();
}

void loop(void) {
  for(int i = 0 ; i < ds.getDeviceCount() ; i++) {
    Serial.println("-------------------------------------------");
    Serial.print("DEVICE ADDRESS:    ");
    sendAddress(ds.getAddressFromIndex(i));
    Serial.print("TEMPERATURE VALUE: ");
    Serial.print(ds.getCelsius(i));
    Serial.println(" C");
  }

  /*
    TODO: try to get index from 28 DA E5 D1 3 0 0 77 and 28 DA 19 0 0 0 20 32
  */
}


#include "Constants.h"
#include "Display.h"
#include "Buttons.h"

Display display;
Buttons buttons;

unsigned long start_time = 0;

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  start_time = millis();
}

void loop() {

  unsigned long current_time = millis() - start_time;
  display.displayTime( current_time / 1000 );

  int button = buttons.get_button_press();
  if ( button == BUTTON_RESTART ) {
    // reset the start time
    start_time = millis();
  }

}

Change code to count down instead of up

#include "Constants.h"
#include "Display.h"
#include "Buttons.h"

Display display;
Buttons buttons;

unsigned long countdown_ends;
unsigned long countdown_duration;

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  countdown_ends = 0;
  countdown_duration = 900000; // 15 mins in ms
  countdown_ends = millis() + countdown_duration;
}

void loop() {

  long time_remaining = countdown_ends - millis();
  Serial.println(countdown_duration);
  display.displayTime( time_remaining / 1000 );

  int button = buttons.get_button_press();
  if ( button == BUTTON_RESTART ) {
    // reset the start time
    countdown_ends = millis() + countdown_duration + 500;
  }

}


#include <ros.h>

ros::NodeHandle nh;
std_msgs::Float64 state;

void callback(const std_msgs::Float64 cmd);
{

}

ros::Publisher state_pub("state", &state);
ros::Subscriber<std_msgs::Float64> cmd_sub("command", &callback);

void setup()
{
  nh.initNode();
  nh.advertise(state_pub);

}

void loop()
{
  nh.spinOnce();

  state[0] = port_servo_pos;
  state[1] = stbd_servo_pos;

  state_pub.publish(&state);

  delay(33);
}

Add i2c to thruster control sketch.

#include <Wire.h>

#include <ros.h>
#include <std_msgs/Int8.h>

ros::NodeHandle nh;

std_msgs::Int8 state;

ros::Publisher state_pub("state", &state);

void callback(const std_msgs::Int8 &cmd)
{
  state.data = 0;
  state_pub.publish(&state);

  Wire.beginTransmission(3);
  Wire.write(0x10);
  Wire.write(0x10);
  Wire.write(0x10);
  Wire.endTransmission();

  delay(5);

  Wire.beginTransmission(3);
  Wire.write(0x20);
  Wire.write(0x20);
  Wire.write(0x20);
  Wire.endTransmission();

  delay(5);

  Wire.requestFrom(0x10, 4);

  while(Wire.available())
  {
    char c = Wire.read();
    state.data = c;
    state_pub.publish(&state);
  }
}

ros::Subscriber<std_msgs::Int8> cmd_sub("command", &callback);

void setup()
{
  Wire.begin();

  nh.initNode();
  nh.advertise(state_pub);

}

void loop()
{
  nh.spinOnce();

  delay(33);
}


/**
 * Use this sketch to talk directly to the LoRa module.
 *
 * In Serial Monitor, select "Both NL & CR" and "9600 baud" in
 * the bottom right dropdowns and send command a command like:
 *
 * mac get deveui
 * sys reset
 */

#define loraSerial Serial1
#define debugSerial Serial

void setup() {
  loraSerial.begin(57600);
  debugSerial.begin(9600);
}

void loop() {
  while (debugSerial.available()) {
    loraSerial.write(debugSerial.read());
  }
  while (loraSerial.available()) {
    debugSerial.write(loraSerial.read());
  }
}

Update pass through to work with Node

/**
 * Use this sketch to talk directly to the LoRa module.
 *
 * In Serial Monitor, select "Both NL & CR" and "115200 baud" in
 * the bottom right dropdowns and send command a command like:
 *
 * mac get deveui
 * sys reset
 */

#define loraSerial Serial1
#define debugSerial Serial

void setup() {
  while(!debugSerial || !loraSerial);

  debugSerial.begin(115200);
  delay(1000);

  loraSerial.begin(57600);
}

void loop() {
  while (debugSerial.available()) {
    loraSerial.write(debugSerial.read());
  }
  while (loraSerial.available()) {
    debugSerial.write(loraSerial.read());
  }
}


#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

  // initialize the M5Stack object
  M5.begin();

  // Lcd display
  M5.Lcd.println("This is software power off demo");
  M5.Lcd.println("Press the button A to power off.");

  // Set the wakeup button
  M5.Power.setWakeupButton(BUTTON_A_PIN);
}

// the loop routine runs over and over again forever
void loop() {

  if(M5.BtnA.wasPressed()) {
    M5.Power.deepSleep();
  }

  M5.update();
}

Use powerOFF on powerOFF example

#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up
void setup(){

  // initialize the M5Stack object
  M5.begin();

  // Lcd display
  M5.Lcd.println("This is software power off demo");
  M5.Lcd.println("Press the button A to power off.");

  // Set the wakeup button
  M5.Power.setWakeupButton(BUTTON_A_PIN);
}

// the loop routine runs over and over again forever
void loop() {

  if(M5.BtnA.wasPressed()) {
    M5.Power.powerOFF();
  }

  M5.update();
}


/*
This example is basically the same as SimpleSerialPrinter but utilize
the EnableInterrupt library.  EnableInterrupt make pin change
interrupts available and thus allows to use arbitrary pins.
*/

// EnableInterrupt from https://github.com/GreyGnome/EnableInterrupt
// include it before RadiationWatch.h
#include "EnableInterrupt.h"
#include "RadiationWatch.h"

// Use any pin as you like
// Here: signPin = 5, noisePin = 6
RadiationWatch radiationWatch(5, 6);

void onRadiation()
{
  Serial.println("A wild gamma ray appeared");
  Serial.print(radiationWatch.uSvh());
  Serial.print(" uSv/h +/- ");
  Serial.println(radiationWatch.uSvhError());
}

void onNoise()
{
  Serial.println("Argh, noise, please stop moving");
}

void setup()
{
  Serial.begin(9600);
  radiationWatch.setup();
  // Register the callbacks.
  radiationWatch.registerRadiationCallback(&onRadiation);
  radiationWatch.registerNoiseCallback(&onNoise);
}

void loop()
{
  radiationWatch.loop();
}

Add link to EnableInterupt pin beastiary

/*
This example is basically the same as SimpleSerialPrinter but utilize
the EnableInterrupt library.

The EnableInterrupt library make pin change interrupts available and
thus allows to use arbitrary pins.

See a list of pins supported here:
https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#pin--port-bestiary

You can install the library from the Arduino Library Manager:
http://www.arduinolibraries.info/libraries/enable-interrupt
*/

// EnableInterrupt from https://github.com/GreyGnome/EnableInterrupt
// include it before RadiationWatch.h
#include "EnableInterrupt.h"
#include "RadiationWatch.h"

// Use any pin as you like
// Here: signPin = 5, noisePin = 6
RadiationWatch radiationWatch(5, 6);

void onRadiation()
{
  Serial.println("A wild gamma ray appeared");
  Serial.print(radiationWatch.uSvh());
  Serial.print(" uSv/h +/- ");
  Serial.println(radiationWatch.uSvhError());
}

void onNoise()
{
  Serial.println("Argh, noise, please stop moving");
}

void setup()
{
  Serial.begin(9600);
  radiationWatch.setup();
  // Register the callbacks.
  radiationWatch.registerRadiationCallback(&onRadiation);
  radiationWatch.registerNoiseCallback(&onNoise);
}

void loop()
{
  radiationWatch.loop();
}


#include "pn532_i2c_particle/pn532_i2c_particle.h"
#include "pn532_i2c_particle/PN532.h"
#include "pn532_i2c_particle/NfcAdapter.h"

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);

void setup(void) {
    Serial.begin(9600);
    Serial.println("NDEF Reader");
    nfc.begin();
}

void loop(void) {
    Serial.println("\nScan a NFC tag\n");
    if (nfc.tagPresent())
    {
        NfcTag tag = nfc.read();
        //tag.print();
        if(tag.hasNdefMessage()){
                NdefMessage tagMessage = tag.getNdefMessage();

        }
        }
    }
    delay(5000);
}

Update readTag to fetch just the payload from the messages on the tag

#include "pn532_i2c_particle/pn532_i2c_particle.h"
#include "pn532_i2c_particle/PN532.h"
#include "pn532_i2c_particle/NfcAdapter.h"

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);

void setup(void) {
    Serial.begin(9600);
    Serial.println("NDEF Reader");
    nfc.begin();
}

void loop(void) {
    Serial.println("\nScan a NFC tag\n");
    if (nfc.tagPresent())
    {
        NfcTag tag = nfc.read();
        //tag.print();
        if(tag.hasNdefMessage()){
                NdefMessage tagMessage = tag.getNdefMessage();
                int i;
                for (i = 0; i < tagMessage.getRecordCount()   ; i++)  {
                         //
                         NdefRecord tagRecord = tagMessage.getRecord(i);
                         tagRecord.print();

                }
        }
    }
    delay(5000);
}


#include <FastLED.h>

#define WIDTH 16
#define HEIGHT 16
#define NUM_LEDS (WIDTH * HEIGHT)
#define PIN 6
#define BAUD 115200
#define BRIGHTNESS 32

CRGB leds[NUM_LEDS];
int r, g, b;
int x, y, yy;

void setup() {
  FastLED.addLeds<WS2812B, PIN>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);
  Serial.begin(BAUD);
  FastLED.show();
}

void loop() {
  Serial.write("R");

  for (x = 0; x < WIDTH; x++) {
    for (y = 0; y < HEIGHT; y++) {
      while (Serial.available() < 3);
      r = Serial.read();
      g = Serial.read();
      b = Serial.read();
      if (x % 2 == 0) {
        yy = HEIGHT - y - 1;
      } else {
        yy = y;
      }
      leds[yy + x * HEIGHT] = CRGB(g, r, b);  // Seems to be running as GRB, not RGB
    }
  }
  FastLED.show();
}

Reduce led brightness to save my eyes.

#include <FastLED.h>

#define WIDTH 16
#define HEIGHT 16
#define NUM_LEDS (WIDTH * HEIGHT)
#define PIN 6
#define BAUD 115200
#define BRIGHTNESS 8

CRGB leds[NUM_LEDS];
int r, g, b;
int x, y, yy;

void setup() {
  FastLED.addLeds<WS2812B, PIN>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);
  Serial.begin(BAUD);
  FastLED.show();
}

void loop() {
  Serial.write("R");

  for (x = 0; x < WIDTH; x++) {
    for (y = 0; y < HEIGHT; y++) {
      while (Serial.available() < 3);
      r = Serial.read();
      g = Serial.read();
      b = Serial.read();
      if (x % 2 == 0) {
        yy = HEIGHT - y - 1;
      } else {
        yy = y;
      }
      leds[yy + x * HEIGHT] = CRGB(g, r, b);  // Seems to be running as GRB, not RGB
    }
  }
  FastLED.show();
}


#include <MiniRobot.h>

MiniRobot robot;

void setup() {
}

void loop() {
  if (robot.leftEdge() && robot.distanceToEnemy() == 0) {
    robot.leftBack();
  } else {
    robot.leftForward();
  }
  if (robot.rightEdge() && robot.distanceToEnemy() == 0) {
    robot.rightBack();
  } else {
    robot.rightForward();
  }
}

Use interrupt to IR sensors

#include <MiniRobot.h>

MiniRobot robot;

byte status = 2;
/*
0 - don't need changes;
1 - counter only
2 - drive straight back;
3 - drive straight forward;
4 - spin around
 - enemy forward;
*/

int count = 0;

void setup() {
  PCMSK1 |= bit(0) | bit(1);
  PCIFR  |= bit(1);
  PCICR  |= bit(1);
  pinMode(A0,INPUT);   // set Pin as Input (default)
  digitalWrite(A0,HIGH);  // enable pullup resistor
  pinMode(A1,INPUT);   // set Pin as Input (default)
  digitalWrite(A1,HIGH);  // enable pullup resistor
}

ISR (PCINT1_vect)
{
  if (robot.leftEdge() || robot.rightEdge()) {
    status = 4;
  }
}

void loop() {
  switch (status) {
    case 1:
      count--;
      if (count <= 0) {
        status = 3;
      }
      break;
    case 2:
      robot.back();
      count = 15;
      status = 1;
      break;
    case 3:
      robot.forward();
      status = 0;
      break;
    case 4:
      robot.leftBack();
      robot.rightForward();
      count = 10;
      status = 1;
      break;
  }
}


#include "Watering.h"

void setup () {

  //Init serial connection
  Serial.begin(SERIAL_BAUD);

  //Init LED Pin
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

}

void loop() {

  if ( Serial.available() ) {

    byte command = Serial.read();

    switch( command ) {

      case WATER_LEVEL:
          break;
      case SUNLIGHT_LEVEL:
          break;
      case RELAY_ON:
          digitalWrite(LED_PIN, HIGH);
          break;
      case RELAY_OFF:
          digitalWrite(LED_PIN, LOW);
          break;
      default:
          break;

    }
  }
}

Send a response after the Arduino has completed its work.

#include "Watering.h"

void setup () {

  //Init serial connection
  Serial.begin(SERIAL_BAUD);

  //Init LED Pin
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

}

void loop() {

  if ( Serial.available() ) {

    byte command = Serial.read();
    byte output[4];
    byte numBytes = 0;

    switch( command ) {

      case WATER_LEVEL:
          break;
      case SUNLIGHT_LEVEL:
          break;
      case RELAY_ON:
          digitalWrite(LED_PIN, HIGH);

          // Prepping to send a response
          output[0] = command;
          output[1] = 0;
          numBytes = 2;
          break;
      case RELAY_OFF:
          digitalWrite(LED_PIN, LOW);

          // Prepping to send a response
          output[0] = command;
          output[1] = 0;
          numBytes = 2;
          break;
      default:
          break;

    }

    //Sending a response after the command has completed
    Serial.write(output, numBytes);

  }
}


/*
Pines of the first sensor.
*/
#define S1echo 7
#define S1trig 8

/*
Pines of the second sensor.
*/
#define S2echo 10
#define S2trig 11

long duration, distance;
void setup() {
  /*
  Setup of the echo & trig of everysensor.
  */
  pinMode(S1echo, INPUT);
  //pinMode(S2echo, INPUT);

  pinMode(S1trig, OUTPUT);
  //pinMode(S2trig, OUTPUT);

}

void loop() {
  printReadings("Testing",0);
  estimateDistance(S1trig, S1echo);
  delayMicroseconds(1000);
}

void printReadings(String label, long value){
  String phrase = label+": "+value;
  Serial.print(phrase);
}

/*
Estimate the distance received from the ultrasonic sensor.
*/
int estimateDistance(int trig, int echo){
  digitalWrite(trig,LOW);
  delayMicroseconds(2);

  digitalWrite(trig,HIGH);
  delayMicroseconds(10);

  digitalWrite(trig,LOW);

  //Claculate Duration of pulse.
  duration = pulseIn(echo,HIGH);
  printReadings("Duration", duration);

  //Distance in centimeters
  distance = duration/58.2;
  printReadings("Distance", distance);

  return distance;
}

Change on Serial stuff to show data

/*
Pines of the first sensor.
*/
#define S1echo 7
#define S1trig 8

/*
Pines of the second sensor.
*/
#define S2echo 10
#define S2trig 11

long duration, distance;
void setup() {
  Serial.begin(9600);
  /*
  Setup of the echo & trig of everysensor.
  */
  pinMode(S1echo, INPUT);
  //pinMode(S2echo, INPUT);

  pinMode(S1trig, OUTPUT);
  //pinMode(S2trig, OUTPUT);

}

void loop() {
  printString("Testing");
  estimateDistance(S1trig, S1echo);
  delay(10000);
}

void printReadings(String label, long value){
  String phrase = label+": "+value;
  printString(phrase);
}
void printString(String phrase){
  Serial.println(phrase);
  Serial.println(" ");
}
/*
Estimate the distance received from the ultrasonic sensor.
*/
int estimateDistance(int trig, int echo){
  digitalWrite(trig,LOW);
  delayMicroseconds(2);

  digitalWrite(trig,HIGH);
  delayMicroseconds(10);

  digitalWrite(trig,LOW);

  //Calculate Duration of pulse.
  duration = pulseIn(echo,HIGH);
  printReadings("Duration", duration);

  //Distance in centimeters
  distance = duration/58.2;
  printReadings("Distance", distance);

  return distance;
}


/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to use ordinary Arduino Serial
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 **************************************************************
 *            USB HOWTO: http://tiny.cc/BlynkUSB
 **************************************************************/

#define BLYNK_PRINT Serial1
#include <BlynkSimpleSerial.h>

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

void setup()
{
  // Debug prints on pins 39 (RX), 40 (TX)
  Serial1.begin(9600);

  // Blynk will work through Serial
  Serial.begin(9600);
  Blynk.begin(auth, Serial);
}

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

Switch chipKIT UNO32 to use new Stream API

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example shows how to use ordinary Arduino Serial
 * to connect your project to Blynk.
 * Feel free to apply it to any other example. It's simple!
 *
 **************************************************************
 *            USB HOWTO: http://tiny.cc/BlynkUSB
 **************************************************************/

#define BLYNK_PRINT Serial1
#include <BlynkSimpleStream.h>

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

void setup()
{
  // Debug prints on pins 39 (RX), 40 (TX)
  Serial1.begin(9600);

  // Blynk will work through Serial
  Serial.begin(9600);
  Blynk.begin(auth, Serial);
}

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


#include <Homie.h>

const int doorPin = 16;

Bounce debouncer = Bounce(); // Bounce is built into Homie, so you can use it without including it first
unsigned long lastDoorValue = -1;

HomieNode doorNode("door", "door");

void loopHandler() {
  int doorValue = debouncer.read();

  if (doorValue != lastDoorValue) {
     Serial.print("Door is now: ");
     Serial.println(doorValue ? "open" : "close");

     if (Homie.setNodeProperty(doorNode, "open", String(doorValue ? "true" : "false"), true)) {
       lastDoorValue = doorValue;
     } else {
       Serial.println("Sending failed");
     }
  }
}

void setup() {
  pinMode(doorPin, INPUT);
  digitalWrite(doorPin, HIGH);
  debouncer.attach(doorPin);
  debouncer.interval(50);

  Homie.setFirmware("awesome-door", "1.0.0");
  Homie.registerNode(doorNode);
  Homie.setLoopFunction(loopHandler);
  Homie.setup();
}

void loop() {
  Homie.loop();
  debouncer.update();
}

Fix caps in constant example

#include <Homie.h>

const int PIN_DOOR = 16;

Bounce debouncer = Bounce(); // Bounce is built into Homie, so you can use it without including it first
unsigned long lastDoorValue = -1;

HomieNode doorNode("door", "door");

void loopHandler() {
  int doorValue = debouncer.read();

  if (doorValue != lastDoorValue) {
     Serial.print("Door is now: ");
     Serial.println(doorValue ? "open" : "close");

     if (Homie.setNodeProperty(doorNode, "open", String(doorValue ? "true" : "false"), true)) {
       lastDoorValue = doorValue;
     } else {
       Serial.println("Sending failed");
     }
  }
}

void setup() {
  pinMode(PIN_DOOR, INPUT);
  digitalWrite(PIN_DOOR, HIGH);
  debouncer.attach(PIN_DOOR);
  debouncer.interval(50);

  Homie.setFirmware("awesome-door", "1.0.0");
  Homie.registerNode(doorNode);
  Homie.setLoopFunction(loopHandler);
  Homie.setup();
}

void loop() {
  Homie.loop();
  debouncer.update();
}


// Moving Average Example
// Shows how to use an FIR filter as a moving average on a simple
// set of data that can be easily verified by hand.

#include <FIR.h>

// Make an instance of the FIR filter. In this example we'll use
// floating point values and an 8 element filter. For a moving average
// that means an 8 point moving average.
FIR<float, 8> fir;

void setup() {
  Serial.begin(115200); // Start a serial port

  // For a moving average we want all of the coefficients to be unity.
  float coef[8] = { 1., 1., 1., 1., 1., 1., 1., 1.};

  // Set the coefficients
  fir.setFilterCoeffs(coef);

  // The gain should be the number of elements for a moving average.
  float gain = 8;

  // Set the gain
  fir.setGain(gain);
}

void loop() {
  // Calculate the moving average for a time series with the elements.
  // 0, 1, 2, ...., 13, 14, 15
  for (float i=0; i < 16; i++) {
    Serial.println(fir.processReading(i));
  }

  while (true) {}; // Spin forever
}

Change to use automatic gain.

// Moving Average Example
// Shows how to use an FIR filter as a moving average on a simple
// set of data that can be easily verified by hand.

#include <FIR.h>

// Make an instance of the FIR filter. In this example we'll use
// floating point values and an 8 element filter. For a moving average
// that means an 8 point moving average.
FIR<float, 8> fir;

void setup() {
  Serial.begin(115200); // Start a serial port

  // For a moving average we want all of the coefficients to be unity.
  float coef[8] = { 1., 1., 1., 1., 1., 1., 1., 1.};

  // Set the coefficients
  fir.setFilterCoeffs(coef);

  Serial.print("Gain set: ");
  Serial.println(fir.getGain());
}

void loop() {
  // Calculate the moving average for a time series with the elements.
  // 0, 1, 2, ...., 13, 14, 15
  for (float i=0; i < 16; i++) {
    Serial.println(fir.processReading(i));
  }

  while (true) {}; // Spin forever
}


#include <Smartcar.h>

SR04 front;
const int TRIGGER_PIN = 6; //D6
const int ECHO_PIN = 7; //D7

void setup() {
  Serial.begin(9600);
  front.attach(TRIGGER_PIN, ECHO_PIN); //trigger pin, echo pin
}

void loop() {
  Serial.println(front.getDistance());
  delay(100);
}

Update SR04 example to new 5.0 API

#include <Smartcar.h>

const int TRIGGER_PIN = 6; //D6
const int ECHO_PIN = 7; //D7
SR04 front(TRIGGER_PIN, ECHO_PIN, 10);

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

void loop() {
  Serial.println(front.getDistance());
  delay(100);
}


int vinpin = A0;
int voutpin = A1;
int gndpin = A2;
int zpin = A3;
int ypin = A4;
int xpin = A5;

void setup() {
  Serial.begin(115200);
  pinMode(vinpin, OUTPUT); digitalWrite(vinpin, HIGH);
  pinMode(gndpin, OUTPUT); digitalWrite(gndpin, LOW);
  pinMode(voutpin, INPUT);
  pinMode(xpin, INPUT);
  pinMode(ypin, INPUT);
  pinMode(zpin, INPUT);
}

void loop() {
  Serial.print(analogRead(xpin)); Serial.print("\t");
  Serial.print(analogRead(ypin)); Serial.print("\t");
  Serial.print(analogRead(zpin)); Serial.println();
}

Change baud rate to 9600.

int vinpin = A0;
int voutpin = A1;
int gndpin = A2;
int zpin = A3;
int ypin = A4;
int xpin = A5;

void setup() {
  Serial.begin(9600);
  pinMode(vinpin, OUTPUT); digitalWrite(vinpin, HIGH);
  pinMode(gndpin, OUTPUT); digitalWrite(gndpin, LOW);
  pinMode(voutpin, INPUT);
  pinMode(xpin, INPUT);
  pinMode(ypin, INPUT);
  pinMode(zpin, INPUT);
}

void loop() {
  Serial.print(analogRead(xpin)); Serial.print("\t");
  Serial.print(analogRead(ypin)); Serial.print("\t");
  Serial.print(analogRead(zpin)); Serial.println();
}


#include <Wire.h>

// begin SD card libraries
#include <BlockDriver.h>
#include <FreeStack.h>
#include <MinimumSerial.h>
#include <SdFat.h>
#include <SdFatConfig.h>
#include <SysCall.h>
// end SD card libraries

#include "Bmp180.h" // RCR header

File file; // file object
//SdFatSdio sd_card; // MicroSD card

namespace rcr {
namespace level1payload {

void setup() {
  // Start serial communication.
  Serial.begin(9600); // in bits/second
}

void printBmpData(void) {

  Serial.print("Temperature = ");
  Serial.print(bmp_data.temperature);
  Serial.println(" °C");

  Serial.print("Ambient pressure = ");
  Serial.print(bmp_data.ambient_pressure);
  Serial.println(" Pa");

  Serial.print("Pressure altitude = ");
  Serial.print(bmp_data.pressure_altitude);
  Serial.println(" meters");
  Serial.println();
}

void loop() {
  printBmpData();
  delay(1000);
}

} // namespace level1_payload
} // namespace rcr

Implement custom BMP data structure in program

#include <Wire.h>

// begin SD card libraries
#include <BlockDriver.h>
#include <FreeStack.h>
#include <MinimumSerial.h>
#include <SdFat.h>
#include <SdFatConfig.h>
#include <SysCall.h>
// end SD card libraries

#include "Bmp180.h" // RCR header

namespace rcr {
namespace level1payload {

Bmp180 bmp;
File file; // file object
//SdFatSdio sd_card; // MicroSD card

void setup() {
  // Start serial communication.
  Serial.begin(9600); // in bits/second
}

void printBmpData(void) {

  Serial.print("Temperature = ");
  Serial.print(bmp.temperature());
  Serial.println(" °C");

  Serial.print("Ambient pressure = ");
  Serial.print(bmp.ambient_pressure());
  Serial.println(" Pa");

  Serial.print("Pressure altitude = ");
  Serial.print(bmp.pressure_altitude());
  Serial.println(" meters");
  Serial.println();
}

void loop() {
  printBmpData();
  delay(1000);
}

} // namespace level1_payload
} // namespace rcr


#include <stdint.h>

#include "zg01_fsm.h"

#define PIN_CLOCK   2
#define PIN_DATA    3
#define PIN_LED     13

static uint8_t buffer[5];

void setup(void)
{
    // initialize ZG01 pins
    pinMode(PIN_CLOCK, INPUT);
    pinMode(PIN_DATA, INPUT);

    // initialize LED
    pinMode(PIN_LED, OUTPUT);

    // initialize serial port
    Serial.begin(9600);
    Serial.println("Hello world!\n");

    // initialize ZG01 finite state machine
    zg01_init(buffer);
}

void loop(void)
{
    // wait until clock is low
    while (digitalRead(PIN_CLOCK) != LOW);

    // indicate activity on LED
    digitalWrite(PIN_LED, HIGH);

    // sample data and process in the ZG01 state machine
    uint8_t data = (digitalRead(PIN_DATA) == HIGH) ? 1 : 0;
    unsigned long ms = millis();
    bool ready = zg01_process(ms, data);

    // process data if ready
    if (ready) {
        for (int i = 0; i < 5; i++) {
            Serial.print(HEX, buffer[i]);
            Serial.print(" ");
        }
        Serial.println();
    }

    // wait until clock is high again
    while (digitalRead(PIN_CLOCK) == LOW);

    // indicate activity on LED
    digitalWrite(PIN_LED, LOW);
}

Fix order of Serial.println arguments for HEX printing

#include <stdint.h>

#include "zg01_fsm.h"

#define PIN_CLOCK   2
#define PIN_DATA    3
#define PIN_LED     13

static uint8_t buffer[5];

void setup(void)
{
    // initialize ZG01 pins
    pinMode(PIN_CLOCK, INPUT);
    pinMode(PIN_DATA, INPUT);

    // initialize LED
    pinMode(PIN_LED, OUTPUT);

    // initialize serial port
    Serial.begin(9600);
    Serial.println("Hello world!\n");

    // initialize ZG01 finite state machine
    zg01_init(buffer);
}

void loop(void)
{
    // wait until clock is low
    while (digitalRead(PIN_CLOCK) != LOW);

    // indicate activity on LED
    digitalWrite(PIN_LED, HIGH);

    // sample data and process in the ZG01 state machine
    uint8_t data = (digitalRead(PIN_DATA) == HIGH) ? 1 : 0;
    unsigned long ms = millis();
    bool ready = zg01_process(ms, data);

    // process data if ready
    if (ready) {
        for (int i = 0; i < 5; i++) {
            Serial.print(buffer[i], HEX);
            Serial.print(" ");
        }
        Serial.println();
    }

    // wait until clock is high again
    while (digitalRead(PIN_CLOCK) == LOW);

    // indicate activity on LED
    digitalWrite(PIN_LED, LOW);
}


//
// FaBo AmbientLight Brick
//
// brick_i2c_ambientlight
//

#include <Wire.h>
#include "fabo-isl29034.h"

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

  faboAmbientLight.configuration();
  faboAmbientLight.powerOn();
}

void loop()
{
  double ambient = faboAmbientLight.readData();

  Serial.print("Ambient:");
  Serial.println(ambient);
  delay(1000);
}

Update class name. ToDo: search slave address.

//
// FaBo AmbientLight Brick
//
// brick_i2c_ambientlight
//

#include <Wire.h>
#include "fabo-isl29034.h"

FaBoAmbientLight faboAmbientLight;

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

  faboAmbientLight.configuration();
  faboAmbientLight.powerOn();
}

void loop()
{
  double ambient = faboAmbientLight.readData();

  Serial.print("Ambient:");
  Serial.println(ambient);
  delay(1000);
}


// This provides a variable, colour, a function to set the variable from a hex
// string, set_colour, and programs the RGB LED on the spark core to reflect
// the RRGGBB value last programmed.  The default on reboot is black.

// BEWARE: British spelling ahead!

#include "spark-parse.h"

static int colour = 0;

int set_colour(String args)
{
    // parse_hex only likes uppercase
    args.toUpperCase();

    // Parse arg to colour settings
    int val = parse_hex(args);
    if (val != -1) {
        colour = val;
    }

    // Returns the value, if it took, or the previous colour setting, if
    // it didn't.
    return colour;
}

void setup() {
    RGB.control(true);

    Spark.function("set_colour", set_colour);
    Spark.variable("colour", &colour, INT);
}

void loop() {
    // Colour value is the standard RRGGBB layout, which we break up here.
    RGB.color((colour >> 16) & 255, (colour >> 8) & 255, colour & 255);
}

Correct the include path to the one the Spark IDE wants

#include "spark-parse/spark-parse.h"

// This provides a variable, colour, a function to set the variable from a hex
// string, set_colour, and programs the RGB LED on the spark core to reflect
// the RRGGBB value last programmed.  The default on reboot is black.

// BEWARE: British spelling ahead!

static int colour = 0;

int set_colour(String args)
{
    // parse_hex only likes uppercase
    args.toUpperCase();

    // Parse arg to colour settings
    int val = parse_hex(args);
    if (val != -1) {
        colour = val;
    }

    // Returns the value, if it took, or the previous colour setting, if
    // it didn't.
    return colour;
}

void setup() {
    RGB.control(true);

    Spark.function("set_colour", set_colour);
    Spark.variable("colour", &colour, INT);
}

void loop() {
    // Colour value is the standard RRGGBB layout, which we break up here.
    RGB.color((colour >> 16) & 255, (colour >> 8) & 255, colour & 255);
}


/*
  String replace()
  Examples of how to replace characters or substrings of a string

  created 27 July 2010
  modified 2 Apr 2012
  by Tom Igoe

  Hardware Required:
  * MSP-EXP430G2 LaunchPad

  This example code is in the public domain.
*/

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

  // send an intro:
  Serial.println("\n\nString  replace:\n");
  Serial.println();
}

void loop() {
  String stringOne = "<HTML><HEAD><BODY>"";
  Serial.println(stringOne);
  // replace() changes all instances of one substring with another:
  // first, make a copy of th original string:
  String stringTwo = stringOne;
  // then perform the replacements:
  stringTwo.replace("<", "</");
  // print the original:
  Serial.println("Original string: " + stringOne);
  // and print the modified string:
  Serial.println("Modified string: " + stringTwo);

  // you can also use replace() on single characters:
  String normalString = "bookkeeper";
  Serial.println("normal: " + normalString);
  String leetString = normalString;
  leetString.replace('o', '0');
  leetString.replace('e', '3');
  Serial.println("l33tspeak: " + leetString);

  // do nothing while true:
  while(true);
}

Fix typo in string termination

/*
  String replace()
  Examples of how to replace characters or substrings of a string

  created 27 July 2010
  modified 2 Apr 2012
  by Tom Igoe

  Hardware Required:
  * MSP-EXP430G2 LaunchPad

  This example code is in the public domain.
*/

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

  // send an intro:
  Serial.println("\n\nString  replace:\n");
  Serial.println();
}

void loop() {
  String stringOne = "<HTML><HEAD><BODY>";
  Serial.println(stringOne);
  // replace() changes all instances of one substring with another:
  // first, make a copy of th original string:
  String stringTwo = stringOne;
  // then perform the replacements:
  stringTwo.replace("<", "</");
  // print the original:
  Serial.println("Original string: " + stringOne);
  // and print the modified string:
  Serial.println("Modified string: " + stringTwo);

  // you can also use replace() on single characters:
  String normalString = "bookkeeper";
  Serial.println("normal: " + normalString);
  String leetString = normalString;
  leetString.replace('o', '0');
  leetString.replace('e', '3');
  Serial.println("l33tspeak: " + leetString);

  // do nothing while true:
  while(true);
}


const int buttonPin = 2;

int buttonState = 0;

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

void loop() {
  int randNum = random(300);
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) {
    Serial.println(randNum);
  }
  delay(500);
}

Update delay time for arduino button read

const int buttonPin = 2;

int buttonState = 0;

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

void loop() {
  int randNum = random(300);
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) {
    Serial.println(randNum);
    while(buttonState) {
      buttonState = digitalRead(buttonPin);
    }
  }
  delay(50);
}


/*
 Battery indicator on the TFT screen.
 */

#include <ArduinoRobot.h>
#include "RobotBattery.h"

RobotBattery battery = RobotBattery();
int bat_val_prev = 0;

void setup() {

  // initialize the robot
  Robot.begin();

  // initialize the screen
  Robot.beginTFT();

  // Black screen
  Robot.background(0,0,0);

  // Draw the battery icon with white edges.
  battery.beginIcon(255, 255, 255);

}
void loop()
{

  int bat_val = battery.update();
  if (bat_val != bat_val_prev) {
    bat_val_prev = bat_val;
    // Large number center screen
    // Clear
    Robot.stroke(0,0,0);
    Robot.textSize(3);
    Robot.text(bat_val_prev, 15, 50);
    // Write
    Robot.stroke(0,255,0);
    Robot.textSize(3);
    Robot.text(bat_val, 15, 50);

    Robot.textSize(2);
    Robot.text("mV", 92, 58);
  }

  delay(2000);
}

Clear the text before setting the previous value

/*
 Battery indicator on the TFT screen.
 */

#include <ArduinoRobot.h>
#include "RobotBattery.h"

RobotBattery battery = RobotBattery();
int bat_val_prev = 0;

void setup() {

  // initialize the robot
  Robot.begin();

  // initialize the screen
  Robot.beginTFT();

  // Black screen
  Robot.background(0,0,0);

  // Draw the battery icon with white edges.
  battery.beginIcon(255, 255, 255);

}
void loop()
{

  int bat_val = battery.update();
  if (bat_val != bat_val_prev) {

    // Large number center screen
    // Clear
    Robot.stroke(0,0,0);
    Robot.textSize(3);
    Robot.text(bat_val_prev, 15, 50);
    // Write
    Robot.stroke(0,255,0);
    Robot.textSize(3);
    Robot.text(bat_val, 15, 50);

    Robot.textSize(2);
    Robot.text("mV", 92, 58);

    bat_val_prev = bat_val;
  }

  delay(2000);
}