Portland Art Museum triangles

Portland Art Museum triangles

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

--- examples/pam-triangles/pam-triangles.ino
+++ examples/pam-triangles/pam-triangles.ino
@@ -0,0 +1,178 @@
+#include "pixelmap/pixelmap.h"
+#include <FastLED.h>
+#include <Logging.h>
+#include <Audio.h>
+
+// Uncomment to turn off assertions
+#define NDEBUG
+
+// Weird thing I had to do to get the Logging library working with teensy
+extern "C" {
+  int _getpid() { return -1; }
+  int _kill(int pid, int sig) { return -1; }
+  int _write() { return -1; }
+}
+
+#define LOGLEVEL LOG_LEVEL_INFOS
+
+using namespace pixelmap;
+
+
+// Triangles strip, in series, 3 groups of 3 triangles, inner -> outer -> outer
+#define TRIANGLE 55
+#define GROUP TRIANGLE * 3
+#define STRIP GROUP * 3
+
+#define IN_START1 19
+#define IN_START2 37
+#define IN_START3 0
+#define IN_LENGTH1 18
+#define IN_LENGTH2 19
+#define IN_LENGTH3 18
+
+#define OUT1_START1 37
+#define OUT1_START2 0
+#define OUT1_START3 19
+#define OUT1_LENGTH1 18
+#define OUT1_LENGTH2 19
+#define OUT1_LENGTH3 18
+
+#define OUT2_START1 19
+#define OUT2_START2 37
+#define OUT2_START3 0
+#define OUT2_LENGTH1 18
+#define OUT2_LENGTH2 18
+#define OUT2_LENGTH3 19
+
+Input* input;
+
+LEDStrip strip = LEDStrip(STRIP);
+LEDStrip* strips[] = {&strip, &strip, &strip};
+
+// Inner triangles
+int in_starts1[] = {
+  IN_START1 + (GROUP * 0),
+  IN_START2 + (GROUP * 0),
+  IN_START3 + (GROUP * 0)
+};
+int in_starts2[] = {
+  IN_START1 + (GROUP * 1),
+  IN_START2 + (GROUP * 1),
+  IN_START3 + (GROUP * 1)
+};
+int in_starts3[] = {
+  IN_START1 + (GROUP * 2),
+  IN_START2 + (GROUP * 2),
+  IN_START3 + (GROUP * 2)
+};
+int in_lengths[] = {IN_LENGTH1, IN_LENGTH2, IN_LENGTH3};
+
+LEDs leds1 = LEDs(3, strips, in_starts1, in_lengths);
+LEDs leds2 = LEDs(3, strips, in_starts2, in_lengths);
+LEDs leds3 = LEDs(3, strips, in_starts3, in_lengths);
+
+LEDs* inner_leds[] = {&leds1, &leds2, &leds3};
+
+// First outer triangle
+int out1_starts1[] = {
+  OUT1_START1 + TRIANGLE + (GROUP * 0),
+  OUT1_START2 + TRIANGLE + (GROUP * 0),
+  OUT1_START3 + TRIANGLE + (GROUP * 0)
+};
+int out1_starts2[] = {
+  OUT1_START1 + TRIANGLE + (GROUP * 1),
+  OUT1_START2 + TRIANGLE + (GROUP * 1),
+  OUT1_START3 + TRIANGLE + (GROUP * 1)
+};
+int out1_starts3[] = {
+  OUT1_START1 + TRIANGLE + (GROUP * 2),
+  OUT1_START2 + TRIANGLE + (GROUP * 2),
+  OUT1_START3 + TRIANGLE + (GROUP * 2)
+};
+int out1_lengths[] = {OUT1_LENGTH1, OUT1_LENGTH2, OUT1_LENGTH3};
+
+LEDs leds4 = LEDs(3, strips, out1_starts1, out1_lengths);
+LEDs leds5 = LEDs(3, strips, out1_starts2, out1_lengths);
+LEDs leds6 = LEDs(3, strips, out1_starts3, out1_lengths);
+
+// Second outer triangle
+int out2_starts1[] = {
+  OUT2_START1 + (TRIANGLE * 2) + (GROUP * 0),
+  OUT2_START2 + (TRIANGLE * 2) + (GROUP * 0),
+  OUT2_START3 + (TRIANGLE * 2) + (GROUP * 0)
+};
+int out2_starts2[] = {
+  OUT2_START1 + (TRIANGLE * 2) + (GROUP * 1),
+  OUT2_START2 + (TRIANGLE * 2) + (GROUP * 1),
+  OUT2_START3 + (TRIANGLE * 2) + (GROUP * 1)
+};
+int out2_starts3[] = {
+  OUT2_START1 + (TRIANGLE * 2) + (GROUP * 2),
+  OUT2_START2 + (TRIANGLE * 2) + (GROUP * 2),
+  OUT2_START3 + (TRIANGLE * 2) + (GROUP * 2)
+};
+int out2_lengths[] = {OUT2_LENGTH1, OUT2_LENGTH2, OUT2_LENGTH3};
+
+LEDs leds7 = LEDs(3, strips, out2_starts1, out2_lengths);
+LEDs leds8 = LEDs(3, strips, out2_starts2, out2_lengths);
+LEDs leds9 = LEDs(3, strips, out2_starts3, out2_lengths);
+
+LEDs* outer_leds[] = {&leds4, &leds5, &leds6, &leds7, &leds8, &leds9};
+
+Visualization* viz;
+
+TriangleAnimation* anim1;
+TriangleAnimation* anim2;
+
+// Audio shield setup
+AudioInputI2S audio;
+AudioAnalyzePeak peak;
+AudioAnalyzeNoteFrequency freq;
+AudioConnection patchCord1(audio, peak);
+AudioConnection patchCord2(audio, freq);
+AudioControlSGTL5000 audioShield;
+
+void setup() {
+  Log.Init(LOGLEVEL, 9600);
+  delay(1000);
+  Log.Info("Starting setup()\n");
+  Serial.flush();
+  delay(1000);
+
+  AudioMemory(5);
+  audioShield.enable();
+  audioShield.inputSelect(AUDIO_INPUT_MIC);
+  audioShield.micGain(50);
+
+  input = new AudioShieldInput(&peak);
+
+  viz = new RippleVisualization(input, 150, 1);
+
+  anim1 = new TriangleAnimation(viz, inner_leds, 3);
+  anim2 = new TriangleAnimation(viz, outer_leds, 6);
+
+  anim1->init(1.0);
+  anim2->init(1.0, true);
+
+  FastLED.addLeds<WS2811, 6, GRB>(strip.leds, STRIP);
+
+  FastLED.setBrightness(32);
+
+  Looper* looper = Looper::instance();
+  looper->addInput(input);
+  looper->addVisualization(viz);
+  looper->addAnimation(anim1);
+  looper->addAnimation(anim2);
+  //looper->setFramesPerSecond(30);
+  looper->setUpdatesPerSecond(30);
+
+  Log.Info("Finished setup()\n");
+  delay(1000);
+}
+
+void loop() {
+  AudioNoInterrupts();
+  Looper::instance()->loop();
+  AudioInterrupts();
+  delay(10);
+}


Add example demonstrating time syncronization with the network

error: pathspec 'examples/ttn-otaa-network-time/ttn-otaa-network-time.ino' did not match any file(s) known to git

--- examples/ttn-otaa-network-time/ttn-otaa-network-time.ino
+++ examples/ttn-otaa-network-time/ttn-otaa-network-time.ino
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman
+ * Copyright (c) 2018 Terry Moore, MCCI
+ *
+ * Permission is hereby granted, free of charge, to anyone
+ * obtaining a copy of this document and accompanying files,
+ * to do whatever they want with them without any restriction,
+ * including, but not limited to, copying, modification and redistribution.
+ * NO WARRANTY OF ANY KIND IS PROVIDED.
+ *
+ * This example sends a valid LoRaWAN packet with payload "Hello,
+ * world!", using frequency and encryption settings matching those of
+ * the The Things Network.
+ *
+ * This uses OTAA (Over-the-air activation), where where a DevEUI and
+ * application key is configured, which are used in an over-the-air
+ * activation procedure where a DevAddr and session keys are
+ * assigned/generated for use with all further communication.
+ *
+ * Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in
+ * g1, 0.1% in g2), but not the TTN fair usage policy (which is probably
+ * violated by this sketch when left running for longer)!
+
+ * To use this sketch, first register your application and device with
+ * the things network, to set or generate an AppEUI, DevEUI and AppKey.
+ * Multiple devices can use the same AppEUI, but each device has its own
+ * DevEUI and AppKey.
+ *
+ * Do not forget to define the radio type correctly in config.h.
+ *
+ *******************************************************************************/
+
+#include <Time.h>
+#include <lmic.h>
+#include <hal/hal.h>
+#include <SPI.h>
+
+//
+// For normal use, we require that you edit the sketch to replace FILLMEIN
+// with values assigned by the TTN console. However, for regression tests,
+// we want to be able to compile these scripts. The regression tests define
+// COMPILE_REGRESSION_TEST, and in that case we define FILLMEIN to a non-
+// working but innocuous value.
+//
+#ifdef COMPILE_REGRESSION_TEST
+# define FILLMEIN 0
+#else
+# warning "You must replace the values marked FILLMEIN with real values from the TTN control panel!"
+# define FILLMEIN (#dont edit this, edit the lines that use FILLMEIN)
+#endif
+
+
+// This EUI must be in little-endian format, so least-significant-byte
+// first. When copying an EUI from ttnctl output, this means to reverse
+// the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3,
+// 0x70.
+static const u1_t PROGMEM APPEUI[8]={ FILLMEIN };
+void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);}
+
+// This should also be in little endian format, see above.
+static const u1_t PROGMEM DEVEUI[8]={ FILLMEIN };
+void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);}
+
+// This key should be in big endian format (or, since it is not really a
+// number but a block of memory, endianness does not really apply). In
+// practice, a key taken from ttnctl can be copied as-is.
+static const u1_t PROGMEM APPKEY[16] = { FILLMEIN };
+void os_getDevKey (u1_t* buf) {  memcpy_P(buf, APPKEY, 16);}
+
+static uint8_t mydata[] = "Hello, world!";
+static osjob_t sendjob;
+
+// Schedule TX every this many seconds (might become longer due to duty
+// cycle limitations).
+const unsigned TX_INTERVAL = 60;
+
+// Pin mapping
+const lmic_pinmap lmic_pins = {
+    .nss = 6,
+    .rxtx = LMIC_UNUSED_PIN,
+    .rst = 5,
+    .dio = {2, 3, 4},
+};
+
+void onEvent (ev_t ev) {
+    Serial.print(os_getTime());
+    Serial.print(": ");
+    switch(ev) {
+        case EV_SCAN_TIMEOUT:
+            Serial.println(F("EV_SCAN_TIMEOUT"));
+            break;
+        case EV_BEACON_FOUND:
+            Serial.println(F("EV_BEACON_FOUND"));
+            break;
+        case EV_BEACON_MISSED:
+            Serial.println(F("EV_BEACON_MISSED"));
+            break;
+        case EV_BEACON_TRACKED:
+            Serial.println(F("EV_BEACON_TRACKED"));
+            break;
+        case EV_JOINING:
+            Serial.println(F("EV_JOINING"));
+            break;
+        case EV_JOINED:
+            Serial.println(F("EV_JOINED"));
+            {
+              u4_t netid = 0;
+              devaddr_t devaddr = 0;
+              u1_t nwkKey[16];
+              u1_t artKey[16];
+              LMIC_getSessionKeys(&netid, &devaddr, nwkKey, artKey);
+              Serial.print("netid: ");
+              Serial.println(netid, DEC);
+              Serial.print("devaddr: ");
+              Serial.println(devaddr, HEX);
+              Serial.print("artKey: ");
+              for (int i=0; i<sizeof(artKey); ++i) {
+                Serial.print(artKey[i], HEX);
+              }
+              Serial.println("");
+              Serial.print("nwkKey: ");
+              for (int i=0; i<sizeof(nwkKey); ++i) {
+                Serial.print(nwkKey[i], HEX);
+              }
+              Serial.println("");
+            }
+            // Disable link check validation (automatically enabled
+            // during join, but because slow data rates change max TX
+	    // size, we don't use it in this example.
+            LMIC_setLinkCheckMode(0);
+            break;
+        /*
+        || This event is defined but not used in the code. No
+        || point in wasting codespace on it.
+        ||
+        || case EV_RFU1:
+        ||     Serial.println(F("EV_RFU1"));
+        ||     break;
+        */
+        case EV_JOIN_FAILED:
+            Serial.println(F("EV_JOIN_FAILED"));
+            break;
+        case EV_REJOIN_FAILED:
+            Serial.println(F("EV_REJOIN_FAILED"));
+            break;
+        case EV_TXCOMPLETE:
+            Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
+            if (LMIC.txrxFlags & TXRX_ACK)
+              Serial.println(F("Received ack"));
+            if (LMIC.dataLen) {
+              Serial.print(F("Received "));
+              Serial.print(LMIC.dataLen);
+              Serial.println(F(" bytes of payload"));
+            }
+            // Schedule next transmission
+            os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
+            break;
+        case EV_LOST_TSYNC:
+            Serial.println(F("EV_LOST_TSYNC"));
+            break;
+        case EV_RESET:
+            Serial.println(F("EV_RESET"));
+            break;
+        case EV_RXCOMPLETE:
+            // data received in ping slot
+            Serial.println(F("EV_RXCOMPLETE"));
+            break;
+        case EV_LINK_DEAD:
+            Serial.println(F("EV_LINK_DEAD"));
+            break;
+        case EV_LINK_ALIVE:
+            Serial.println(F("EV_LINK_ALIVE"));
+            break;
+        /*
+        || This event is defined but not used in the code. No
+        || point in wasting codespace on it.
+        ||
+        || case EV_SCAN_FOUND:
+        ||    Serial.println(F("EV_SCAN_FOUND"));
+        ||    break;
+        */
+        case EV_TXSTART:
+            Serial.println(F("EV_TXSTART"));
+            break;
+        default:
+            Serial.print(F("Unknown event: "));
+            Serial.println((unsigned) ev);
+            break;
+    }
+}
+
+uint32_t userUTCTime; // Seconds since the UTC epoch
+
+// Utility function for digital clock display: prints preceding colon and
+// leading 0
+void printDigits(int digits) {
+
+    Serial.print(':');
+    if (digits < 10) Serial.print('0');
+    Serial.print(digits);
+}
+
+void user_request_network_time_callback(uint32_t *pUserUTCTime, int flagSuccess) {
+
+    // A struct that will be populated by LMIC_getNetworkTimeReference.
+    // It contains the following fields:
+    //  - tLocal: the value returned by os_GetTime() when the time
+    //            request was sent to the gateway, and
+    //  - tNetwork: the seconds between the GPS epoch and the time
+    //              the gateway received the time request
+    lmic_time_reference_t lmicTimeReference;
+
+    if (flagSuccess != 1) {
+        Serial.println(F("USER CALLBACK: Not a success"));
+        return;
+    }
+
+    // Populate "lmic_time_reference"
+    flagSuccess = LMIC_getNetworkTimeReference(&lmicTimeReference);
+    if (flagSuccess != 1) {
+        Serial.println(F("USER CALLBACK: LMIC_getNetworkTimeReference didn't succeed"));
+        return;
+    }
+
+    // Update userUTCTime, considering the difference between the GPS and UTC
+    // epoch, and the leap seconds
+    *pUserUTCTime = lmicTimeReference.tNetwork + 315964800;
+
+    // Add the delay between the instant the time was transmitted and
+    // the current time
+
+    // Current time, in ticks
+    ostime_t ticksNow = os_getTime();
+    // Time when the request was sent, in ticks
+    ostime_t ticksRequestSent = lmicTimeReference.tLocal;
+    uint32_t requestDelaySec = osticks2ms(ticksNow - ticksRequestSent) / 1000;
+    *pUserUTCTime += requestDelaySec;
+
+    // Update the system time with the time read from the network
+    setTime(*pUserUTCTime);
+
+    Serial.print(F("The current UTC time is: "));
+    Serial.print(hour());
+    printDigits(minute());
+    printDigits(second());
+    Serial.print(' ');
+    Serial.print(day());
+    Serial.print('/');
+    Serial.print(month());
+    Serial.print('/');
+    Serial.print(year());
+    Serial.println();
+}
+
+void do_send(osjob_t* j) {
+    // Check if there is not a current TX/RX job running
+    if (LMIC.opmode & OP_TXRXPEND) {
+        Serial.println(F("OP_TXRXPEND, not sending"));
+    } else {
+        // Schedule a network time request at the next possible time
+        LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime);
+
+        // Prepare upstream data transmission at the next possible time.
+        LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0);
+        Serial.println(F("Packet queued"));
+    }
+    // Next TX is scheduled after TX_COMPLETE event.
+}
+
+void setup() {
+    Serial.begin(9600);
+    Serial.println(F("Starting"));
+
+    #ifdef VCC_ENABLE
+    // For Pinoccio Scout boards
+    pinMode(VCC_ENABLE, OUTPUT);
+    digitalWrite(VCC_ENABLE, HIGH);
+    delay(1000);
+    #endif
+
+    // LMIC init
+    os_init();
+    // Reset the MAC state. Session and pending data transfers will be discarded.
+    LMIC_reset();
+
+    // Start job (sending automatically starts OTAA too)
+    do_send(&sendjob);
+}
+
+void loop() {
+    os_runloop_once();
+}


Add PubSub example.

Add PubSub example.

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

--- examples/PubSub/PubSub.ino
+++ examples/PubSub/PubSub.ino
@@ -0,0 +1,187 @@
+/*
+ *******************************************************************************
+ *
+ * Purpose: Example of using the Arduino MqttClient
+ * Project URL: https://github.com/monstrenyatko/ArduinoMqtt
+ *
+ *******************************************************************************
+ * Copyright Oleg Kovalenko 2016.
+ *
+ * Distributed under the MIT License.
+ * (See accompanying file LICENSE or copy at http://opensource.org/licenses/MIT)
+ *******************************************************************************
+ */
+
+#include <Arduino.h>
+#include <SoftwareSerial.h>
+
+// Enable MqttClient logs
+#define MQTT_LOG_ENABLED 1
+// Include library
+#include <MqttClient.h>
+
+
+#define LOG_PRINTFLN(fmt, ...)	printfln_P(PSTR(fmt), ##__VA_ARGS__)
+#define LOG_SIZE_MAX 128
+void printfln_P(const char *fmt, ...) {
+	char buf[LOG_SIZE_MAX];
+	va_list ap;
+	va_start(ap, fmt);
+	vsnprintf_P(buf, LOG_SIZE_MAX, fmt, ap);
+	va_end(ap);
+	Serial.println(buf);
+}
+
+#define HW_UART_SPEED									57600L
+#define MQTT_ID											"TEST-ID"
+const char* MQTT_TOPIC_SUB = "test/"MQTT_ID"/sub";
+const char* MQTT_TOPIC_PUB = "test/"MQTT_ID"/pub";
+MqttClient *mqtt = NULL;
+
+// ============== Object to supply current time ================================
+class Time: public MqttClient::Time {
+public:
+	unsigned long millis() const {
+		return ::millis();
+	}
+} time;
+
+// ============== Object to implement network connectivity =====================
+// Current example assumes the network TCP stack is connected using serial
+// interface to pins 10(RX) and 11(TX). The SoftwareSerial library is used
+// for actual communication.
+#define SW_UART_PIN_RX								10
+#define SW_UART_PIN_TX								11
+#define SW_UART_SPEED								9600L
+class Network {
+public:
+	Network() {
+		mNet = new SoftwareSerial(SW_UART_PIN_RX, SW_UART_PIN_TX);
+		mNet->begin(SW_UART_SPEED);
+	}
+
+	int connect(const char* hostname, int port) {
+		// TCP connection is already established otherwise do it here
+		return 0;
+	}
+
+	int read(unsigned char* buffer, int len, unsigned long timeoutMs) {
+		unsigned long startMs = time.millis();
+		mNet->setTimeout(timeoutMs);
+		do {
+			int qty = mNet->readBytes((char*) buffer, len);
+			if (qty > 0) {
+				return qty;
+			}
+		} while(time.millis() - startMs < timeoutMs);
+		return 0;
+	}
+
+	int write(unsigned char* buffer, int len, unsigned long timeoutMs) {
+		mNet->setTimeout(timeoutMs);
+		for (int i = 0; i < len; ++i) {
+			mNet->write(buffer[i]);
+		}
+		mNet->flush();
+		return len;
+	}
+
+	int disconnect() {
+		// Implement TCP network disconnect here
+		return 0;
+	}
+
+private:
+	SoftwareSerial										*mNet;
+} *network = NULL;
+
+// ============== Setup all objects ============================================
+void setup() {
+	// Setup hardware serial for logging
+	Serial.begin(HW_UART_SPEED);
+	while (!Serial);
+	// Setup network
+	network = new Network;
+	// Setup MqttClient
+	MqttClient::Logger *mqttLogger = new MqttClient::LoggerImpl<HardwareSerial>(Serial);
+	MqttClient::Network * mqttNetwork = new MqttClient::NetworkImpl<Network>(*network, time);
+	//// Make 128 bytes send buffer
+	MqttClient::Buffer *mqttSendBuffer = new MqttClient::ArrayBuffer<128>();
+	//// Make 128 bytes receive buffer
+	MqttClient::Buffer *mqttRecvBuffer = new MqttClient::ArrayBuffer<128>();
+	//// Allow up to 2 subscriptions simultaneously
+	MqttClient::MessageHandlers *mqttMessageHandlers = new MqttClient::MessageHandlersImpl<2>();
+	//// Configure client options
+	MqttClient::Options mqttOptions;
+	////// Set command timeout to 10 seconds
+	mqttOptions.commandTimeoutMs = 10000;
+	//// Make client object
+	mqtt = new MqttClient (
+		mqttOptions, *mqttLogger, time, *mqttNetwork, *mqttSendBuffer,
+		*mqttRecvBuffer, *mqttMessageHandlers
+	);
+}
+
+// ============== Subscription callback ========================================
+void processMessage(MqttClient::MessageData& md) {
+	const MqttClient::Message& msg = md.message;
+	char payload[msg.payloadLen + 1];
+	memcpy(payload, msg.payload, msg.payloadLen);
+	payload[msg.payloadLen] = '\0';
+	LOG_PRINTFLN(
+		"Message arrived: qos %d, retained %d, dup %d, packetid %d, payload:[%s]",
+		msg.qos, msg.retained, msg.dup, msg.id, payload
+	);
+}
+
+// ============== Main loop ====================================================
+void loop() {
+	// Check connection status
+	if (!mqtt->isConnected()) {
+		// Re-establish TCP connection with MQTT broker
+		network->disconnect();
+		network->connect("mymqttserver.com", 1883);
+		// Start new MQTT connection
+		LOG_PRINTFLN("Connecting");
+		MqttClient::ConnectResult connectResult;
+		// Connect
+		{
+			MQTTPacket_connectData options = MQTTPacket_connectData_initializer;
+			options.MQTTVersion = 4;
+			options.clientID.cstring = (char*)MQTT_ID;
+			options.cleansession = true;
+			options.keepAliveInterval = 15; // 15 seconds
+			MqttClient::Error::type rc = mqtt->connect(options, connectResult);
+			if (rc != MqttClient::Error::SUCCESS) {
+				LOG_PRINTFLN("Connection error: %i", rc);
+				return;
+			}
+		}
+		// Subscribe
+		{
+			MqttClient::Error::type rc = mqtt->subscribe(
+				MQTT_TOPIC_SUB, MqttClient::QOS0, processMessage
+			);
+			if (rc != MqttClient::Error::SUCCESS) {
+				LOG_PRINTFLN("Subscribe error: %i", rc);
+				LOG_PRINTFLN("Drop connection");
+				mqtt->disconnect();
+				return;
+			}
+		}
+	} else {
+		// Publish
+		{
+			const char* buf = "Hello";
+			MqttClient::Message message;
+			message.qos = MqttClient::QOS0;
+			message.retained = false;
+			message.dup = false;
+			message.payload = (void*) buf;
+			message.payloadLen = strlen(buf) + 1;
+			mqtt->publish(MQTT_TOPIC_PUB, message);
+		}
+		// Idle for 30 seconds
+		mqtt->yield(30000L);
+	}
+}


maybe it works i dunno

maybe it works i dunno

error: pathspec 'code' did not match any file(s) known to git
error: pathspec 'dump/lab2/averagingLineSensor.ino' did not match any file(s) known to git


Added RTC demo sketch.

Added RTC demo sketch.

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

--- zero_rtc/zero_rtc.ino
+++ zero_rtc/zero_rtc.ino
@@ -0,0 +1,73 @@
+/*
+  Simple RTC for Arduino Zero and MKR1000
+
+ Demonstrates the use of the RTC library for the Arduino Zero and MKR1000
+
+ This example code is in the public domain
+
+ http://arduino.cc/en/Tutorial/SimpleRTC
+
+  created by Arturo Guadalupi <a.guadalupi@arduino.cc>
+  15 Jun 2015
+
+  modified
+  18 Feb 2016
+*/
+
+#include <RTCZero.h>
+
+/* Create an rtc object */
+RTCZero rtc;
+
+/* Change these values to set the current initial time */
+const byte seconds = 0;
+const byte minutes = 37;
+const byte hours = 11;
+
+/* Change these values to set the current initial date */
+const byte day = 24;
+const byte month = 3;
+const byte year = 16;
+
+void setup()
+{
+  Serial.begin(9600);
+
+  rtc.begin(); // initialize RTC
+
+  // Set the time
+  rtc.setHours(hours);
+  rtc.setMinutes(minutes);
+  rtc.setSeconds(seconds);
+
+  // Set the date
+  rtc.setDay(day);
+  rtc.setMonth(month);
+  rtc.setYear(year);
+
+  // you can use also
+  //rtc.setTime(hours, minutes, seconds);
+  //rtc.setDate(day, month, year);
+}
+
+void loop()
+{
+  // Print date...
+  Serial.print(rtc.getDay());
+  Serial.print("/");
+  Serial.print(rtc.getMonth());
+  Serial.print("/");
+  Serial.print(rtc.getYear());
+  Serial.print("\t");
+
+  // ...and time
+  Serial.print(rtc.getHours());
+  Serial.print(":");
+  Serial.print(rtc.getMinutes());
+  Serial.print(":");
+  Serial.print(rtc.getSeconds());
+
+  Serial.println();
+
+  delay(1000);
+}


sabado 30

sabado 30

error: pathspec 'Practicas' did not match any file(s) known to git
error: pathspec 'en' did not match any file(s) known to git
error: pathspec 'clase/control_de_acceso/control_de_acceso.ino' did not match any file(s) known to git


grammar corrections

grammar corrections

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


Add new LED example

Add new LED example

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

--- libraries/CurieBle/examples/LED/LED.ino
+++ libraries/CurieBle/examples/LED/LED.ino
@@ -0,0 +1,78 @@
+/*
+   Copyright (c) 2015 Intel Corporation.  All rights reserved.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+#include <CurieBle.h>
+
+/* BLE Peripheral (this Intel Curie device) */
+BlePeripheral blePeripheral;
+
+/* BLE LED Service */
+BleService ledService("19B10000-E8F2-537E-4F6C-D104768A1214");
+
+/* BLE Switch Characteristic - custom 128-bit UUID, read and writable by central */
+BleUnsignedCharCharacteristic switchCharacteristic("19B10000E8F2537E4F6CD104768A1214", BleRead | BleWrite);
+
+const int ledPin = 13; // pin to use for the LED
+
+void setup() {
+  Serial.begin(9600);
+
+  // set LED pin to output mode
+  pinMode(ledPin, OUTPUT);
+
+  // set advertised local name and service UUID
+  blePeripheral.setLocalName("LED");
+  blePeripheral.setAdvertisedServiceUuid(ledService.uuid());
+
+  // add service and characteristic
+  blePeripheral.addAttribute(ledService);
+  blePeripheral.addAttribute(switchCharacteristic);
+
+  // begin initialization
+  blePeripheral.begin();
+
+  Serial.println(F("BLE LED Peripheral"));
+}
+
+void loop() {
+  BleCentral central = blePeripheral.central();
+
+  if (central) {
+    // central connected to peripheral
+    Serial.print(F("Connected to central: "));
+    Serial.println(central.address());
+
+    while (central.connected()) {
+      // central still connected to peripheral
+      if (switchCharacteristic.written()) {
+        // central wrote new value to characteristic, update LED
+        if (switchCharacteristic.value()) {
+          Serial.println(F("LED on"));
+          digitalWrite(ledPin, HIGH);
+        } else {
+          Serial.println(F("LED off"));
+          digitalWrite(ledPin, LOW);
+        }
+      }
+    }
+
+    // central disconnected
+    Serial.print(F("Disconnected from central: "));
+    Serial.println(central.address());
+  }
+}
+


Create soil_moisture_sensor.ino

Create soil_moisture_sensor.ino

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

--- arduino/soil_moisture_sensor/soil_moisture_sensor.ino
+++ arduino/soil_moisture_sensor/soil_moisture_sensor.ino
@@ -0,0 +1,38 @@
+/*
+
+ All the resources for this project:
+ http://randomnerdtutorials.com/
+
+*/
+
+int rainPin = A0;
+int greenLED = 6;
+int redLED = 7;
+// you can adjust the threshold value
+int thresholdValue = 800;
+
+void setup(){
+  pinMode(rainPin, INPUT);
+  pinMode(greenLED, OUTPUT);
+  pinMode(redLED, OUTPUT);
+  digitalWrite(greenLED, LOW);
+  digitalWrite(redLED, LOW);
+  Serial.begin(9600);
+}
+
+void loop() {
+  // read the input on analog pin 0:
+  int sensorValue = analogRead(rainPin);
+  Serial.print(sensorValue);
+  if(sensorValue < thresholdValue){
+    Serial.println(" - Doesn't need watering");
+    digitalWrite(redLED, LOW);
+    digitalWrite(greenLED, HIGH);
+  }
+  else {
+    Serial.println(" - Time to water your plant");
+    digitalWrite(redLED, HIGH);
+    digitalWrite(greenLED, LOW);
+  }
+  delay(500);
+}


get four analog values, timestamp and write in binary

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

--- scriptor.ino
+++ scriptor.ino
@@ -0,0 +1,32 @@
+/*
+Reads the values from a0-a3 and writes them as binary to the serial interface.
+
+MIT LICENSE 2016
+*/
+
+// the setup routine runs once when you press reset:
+void setup() {
+  // initialize serial communication
+  Serial.begin(115200); // bits per second
+}
+
+// the loop routine runs over and over again forever:
+// TODO: Loop timing
+void loop() {
+  // read the input on analog pin 0:
+  unsigned long time = micros(); // time since program start.
+                                 // Overflows after 40 minutes
+
+  // It takes about 100 microseconds (0.0001 s) to read an analog input,
+  // so the maximum reading rate is about 10,000 times a second.
+  int a0 = analogRead(A0);
+  int a1 = analogRead(A1);
+  int a2 = analogRead(A2);
+  int a3 = analogRead(A3);
+
+  int t0 = (int) (time >> 16);
+  int t1 = (int) (time & 0x0000ffff);
+  int values[7] = {t0, t1, a0, a1, a2, a3, 0xFFFF};
+  // print out the value you read:
+  Serial.write((uint8_t*) &values, 7*sizeof(*values));
+}


Added arduino sketch

Added arduino sketch

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


Added Pascal's dmxtest4.ino

Added Pascal's dmxtest4.ino

This has his latest version of the dmx-update code. Needs to be ported
over to a proper .cpp file, but the hard work has been done here.

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

--- dmxtest4/dmxtest4.ino
+++ dmxtest4/dmxtest4.ino
@@ -0,0 +1,77 @@
+#include "sam.h"
+#include <FastLED.h>
+
+// Units are in timer ticks.
+#define DMX_BRKTIME       (100)       // Time to hold serial in break before mark
+#define DMX_MARKTIME      (25)         // Time to hold serial in mark after break
+#define DMX_BAUDRATE      (250000)     // DMX baurate
+#define DMX_FRAMING       (SERIAL_8N2) // Serial framing configuraiton
+#define DMX_UART          (USART0)     // Due USART device (must be a USART not a UART)
+#define DMX_SERIAL        (Serial1)    // Arduinoish serial object associated with above USART
+
+/* DMX state */
+bool dmx_inited = false;    // To prevent double-init
+uint8_t *_dmx_buf;          // Private buffer the DMA to serial
+size_t dmx_buflen;          // Buffer length
+
+/* Init and start the DMX system */
+void dmx_init(size_t buflen) {
+   // Don't double-init
+   if(dmx_inited == true) {
+     return;
+   }
+
+   dmx_buflen = buflen;
+   _dmx_buf = (uint8_t *)malloc(buflen+1);
+   memset(_dmx_buf, 0, buflen+1);
+
+   // Init serial port
+   DMX_SERIAL.begin(DMX_BAUDRATE, DMX_FRAMING);
+}
+
+void dmx_send(uint8_t *buf)
+{
+  _dmx_buf[0] = 0;
+  memcpy(_dmx_buf+1, buf, dmx_buflen);
+  DMX_UART->US_CR |= US_CR_STTBRK;   // Start break
+  delayMicroseconds(DMX_BRKTIME);
+  DMX_UART->US_CR |= US_CR_STPBRK;  // Stop break signal
+  delayMicroseconds(DMX_MARKTIME);
+  DMX_SERIAL.write(_dmx_buf, dmx_buflen);
+  return;
+}
+
+CRGB rope[ 1024 ];
+CRGB dmx[ 18 ];
+void setup() {
+  pinMode( 32, OUTPUT );
+  pinMode( 37, OUTPUT );
+  digitalWrite(32, LOW);
+  digitalWrite(37, LOW);
+  FastLED.addLeds<WS2811_PORTD, 8>( rope, 128 );
+  dmx_init(18*sizeof(CRGB));
+}
+
+void loop() {
+  for (int i = 0; i < 1024; ++i ) {
+     rope[ i ].r = random(255);
+     rope[ i ].b = random(255);
+     rope[ i ].g = random(255);
+  }
+
+  for(int i=0;i<18;i++) {
+      dmx[i].r = random(255);
+      dmx[i].b = random(255);
+      dmx[i].g = random(255);
+  }
+
+   digitalWrite(32, HIGH);
+   dmx_send((void *)dmx);
+   digitalWrite(32, LOW);
+
+   digitalWrite(37, HIGH);
+   FastLED.show();
+   digitalWrite(37, LOW);
+
+   delayMicroseconds( 100000 );
+}


Initial firmware version. Supports on/off and custom brightness using MQTT messages

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

--- firmware/firmware.ino
+++ firmware/firmware.ino
@@ -0,0 +1,145 @@
+#include <ESP8266WiFi.h>
+#include "Adafruit_MQTT.h"
+#include "Adafruit_MQTT_Client.h"
+
+#define WLAN_SSID   "FRITZ!Box 7272"
+#define WLAN_PASS   "Aezakmi123!"
+
+#define SERVER      "minibian"
+#define SERVERPORT  1883
+
+#define LED         4
+#define DS18B20     5 // Dallas DS18B20 digital thermometer
+
+unsigned int brightness = 1023;
+
+// Create an ESP8266 WiFiClient class to connect to the MQTT server.
+WiFiClient client;
+
+Adafruit_MQTT_Client mqtt(&client, SERVER, SERVERPORT);
+Adafruit_MQTT_Subscribe onoffsw = Adafruit_MQTT_Subscribe(&mqtt, "/light/1");
+
+// Bug workaround for Arduino 1.6.6, it seems to need a function declaration
+// for some reason (only affects ESP8266, likely an arduino-builder bug).
+void MQTT_connect();
+
+void setup() {
+  pinMode(LED, OUTPUT);
+  Serial.begin(74880);
+  delay(10);
+
+  // Connect to WiFi access point.
+  Serial.println(); Serial.println();
+  Serial.print(F("Connecting to "));
+  Serial.println(WLAN_SSID);
+
+  WiFi.begin(WLAN_SSID, WLAN_PASS);
+  if (WiFi.status() != WL_CONNECTED) {
+    delay(300);
+    Serial.print(F("."));
+  }
+  Serial.println();
+  Serial.println(F("WiFi connected"));
+  Serial.println(F("IP address: "));
+  Serial.println(WiFi.localIP());
+
+  // Setup MQTT subscription for onoff feed.
+  mqtt.subscribe(&onoffsw);
+}
+
+uint32_t x = 0;
+unsigned int i = 0;
+void loop() {
+  // Ensure the connection to the MQTT server is alive (this will make the first
+  // connection and automatically reconnect when disconnected).  See the MQTT_connect
+  // function definition further below.
+  MQTT_connect();
+  // try to spend your time here
+
+  Adafruit_MQTT_Subscribe *subscription;
+  while ((subscription = mqtt.readSubscription(10000))) {
+
+    if (strcmp((char *)onoffsw.lastread, "{\"On\":1}") == 0) {
+      Serial.println(F("On"));
+      i = 0;
+      while (i < brightness) {
+        analogWrite(LED, i);
+        i += 2;
+        delay(4);
+      }
+    }
+    else if (strcmp((char *)onoffsw.lastread, "{\"On\":0}") == 0) {
+      Serial.println(F("Off"));
+      while (i > 10) {
+        analogWrite(LED, i);
+        i -= 10;
+        delay(20);
+      }
+      analogWrite(LED, 0);
+      i = 0;
+    }
+    // Check if the brightness setting has been updated
+    else if (strncmp((char *)onoffsw.lastread, "{\"Brightness\":", 14) == 0 ) {
+      Serial.print(F("Brightness: "));
+
+      unsigned int l = strlen((char *)onoffsw.lastread);
+      onoffsw.lastread[l - 1] = '\0'; // overwrite the ending bracket
+      unsigned int bright_perc = atoi((char *)onoffsw.lastread + 14);
+      Serial.println(bright_perc);
+      unsigned int new_brightness = 1023 * bright_perc / 100;
+      if (new_brightness > 1023) new_brightness = 1023;
+
+      if (new_brightness > brightness) {
+        i = brightness;
+        while (i < new_brightness) {
+          analogWrite(LED, i);
+          i += 2;
+          delay(4);
+        }
+        analogWrite(LED, new_brightness);
+        i = new_brightness;
+
+      }
+      else {
+        while (i > new_brightness) {
+          analogWrite(LED, i);
+          i -= 1;
+          delay(2);
+
+        }
+        analogWrite(LED, new_brightness);
+        i = new_brightness;
+      }
+      brightness = new_brightness;
+    }
+  }
+}
+
+
+
+// Function to connect and reconnect as necessary to the MQTT server.
+// Should be called in the loop function and it will take care if connecting.
+void MQTT_connect() {
+  int8_t ret;
+
+  // Stop if already connected.
+  if (mqtt.connected()) {
+    return;
+  }
+
+  Serial.print(F("Connecting to MQTT... "));
+
+  uint8_t retries = 3;
+  while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
+    Serial.println(mqtt.connectErrorString(ret));
+    Serial.println(F("Retrying MQTT connection in 5 seconds..."));
+    mqtt.disconnect();
+    delay(5000);  // wait 5 seconds
+    retries--;
+    if (retries == 0) {
+      // basically die and wait for WDT to reset me
+      while (1);
+    }
+  }
+  Serial.println(F("MQTT Connected!"));
+}


Initial commit SwitchScience Copy

Initial commit SwitchScience Copy

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


Create ardserial.ino

Create ardserial.ino

Arduino's script to work with serial port

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


lego car initial import

lego car initial import

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

--- lego_car/lego_car.ino
+++ lego_car/lego_car.ino
@@ -0,0 +1,67 @@
+const int controlPin1 = 2;
+const int controlPin2 = 3;
+const int enablePin = 9;
+//const int directionSwitchPin = 4;
+//const int onOffSwitchStateSwitchPin = 5;
+const int potPin = A0;
+
+int onOffSwitchState = 0;
+int previousOnOffSwitchState = 0;
+int directionSwitchState = 0;
+int previousDirectionSwitchState = 0;
+int motorEnabled = 0;
+int motorSpeed = 0;
+int motorDirection = 1;
+
+void setup() {
+  Serial.begin(9600);
+  //pinMode(directionSwitchPin, INPUT);
+  //pinMode(onOffSwitchStateSwitchPin, INPUT);
+  pinMode(controlPin1, OUTPUT);
+  pinMode(controlPin2, OUTPUT);
+  pinMode(enablePin, OUTPUT);
+  digitalWrite(enablePin, LOW);
+}
+
+void loop() {
+  onOffSwitchState = HIGH; //digitalRead(onOffSwitchStateSwitchPin);
+  delay(1);
+  directionSwitchState = HIGH; // digitalRead(directionSwitchPin);
+  motorSpeed = analogRead(potPin)/4;
+  if (onOffSwitchState != previousOnOffSwitchState && onOffSwitchState == HIGH) {
+    motorEnabled = !motorEnabled;
+  }
+  if (directionSwitchState != previousDirectionSwitchState && directionSwitchState == HIGH) {
+    motorDirection = !motorDirection;
+  }
+
+  Serial.print("onOffSwitchState:");
+  Serial.print(onOffSwitchState);
+  Serial.print(", directionSwitchState:");
+  Serial.print(directionSwitchState);
+  Serial.print(", motorEnabled:");
+  Serial.print(motorEnabled);
+  Serial.print(", motorDirection:");
+  Serial.print(motorDirection);
+  Serial.print(", motorSpeed:");
+  Serial.println(motorSpeed);
+
+
+  if (motorDirection == 1) {
+    digitalWrite(controlPin1, HIGH);
+    digitalWrite(controlPin2, LOW);
+  } else {
+    digitalWrite(controlPin1, LOW);
+    digitalWrite(controlPin2, HIGH);
+  }
+
+  if (motorEnabled == 1) {
+    analogWrite(enablePin, motorSpeed);
+  } else {
+    analogWrite(enablePin, 0);
+  }
+
+  previousDirectionSwitchState = directionSwitchState;
+  previousOnOffSwitchState = onOffSwitchState;
+}
+


Added files via upload

Added files via upload

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

--- 001TargetDownLeft/DianaParteInferior.ino
+++ 001TargetDownLeft/DianaParteInferior.ino
@@ -0,0 +1,225 @@
+//Comunicacion i2c
+//1-manager
+//2 diana inferior izqda 3 diana inferior central 4 diana inferior dcha
+//5 diana superior medio 6 diana superior alta
+
+// Receptor - Seria la diana de la feria
+#include <IRremote.h>
+#include <Servo.h>
+#include <Wire.h>
+
+const int ledPin =  13;
+int RECV_PIN = 11;
+Servo myservo;
+int pos = 15;
+boolean Playing;
+IRrecv irrecv(RECV_PIN);
+char MessageReceived;
+unsigned long timer = millis();
+unsigned long time_between_target = 7;
+int randNumber = 0;
+int UpDegrees = 70;  //Grados a los que la diana esta vertical
+int DownDegrees = 10;  //Grados a los que la diana esta abajo
+int Shoots = 0; //Guardaremos el numero de diana y en función de ella modificaremos la dificultad
+boolean TargetUp;
+const int delayForSound = 100;
+
+String texto;
+decode_results results;
+
+void setup()
+{
+  Serial.begin(9600);
+  irrecv.enableIRIn(); // Start the receiver
+  myservo.attach(9);
+  //Serial.println ("Comenzamos...");
+  myservo.write(DownDegrees);
+  delay(15);
+  Playing = false;
+  pinMode(ledPin, OUTPUT);
+  Wire.begin(2);                // join i2c bus with address #2
+  Wire.onReceive(receiveEvent); // register event
+  //Serial.println (millis());ç
+  //Manager.begin(9600);
+
+}
+
+void (* resetFunc) (void) = 0;
+
+
+void loop() {
+  //Esperamos la señal de que comience la partida -1(49) - Acabar la partida 0 (48) - 2 modo demo (50) - 3 tiro acertado (51)
+
+
+  if (Playing)
+  {
+
+
+
+    if ((timer < millis()) && (!TargetUp))
+    { //levantamos la diana transcurrido un tiempo aleatorio desde el ultimo blanco
+      Wire.beginTransmission(1); // transmit to device #1
+      Wire.write("go001");              // sends one byte
+      Wire.endTransmission();    // stop transmitting
+      delay (delayForSound);
+      for (pos = DownDegrees; pos <= UpDegrees; pos += 1) // goes from 0 degrees to 180 degrees
+      { // in steps of 1 degree
+        myservo.write(pos);              // tell servo to go to position in variable 'pos'
+        delay(5);                       // waits 5ms for the servo to reach the position
+      }
+      TargetUp = true;
+
+      //bajaremos la diana en 1-5 segundos depende de la dificultad
+
+      switch (Shoots) {
+        case  2:
+          time_between_target = 5;
+          //Serial.println (time_between_target);
+          break;
+        case  3:
+          time_between_target = 4;
+          //Serial.println (time_between_target);
+          break;
+
+        case  5:
+          time_between_target = 3;
+          //Serial.println (time_between_target);
+          break;
+
+        case  7:
+          time_between_target = 1;
+          //Serial.println (time_between_target);
+          break;
+      }
+    }
+
+    if (timer + (time_between_target * 1000) < millis()) //Si ha pasado el tiempo marcado desde el ultimo tiro, bajamos la diana
+    {
+      //      Serial.println (timer);
+      //      Serial.println (time_between_target * 1000);
+      //      Serial.println (timer + (time_between_target * 1000) );
+      //      Serial.println (millis());
+      //      Serial.println ("Aqui2");
+      Wire.beginTransmission(1); // transmit to device #1
+      Wire.write("nok001");              // sends one byte
+      Wire.endTransmission();    // stop transmitting
+      for (pos = UpDegrees; pos >= DownDegrees; pos -= 1)
+      {
+        myservo.write(pos);
+        delay(5);
+      }
+      TargetUp = false;
+      randNumber = random(2, time_between_target);
+      //Serial.println (randNumber);
+      timer = randNumber * 1000 + millis();
+      randomSeed(analogRead(0));
+      irrecv.resume(); // Receive the next value
+      //      Serial.println (timer);
+      //      Serial.println (millis());
+      //      Serial.println ("Aqui3");
+
+    }
+
+
+
+    if (irrecv.decode(&results) && TargetUp) {
+      //Serial.println(results.value, DEC);
+      irrecv.resume(); // Receive the next value
+      if (results.value == 2704)  //valor que dispara el emisor de infrarrojos (apagado de tele sony)
+      {
+        //Serial.print ("Blanco: ");
+        //Manager.listen();
+        Wire.beginTransmission(1); // transmit to device #1
+        Wire.write("ok001");              // sends one byte
+        Wire.endTransmission();    // stop transmitting
+        myservo.write(UpDegrees - 30);
+        delay (1500);
+        Shoots = Shoots + 1;
+        randNumber = random(2, time_between_target);
+        //Serial.println (randNumber);
+        timer = randNumber * 1000 + millis();
+        randomSeed(analogRead(0));
+        //Serial.println (timer);
+        //Serial.println (millis());
+        for (pos = UpDegrees - 30; pos >= DownDegrees; pos -= 1) // goes from 180 degrees to 0 degrees
+        {
+          myservo.write(pos);              // tell servo to go to position in variable 'pos'
+          delay(5);                       // waits 15ms for the servo to reach the position
+        }
+        TargetUp = false;
+        irrecv.resume();
+        //Serial.println (pos);
+        //delay(300);
+      }
+    }
+
+  }
+
+
+}
+
+// function that executes whenever data is received from master
+// this function is registered as an event, see setup()
+void receiveEvent(int howMany) {
+  while ( Wire.available()) { // loop through all but the last
+    char c = Wire.read(); // receive byte as a character
+    texto = texto + c;
+    Serial.print(c);         // print the character
+  }
+
+  if (texto == "rst")
+  {
+    resetFunc();
+  }
+  if (texto == "go")
+  {
+    Playing = true;
+    Serial.println ("Comienza la partida!!");
+    randomSeed(analogRead(0));
+    for (pos = DownDegrees; pos <= UpDegrees; pos += 1) // goes from 0 degrees to 180 degrees
+    { // in steps of 1 degree
+      myservo.write(pos);              // tell servo to go to position in variable 'pos'
+      delay(5);                       // waits 15ms for the servo to reach the position
+      time_between_target = 7;
+      Shoots = 0;
+      digitalWrite(ledPin, HIGH);
+
+    }
+    TargetUp = true;
+    timer = millis();
+  }
+  if (texto == "end")
+  {
+    Playing = false;
+    Serial.println ("Fin de la partida!!");
+    for (pos = UpDegrees; pos >= DownDegrees; pos -= 1) // goes from 180 degrees to 0 degrees
+    {
+      myservo.write(pos);              // tell servo to go to position in variable 'pos'
+      delay(5);                       // waits 5ms for the servo to reach the position
+    }
+    TargetUp = false;
+    Shoots = 0;
+    digitalWrite(ledPin, LOW);
+  }
+  if (texto == "gup")
+  {
+
+    myservo.write(UpDegrees);
+  }
+  if (texto == "gdo")
+  {
+
+    myservo.write(DownDegrees);
+  }
+  if (texto == "gme")
+  {
+
+    myservo.write(UpDegrees / 2);
+  }
+
+
+
+  texto = "";
+
+
+}


Add TinkerWatch.ino

Add TinkerWatch.ino

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

--- applications/TinkerWatch/TinkerWatch.ino
+++ applications/TinkerWatch/TinkerWatch.ino
@@ -0,0 +1,52 @@
+#include "ToggleSwitch.h"
+#include "SerialLog.h"
+#include "SequentialStatusSwitcher.h"
+#include "TimedButton.h"
+
+/*******************************
+ * Tinker Watch
+ *******************************/
+
+Tinker::SerialLog 		serialLog;
+typedef Tinker::SequentialStatusSwitcher<Tinker::TimedButton>	StatusSwitcher;
+
+StatusSwitcher::status_type nStatus = 5;
+StatusSwitcher::status_type currentStatus = 0;
+
+StatusSwitcher statusSwitcher;
+
+enum Mode{
+	Compass = 0,
+	Accellerometer = 1,
+	GPS = 2,
+	Clock = 3,
+	RandomAnimation = 4
+};
+
+void setup(){
+	Serial.begin(9600);
+	serialLog.display("Tinker Watch\n");
+
+// Status switcher initialization
+	statusSwitcher._log = &serialLog;
+	statusSwitcher.switcher().setPin(10);
+	statusSwitcher.switcher().initialize(1000,5000); //Setting a minimum of one sec and a maximum of five sec to activate
+	statusSwitcher.setNumberOfStatus(nStatus);
+	statusSwitcher.setStatus(currentStatus);
+}
+
+void loop(){
+	statusSwitcher.refresh();
+	StatusSwitcher::status_type s = statusSwitcher.status();
+	if(s!=currentStatus){
+		SECURE_LOG_VAL(statusSwitcher._log,"New status",s);
+		currentStatus = s;
+	}
+	switch(currentStatus){
+		case Compass: break;
+		case Accellerometer: break;
+		case GPS: break;
+		case Clock: break;
+		case RandomAnimation: break;
+	}
+}


Changed nothing. Lol

Changed nothing. Lol

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


New Arduino test

New Arduino test

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

--- Arduino/PruebaC/PruebaC.ino
+++ Arduino/PruebaC/PruebaC.ino
@@ -0,0 +1,34 @@
+#include <SPI.h>
+
+const int slaveSelectPin = 46;
+
+void setup() {
+  pinMode(slaveSelectPin, OUTPUT);
+  SPI.begin();
+
+  for (int i = 0; i < 255; i++) {
+    digitalPotWrite(5, i);
+    delay(50);
+  }
+}
+
+void loop() {
+  //    for (int i = 0; i < 255; i++) {
+  //      digitalPotWrite(3, i);
+  //      delay(50);
+  //    }
+  //
+  //    for (int i = 255; i > 0; i--) {
+  //      digitalPotWrite(3, i);
+  //      delay(50);
+  //    }
+
+  //  digitalPotWrite(3, 255);
+}
+
+void digitalPotWrite(int address, int value) {
+  digitalWrite(slaveSelectPin, LOW);
+  SPI.transfer(address);
+  SPI.transfer(255 - value);
+  digitalWrite(slaveSelectPin, HIGH);
+}


Arduino sketches for Teensy

Arduino sketches for Teensy

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

--- arduino/serial_replay/serial_replay.ino
+++ arduino/serial_replay/serial_replay.ino
@@ -0,0 +1,161 @@
+
+/*
+ * Test receiving bytes from a host.
+ *
+ * Bytes are captured from IPS2 protocol, try and find header words with length.
+ *
+ * Print back to USB when found. Include packet length to evaluate health of detected packet
+ *
+ */
+
+// set this to the hardware serial port you wish to use
+#define HWSERIAL Serial1
+
+unsigned long baud = 19200;
+const int reset_pin = 4;
+const int led_pin = 13;
+
+#define RECBUFF 256
+byte buffer[RECBUFF];
+
+void setup() {
+    pinMode(led_pin, OUTPUT);
+    digitalWrite(led_pin, LOW);
+    digitalWrite(reset_pin, HIGH);
+    pinMode(reset_pin, OUTPUT);
+    Serial.begin(baud);  // USB, communication to PC or Mac
+    // Don't need Serial1 for now
+//    HWSERIAL.begin(baud); // communication to hardware serial
+    showLed();
+    while(!Serial) {
+      // Wait one second with blinks 2 x (250 + 250)
+      blinkLed(2, 250, 250);
+    }
+
+    Serial.println("Serial Ready");
+
+//    if (baud != Serial.baud()) {
+//      blinkLed(10, 250, 750);
+//    } else {
+//      blinkLed(20, 250, 250);
+//    }
+}
+
+/*
+ * Reset pin is triggered by USB Serial DTR
+ */
+unsigned char prev_dtr = 0;
+void maintainReset() {
+  unsigned char dtr;
+    // check if the USB virtual serial port has raised DTR
+  dtr = Serial.dtr();
+  if (dtr && !prev_dtr) {
+    Serial.println("Reset triggered");
+    digitalWrite(reset_pin, LOW);
+    delayMicroseconds(250);
+    digitalWrite(reset_pin, HIGH);
+  }
+  prev_dtr = dtr;
+}
+
+void maintainUSB() {
+    // check if the USB virtual serial wants a new baud rate
+  if (Serial.baud() != baud) {
+    baud = Serial.baud();
+    if (baud == 57600) {
+      // This ugly hack is necessary for talking
+      // to the arduino bootloader, which actually
+      // communicates at 58824 baud (+2.1% error).
+      // Teensyduino will configure the UART for
+      // the closest baud rate, which is 57143
+      // baud (-0.8% error).  Serial communication
+      // can tolerate about 2.5% error, so the
+      // combined error is too large.  Simply
+      // setting the baud rate to the same as
+      // arduino's actual baud rate works.
+      HWSERIAL.begin(58824);
+      showLed();
+      delay(2000);
+
+    } else {
+      HWSERIAL.begin(baud);
+    }
+    Serial.println("!!! Serial baud mismatch !!!");
+  }
+}
+
+long led_on_time = 0;
+
+void showLed() {
+  // turn on the LED to indicate activity
+  digitalWrite(led_pin, HIGH);
+  led_on_time = millis();
+}
+
+void hideLed() {
+  digitalWrite(led_pin, LOW);
+  led_on_time = 0;
+}
+
+/*
+ * LED needs to be turned off after idling for some period
+ */
+void maintainLed() {
+    // if the LED has been left on without more activity, turn it off
+  if (led_on_time > 0 && millis() - led_on_time > 3) {
+    hideLed();
+  }
+}
+
+void blinkLed(int count, int onDuty, int offDuty) {
+  for (int i = 0; i < count; i++) {
+    showLed();
+    delay(onDuty);
+    hideLed();
+    delay(offDuty);
+  }
+}
+
+/*
+ * Consume byte buffer for header word mask
+ */
+short headerword = 0x0000;
+int streamDepth = 0;
+
+void scanForHeaderWord(int dataLen) {
+  Serial.print("Stream Depth = ");
+  Serial.print(streamDepth);
+  Serial.print("; Data length = ");
+  Serial.println(dataLen);
+
+  for (int i = 0; i < dataLen; i++) {
+    byte LSB = buffer[i];
+    // Shift along the existing LSB to MSB, and add new LSB
+    headerword = ((headerword & 0x00FF) << 8) | LSB;
+    Serial.println(headerword, HEX);
+    streamDepth++;
+  }
+  Serial.println();
+}
+
+/************
+ * Main Loop
+ */
+
+void loop() {
+  int incoming_available, incoming_read;
+
+  // check if any data has arrived on the USB virtual serial port
+  incoming_available = Serial.available();
+  if (incoming_available > 0) {
+      if (incoming_available > RECBUFF) incoming_available = RECBUFF;
+      // read data from the USB port
+      incoming_read = Serial.readBytes((char *)buffer, incoming_available);
+      scanForHeaderWord(incoming_read);
+      showLed();
+    }
+
+  maintainReset();
+  maintainLed();
+//  maintainUSB();
+}


Add files via upload

Add files via upload

Update, new functions, bug fixed

error: pathspec 'OLED-Wifi-Scanner.ino' did not match any file(s) known to git

--- OLED-Wifi-Scanner.ino
+++ OLED-Wifi-Scanner.ino
@@ -0,0 +1,393 @@
+// **********************************************************************************
+// Scan-I2C-WiFi
+// **********************************************************************************
+// Written by Charles-Henri Hallard (http://hallard.me)
+//
+// History : V1.00 2014-04-21 - First release
+//         : V1.11 2015-09-23 - rewrite for ESP8266 target
+//         : V1.20 2016-07-13 - Added new OLED Library and NeoPixelBus
+//
+// **********************************************************************************
+
+#include <ESP8266WiFi.h>
+#include <Ticker.h>
+#include <Wire.h>
+#include "icons.h"
+#include "fonts.h"
+
+// ===========================================
+// Setup your board configuration here
+// ===========================================
+
+// I2C Pins Settings
+#define SDA_PIN D3
+#define SDC_PIN D4
+
+// Display Settings
+// OLED will be checked with this address and this address+1
+// so here 0x03c and 0x03d
+#define I2C_DISPLAY_ADDRESS 0x3c
+// Choose OLED Type (one only)
+#define OLED_SSD1306
+//#define OLED_SH1106
+
+// ===========================================
+// End of configuration
+// ===========================================
+
+#if defined (OLED_SSD1306)
+#include <SSD1306Wire.h>
+#include <OLEDDisplayUi.h>
+#elif defined (OLED_SH1106)
+#include <SH1106Wire.h>
+#include <OLEDDisplayUi.h>
+#endif
+
+
+// Number of line to display for devices and Wifi
+#define I2C_DISPLAY_DEVICE  4
+#define WIFI_DISPLAY_NET    4
+#ifdef OLED_SSD1306
+SSD1306Wire  display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN);
+#else
+SH1106Wire  display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN);
+#endif
+OLEDDisplayUi ui( &display );
+
+Ticker ticker;
+Ticker tickerWifi;
+bool readyForUpdate = false;  // flag to launch update (I2CScan)
+bool readyForWifiUpdate = false;  // flag to launch update (I2CScan)
+
+
+bool has_display          = false;  // if I2C display detected
+uint8_t NumberOfI2CDevice = 0;      // number of I2C device detected
+int8_t NumberOfNetwork    = 0;      // number of wifi networks detected
+
+int8_t currentNumberOfNetwork    = 0;      // number of wifi networks detected
+bool startNetwork = true;
+int8_t delayCounter    = 0;      // number of wifi networks detected
+int8_t delayCounterMax    = 126;      // number of wifi networks detected
+
+
+char i2c_dev[I2C_DISPLAY_DEVICE][32]; // Array on string displayed
+
+
+/* ======================================================================
+  Function: i2cScan
+  Purpose : scan I2C bus
+  Input   : specifc address if looking for just 1 specific device
+  Output  : number of I2C devices seens
+  Comments: -
+  ====================================================================== */
+uint8_t i2c_scan(uint8_t address = 0xff)
+{
+  uint8_t error;
+  int nDevices;
+  uint8_t start = 1 ;
+  uint8_t end   = 0x7F ;
+  uint8_t index = 0;
+  char device[16];
+  char buffer[32];
+
+  if (address >= start && address <= end) {
+    start = address;
+    end   = address + 1;
+    Serial.print(F("Searching for device at address 0x"));
+    Serial.printf("%02X ", address);
+  } else {
+    Serial.println(F("Scanning I2C bus ..."));
+  }
+
+  nDevices = 0;
+  for (address = start; address < end; address++ ) {
+    // The i2c_scanner uses the return value of
+    // the Write.endTransmisstion to see if
+    // a device did acknowledge to the address.
+    Wire.beginTransmission(address);
+    error = Wire.endTransmission();
+
+    if (error == 0) {
+      Serial.printf("Device ");
+
+      if (address == 0x40)
+        strcpy(device, "TH02" );
+      else if (address == 0x29 || address == 0x39 || address == 0x49)
+        strcpy(device, "TSL2561" );
+      else if (address == I2C_DISPLAY_ADDRESS || address == I2C_DISPLAY_ADDRESS + 1)
+        strcpy(device, "OLED SSD1306" );
+      else if (address == 0x64)
+        strcpy(device, "ATSHA204" );
+      else
+        strcpy(device, "Unknown" );
+
+      sprintf(buffer, "0x%02X : %s", address, device );
+      if (index < I2C_DISPLAY_DEVICE) {
+        strcpy(i2c_dev[index++], buffer );
+      }
+
+      Serial.println(buffer);
+      nDevices++;
+    }
+    else if (error == 4)
+    {
+      Serial.printf("Unknow error at address 0x%02X", address);
+    }
+
+    yield();
+  }
+  if (nDevices == 0)
+    Serial.println(F("No I2C devices found"));
+  else
+    Serial.printf("Scan done, %d device found\r\n", nDevices);
+
+  return nDevices;
+}
+
+
+/* ======================================================================
+  Function: drawProgress
+  Purpose : prograss indication
+  Input   : OLED display pointer
+          percent of progress (0..100)
+          String above progress bar
+          String below progress bar
+  Output  : -
+  Comments: -
+  ====================================================================== */
+void drawProgress(OLEDDisplay *display, int percentage, String labeltop, String labelbot) {
+  if (has_display) {
+    display->clear();
+    display->setTextAlignment(TEXT_ALIGN_CENTER);
+    display->setFont(Roboto_Condensed_Bold_Bold_16);
+    display->drawString(64, 8, labeltop);
+    display->drawProgressBar(10, 28, 108, 12, percentage);
+    display->drawString(64, 48, labelbot);
+    display->display();
+  }
+}
+
+/* ======================================================================
+  Function: drawProgress
+  Purpose : prograss indication
+  Input   : OLED display pointer
+          percent of progress (0..100)
+          String above progress bar
+  Output  : -
+  Comments: -
+  ====================================================================== */
+void drawProgress(OLEDDisplay *display, int percentage, String labeltop ) {
+  drawProgress(display, percentage, labeltop, String(""));
+}
+
+
+/* ======================================================================
+  Function: drawFrameNet
+  Purpose : WiFi network info screen (called by OLED ui)
+  Input   : OLED display pointer
+  Output  : -
+  Comments: -
+  ====================================================================== */
+void drawFrameNet(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
+  char buff[64];
+  sprintf(buff, "%d Wifi Network", NumberOfNetwork);
+  display->clear();
+  display->setTextAlignment(TEXT_ALIGN_CENTER);
+  display->setFont(Roboto_Condensed_Bold_Bold_16);
+  display->drawString(x + 64, y + 0 , buff);
+  display->setTextAlignment(TEXT_ALIGN_LEFT);
+  display->setFont(Roboto_Condensed_12);
+
+
+  for (int i = 0; i < WIFI_DISPLAY_NET; i++) {
+    // Print SSID and RSSI for each network found
+    if (i + currentNumberOfNetwork < NumberOfNetwork) {
+      sprintf(buff, "%s %c", WiFi.SSID(i + currentNumberOfNetwork).c_str(), WiFi.encryptionType(i + currentNumberOfNetwork) == ENC_TYPE_NONE ? ' ' : '*' );
+      display->drawString(x + 0, y + 16 + 12 * i, buff);
+    }
+  }
+
+  ui.disableIndicator();
+}
+
+/* ======================================================================
+  Function: drawFrameWifi
+  Purpose : WiFi logo and IP address
+  Input   : OLED display pointer
+  Output  : -
+  Comments: -
+  ====================================================================== */
+void drawFrameWifi(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
+  display->clear();
+  display->setTextAlignment(TEXT_ALIGN_CENTER);
+  display->setFont(Roboto_Condensed_Bold_Bold_16);
+  // see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
+  // on how to create xbm files
+  display->drawXbm( x + (128 - WiFi_width) / 2, 0, WiFi_width, WiFi_height, WiFi_bits);
+  //display->drawString(x+ 64, WiFi_height+4, WiFi.localIP().toString());
+  ui.disableIndicator();
+}
+
+/* ======================================================================
+  Function: drawFrameLogo
+  Purpose : Company logo info screen (called by OLED ui)
+  Input   : OLED display pointer
+  Output  : -
+  Comments: -
+  ====================================================================== */
+void drawFrameLogo(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
+  display->clear();
+  display->drawXbm(x + (128 - ch2i_width) / 2, y, ch2i_width, ch2i_height, ch2i_bits);
+  ui.disableIndicator();
+}
+
+// this array keeps function pointers to all frames
+// frames are the single views that slide from right to left
+FrameCallback frames[] = {drawFrameNet};
+int numberOfFrames = 1;
+
+
+/* ======================================================================
+  Function: setReadyForUpdate
+  Purpose : Called by ticker to tell main loop we need to update data
+  Input   : -
+  Output  : -
+  Comments: -
+  ====================================================================== */
+void setReadyForUpdate() {
+  Serial.println("Setting readyForUpdate to true");
+  readyForUpdate = true;
+}
+
+void setReadyForWifiUpdate() {
+  Serial.println("Setting readyForWifiUpdate to true");
+  readyForWifiUpdate = true;
+}
+
+
+void wifiscan() {
+  uint16_t progress = 0;
+  Serial.println(F("WiFi scan start"));
+  drawProgress(&display, progress, F("Scanning WiFi"));
+
+  // WiFi.scanNetworks will return the number of networks found
+  NumberOfNetwork = 0;
+  WiFi.scanNetworks(true);
+  // Async, wait start
+  while (WiFi.scanNetworks() != WIFI_SCAN_RUNNING );
+
+  do {
+    progress++;
+    if (progress > 100) {
+      progress = 100;
+    }
+    drawProgress(&display, progress, F("Scanning WiFi"));
+
+    NumberOfNetwork = WiFi.scanComplete();
+    //Serial.printf("NumberOfNetwork=%d\n", NumberOfNetwork);
+  } while (NumberOfNetwork == WIFI_SCAN_RUNNING || NumberOfNetwork == WIFI_SCAN_FAILED);
+
+  Serial.println(F("scan done"));
+
+}
+
+void displayWifiLogo() {
+  if (has_display) {
+    Serial.println(F("Display found"));
+    // initialize dispaly
+    display.init();
+    display.flipScreenVertically();
+    display.clear();
+    display.setFont(Roboto_Condensed_Bold_Bold_16);
+    display.setTextAlignment(TEXT_ALIGN_CENTER);
+    display.drawXbm( (128 - WiFi_width) / 2, 0, WiFi_width, WiFi_height, WiFi_bits);
+    display.drawString( 64, WiFi_height + 4, "Wifi scanner");
+    display.drawString( 64, WiFi_height + 4, "Wifi scanner");
+    display.display();
+    display.setContrast(255);
+    delay(1000);
+  }
+
+}
+
+
+/* ======================================================================
+  Function: setup
+  Purpose : you should know ;-)
+  ====================================================================== */
+void setup()
+{
+  uint8_t pbar = 0;
+
+  Serial.begin(115200);
+  Serial.print(F("\r\nBooting on "));
+  Serial.println(ARDUINO_BOARD);
+
+  //Wire.pins(SDA, SCL);
+  Wire.begin(SDA_PIN, SDC_PIN);
+  Wire.setClock(100000);
+
+  if (i2c_scan(I2C_DISPLAY_ADDRESS)) {
+    has_display = true;
+  } else {
+    if (i2c_scan(I2C_DISPLAY_ADDRESS + 1)) {
+      has_display = true;
+    }
+  }
+
+  displayWifiLogo();
+
+  // Set WiFi to station mode and disconnect from an AP if it was previously connected
+  WiFi.mode(WIFI_STA);
+  delay(100);
+
+  wifiscan();
+  Serial.println(F("Setup done"));
+  drawProgress(&display, 100, F("Setup Done"));
+
+
+  if (has_display) {
+    ui.setTargetFPS(30);
+    //ui.setFrameAnimation(SLIDE_LEFT);
+    ui.disableAutoTransition();
+    ui.setFrames(frames, numberOfFrames);
+    ui.init();
+    display.flipScreenVertically();
+  }
+
+  ticker.attach(5, setReadyForUpdate);
+  tickerWifi.attach(60, setReadyForWifiUpdate);
+}
+
+/* ======================================================================
+  Function: loop
+  Purpose : you should know ;-)
+  ====================================================================== */
+void loop()
+{
+  if (has_display) {
+    int remainingTimeBudget = ui.update();
+
+    if (remainingTimeBudget > 0) {
+      // You can do some work here
+      // Don't do stuff if you are below your
+      // time budget.
+      delay(remainingTimeBudget);
+    }
+  }
+
+  if (readyForUpdate) {
+    readyForUpdate = false;
+    currentNumberOfNetwork += WIFI_DISPLAY_NET;
+    if (currentNumberOfNetwork >= NumberOfNetwork) {
+      currentNumberOfNetwork = 0;
+    }
+  }
+  if (readyForWifiUpdate) {
+    readyForWifiUpdate = false;
+    wifiscan();
+    displayWifiLogo();
+    currentNumberOfNetwork = 0;
+  }
+}
+


initial commit

initial commit

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


Add SIM multiple func sample

Add SIM multiple func sample

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


Test input values by displaying in the serial monitor

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

--- Functionality/SetupTemplate/SetupTemplate/SetupTemplate.ino
+++ Functionality/SetupTemplate/SetupTemplate/SetupTemplate.ino
@@ -0,0 +1,59 @@
+//Skript for testing the input-values of the arduino by displaying values in the serial monitor
+
+int delayTime = 4000;
+int buttonState = 0;
+
+int piezo = A0;
+int photo = A1;
+int poti = A2;
+int switchBtn = 11;
+int buttonBtn = 12;
+int extFlash = 8;
+int camTrigger = 9;
+int camFocus = 10;
+
+int piezoValue = 0;
+int photoValue = 0;
+int potiValue = 0;
+int btnState = 0;
+int switchState = 0;
+
+
+void setup()
+{
+ Serial.begin(9600);
+ pinMode(piezo, INPUT); pinMode(photo, INPUT); pinMode(poti, INPUT); pinMode(switchBtn, INPUT);
+ pinMode(buttonBtn, INPUT); pinMode(extFlash, OUTPUT); pinMode(camTrigger, OUTPUT); pinMode(camFocus, OUTPUT);
+}
+
+void loop()
+{
+  if(readSensors() == true)
+  {
+    takePicture();
+  }
+  delay(delayTime);
+}
+
+int readSensors()
+{
+piezoValue = analogRead(piezo);
+photoValue = analogRead(photo);
+potiValue = analogRead(poti);
+
+btnState = digitalRead(buttonBtn);
+switchState = digitalRead(switchBtn);
+
+Serial.print("Piezo-Wert : ");Serial.println(piezoValue);
+Serial.print("Photo-Resistor : ");Serial.println(photoValue);
+Serial.print("Potentiometer : ");Serial.println(potiValue);
+Serial.print("Taster : ");Serial.println(btnState);
+Serial.print("Schalter : ");Serial.println(switchState);
+Serial.println("  ");
+return(true);
+}
+
+void takePicture()
+{
+// do stuff here
+}


moved cruise control example into this repo

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

--- examples/cruiseExample/cruiseExample.ino
+++ examples/cruiseExample/cruiseExample.ino
@@ -0,0 +1,56 @@
+#include "Servo.h"
+#include "SPI.h"
+#include "Wire.h"
+#include "MINDSi.h"
+#include "Encoder.h"
+#include "DroneLibs.h"
+
+const float maxMPH        = 6.0;
+const float tireDiameter  = 5.85;
+                            //tire circ in miles per inch diameter * diff ratio
+const float MilesPerRev   = (((PI)/12.f)/5280.f) * (13.f/37.f);
+                            //hours per min      rev per mile
+const float MPHvRPM       = (1.f/60.f)        * (1.f/MilesPerRev);
+inline float MPHtoRPM(float mph){ return (mph*MPHvRPM)/tireDiameter; }
+inline float RPMtoMPH(float rpm){ return (rpm*tireDiameter)/MPHvRPM; }
+
+PIDparameters param(0.05 ,0.1,0.0);
+PIDcontroller cruise(param);
+Servo drive, steer, backsteer;
+
+void setup(){
+    Serial.begin(9600);
+
+    drive.attach(4);
+    steer.attach(5);
+    backsteer.attach(6);
+    drive.write(90);
+    steer.write(90);
+    backsteer.write(90);
+    delay(2000);
+
+    encoder::begin(0, 1);
+}
+
+void loop(){
+    float   mph = ((getRadio(2)-90) / 90.f)*maxMPH;
+    uint8_t str = getRadio(3);
+
+    if(abs(mph)<0.5f){
+        cruise.stop();
+    } else {
+        cruise.set(MPHtoRPM(mph));
+    }
+
+    float output = cruise.calc(encoder::getRPM());
+    drive.write(90+output);
+    steer.write(str);
+    backsteer.write(180-str);
+
+    Serial.print(90+output);
+    Serial.print("\t");
+    Serial.print(str);
+    Serial.print("\n");
+
+    delay(2);
+}


From last nigh

From last nigh

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


moved valve control for arudino comp

moved valve control for arudino comp

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

--- valves/Bar_Robot_Valve_Control/Bar_Robot_Valve_Control.ino
+++ valves/Bar_Robot_Valve_Control/Bar_Robot_Valve_Control.ino
@@ -0,0 +1,55 @@
+byte in_byte;
+int valve_pins[6] = {1, 2, 3, 4, 5, 6};
+int max_time = 30000;
+
+void setup()
+{
+  Serial.begin(9600);
+  for (int i=0; i<6; i++) {
+   pinMode(valve_pins[i], OUTPUT);
+  }
+  for (int i=0; i<6; i++) {
+   digitalWrite(valve_pins[i], HIGH);
+  }
+  Serial.print("Ready");
+}
+
+void loop()
+{
+  byte valve_times[6];
+  boolean reading = false;
+  int current_byte=0;
+  if (Serial.available() > 0) {
+    in_byte= Serial.read();
+    if (in_byte == 1 && !reading) {
+      for (int i=0; i<6; ++i) {
+        valve_times[0] = 0;
+      }
+      reading = true;
+      current_byte=0;
+    }
+    if (reading) {
+      valve_times[current_byte] = Serial.read();
+      current_byte++;
+      if (current_byte == 6) {
+        reading = false;
+        // Begin valve control
+
+        // Initially turn on all valves
+        for (int i=0; i<6; i++) {
+          digitalWrite(valve_pins[i], LOW);
+        }
+        for (int time=2; time<256; ++time) {
+          for (int i=0; i<6; ++i) {
+            if (valve_times[i] == time) {
+              digitalWrite(valve_pins[i], HIGH);
+            }
+          }
+          delay(max_time / 256);
+        }
+      }
+    }
+  }
+}
+
+


Create ESP8266-NRF24L01-Remote.ino

Create ESP8266-NRF24L01-Remote.ino

error: pathspec 'ESP8266/ESP8266-NRF24L01-Remote/ESP8266-NRF24L01-Remote.ino' did not match any file(s) known to git

--- ESP8266/ESP8266-NRF24L01-Remote/ESP8266-NRF24L01-Remote.ino
+++ ESP8266/ESP8266-NRF24L01-Remote/ESP8266-NRF24L01-Remote.ino
@@ -0,0 +1,456 @@
+#include <SPI.h>
+#include <nRF24L01.h>
+#include <RF24.h>
+
+#include <Esp.h>
+#include <ESP8266WiFi.h>
+#include <WiFiClient.h>
+#include <ESP8266WebServer.h>
+#include <ESP8266mDNS.h>
+
+#include <Keypad_MC17.h>
+#include <Keypad.h>
+#include <Wire.h>
+
+// Keypad Configuration
+
+#define I2CADDR 0x20
+
+const byte ROWS = 7; //four rows
+const byte COLS = 5; //five columns
+//define the cymbols on the buttons of the keypads
+char keys[ROWS][COLS] = {
+  {'0','0','0','C','3'},
+  {'0','J','9','H','L'},
+  {'B','K','D','4','7'},
+  {'G','W','8','A','O'},
+  {'R','N','5','0','6'},
+  {'0','M','I','F','2'},
+  {'0','0','0','E','1'}
+};
+byte rowPins[ROWS] = {0, 1, 2, 3, 4, 5, 6}; //connect to the row pinouts of the keypad
+byte colPins[COLS] = {12, 11, 10, 9, 8}; //connect to the column pinouts of the keypad
+
+//initialize an instance of class NewKeypad
+Keypad_MC17 customKeypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS, I2CADDR);
+
+// NRF24L01+ Radio Configuration
+
+RF24 radio(16, 15);
+byte address[6] = "01337";
+
+// Wi-Fi Configuration
+
+MDNSResponder mdns;
+const char *ssid = "*";
+const char *password = "*";
+
+// HTTP Server Configuration - Part 1
+
+ESP8266WebServer server(80);
+
+String webPage = "";
+
+
+void setup()
+{
+
+// HTTP Server Configuration - Part 2
+// Build the web page
+  webPage += "";
+  webPage +="<META HTTP-EQUIV=\"refresh\" CONTENT=\"15;URL=/\">";
+  webPage += "<title>Wrench Mask LED Control</title>";
+  webPage += "";
+  webPage += "";
+  webPage += "";
+  webPage += "
Wrench Mask LED Control
";
+// Color Options
+  webPage += "
<button style=\"height:100px;width:250px;font-size:50px;color:red\">RED</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px;color:green\">GREEN</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px;color:blue\">BLUE</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px;color:white\">WHITE</button>
";
+// Face Options 1-3
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">X_X</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">>_<</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">^_^</button>";
+  webPage += "
";
+// Face Options 4-6
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">@_@</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">/_\\</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">?_?</button>";
+  webPage += "
";
+// Face Options 7-9
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">O_o</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">\\_/</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">Z_Z</button>";
+  webPage += "
";
+// Face Options 10-12
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">#_#</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">=_=</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">~_^</button>";
+  webPage += "
";
+// Face Options 13-15
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">9_9</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">!_!</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">*_*</button>";
+  webPage += "
";
+// Face Options 16-18
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">'_'</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">;_;</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">.)_.)</button>";
+  webPage += "
";
+// Face Options 19-21
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">(._(.</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">o_O</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">._.</button>";
+  webPage += "
";
+// Face Options 22-23
+  webPage += "
";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\">&#8976_&#8976</button>";
+  webPage += "<button style=\"height:100px;width:250px;font-size:50px\"><3_<3</button>";
+  webPage += "
";
+
+// Initialize all the things
+
+  delay(1000);
+  Wire.begin( );
+  customKeypad.begin( );
+  Serial.begin(115200);
+  Serial.println("Starting Remote");
+  Serial.println("");
+  Serial.print("Initializing NRF24 Radio...");
+  radio.begin();
+  radio.openWritingPipe(address);
+  radio.setPALevel(RF24_PA_HIGH);
+  radio.stopListening();
+  Serial.println("Done");
+//  radio.printDetails();
+  Serial.print("Initializing WiFi Radio..");
+  WiFi.begin(ssid, password);
+// Wait for connection
+  while (WiFi.status() != WL_CONNECTED)
+  {
+    delay(500);
+    Serial.print(".");
+  }
+  Serial.println("Done");
+  Serial.println("");
+  Serial.print("Connected to: ");
+  Serial.println(ssid);
+  Serial.print("IP address: ");
+  Serial.println(WiFi.localIP());
+  Serial.println("");
+  if (mdns.begin("esp8266", WiFi.localIP()))
+  {
+    Serial.println("MDNS responder started");
+  }
+  Serial.println("");
+  Serial.println("Remote Startup Complete");
+
+// HTTP Server Configuration - Part 3
+
+  server.on("/", []()
+  {
+    server.send(200, "text/html", webPage);
+  });
+  server.on("/Red", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("HTTP Button Press Detected");
+    Serial.println("Button: RED");
+    Serial.println("Setting Color to Red");
+    char ColorRed = 'R';
+    radio.write(&ColorRed, sizeof(ColorRed));
+  });
+  server.on("/Green", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("HTTP Button Press Detected");
+    Serial.println("Button: GREEN");
+    Serial.println("Setting Color to Green");
+    char ColorGreen = 'G';
+    radio.write(&ColorGreen, sizeof(ColorGreen));
+  });
+  server.on("/Blue", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("HTTP Button Press Detected");
+    Serial.println("Button: BLUE");
+    Serial.println("Setting Color to Blue");
+    char ColorBlue = 'B';
+    radio.write(&ColorBlue, sizeof(ColorBlue));
+  });
+  server.on("/White", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("HTTP Button Press Detected");
+    Serial.println("Button: WHITE");
+    Serial.println("Setting Color to White");
+    char ColorWhite = 'W';
+    radio.write(&ColorWhite, sizeof(ColorWhite));
+  });
+  server.on("/Face001", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 001");
+    char Face001 = '1' ;
+    radio.write(&Face001, sizeof(Face001));
+  });
+  server.on("/Face002", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 002");
+    char Face002 = '2';
+    radio.write(&Face002, sizeof(Face002));
+  });
+  server.on("/Face003", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 003");
+    char Face003 = '3';
+    radio.write(&Face003, sizeof(Face003));
+  });
+  server.on("/Face004", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 004");
+    char Face004 = '4';
+    radio.write(&Face004, sizeof(Face004));
+  });
+  server.on("/Face005", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 005");
+    char Face005 = '5';
+    radio.write(&Face005, sizeof(Face005));
+  });
+  server.on("/Face006", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 006");
+    char Face006 = '6';
+    radio.write(&Face006, sizeof(Face006));
+  });
+  server.on("/Face007", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 007");
+    char Face007 = '7';
+    radio.write(&Face007, sizeof(Face007));
+  });
+  server.on("/Face008", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 008");
+    char Face008 = '8';
+    radio.write(&Face008, sizeof(Face008));
+  });
+  server.on("/Face009", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 009");
+    char Face009 = '9';
+    radio.write(&Face009, sizeof(Face009));
+  });
+  server.on("/Face010", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 010");
+    char Face010 = '0';
+    radio.write(&Face010, sizeof(Face010));
+  });
+  server.on("/Face011", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 011");
+    char Face011 = 'A';
+    radio.write(&Face011, sizeof(Face011));
+  });
+  server.on("/Face012", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 012");
+    char Face012 = 'I';
+    radio.write(&Face012, sizeof(Face012));
+  });
+  server.on("/Face013", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 013");
+    char Face013 = 'C';
+    radio.write(&Face013, sizeof(Face013));
+  });
+  server.on("/Face014", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 014");
+    char Face014 = 'D';
+    radio.write(&Face014, sizeof(Face014));
+  });
+  server.on("/Face015", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 015");
+    char Face015 = 'E';
+    radio.write(&Face015, sizeof(Face015));
+  });
+  server.on("/Face016", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 016");
+    char Face016 = 'F';
+    radio.write(&Face016, sizeof(Face016));
+  });
+  server.on("/Face017", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 017");
+    char Face017 = 'H';
+    radio.write(&Face017, sizeof(Face017));
+  });
+  server.on("/Face018", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 018");
+    char Face018 = 'J';
+    radio.write(&Face018, sizeof(Face018));
+  });
+  server.on("/Face019", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 019");
+    char Face019 = 'K';
+    radio.write(&Face019, sizeof(Face019));
+  });
+  server.on("/Face020", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 020");
+    char Face020 = 'L';
+    radio.write(&Face020, sizeof(Face020));
+  });
+  server.on("/Face021", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 021");
+    char Face021 = 'M';
+    radio.write(&Face021, sizeof(Face021));
+  });
+  server.on("/Face022", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 022");
+    char Face022 = 'N';
+    radio.write(&Face022, sizeof(Face022));
+  });
+  server.on("/Face023", []()
+  {
+    server.send(200, "text/html", webPage);
+    Serial.println("Drawing Face 023");
+    char Face023 = 'O';
+    radio.write(&Face023, sizeof(Face023));
+  });
+  server.begin();
+  Serial.println("HTTP server started");
+}
+
+void loop(){
+  server.handleClient();
+  char key = customKeypad.getKey();
+
+  if (key != NO_KEY){
+    Serial.println("Keypad Button Press Detected");
+    Serial.print("Button : ");
+    Serial.println(key);
+    radio.write(&key, sizeof(key));
+    if (key == '1'){
+      Serial.println("Drawing Face 001");
+    }
+    else if(key == '2'){
+      Serial.println("Drawing Face 002");
+    }
+    else if(key == '3'){
+      Serial.println("Drawing Face 003");
+    }
+    else if(key == '4'){
+      Serial.println("Drawing Face 004");
+    }
+    else if(key == '5'){
+      Serial.println("Drawing Face 005");
+    }
+    else if(key == '6'){
+      Serial.println("Drawing Face 006");
+    }
+    else if(key == '7'){
+      Serial.println("Drawing Face 007");
+    }
+    else if(key == '8'){
+      Serial.println("Drawing Face 008");
+    }
+    else if(key == '9'){
+      Serial.println("Drawing Face 009");
+    }
+    else if(key == '0'){
+      Serial.println("Drawing Face 010");
+    }
+    else if(key == 'A'){
+      Serial.println("Drawing Face 011");
+    }
+    else if(key == 'I'){
+      Serial.println("Drawing Face 011");
+    }
+    else if(key == 'C'){
+      Serial.println("Drawing Face 013");
+    }
+    else if(key == 'D'){
+      Serial.println("Drawing Face 014");
+    }
+    else if(key == 'E'){
+      Serial.println("Drawing Face 015");
+    }
+    else if(key == 'F'){
+      Serial.println("Drawing Face 016");
+    }
+    else if(key == 'H'){
+      Serial.println("Drawing Face 017");
+    }
+    else if(key == 'J'){
+      Serial.println("Drawing Face 018");
+    }
+    else if(key == 'K'){
+      Serial.println("Drawing Face 019");
+    }
+    else if(key == 'L'){
+      Serial.println("Drawing Face 020");
+    }
+    else if(key == 'M'){
+      Serial.println("Drawing Face 021");
+    }
+    else if(key == 'N'){
+      Serial.println("Drawing Face 022");
+    }
+    else if(key == 'O'){
+      Serial.println("Drawing Face 023");
+    }
+    else if(key == 'R'){
+      Serial.println("Setting Color to Red");
+    }
+    else if(key == 'G'){
+      Serial.println("Setting Color to Greed");
+    }
+    else if(key == 'B'){
+      Serial.println("Setting Color to Blue");
+    }
+    else if(key == 'W'){
+      Serial.println("Setting Color to White");
+    }
+  }
+  yield();
+}


Initial prototype to clarify concept

Initial prototype to clarify concept

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

--- TPSrescale_prototype/TPSrescale_prototype.ino
+++ TPSrescale_prototype/TPSrescale_prototype.ino
@@ -0,0 +1,85 @@
+#define INPUTPIN 0
+#define SAMPLES 4
+#define SCALE 10
+#define OUTPUTPIN 1
+#define MAXOUT 1023
+
+
+void setup() {
+  // put your setup code here, to run once:
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+  int dTPS = 0;
+  int samples[SAMPLES];
+  unsigned long timeSamples[SAMPLES];
+  int startAvg = 0;
+  int endAvg = 0;
+  int startTime = 0;
+  int endTime = 0;
+  int outAvg = 0;
+
+  //sample count is defined by SAMPLES.
+  sample(samples, timeSamples); //this accumulates some samples of TPS signal with timestamps.
+
+  // Note that after this point we assume that the array is populated with values!
+  dTPScalc(startAvg, endAvg, startTime, endTime, dTPS, samples, timeSamples); //get the dTPS value
+
+  if (dTPS > 0) //rescale the value only if it's increasing
+  {
+    rescale(outAvg, dTPS, startTime, startAvg);
+  }
+  else
+  {
+    //if we hit this, we need to decay towards the "true" TPS value or do nothing
+
+  }
+}
+
+void sample(int (&samples)[SAMPLES], unsigned long (&timeSamples)[SAMPLES]) {
+  for (int i = 0; i < SAMPLES; i++)
+  {
+    samples[i] = analogRead(INPUTPIN);
+    timeSamples[i] = millis();
+  }
+}
+
+void dTPScalc(int &startAvg, int &endAvg, int &startTime, int &endTime, int &dTPS, int (&samples)[SAMPLES], unsigned long (&timeSamples)[SAMPLES]) {
+  int midCount = SAMPLES / 2;
+  startAvg = 0;
+  endAvg = 0;
+  startTime = 0;
+  endTime = 0;
+  for (int i = 0; i < midCount; i++)
+  {
+    startAvg += samples[i];
+    startTime += timeSamples[i];
+  }
+  startAvg /= midCount;
+  startTime /= midCount;
+
+  for (int i = midCount; i < SAMPLES; i++)
+  {
+    endAvg += samples[i];
+    endTime += timeSamples[i];
+  }
+  endAvg /= midCount;
+  endTime /= midCount;
+  dTPS = (endAvg - startAvg) / (endTime - startTime);
+}
+
+void rescale(int &outAvg, int &dTPS, int &startTime, int &startAvg) {
+  int targetdTPS = 10 * dTPS;
+  int currentTime = millis();
+
+  outAvg = (currentTime - startTime) * targetdTPS;
+  outAvg += startAvg;
+
+  if (outAvg > MAXOUT)
+  {
+    outAvg = MAXOUT;
+  }
+  analogWrite(OUTPUTPIN, outAvg / 4);
+}
+


Add sketch to test mavlink protocol using mavlink 1.0 from https://github.com/mavlink/c_library

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

--- Arduino/ArduinoMAVLink/ArduinoMAVLink.ino
+++ Arduino/ArduinoMAVLink/ArduinoMAVLink.ino
@@ -0,0 +1,65 @@
+// Arduino MAVLink test code.
+
+#include "/home/bat/sketchbook/libraries/mavlink/ardupilotmega/mavlink.h"        // Mavlink interface
+long last_time = 0;
+void setup() {
+  Serial.begin(57600);
+  pinMode(13, OUTPUT);
+}
+
+void loop() {
+	// Define the system type (see mavlink_types.h for list of possible types)
+
+	// Initialize the required buffers
+	mavlink_message_t msg;
+	uint8_t buf[MAVLINK_MAX_PACKET_LEN];
+
+        long t = millis();
+        if (fabs(t-last_time) >= 1000 )
+        {
+          digitalWrite(13, HIGH);
+    	  // Pack the message
+          // static inline uint16_t mavlink_msg_heartbeat_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
+          //	uint8_t type, uint8_t autopilot, uint8_t base_mode, uint32_t custom_mode, uint8_t system_status)
+    	  mavlink_msg_heartbeat_pack(100, 200, &msg, MAV_TYPE_KITE, MAV_AUTOPILOT_GENERIC, MAV_MODE_GUIDED_ARMED, 0, MAV_STATE_ACTIVE);
+
+    	  // Copy the message to send buffer
+    	  uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
+
+    	  // Send the message (.write sends as bytes)
+    	  Serial.write(buf, len);
+          //Serial.println("");
+          last_time = t;
+        }
+        delay(100);
+        digitalWrite(13, LOW);
+}
+
+void SerialEvent() {
+	mavlink_message_t msg;
+	mavlink_status_t status;
+
+	//receive data over serial
+
+        while(Serial.available() > 0) {
+		uint8_t c = Serial.read();
+
+		//try to get a new message
+		if(mavlink_parse_char(MAVLINK_COMM_0, c, &msg, &status)) {
+			// Handle message
+ 			switch(msg.msgid) {
+			        case MAVLINK_MSG_ID_SET_MODE: {
+			        	// set mode
+			        }
+			        break;
+			        case MAVLINK_MSG_ID_COMMAND_ACK:
+					// EXECUTE ACTION
+				break;
+				default:
+					//Do nothing
+				break;
+			}
+		}
+		// And get the next one
+	}
+}


Create Sample.ino

Create Sample.ino

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

--- Examples/Sample/Sample.ino
+++ Examples/Sample/Sample.ino
@@ -0,0 +1,136 @@
+#include <SPI.h>
+#include <MudbusWiFi.h>
+#include <avr/pgmspace.h>
+#include <WiFi.h>
+
+MudbusWiFi Mb;
+//Lamps
+int Out2 = 2;
+int Out3 = 3;
+int Out4 = 4;
+
+void setup()
+{
+ Serial.begin(9600);
+  char ssid[] = "****";      //  your network SSID (name)
+  char pass[] = "****";   // your network password
+  int status = WL_IDLE_STATUS;     // the Wifi radio's stat
+  pinMode(Out2, OUTPUT);               // assign Pin 2 as Output
+  pinMode(Out3, OUTPUT);               // assign Pin 3 as Output
+  pinMode(Out4, OUTPUT);               // assign Pin 4 as Output
+
+
+// check for the presence of the shield:
+  if (WiFi.status() == WL_NO_SHIELD) {
+    Serial.println("WiFi shield not present");
+    // don't continue:
+    while (true);
+  }
+
+  String fv = WiFi.firmwareVersion();
+  if ( fv != "1.1.0" )
+    Serial.println("Please upgrade the firmware");
+
+  // attempt to connect to Wifi network:
+  while ( status != WL_CONNECTED) {
+    Serial.print("Attempting to connect to WPA SSID: ");
+    Serial.println(ssid);
+    // Connect to WPA/WPA2 network:
+    status = WiFi.begin(ssid, pass);
+
+    // wait 10 seconds for connection:
+    delay(10000);
+  }
+
+  // you're connected now, so print out the data:
+  Serial.print("You're connected to the network");
+  printCurrentNet();
+  printWifiData();
+  Serial.print("Connected to wifi. My address:");
+  IPAddress myAddress = WiFi.localIP();
+  Serial.println(myAddress);
+}
+
+void loop()
+{
+    Mb.Run(); // start MbTcp subroutine
+    delay(1000);
+    // Digital OUT 2 (as  Modbus Coil 1)
+  if   (Mb.C[0] == HIGH) {
+    digitalWrite(Out2, HIGH);
+  }
+  else {
+    digitalWrite(Out2, LOW);
+  }
+  // Digital OUT 3 (as  Modbus Coil 2)
+  if   (Mb.C[1] == HIGH) {
+    digitalWrite(Out3, HIGH);
+  }
+  else {
+    digitalWrite(Out3, LOW);
+  }
+  // Digital OUT 4 (as  Modbus Coil 3)
+  if   (Mb.C[2] == HIGH) {
+    digitalWrite(Out4, HIGH);
+  }
+  else {
+    digitalWrite(Out4, LOW);
+  }
+}
+
+void printWifiData() {
+  // print your WiFi shield's IP address:
+  IPAddress ip = WiFi.localIP();
+  Serial.print("IP Address: ");
+  Serial.println(ip);
+
+  // print your MAC address:
+  byte mac[6];
+  WiFi.macAddress(mac);
+  Serial.print("MAC address: ");
+  Serial.print(mac[5], HEX);
+  Serial.print(":");
+  Serial.print(mac[4], HEX);
+  Serial.print(":");
+  Serial.print(mac[3], HEX);
+  Serial.print(":");
+  Serial.print(mac[2], HEX);
+  Serial.print(":");
+  Serial.print(mac[1], HEX);
+  Serial.print(":");
+  Serial.println(mac[0], HEX);
+
+}
+
+void printCurrentNet() {
+  // print the SSID of the network you're attached to:
+  Serial.print("SSID: ");
+  Serial.println(WiFi.SSID());
+
+  // print the MAC address of the router you're attached to:
+  byte bssid[6];
+  WiFi.BSSID(bssid);
+  Serial.print("BSSID: ");
+  Serial.print(bssid[5], HEX);
+  Serial.print(":");
+  Serial.print(bssid[4], HEX);
+  Serial.print(":");
+  Serial.print(bssid[3], HEX);
+  Serial.print(":");
+  Serial.print(bssid[2], HEX);
+  Serial.print(":");
+  Serial.print(bssid[1], HEX);
+  Serial.print(":");
+  Serial.println(bssid[0], HEX);
+
+  // print the received signal strength:
+  long rssi = WiFi.RSSI();
+  Serial.print("signal strength (RSSI):");
+  Serial.println(rssi);
+
+  // print the encryption type:
+  byte encryption = WiFi.encryptionType();
+  Serial.print("Encryption Type:");
+  Serial.println(encryption, HEX);
+  Serial.println();
+}


Initial commit

Initial commit

--- bolt-arduino.ino
+++ bolt-arduino.ino
@@ -0,0 +1,62 @@
+const int P_LED_VCC = 3;
+const int P_LED_DATA = 9;
+const int P_LED_CLOCK = 10;
+const int P_LED_LATCH = 11;
+
+const int LED_TWO_VOLTS = 105;
+
+const uint8_t LED_STATE_OFF = 0;
+const uint8_t LED_STATE_ON = 1;
+
+
+//byte val = B10101010;
+
+byte states[8];
+
+void setup() {
+  Serial.begin(115200);
+
+  // put your setup code here, to run once:
+  pinMode(P_LED_VCC, OUTPUT);
+  pinMode(P_LED_DATA, OUTPUT);
+  pinMode(P_LED_CLOCK, OUTPUT);
+  pinMode(P_LED_LATCH, OUTPUT);
+
+  analogWrite(P_LED_VCC, LED_TWO_VOLTS);
+
+  states[0] = LED_STATE_ON;
+
+  shiftOut();
+
+}
+
+void loop() {}
+
+
+void shiftOut() {
+
+  analogWrite(P_LED_LATCH, LOW);
+
+  //Loop for every byte
+  for (uint8_t i = 0; i < 8; i++)  {
+    //Write byte
+
+    switch (states[i]) {
+      case LED_STATE_OFF:
+      Serial.println("Index : " + String(i) + ". State : OFF " + String(states[i]));
+        analogWrite(P_LED_DATA, LOW);
+        break;
+      case LED_STATE_ON:
+      Serial.println("Index : " + String(i) + ". State : ON " + String(states[i]));
+        analogWrite(P_LED_DATA, LED_TWO_VOLTS);
+        break;
+    }
+
+    //Clock
+    analogWrite(P_LED_CLOCK, LED_TWO_VOLTS);
+    analogWrite(P_LED_CLOCK, LOW);
+  }
+
+  analogWrite(P_LED_LATCH, LED_TWO_VOLTS);
+}
+


código inicial de temperatura

código inicial de temperatura

--- dht_11.ino
+++ dht_11.ino
@@ -0,0 +1,31 @@
+#include "DHT.h"
+#define DHTPIN 2
+#define DHTTYPE DHT11
+DHT dht(DHTPIN, DHTTYPE);
+int pinLDR = A0;
+int valorLDR = 0;
+
+//librerias del DHT 11
+void setup() {
+Serial.begin(9600); //Se inicia la comunicación serial
+dht.begin(); //Se inicia el sensor
+}
+
+void loop(){
+  float h = dht.readHumidity(); //se lee la humedad
+  float t= dht.readTemperature(); // se lee la temperatura
+
+  // con respecto a la luz percibida por el LDR
+  valorLDR= analogRead(pinLDR);
+  Serial.println("Humedad: ");
+  Serial.println(h);
+  Serial.println("Temperatura :");
+  Serial.println(t);
+  Serial.println("Luminosidad: ");
+  Serial.println(valorLDR);
+  // se imprime las variables de temperatura y humedad
+  delay(5000);
+  //con un retraso de 500 milisegundos
+}
+
+


Beispiel Code

Beispiel Code

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

--- examples/LightMeter_LCD/LightMeter_LCD.ino
+++ examples/LightMeter_LCD/LightMeter_LCD.ino
@@ -0,0 +1,82 @@
+#include <Wire.h>
+#include <AS_BH1750.h>
+#include <LiquidCrystal.h>
+
+/*
+ * Clock_LCD
+ *
+ * Author: Alexander Schulz
+ * Version 1.2
+ * Datum: 05.08.2013
+ *
+ * Das Programm benutzt den RTC DS1307 und
+ * zeigt die Zeit auf einem 16x2-Symbol-LCD.
+ *
+ * Verdrahtung (UNO, Nano...)
+ *
+ * BH1750:
+ *     Sensor SCL pin an A5
+ *     Sensor SDA pin an A4
+ *     Sensor VDD pin an 5V
+ *     Sensor GND pin an GND
+ *     Sensor ADDR pin frei
+ *
+ * LCD in 4-Bit-Modus:
+ *     LCD RS pin an digital pin 8
+ *     LCD RW pin an digital pin 13
+ *     LCD Enable pin an digital pin 9
+ *     LCD D4 pin an digital pin 4
+ *     LCD D5 pin an digital pin 5
+ *     LCD D6 pin an digital pin 6
+ *     LCD D7 pin an digital pin 7
+ */
+
+AS_BH1750 lightMeter;
+
+// Setup LCD-Shield
+LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
+
+void setup() {
+  // Display initialisieren
+  lcd.clear();
+  lcd.begin(16, 2); // 16x2 Zeichen
+  lcd.setCursor(0,0);
+  lcd.print("LightMeter v1.0");
+  lcd.setCursor(0,1);
+  lcd.print("Initializing...");
+  delay(1000);
+  lcd.clear();
+
+  if(!lightMeter.begin()){
+    // Prüfen, ob Sensor vorhanden ist
+    lcd.clear();
+    lcd.setCursor(0,0);
+    lcd.print("BH1750 not found");
+    lcd.setCursor(0,1);
+    lcd.print("check wiring!");
+    while (1) {
+      delay(1000);
+    }
+  }
+
+}
+
+void loop() {
+  // Textvariablen
+  char clux[9];
+
+  // Werte auslesen und aufbereiten
+  float lux = lightMeter.readLightLevel();
+  dtostrf(lux, 8, 1, clux);
+
+  lcd.setCursor(0,0);
+  lcd.print("Light level: ");
+  lcd.setCursor(5,1);
+  lcd.print(clux);
+  lcd.print(" lx");
+
+  delay(500);
+}
+
+
+