Create pool_monitor.ino

Create pool_monitor.ino

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

--- ESP8266-Pool_Monitor/pool_monitor.ino
+++ ESP8266-Pool_Monitor/pool_monitor.ino
@@ -0,0 +1,413 @@
+//Project: Monitor water level (HC-SR04P) of Balacing tank and the Temperature of Water (DS18b20) / Ambient (DHT22)
+//         Send alert via Blynk app if water level is too high, or water temperature is higher than 28 C
+
+/*
+//https://community.blynk.cc/t/water-tank-level-indicator-with-low-level-warning-notifications/26271
+
+//v1.0 - Wifi Manager + Blynk
+//v1.1 - added deep sleep function - https://community.blynk.cc/t/esp-deep-sleep/5622/13
+//v1.2 - added run time change of deep sleep interval via UI setup
+//v1.3 -
+
+//**** Blynk Virtual Pin Assignments****
+// V0 - Water temperature alert
+// V1 - Tank Height (cm)
+// V2 - Sensor distance from Tank (cm)
+// V3 - Temperature
+// V4 - Battery voltage
+// V6 - Numeric Widget - Sleep interval (mins)
+// V9 - Level V widget - Water Level %
+//V10 - Numeric Widget - Level exceed then will trigger Alert
+//V11 - Button Widget -  To enable / disable Alert
+//V12 - Distance - height from sensor to water level
+
+Hardware:
+1. Wemos D1 Pro
+2. DS18B20 Temperature Sensor
+3. Ultra Sonic Sensor
+4. 4.7k resistor - put between D4 and VCC
+
+
+Ultra sonic Sensor: Vcc - D7, Gnd - Gnd, Echo - D6, Trigger - D5
+DS18820 - Vcc - D8, Gnd - Gnd, Data - D4
+
+Todo
+----
+- if sonar sensor out of range --> don't save but Alert
+- water temperature alert
+
+*/
+
+#include <OneWire.h>
+#include <DallasTemperature.h>
+#include <ESP8266WiFi.h>
+#include <BlynkSimpleEsp8266.h>
+
+char auth[] = "X2Z4r2nC8AxFGrZQqMhbhBbCgVCtOnhl";
+
+char ssid[] = "dongdaemum";
+char pass[] = "1111111111";
+
+BlynkTimer timer;
+
+//HC-SR04 ultra sonic sensor
+#define trigPin D5  // Trigger Pin
+#define echoPin D6  // Echo Pin
+#define RadarPowerPin D7 //GPIO12 = D6, GPIO14 = D5, GPIO15 = D8
+
+//DS18820 temperature sensor
+#define sensorPin D4
+#define TempPowerPin D8
+
+#define filterSamples   15              // filterSamples should  be an odd number, no smaller than 3
+
+int alertLevelCounter = 0; //Counter starts at zero
+//int volume1; // for smoothing algorithum
+double wLevel; // for smoothing algorithum
+int levelAlert;
+int wateralert = 0;
+//int sensSmoothArray1 [filterSamples];   // array for holding raw sensor values for sensor1
+int smoothDistance;                     // variables for sensor1 data
+
+//double alertInMin = 0.5;                //Alert time following alert water level being reached (0.5 = 30secs)
+//const int alertDuration = 2;            //Alert sent every 2 minutes
+
+int checkFreq = 2;                //how often run the check / sleep for how long before wake up, in mins
+int tankHeight = 100;             //tank's height
+int heightFrTank = 20;            //sensor distance from tank
+long duration, distance;          // Duration used to calculate distance
+
+//init DS11820
+OneWire oneWire(sensorPin);
+DallasTemperature DS18B20(&oneWire);
+float temp;
+float volt;
+
+BLYNK_CONNECTED() { // runs once at device startup, once connected to server.
+  Blynk.syncVirtual(V1);
+  Blynk.syncVirtual(V2);
+  Blynk.syncVirtual(V6);
+  Blynk.syncVirtual(V10);
+  Blynk.syncVirtual(V11);
+}
+
+BLYNK_WRITE(V1) {
+  tankHeight = param.asInt();
+  Serial.print("\nTank's Height: ");
+  Serial.println(tankHeight);
+  Serial.println();
+}
+
+BLYNK_WRITE(V2) {
+  heightFrTank = param.asInt();
+  Serial.print("Height from Tank: ");
+  Serial.println(heightFrTank);
+  Serial.println();
+}
+
+BLYNK_WRITE(V6) {
+  checkFreq = param.asInt();
+  Serial.print("Sleep Interval: ");
+  Serial.println(checkFreq);
+  Serial.println();
+}
+
+BLYNK_WRITE(V10) {
+  levelAlert = param.asInt();
+  Serial.print("Water Level Alert: ");
+  Serial.println(levelAlert);
+  Serial.println();
+}
+
+BLYNK_WRITE(V11) {
+
+  int alertOff = param.asInt();
+
+  if(alertOff == 0) {
+    resetWaterLevelAlert();
+    wateralert = 1;
+    Serial.print("Level Alert is OFF.");
+    Serial.println();
+  }
+  else {
+    resetWaterLevelAlert();
+    wateralert = 0;
+    Serial.print("Level Alert is ON.");
+    Serial.println();
+  }
+
+}
+
+void resetWaterLevelAlert() {
+  alertLevelCounter = 0;
+  wateralert = 0;
+}
+
+void checkWaterLevel() {
+  Serial.print("Water Level (%) = ");
+  Serial.println(wLevel);
+  Serial.print("Level Alert (%) = ");
+  Serial.println(levelAlert);
+  Serial.print("Alert (1 = off, 0 = on) = ");
+  Serial.println(wateralert);
+
+  if(wLevel > levelAlert && wateralert == 0){
+//    alertLevelCounter += 1;
+    Blynk.notify("Water Tank Level Alert"); // send push notification to blynk app
+
+  }
+
+//  if(alertLevelCounter > alertInMin * 60 && wateralert == 0){
+//    Blynk.notify("Water Tank Level Alert"); // send push notification to blynk app
+//    wateralert = 1;
+//    resetWaterLevelAlert();
+//  }
+}
+
+void MeasureCmForSmoothing() {
+
+  //take multiple reading
+
+  digitalWrite(RadarPowerPin, HIGH);  //provide power
+  delay(1000);
+
+    smoothDistance = mesureDistance();
+
+  digitalWrite(RadarPowerPin, LOW);  //turn off power
+  delay(100);
+
+  Serial.print("Smoothed Distance: ");
+  Serial.println(smoothDistance);
+
+  //tank height 100 cm, sensor is 20 cm above the tank
+  wLevel = (tankHeight + heightFrTank - smoothDistance);
+
+  Serial.print("Water Level (cm): ");
+  Serial.println(wLevel);
+
+  //convert to %
+  wLevel = wLevel / tankHeight * 100;
+
+  Serial.print("Water Level (%): ");
+  Serial.println(wLevel);
+
+  Blynk.virtualWrite(V12, smoothDistance); // virtual pin
+  Blynk.virtualWrite(V9, wLevel); // virtual pin
+  delay(1000);
+}
+
+void UploadMeasureCmForSmoothing() {
+
+  Blynk.virtualWrite(V3, temp); // Water level %
+  Blynk.virtualWrite(V4, volt); // battery
+  Blynk.virtualWrite(V9, wLevel); // Water level %
+  Blynk.virtualWrite(V12, smoothDistance); // virtual pin
+
+}
+
+
+void setup() {
+  Serial.begin(115200);
+  Blynk.begin(auth, ssid, pass);
+
+  pinMode(trigPin, OUTPUT);
+  pinMode(echoPin, INPUT);
+  //pin to provide power to ultra sonic sensor
+  pinMode(RadarPowerPin, OUTPUT);
+
+  //pin to provide power to temperature sensor
+  pinMode(TempPowerPin, OUTPUT);
+
+  Serial.println("Measure Water Temperature");
+  measurementEvent();
+
+  Serial.println("\nMeasure Water Level");
+  MeasureCmForSmoothing();
+
+  Serial.println("Upload Data");
+  UploadMeasureCmForSmoothing();
+
+  Serial.println("check WaterLevel Alert");
+  checkWaterLevel();
+
+  goToSleep();
+
+}
+
+void loop() {
+
+}
+
+int digitalSmooth(int rawIn, int *sensSmoothArray){     // "int *sensSmoothArray" passes an array to the function - the asterisk indicates the array name is a pointer
+int j, k, temp, top, bottom;
+long total;
+static int i;
+// static int raw[filterSamples];
+static int sorted[filterSamples];
+boolean done;
+
+i = (i + 1) % filterSamples;    // increment counter and roll over if necc. -  % (modulo operator) rolls over variable
+sensSmoothArray[i] = rawIn;                 // input new data into the oldest slot
+
+// Serial.print("raw = ");
+
+ for (j=0; j<filterSamples; j++){     // transfer data array into anther array for sorting and averaging
+     sorted[j] = sensSmoothArray[j];
+ }
+
+   done = 0;                // flag to know when we're done sorting
+ while(done != 1){        // simple swap sort, sorts numbers from lowest to highest
+      done = 1;
+        for(j = 0; j < (filterSamples - 1); j++){
+           if(sorted[j] > sorted[j + 1]){     // numbers are out of order - swap
+             temp = sorted[j + 1];
+             sorted [j+1] =  sorted[j] ;
+             sorted [j] = temp;
+             done = 0;
+           }
+        }
+  }
+
+   // throw out top and bottom 15% of samples - limit to throw out at least one from top and bottom
+   //  bottom = max(((filterSamples * 15)  / 100), 1);
+   //  top = min((((filterSamples * 85) / 100) + 1  ), (filterSamples - 1));   // the + 1 is to make up for asymmetry caused by integer rounding
+   bottom = max(((filterSamples * 20)  / 100), 1);
+   top = min((((filterSamples * 80) / 100) + 1  ), (filterSamples - 1));   // the + 1 is to make up for asymmetry caused by integer rounding
+   k = 0;
+   total = 0;
+  for( j = bottom; j< top; j++){
+ total += sorted[j];  // total remaining indices
+ k++;
+ //Serial.print(sorted[j]);
+ //Serial.print("   ");
+ //terminal.print(sorted[j]);
+ //terminal.println("   ");
+
+  }
+   //terminal.print("average: ");
+   //terminal.println(total/k);
+   //terminal.flush();
+   //Serial.println();
+   //Serial.print("average = ");
+   //Serial.println(total/k);
+  return total / k;    // divide by number of samples
+}
+
+int mesureSingleDistance() {
+      long duration, distance;
+
+      digitalWrite(trigPin, LOW);
+      delayMicroseconds(2);
+      digitalWrite(trigPin, HIGH);
+      delayMicroseconds(10);
+      digitalWrite(trigPin, LOW);
+      duration = pulseIn(echoPin, HIGH);
+      distance = (duration/2) / 29.1;
+
+      Serial.print("Distance: ");
+      Serial.println(distance);
+
+      return distance;
+  }
+
+/**
+ * mresure distnce average delay 10ms
+ */
+int mesureDistance() {
+    const int ULTRASONIC_MIN_DISTANCE = heightFrTank;  //20
+    const int ULTRASONIC_MAX_DISTANCE = tankHeight + heightFrTank;  //120
+
+      int i, total_count = 0, total_distance = 0, distance, values[10], average, temp, new_count = 0;
+
+      for(i=0; i<5; i++){
+          distance = mesureSingleDistance();
+          //check if out of range
+          if(distance > ULTRASONIC_MIN_DISTANCE && distance < ULTRASONIC_MAX_DISTANCE) {
+              total_distance += distance;
+              values[total_count++]=distance;
+              Serial.printf("Value %d...\n", distance);
+          }
+      }
+
+      Serial.print("total_count = ");
+      Serial.println(total_count);
+      if(total_count > 0) {
+
+          average = total_distance / total_count;
+          total_distance = 0;
+          Serial.printf("Average %d...\n", average);
+
+          for(i=0; i<total_count; i++){
+              temp = (average - values[i])*100/average;
+              Serial.printf("Analyze %d....%d...\n", values[i],temp);
+              if(temp < 10 && temp > -10){
+                  total_distance += values[i];
+                  new_count++;
+              }
+          }
+
+          if(new_count > 0) {
+//              Serial.print("total_distance = ");
+//              Serial.println(total_distance);
+//              Serial.print("new_count = ");
+//              Serial.println(new_count);
+              return total_distance / new_count;
+          }
+      }
+      Serial.println("Sonar sensor out of range");
+      return 0;  //return 0 meaning the sensor out of range
+  }
+
+void goToSleep() {
+  // calculate required sleep time and go to sleep
+
+  Serial.print(" Going to sleep now for ");
+  Serial.print(checkFreq);
+  Serial.println(" mins");
+
+  ESP.deepSleep(checkFreq * 60 * 1000000); //deepSleep is microseconds 1 sec = 1000000
+  delay(100);
+
+} // end of void goToSleep()
+
+void measurementEvent() {
+
+
+  //******Measure Water Temperature*********************************************
+  digitalWrite(TempPowerPin, HIGH);  //provide power
+  delay(2000);
+
+  DS18B20.begin();
+  DS18B20.requestTemperatures();
+  temp = DS18B20.getTempCByIndex(0); // Celcius
+  Serial.print("Temperature (C) = ");
+  Serial.println(temp);
+
+  digitalWrite(TempPowerPin, LOW);  //turn off power
+  delay(100);
+
+  //******Battery Voltage Monitoring*********************************************
+  //depend on 220k or 100k resistor used, toggle between this 2 calculation
+
+  // using 220k
+  // Voltage divider R1=100k, R2 = (220k + 100k) + 220k = 540k
+  // Calculation to get the factor: 4.2v * 100/540 = 0.7777, 0.7777 * y = 4.2, y = 5.4
+//  float calib_factor = 5.28; // change this value to calibrate the battery voltage, 5.28 is so call calibrated
+//  float calib_factor = 5.4;
+
+  // using 100k
+  // Voltage divider R1 = 100k, R2 = (220k + 100k) + 100k = 420k;
+  // Calculation to get the factor: 4.2v * 100/420 = 1, 1 * y = 4.2, y = 4.2
+  float calib_factor = 4.2;
+
+  unsigned long raw = analogRead(A0);
+//  Serial.print("raw analog = ");
+//  Serial.println(raw);
+  float volt = raw * calib_factor/1024;
+
+  Serial.print( "\nVoltage = ");
+  Serial.print(volt, 2); // print with 2 decimal places
+  Serial.println (" V");
+
+ //*******************************************************************************
+}


Create base2clock2.ino

Create base2clock2.ino

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

--- base2clock2.ino
+++ base2clock2.ino
@@ -0,0 +1,176 @@
+/***************************
+
+	base 2 clock code for arduino
+	Copyleft (C) 2015  Daniel K. Spicer
+
+	This program is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 3 of the License, or
+	(at your option) any later version.
+
+	This program 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 General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+****************************/
+
+//int's representing led's. 1 = on, 0 = off. Initially they will all be off.
+int p1,p2,p3,p4,p5,p6,p7,p8,p9 = 0;
+
+int iterations = 0;
+boolean increment = false;
+
+void setup(){
+  //8 led's as outputs.
+  pinMode(13, OUTPUT);
+  pinMode(12, OUTPUT);
+  pinMode(11, OUTPUT);
+  pinMode(10, OUTPUT);
+  pinMode(9, OUTPUT);
+  pinMode(8, OUTPUT);
+  pinMode(7, OUTPUT);
+  pinMode(6, OUTPUT);
+
+  //2 time set buttons as inputs.
+  pinMode(5, INPUT); digitalWrite(5, HIGH);
+  pinMode(4, INPUT); digitalWrite(4, HIGH);
+
+} // end setup()
+
+void loop(){
+
+	if(!time_set){
+		if(p8 == 1)
+			p8 = p7 = p6 = p5 = p4 = p3 = p2 = p1 = 0;
+		else
+			p8 = p7 = p6 = p5 = p4 = p3 = p2 = p1 = 1;
+	} else { //time_set is true
+
+		iterations +=1;
+		if(iterations == 12){
+			iterations = 0;
+			increment = true;
+		}
+
+		if(increment){
+			increment = false;
+			if(p9 == 0){
+				if(p8 == 1 && p7 == 1 && p6 == 1){
+					p8 = 0;
+					p7 = 0;
+					p6 = 0;
+					if(p5 == 0){
+						p5 = 1;
+					} else {
+						if( p4 == 0){
+							p4 = 1;
+							p5 = 0;
+						} else {
+							if(p3 == 0){
+								p3 = 1;
+								p4 = 0;
+								p5 = 0;
+							} else {
+								if(p2 == 0){
+									p2 = 1;
+									p3 = 0;
+									p4 = 0;
+									p5 = 0;
+								} else {
+									if(p1 == 0) {
+										p1 = 1;
+										p2 = 0;
+										p3 = 0;
+										p4 = 0;
+										p5 = 0;
+									} else {
+										p1 = 0;
+										p2 = 0;
+										p3 = 0;
+										p4 = 0;
+										p5 = 0;
+									}
+								}
+							}
+						}
+					}
+				} else {
+					p9 = 1;
+				}
+			} else { // p9 equals 1
+				p9 = 0;
+				if(p8 == 0){
+					p8 = 1;
+				} else {
+					if(p7 == 0){
+						p7 = 1;
+						p8 = 0;
+					} else {
+						p6 = 1;
+						p7 = 0;
+						p8 = 0;
+					}
+				}
+			}
+		} // end if(increment)
+
+	} //end time_set is true
+
+	if(p1 == 1)
+    digitalWrite(13, HIGH);
+	else
+    digitalWrite(13, LOW);
+	if(p2 == 1)
+    digitalWrite(12, HIGH);
+	else
+    digitalWrite(12, LOW);
+	if(p3 == 1)
+    digitalWrite(11, HIGH);
+	else
+    digitalWrite(11, LOW);
+	if(p4 == 1)
+    digitalWrite(10, HIGH);
+	else
+    digitalWrite(10, LOW);
+	if(p5 == 1)
+    digitalWrite(9, HIGH);
+	else
+    digitalWrite(9, LOW);
+	if(p6 == 1)
+    digitalWrite(8, HIGH);
+	else
+    digitalWrite(8, LOW);
+	if(p7 == 1)
+    digitalWrite(7, HIGH);
+	else
+    digitalWrite(7, LOW);
+	if(p8 == 1)
+    digitalWrite(6, HIGH);
+	else
+    digitalWrite(6, LOW);
+
+
+  if(reset_fast){
+    delay(100);
+		increment = true;
+		time_set = true;
+		iterations = 0;
+  }else{
+    if(reset_slow){
+      delay(1000);
+			increment = true;
+			time_set = true;
+			iterations = 0;
+    }else{
+			if(!time_set)
+				delay(1000);
+			else
+				delay(5000);
+    }
+  }
+
+} // end loop()


updated to use both sd & leds

updated to use both sd & leds

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/prilutskiy/ledpad.git/'


Create ProbeCube_pp_099b0224.ino

Create ProbeCube_pp_099b0224.ino

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


pretty solid

pretty solid

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

--- button_multichannel_resistorexp/button_multichannel_resistorexp.ino
+++ button_multichannel_resistorexp/button_multichannel_resistorexp.ino
@@ -0,0 +1,932 @@
+/**********************************************************
+                Fast PWM Test
+Demostrates the generation of high speed PWM
+using timers 1 and 4
+There are two pieces of code:
+One for pins 9, 10 and 11 using TIMER 1
+with frequencies up to 62kHz
+Other for pins 6 and 13 using TIMER 4
+with frequencies up to 187kHz
+History:
+  12/12/2014 - Version 1.0
+  22/12/2014 - Adding a missing OCR4C value
+
+  http://r6500.blogspot.com/2014/12/fast-pwm-on-arduino-leonardo.html
+
+***********************************************************/
+
+// https://web.archive.org/web/20140101032749/http://coolarduino.wordpress.com/2012/09/19/quasi-real-time-oscilloscope-remix/
+
+
+
+/**********************************************************
+   Fast PWM on pins 9,10,11 (TIMER 1)
+
+   Do not use analogWrite to pins 9, 10 or 11 if using
+   this functions as they use the same timer.
+
+   Those functions will probably conflict with the
+   servo library.
+
+   Uses 5 PWM frequencies between 61Hz and 62.5kHz
+
+**********************************************************/
+
+
+
+
+/**********************************************************
+   Fast PWM on pins 6, 13 (High Speed TIMER 4)
+
+   Do not use analogWrite to pins 6 or 13 if using
+   this functions as they use the same timer.
+
+   Those functions will conflict with the
+   MSTIMER2 library.
+   Uses 7 PWM frequencies between 2930Hz and 187.5kHz
+
+   Timer 4 uses a PLL as input so that its clock frequency
+   can be up to 96MHz on standard Arduino Leonardo.
+   We limit imput frequency to 48MHz to generate 187.5kHz PWM
+   If needed, we can double that up to 375kHz
+**********************************************************/
+
+// Frequency modes for TIMER4
+#define PWM187k 1   // 187500 Hz
+#define PWM94k  2   //  93750 Hz
+#define PWM47k  3   //  46875 Hz
+#define PWM23k  4   //  23437 Hz
+#define PWM12k  5   //  11719 Hz
+#define PWM6k   6   //   5859 Hz
+#define PWM3k   7   //   2930 Hz
+
+// Direct PWM change variables
+#define PWM6        OCR4D
+#define PWM13       OCR4A
+
+// Terminal count
+#define PWM6_13_MAX OCR4C
+
+// Configure the PWM clock
+// The argument is one of the 7 previously defined modes
+void pwm613configure(int mode)
+{
+// TCCR4A configuration
+TCCR4A=0;
+
+// TCCR4B configuration
+TCCR4B=mode;
+
+// TCCR4C configuration
+TCCR4C=0;
+
+// TCCR4D configuration
+TCCR4D=0;
+
+// TCCR4D configuration
+TCCR4D=0;
+
+// PLL Configuration
+// Use 96MHz / 2 = 48MHz
+// PLLFRQ=(PLLFRQ&0xCF)|0x30;
+ PLLFRQ=(PLLFRQ&0xCF)|0x10; // Will double all frequencies
+
+// Terminal count for Timer 4 PWM
+OCR4C=255;
+}
+
+// Set PWM to D6 (Timer4 D)
+// Argument is PWM between 0 and 255
+void pwmSet6(int value)
+{
+OCR4D=value;   // Set PWM value
+DDRD|=1<<7;    // Set Output Mode D7
+TCCR4C|=0x09;  // Activate channel D
+}
+
+// Set PWM to D13 (Timer4 A)
+// Argument is PWM between 0 and 255
+void pwmSet13(int value)
+{
+OCR4A=value;   // Set PWM value
+DDRC|=1<<7;    // Set Output Mode C7
+TCCR4A=0x82;  // Activate channel A
+}
+
+/*************** ADDITIONAL DEFINITIONS ******************/
+
+// Macro to converts from duty (0..100) to PWM (0..255)
+#define DUTY2PWM(x)  ((255*(x))/100)
+
+/**********************************************************/
+
+////////////////////////////////////////
+//////////        WHOA        //////////
+//////////        WHOA        //////////
+//////////        WHOA        //////////
+//////////        WHOA        //////////
+//////////        WHOA        //////////
+////////////////////////////////////////
+
+// Pins
+
+int hvDigitalIn = 19; // pf6 -> A1   D19
+int hvClock = 18;     // pf7 -> A0   D18
+
+int clearPin = 6;     // pd7 -> A7   D6#
+int sense1 = A6;      // pd4 -> A6   D4
+int sense2 = A11;     // pd6 -> A11  D12
+int sense3 = 8;       // pb4 -> A8   D8
+int sense4 = 9;       // pb5 -> A9   D9
+
+int elEnable = 20;    // pf5 -> A2   D20
+
+int detect = 5;
+
+int rxled = 30;
+int txled = 22;
+int rstled = 7;
+
+// This is hacky.
+// Work around from this changing when the program is loaded from the IDE.
+int capSenseFrequency = 1;
+
+// State
+
+#define channelCount 4
+int switched[] = {0, 0, 0, 0};
+bool glow[] = {true, true, true, true};
+bool allGlow[] = {true, true, true, true};
+bool noGlow[] = {false, false, false, false};
+
+#define prevValSize 50
+int prevVal[prevValSize][channelCount];
+
+#define sampleCount 3
+int sampleAll[channelCount][sampleCount];
+int sampleAllVal[channelCount];
+
+int samples[sampleCount];
+int sampleVal = 0;
+
+
+// Helpers
+
+int tempGlow[channelCount];
+byte tempGlow_unroll[channelCount * 2];
+void switchOutputs(bool* glow) {
+  // Make pins on the layout correspond to the pins on the switch
+  tempGlow[2] = glow[0];
+  tempGlow[3] = glow[1];
+  tempGlow[1] = glow[2];
+  tempGlow[0] = glow[3];
+
+  // Process bit flips ahead of sending serial signal
+  PORTF = PORTF | B10000000;
+  for (int i = 0; i < 8; i++) {
+    if (tempGlow[i / 2] == 1) {
+      tempGlow_unroll[i] = PORTF | B01000000;
+    }
+    else {
+      tempGlow_unroll[i] = PORTF & B10111111;
+    }
+  }
+  for (int i = 0; i < 8; i++) {
+    PORTF = tempGlow_unroll[i];
+    //   digitalWrite(hvClock, LOW);
+    PORTF = PORTF & B01111111;
+    //   digitalWrite(hvClock, HIGH);
+    PORTF = PORTF | B10000000;
+  }
+  PORTF = PORTF | B10000000;
+
+
+
+}
+
+void switchOff() {
+
+      //   digitalWrite(hvClock, LOW);
+    PORTF = PORTF & B01111111;
+
+//    digitalWrite(10, HIGH);
+//    digitalWrite(10, LOW);
+    PORTF = PORTF | B00010000;
+    PORTF = PORTF & B11101111;
+
+
+//
+    //   digitalWrite(hvClock, HIGH);
+    PORTF = PORTF | B10000000;
+}
+
+void switchHalfOutputsA() {
+  for (int i = 0; i < 4; i++) {
+    PORTF = PORTF | B01000000;
+ //   PORTF = PORTF | (isSense_active[i] << 6);
+    PORTF = PORTF & B01111111;
+    PORTF = PORTF | B10000000;
+
+    PORTF = PORTF & B10111111;
+    PORTF = PORTF & B01111111;
+    PORTF = PORTF | B10000000;
+  }
+}
+
+void switchHalfOutputsB() {
+  for (int i = 0; i < 4; i++) {
+    PORTF = PORTF & B10111111;
+    PORTF = PORTF & B01111111;
+    PORTF = PORTF | B10000000;
+
+    PORTF = PORTF | B01000000;
+  //  PORTF = PORTF | (isSense_active[i] << 6);
+    PORTF = PORTF & B01111111;
+    PORTF = PORTF | B10000000;
+  }
+}
+
+// This could be fancier...
+void sort(int *a, int len)
+{
+   for (int i = 1; i < len; ++i)
+   {
+     int j = a[i];
+     int k;
+     for (k = i - 1; (k >= 0) && (j < a[k]); k--)
+     {
+       a[k + 1] = a[k];
+     }
+     a[k + 1] = j;
+   }
+}
+
+// This mutates the input array! Beware!
+float getMedian(int* array, int len) {
+//  int len = sizeof(array);
+  sort(array, len);
+  float tempVal = 0;
+  return array[(len / 2) + 1];
+
+//  for (int i = (len / 2) - 1; i < (len / 2) + 2; i++) {
+//    tempVal += array[i];
+//  }
+//  return tempVal / 3;
+}
+
+void ledsOff() {
+  digitalWrite(rxled, LOW);
+  digitalWrite(txled, LOW);
+  digitalWrite(rstled, LOW);
+}
+
+void ledsOn() {
+  digitalWrite(rxled, HIGH);
+  digitalWrite(txled, HIGH);
+  digitalWrite(rstled, HIGH);
+}
+
+unsigned long microsdelay;
+
+// Arduino I/O is real slow.  Opaque bitwise port manipulation ftw!
+int adcSensePorts[] = {B00000000, B00000001, B00000011, B00000100};
+
+// this is internal, use the interface functions below!
+bool toSense_internal[] = {true, true, true, true};
+int senseResults_internal[] = {0, 0, 0, 0};
+
+void el_lightsOn(){
+  PORTF = PORTF | B00100000;
+}
+
+void el_lightsOff(){
+    PORTF = PORTF & B11011111;
+    delayMicroseconds(100);
+}
+
+// Disable the EL supply in a consistent way to ensure
+// more consistent switching/measurements
+void disableELSupply_withResistor(){
+ // listen to resistor
+
+    //  switchOutputs(noGlow);
+    switchOff();
+    //  digitalWrite(elEnable, HIGH);
+    PORTF = PORTF | B00100000;
+    delayMicroseconds(100);
+
+//    microsdelay = micros();
+    while(bitRead(PINC, 6));
+    switchOutputs(allGlow);
+    while(!bitRead(PINC, 6));
+    while(bitRead(PINC, 6));
+
+
+    //  switchOutputs(noGlow);
+    switchOff();
+    delayMicroseconds(30);
+
+//    microsdelay = micros() - microsdelay;
+}
+
+int spinner = 0;
+bool prev = false;
+bool curr = true;
+void disableELSupply_withoutResistor() {
+    PORTF = PORTF | B00100000;
+    delayMicroseconds(100);
+
+    spinner = 0;
+    while(spinner < 10) {
+      spinner += bitRead(PINC, 6);
+    }
+
+    spinner = 0;
+    while(spinner < 10) {
+      spinner += !bitRead(PINC, 6);
+    }
+
+    // digitalWrite(elEnable, LOW);
+    PORTF = PORTF & B11011111;
+
+    switchOutputs(glow);
+    delayMicroseconds(100);
+
+
+
+//    for (int i = 0; i < 10; i++) {
+//      switchHalfOutputsA();
+//      spinner = 0;
+//      while(spinner < 34) {
+//        spinner++;
+//      }
+//
+//      switchHalfOutputsB();
+//      spinner = 0;
+//      while(spinner < 34) {
+//        spinner++;
+//      }
+//    }
+
+    // Make EL lamps float
+ //
+//    switchOff();
+//    switchOutputs(noGlow);
+//        switchOff();
+//    switchOutputs(noGlow);
+//        switchOff();
+}
+
+void enableELSupply() {
+  PORTF = PORTF | B00100000;
+}
+
+void senseChannels_internal(int chargeDelay_micros = 1000) {
+    noInterrupts();
+
+    // make sure pwm oscillator is running.
+    pwm613configure(capSenseFrequency);
+    pwmSet13(127);
+
+    // digitalWrite(clearPin, HIGH);
+    PORTD = PORTD | B10000000;
+
+    if (chargeDelay_micros < 1) {
+      chargeDelay_micros = 1000;
+    }
+
+// Set ADC initialization bits - make sure things haven't gotten misconfigured.
+    // 6: right adjust bits // last 5 bits select ADC.
+    ADMUX = adcSensePorts[3];
+    // high speed mode / 0 / analog selection, extra bit.
+    ADCSRB = B10100000;
+    // disable adc
+    ADCSRA = B00000110;
+
+    disableELSupply_withoutResistor();
+  PORTE = PORTE | B01000000;
+    switchOutputs(noGlow);
+    delayMicroseconds(30);
+
+ //   digitalWrite(rstled, LOW);
+
+// Begin measurement sequence
+    // digitalWrite(clearPin, LOW);
+    PORTD = PORTD & B01111111;
+
+    delayMicroseconds(chargeDelay_micros);
+// start measurement
+// Go backwords so that channel 4 has the lowest sensitivity and 1 has the highest.
+    for(int i = 3; i >= 0; i--) {
+      if (toSense_internal[i]) {
+        // enable / start / auto trigger / interrupt flag / interrupt enable /// scale /// p.315
+        ADCSRA = B11000110;
+        delayMicroseconds(50);
+        ADMUX = adcSensePorts[(i + 3) % 4];
+        while ((ADCSRA & B01000000));
+        sampleVal = ADCL;    // store lower byte ADC
+        sampleVal += ADCH << 8;  // store higher bytes ADC
+        senseResults_internal[i] = sampleVal;
+      }
+      else {
+        ADMUX = adcSensePorts[(i + 3) % 4];
+        senseResults_internal[i] = -1;
+      }
+    }
+
+   //  digitalWrite(elEnable, HIGH);
+   PORTF = PORTF | B00100000;
+   interrupts();
+   //    digitalWrite(clearPin, HIGH);
+   PORTD = PORTD | B10000000;
+   return;
+}
+
+// Sensing interfaces!
+// Note that the channel here corresponds to the number written on the board,
+// which is shifted up by one from the indicies in the senseResults array.
+int senseChannel(int channel, int chargeDelay_micros = 1000, bool isGlow = true) {
+  if (channel < 0 || channel > 4) {
+    Serial.println("Warning: you might not be measuring the channel you intend to!");
+    ledsOn();
+  }
+  channel = (channel - 1) % 4; // sanitize your inputs.
+  for (int i = 0; i < 4; i++) {
+    toSense_internal[i] = false;
+  }
+  toSense_internal[channel] = true;
+  senseChannels_internal(chargeDelay_micros);
+  if (isGlow) {
+    switchOutputs(glow);
+  }
+  return senseResults_internal[channel];
+}
+
+int* senseAll(int chargeDelay_micros = 1000, bool isGlow = true) {
+  for (int i = 0; i < 4; i++) {
+    toSense_internal[i] = true;
+  }
+  senseChannels_internal(chargeDelay_micros);
+
+  if (isGlow) {
+    switchOutputs(glow);
+  }
+  return senseResults_internal;
+}
+
+
+
+bool isSense_active[] = {true, true, true, true};
+int inactiveMeasure[channelCount];
+int activeProbe = 0;
+// This function saves a bit of time by not measuring "inactive" channels each cycle.
+// Makes the measurement go a bit faster, i.e. makes the EL dohickey brighter!
+int* senseAllActive(int chargeDelay_micros = 1000, bool isGlow = true) {
+  activeProbe = (activeProbe + 1) % channelCount;
+  for (int i = 0; i < 4; i++) {
+    if (isSense_active[activeProbe]) {
+      activeProbe = (activeProbe + 1) % channelCount;
+    }
+    else {
+      break;
+    }
+  }
+
+  for (int i = 0; i < 4; i++) {
+    toSense_internal[i] = isSense_active[i];
+    if (i == activeProbe) {
+      toSense_internal[i] = true;
+    }
+  }
+  senseChannels_internal(chargeDelay_micros);
+
+  if (isGlow) {
+    switchOutputs(glow);
+  }
+
+  // Change threshold for activating, might want to make this smaller?
+//  if (inactiveMeasure[activeProbe] - senseResults_internal[activeProbe] > 50 ||
+//      senseResults_internal[activeProbe] < 400) {
+//    isSense_active[activeProbe] = true;
+//  }
+//  else {
+    inactiveMeasure[activeProbe] = senseResults_internal[activeProbe];
+//  }
+
+  for (int i = 0; i < 4; i++) {
+    if (!isSense_active[i]) {
+      senseResults_internal[i] = inactiveMeasure[i];
+    }
+  }
+
+ // Serial.println(isSense_active[2] << 6);
+
+  return senseResults_internal;
+}
+
+// The ardunio IDE insists on changing the frequency of the fast pwm when the board is programmed
+// This is a hack that accounts for that.
+void ensureCorrectFrequency() {
+  switchOutputs(noGlow);
+  ledsOff();
+
+  capSenseFrequency = PWM187k;
+  int read187k = senseChannel(1, 5000);
+  read187k = senseChannel(1, 5000);
+  read187k = senseChannel(1, 5000);
+//  Serial.print("187: ");
+//  Serial.println(read187k);
+
+
+  capSenseFrequency = PWM94k;
+  int read94k = senseChannel(1, 5000);
+  read94k = senseChannel(1, 5000);
+  read94k = senseChannel(1, 5000);
+//  Serial.print("94: ");
+//  Serial.println(read94k);
+
+  if (read94k > read187k) {
+    capSenseFrequency = PWM94k;
+    digitalWrite(rxled, HIGH);
+    if (read94k > 150) {
+      digitalWrite(txled, HIGH);
+    }
+    delay(200);
+  }
+  else{
+    capSenseFrequency = PWM187k;
+    digitalWrite(rstled, HIGH);
+    if (read187k > 150) {
+      digitalWrite(txled, HIGH);
+    }
+    delay(200);
+  }
+  ledsOff();
+}
+
+//////////~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///////////
+
+int* senseResults;
+
+#define smoothedSenseSize 21
+int smoothedSenseHistory[channelCount][smoothedSenseSize];
+int smoothedSenseIter = 1;
+
+void setup() {
+  Serial.begin(9600);
+
+  // hvSwitch communication
+  pinMode(hvDigitalIn, OUTPUT);
+  pinMode(hvClock, OUTPUT);
+
+  pinMode(clearPin, OUTPUT);
+  digitalWrite(clearPin, LOW);
+
+  pinMode(10, OUTPUT);
+
+
+  pinMode(elEnable, OUTPUT);
+  digitalWrite(elEnable, HIGH);
+
+  pinMode(detect, INPUT);
+
+  pinMode(sense1, INPUT);
+  pinMode(sense2, INPUT);
+  pinMode(sense3, INPUT);
+  pinMode(sense4, INPUT);
+
+  pinMode(rxled, OUTPUT);
+  pinMode(txled, OUTPUT);
+  pinMode(rstled, OUTPUT);
+
+  analogReference(DEFAULT);
+
+  // this should be called after the clear pin is set low
+  ensureCorrectFrequency();
+
+  // Disables channels without EL plugged in.
+  senseResults = senseAll(2300, true);
+  for (int i = 0; i < 4; i++) {
+    if (senseResults[i] > 620) {
+      isSense_active[i] = false;
+    }
+  }
+
+  senseResults = senseAll(1500, true);
+  for (int i = 0; i < 4; i++) {
+    inactiveMeasure[i] = senseResults[i];
+  }
+
+  for (int chan = 0; chan < 4; chan++) {
+    for (int s = 0; s < smoothedSenseSize; s++) {
+          smoothedSenseHistory[chan][s] = senseResults[chan];
+    }
+  }
+}
+
+// Do this instead of using a bunch of individual Serial.print statements to save time!
+// If your wire starts flashing when you are logging, this might be why!
+#define printLineSize 200
+char logBuffer[printLineSize];
+char tempLogBuffer[printLineSize];
+
+
+ //   #define ENABLE_LOGGING
+
+#ifdef ENABLE_LOGGING
+
+#define subBufferSize 50
+char signalBuffer[subBufferSize];
+char impulseBuffer[subBufferSize];
+// These are in reference to the impulse, which is itself a funny denoising derivative-y thing
+char extraBuffer[subBufferSize];
+char derivativeBuffer[subBufferSize];
+
+#endif
+
+int val = 0;
+
+int minimum = 10000;
+int maximum = 0;
+
+#define senseSize 21
+int senseHistory[channelCount][senseSize];
+int senseHistoryTemp[senseSize];
+int senseHistoryIter = 0;
+
+bool isTouched = false;
+bool whereTouched[] = {false, false, false, false};
+
+float change = 0;
+
+bool shouldGlow = true;
+
+bool isOn = true;
+bool justSwitched = false;
+int switchedCount = 0;
+
+#define lagWindowSize 21
+int senseIndex[channelCount][lagWindowSize];
+int lagIter = 0;
+int senseLag[] = {0, 0, 0, 0};
+
+int chanImpulse;
+int chanChangeCount;
+
+// Here are the main levers which control the operation of this program
+#define increaseWindow 17
+#define pureIncreaseThreshold 7
+int impulseThresholdBars[] = {3, 3, 6, 9, 13};
+bool isPastThreshold;
+#define glowTime_us 1300
+
+void loop() {
+
+    senseResults = senseAll(1700, true);
+    PORTE = PORTE & B10111111;
+
+    smoothedSenseIter = (smoothedSenseIter + 1) % smoothedSenseSize;
+    lagIter = (lagIter + 1) % lagWindowSize;
+    senseHistoryIter = (senseHistoryIter + 1) % senseSize;
+
+    // Get new smoothed value
+    for (int channel = 0; channel < channelCount; channel++) {
+      senseHistory[channel][senseHistoryIter] = senseResults[channel];
+
+      for (int i = 0; i < senseSize; i++) {
+        senseHistoryTemp[i] = senseHistory[channel][i];
+      }
+
+      sort(senseHistoryTemp, senseSize);
+
+      int prevMeasure = smoothedSenseHistory[channel][(smoothedSenseIter - 1 + smoothedSenseSize) % smoothedSenseSize];
+//      prevMeasure += 1; // slight bias up;
+
+//      // bias towards median
+//      if (prevMeasure > senseHistoryTemp[attractingIndex]) {
+//        prevMeasure = prevMeasure - 1;
+//      }
+//      else {
+//        prevMeasure = prevMeasure + 1;
+//      //  prevMeasure = prevMeasure + (senseHistoryTemp[attractingIndex] - prevMeasure) / 8;
+//      }
+
+//      // slight bias to
+//      if (senseLag[channel] > 1) {
+//        prevMeasure = prevMeasure + 2;
+//      }
+      int bestSquaredError = 10000;
+
+      int startInd = senseIndex[channel][(lagIter + lagWindowSize - 1) % lagWindowSize] - 2;
+      if (startInd < 0) { startInd = 0; }
+      int endInd = startInd + 5 > senseSize - 1 ? senseSize - 1 : startInd + 5;
+
+      for (int i = startInd + 1; i < endInd; i++) {
+        int normError = senseHistoryTemp[i] - prevMeasure;
+        if (normError < 0) {
+          normError = prevMeasure - senseHistoryTemp[i] + 2;
+        }
+//        long currSquaredError = (prevMeasure - senseHistoryTemp[i]) * (prevMeasure - senseHistoryTemp[i]);
+//        if ( prevMeasure < senseHistoryTemp[i]) {
+//
+//        }
+//        long currStep = senseHistoryTemp[i + 1] - senseHistoryTemp[i-1];
+//        long score = (- currSquaredError * currSquaredError);
+//
+        if (normError < bestSquaredError) {
+          bestSquaredError = normError;
+          senseIndex[channel][lagIter] = i;
+        }
+
+      }
+//
+      senseLag[channel] = senseIndex[channel][lagIter] -
+                          senseIndex[channel][(lagIter + 1) % lagWindowSize];
+
+      if (senseLag[channel] >= 3) {
+        senseIndex[channel][lagIter] = senseIndex[channel][(lagIter + 1) % lagWindowSize] + 3;
+      }
+
+      if (senseLag[channel] <= -2) {
+        senseIndex[channel][lagIter] = senseIndex[channel][(lagIter + 1) % lagWindowSize] - 2;
+      }
+//      else if (senseLag[channel] <= -3) {
+//        senseIndex[channel][lagIter] = senseIndex[channel][(lagIter + 1) % lagWindowSize] - 3;
+//      }
+//
+//      startInd = senseIndex[channel][lagIter] + 4;//  > 10 ? senseIndex[channel][lagIter] + 2 : 10;
+//      for (int i = startInd; i > 2; i--) {
+//        if (senseHistoryTemp[i + 1] - senseHistoryTemp[i - 1] > 11) {
+//          senseIndex[channel][lagIter] = i + 1;
+//    //      Serial.println(channel);
+//          break;
+//        }
+//      }
+ //     senseIndex[channel][lagIter] = 8;
+
+      smoothedSenseHistory[channel][smoothedSenseIter] = senseHistoryTemp[senseIndex[channel][lagIter]];
+
+
+
+//      if (bestSquaredError < 3) {
+//        smoothedSenseHistory[channel][smoothedSenseIter] = prevMeasure;
+//      }
+
+//
+//    if(senseHistoryIter==0  && channel == 0){
+//      for(int i=0; i<senseSize; i++){
+//        Serial.print(senseHistoryTemp[i]);
+//        Serial.print(", ");
+//      }
+//      Serial.println();
+//
+//    }
+//
+    }
+
+    for (int channel = 0; channel < channelCount; channel++) {
+      chanImpulse =  smoothedSenseHistory[channel][(smoothedSenseIter + 1 + smoothedSenseSize) % smoothedSenseSize]
+                     - smoothedSenseHistory[channel][smoothedSenseIter];
+      chanChangeCount = 0;
+
+      int senseDiff;
+      for (int steps = 0; steps < increaseWindow; steps++) {
+        senseDiff = smoothedSenseHistory[channel][(smoothedSenseIter - (steps + 1) + smoothedSenseSize) % smoothedSenseSize]
+            - smoothedSenseHistory[channel][(smoothedSenseIter - (steps) + smoothedSenseSize) % smoothedSenseSize];
+
+        if (senseDiff > 0) {
+          chanChangeCount += 1;
+        }
+        if (senseDiff < -2) {
+          chanChangeCount = -1;
+          break;
+        }
+      }
+
+
+      if (chanChangeCount == pureIncreaseThreshold) {
+        isPastThreshold = true;
+      }
+      else if (chanChangeCount > pureIncreaseThreshold - 5) {
+        if (impulseThresholdBars[pureIncreaseThreshold - chanChangeCount] < chanImpulse) {
+          isPastThreshold = true;
+        }
+        else {
+          isPastThreshold = false;
+        }
+      }
+      else {
+        isPastThreshold = false;
+      }
+
+
+      if (switchedCount == 0 && isSense_active[channel] && isPastThreshold){
+        isTouched = true;
+        whereTouched[channel] = true;
+#ifndef ENABLE_LOGGING
+        sprintf(logBuffer, "Switched channel: %d Measurement: %d Impulse: %d Adj transition count: %d",
+          channel, smoothedSenseHistory[channel][smoothedSenseIter], chanImpulse, chanChangeCount);
+        Serial.println(logBuffer);
+#endif
+      }
+#ifdef ENABLE_LOGGING
+
+    // EXEX - Logging inline - pull into a function!
+    int extrabufflen;
+    int derivativelen;
+    int impulselen;
+
+    switch (channel) {
+      case 0:
+        impulselen = sprintf(impulseBuffer, "Imp: %d, ",
+                             chanImpulse);
+        derivativelen = sprintf(derivativeBuffer, "Change: %d, ",
+                                chanChangeCount);
+        extrabufflen = sprintf(extraBuffer, "Smoothing: %d %d, ", senseIndex[channel][lagIter], senseLag[channel]);
+//        extrabufflen = sprintf(extraBuffer, "Is Active: %d, ",isSense_active[channel]);
+                         //     chanImpulse > bigImpulseThreshold && chanChangeCount + 1 >= increaseThresholdWithImpulse);
+
+        break;
+
+      case 1:
+      case 2:
+      case 3:
+        impulselen += sprintf(impulseBuffer + impulselen, "%d, ",
+                              chanImpulse);
+        derivativelen += sprintf(derivativeBuffer + derivativelen, "%d, ",
+                                 chanChangeCount);
+        extrabufflen += sprintf(extraBuffer + extrabufflen, "%d %d, ", senseIndex[channel][lagIter], senseLag[channel]);
+//        extrabufflen += sprintf(extraBuffer + extrabufflen, "%d, ", isSense_active[channel]);
+                        //       chanImpulse > bigImpulseThreshold && chanChangeCount + 1 >= increaseThresholdWithImpulse);
+
+        break;
+
+      default:
+        break;
+    }
+#endif
+
+    }
+
+
+
+#ifdef ENABLE_LOGGING
+  int signallen;
+  for (int chan = 0; chan < channelCount; chan++) {
+    switch (chan) {
+      case 0:
+        for (int l = 0; l < printLineSize; l++) {
+          tempLogBuffer[l] = logBuffer[l];
+        }
+        signallen = sprintf(signalBuffer, "Signal: %d, ", smoothedSenseHistory[chan][smoothedSenseIter]);
+        break;
+
+      case 1:
+      case 2:
+      case 3:
+        signallen += sprintf(signalBuffer + signallen, "%d, ", smoothedSenseHistory[chan][smoothedSenseIter]);
+        break;
+
+      default:
+        Serial.print("blah ");
+        break;
+    }
+  }
+
+  snprintf(logBuffer, printLineSize, "%20s %23s %20s %20s %s",
+           signalBuffer,
+           impulseBuffer,
+           derivativeBuffer,
+           extraBuffer, "");
+
+  Serial.println(logBuffer);
+#endif
+
+
+
+    if (isTouched && switchedCount == 0) {
+      isTouched = false;
+      for (int chan = 0; chan < channelCount; chan++) {
+        if (whereTouched[chan]) {
+#ifdef ENABLE_LOGGING
+          Serial.println("SWITCHED CHANNEL!");
+          Serial.println(chan);
+#endif
+          whereTouched[chan] = false;
+          glow[chan] = !glow[chan];
+        }
+      }
+      switchedCount = senseSize + smoothedSenseSize + lagWindowSize;
+    }
+
+
+
+    disableELSupply_withoutResistor();
+    switchOutputs(glow);
+    enableELSupply();
+
+    if (switchedCount > 0) {
+      switchedCount--;
+    }
+    delayMicroseconds(glowTime_us);
+}


add voc avg ouput

add voc avg ouput


updates in SevenSegController, first version of sketch

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

--- src/elm_clk.ino
+++ src/elm_clk.ino
@@ -0,0 +1,341 @@
+#include <Wire.h>
+
+#include <OneWire.h>
+#include <TimerOne.h>
+#include <DallasTemperature.h>
+
+#include <OneButton.h>
+#include <Time.h>
+#include <MCP79412RTC.h>
+#include "SevenSegController.h"
+
+// ---------------------- //
+//  display control pins
+// ---------------------- //
+#define DIGIT0_PIN 7
+#define DIGIT1_PIN 6
+#define DIGIT2_PIN 5
+#define DIGIT3_PIN 4
+#define COLON_PIN  3
+#define DEGREE_PIN 2
+#define LATCH_PIN  8
+#define CLOCK_PIN 12
+#define DATA_PIN  11
+
+// ---------------------- //
+//  button pins
+// ---------------------- //
+#define BUTTON_A_PIN A0
+#define BUTTON_B_PIN A1
+
+// ---------------------- //
+//  FSM definitions
+// ---------------------- //
+#define EDIT_TIME_MODE 0
+#define SHOW_TIME_MODE 1
+#define SHOW_TEMP_MODE 2
+#define ERROR		   3
+
+#define SHOW_TIME_DURATION 6500
+#define SHOW_TEMP_DURATION 3500
+
+// ---------------------- //
+//  RTC definitions
+// ---------------------- //
+#define NO_OF_DIGITS 4
+
+// ---------------------- //
+//  Thermometer
+// ---------------------- //
+#define ONE_WIRE_BUS 10
+
+// ---------------------- //
+//  Globals
+// ---------------------- //
+byte oldFsmState    = 255;
+byte fsmState       = 0;
+byte activeDigit    = 0;
+byte digitValues[4] = {0,0,0,0};
+int  tempInCelsius  = 0;
+long updateInterval = 100;
+long lastTempRead   = 0;
+long lastClockRead  = 0;
+long lastShowTimeStart = 0;
+long lastShowTempStart = 0;
+
+SevenSegController display(DIGIT0_PIN, DIGIT1_PIN, DIGIT2_PIN, DIGIT3_PIN, COLON_PIN, DEGREE_PIN, LATCH_PIN, DATA_PIN, CLOCK_PIN);
+OneButton buttonA(BUTTON_A_PIN, false);
+OneButton buttonB(BUTTON_B_PIN, false);
+OneWire oneWire(ONE_WIRE_BUS);
+DallasTemperature sensor(&oneWire);
+DeviceAddress devAddr;
+
+void setup()
+{
+	fsmState = EDIT_TIME_MODE;
+
+	// initialize thermometer
+	sensor.begin();
+	sensor.setWaitForConversion(true);
+	sensor.getAddress(devAddr, 0);
+	sensor.requestTemperatures();
+	tempInCelsius = (int) (sensor.getTempC(devAddr)*10);
+
+	// initialize buttons
+	buttonA.setClickTicks(250);
+	buttonA.setPressTicks(600);
+	buttonA.attachLongPressStart(longPressA);
+	buttonA.attachClick(singleClickA);
+	buttonA.attachDoubleClick(doubleClickA);
+
+	buttonB.setClickTicks(250);
+	buttonB.setPressTicks(600);
+	buttonB.attachClick(singleClickB);
+	buttonB.attachDoubleClick(doubleClickB);
+	buttonB.attachLongPressStart(longPressB);
+
+	// initialize rtc
+	// setTime(11, 25, 00, 29, 7, 2015);
+  	// RTC.set(now());
+	setSyncProvider(RTC.get);
+
+	// initialize serial
+	Serial.begin(9600);
+}
+
+void loop()
+{
+	buttonA.tick();
+	buttonB.tick();
+
+	switch (fsmState)
+	{
+		case EDIT_TIME_MODE:
+
+			if (oldFsmState != fsmState)
+			{
+				display.enableClockDisplay();
+				display.enableBlink(0);
+			}
+
+			oldFsmState = fsmState;
+			break;
+
+		case SHOW_TIME_MODE:
+
+			if (oldFsmState != fsmState)
+			{
+				updateTime();
+				lastClockRead = millis();
+				lastShowTimeStart = lastClockRead;
+				display.enableClockDisplay();
+			}
+
+			oldFsmState = fsmState;
+
+			if ((millis() - lastClockRead) > 100)
+			{
+				updateTime();
+				lastClockRead = millis();
+			}
+
+			if ((millis() - lastShowTimeStart) > SHOW_TIME_DURATION)
+			{
+				fsmState = SHOW_TEMP_MODE;
+			}
+
+			break;
+
+		case SHOW_TEMP_MODE:
+
+			if (oldFsmState != fsmState)
+			{
+				updateTemperature();
+				lastTempRead = millis();
+				lastShowTempStart = lastTempRead;
+				display.enableTempDisplay();
+			}
+
+			oldFsmState = fsmState;
+
+			if ((millis() - lastTempRead) > 100)
+			{
+				updateTemperature();
+				lastTempRead = millis();
+			}
+
+			if ((millis() - lastShowTempStart) > SHOW_TEMP_DURATION)
+			{
+				fsmState = SHOW_TIME_MODE;
+			}
+
+			break;
+
+		case ERROR:
+		default:
+			break;
+	}
+
+	delay(10);
+}
+
+// ---------------------- //
+//  Display Update fnc
+// ---------------------- //
+void updateTime()
+{
+	time_t t = now();
+	int h = hour(t);
+	int m = minute(t);
+
+	digitValues[0] = h / 10;
+	digitValues[1] = h % 10;
+	digitValues[2] = m / 10;
+	digitValues[3] = m % 10;
+
+	display.writeDigit(0, digitValues[0]);
+	display.writeDigit(1, digitValues[1]);
+	display.writeDigit(2, digitValues[2]);
+	display.writeDigit(3, digitValues[3]);
+
+	digitalClockDisplay();
+}
+
+
+void updateTemperature()
+{
+	sensor.requestTemperatures();
+	tempInCelsius  = (int) (sensor.getTempC(devAddr)*10);
+	digitValues[0] = tempInCelsius / 100;
+	digitValues[1] = (tempInCelsius % 100) / 10;
+	digitValues[2] = tempInCelsius % 10;
+	display.writeDigit(0,digitValues[0]);
+	display.writeDigit(1,digitValues[1]);
+	display.writeDigit(2,digitValues[2]);
+}
+
+void digitalClockDisplay()
+{
+	time_t t = now();
+	Serial.print(hour(t));
+	printDigits(minute(t));
+	printDigits(second(t));
+	Serial.print(" ");
+	Serial.print(day(t));
+	Serial.print(" ");
+	Serial.print(month(t));
+	Serial.print(" ");
+	Serial.print(year(t));
+	Serial.println();
+}
+
+void printDigits(int digits)
+{
+  // utility function for digital clock display: prints preceding colon and leading 0
+  Serial.print(":");
+  if(digits < 10)
+    Serial.print('0');
+  Serial.print(digits);
+}
+
+int maxValueForDigit(int digit)
+{
+	switch (digit)
+	{
+		case 0:
+			if (digitValues[1] >= 4)
+				return 2;
+			else
+				return 3;
+
+		case 1:
+			if (digitValues[0] <= 1)
+				return 10;
+			else
+				return 4;
+
+		case 2:
+			return 6;
+
+		case 3:
+			return 10;
+	}
+}
+
+// ---------------------- //
+//  Button callbacks
+// ---------------------- //
+void doubleClickA()
+{
+	if (fsmState == EDIT_TIME_MODE)
+	{
+		display.disableBlink(activeDigit);
+		activeDigit+=2;
+		activeDigit %= NO_OF_DIGITS;
+		display.enableBlink(activeDigit);
+	}
+}
+
+void singleClickA()
+{
+	if (fsmState == EDIT_TIME_MODE)
+	{
+		display.disableBlink(activeDigit);
+		activeDigit++;
+		activeDigit %= NO_OF_DIGITS;
+		display.enableBlink(activeDigit);
+	}
+}
+
+void longPressA()
+{
+	switch(fsmState)
+	{
+		case EDIT_TIME_MODE:
+			int h;
+			int m;
+			h = digitValues[0]*10 + digitValues[1];
+			m = digitValues[2]*10 + digitValues[3];
+			setTime(h, m, 0, 1, 1, 2015);
+  			RTC.set(now());
+  			fsmState = SHOW_TIME_MODE;
+  			break;
+
+		case SHOW_TIME_MODE:
+			fsmState = EDIT_TIME_MODE;
+			break;
+	}
+}
+
+void doubleClickB()
+{
+	if (fsmState == EDIT_TIME_MODE)
+	{
+		digitValues[activeDigit] += 2;
+		digitValues[activeDigit] %= maxValueForDigit(activeDigit);
+		display.writeDigit(activeDigit, digitValues[activeDigit]);
+	}
+}
+
+void singleClickB()
+{
+	if (fsmState == EDIT_TIME_MODE)
+	{
+		digitValues[activeDigit]++;
+		digitValues[activeDigit] %= maxValueForDigit(activeDigit);
+		display.writeDigit(activeDigit, digitValues[activeDigit]);
+	}
+}
+
+void longPressB()
+{
+	if (fsmState == EDIT_TIME_MODE)
+	{
+		digitValues[0] = 0; digitValues[1] = 0;
+		digitValues[2] = 0; digitValues[3] = 0;
+		display.writeDigit(0, 0);
+		display.writeDigit(1, 0);
+		display.writeDigit(2, 0);
+		display.writeDigit(3, 0);
+	}
+}


adding basic light sensor to LTC vol 1 example code

error: pathspec 'examples-ltc/7.LTCVolume1/6_LightSensor/BasicLightSensor.ino' did not match any file(s) known to git

--- examples-ltc/7.LTCVolume1/6_LightSensor/BasicLightSensor.ino
+++ examples-ltc/7.LTCVolume1/6_LightSensor/BasicLightSensor.ino
@@ -0,0 +1,22 @@
+// Love to Code
+// Volume 1: Basic Light Sensor
+
+// This code reads a light sensor on pin 5.
+// Pin 0 turns ON when it is dark and OFF when it is bright.
+
+int lightLevel = 0;  // make a variable named lightLevel to save current light level
+
+void setup(){
+  outputMode(0);  // LED on pin 0 will turn on and off
+  inputMode(5);   // light sensor is attached to pin 5
+}
+
+void loop(){
+  bright = read(5);  // read current light level
+
+  if (bright == 1){
+      off(0);        // if light level is bright, turn off pin 0
+    } else {
+      on(0);         // otherwise turn on pin 0
+    }
+}


Delete ESPArto_pinDefRetrigger.ino

Delete ESPArto_pinDefRetrigger.ino

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


Added a individual light test loop.
This tests each green LED and each red LED.

This is the final set of tests.

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


Restore Scout/Arduino test code with better RNG.

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

--- test/ecc_test/ecc_test.ino
+++ test/ecc_test/ecc_test.ino
@@ -0,0 +1,115 @@
+#include <uECC.h>
+
+#include <j0g.h>
+#include <js0n.h>
+
+#include <lwm.h>
+
+#include <bitlash.h>
+
+#include <GS.h>
+
+#include <SPI.h>
+#include <Wire.h>
+#include <Scout.h>
+#include <Shell.h>
+
+
+#include <uECC.h>
+
+extern "C" {
+
+static int RNG(uint8_t *p_dest, unsigned p_size)
+{
+  // Use the least-significant bits from the ADC for an unconnected pin (or connected to a source of random noise)
+  // This can take a long time to generate random data if the result of analogRead(0) doesn't change very frequently.
+  while(p_size) {
+    uint8_t l_val = 0;
+    for(unsigned i=0; i<8; ++i)
+    {
+      int l_init = analogRead(0);
+      int l_count = 0;
+      while(analogRead(0) == l_init)
+      {
+        ++l_count;
+      }
+
+      if(l_count == 0)
+      {
+         l_val = (l_val << 1) | (l_init & 0x01);
+      }
+      else
+      {
+         l_val = (l_val << 1) | (l_count & 0x01);
+      }
+    }
+    *p_dest = l_val;
+    ++p_dest;
+    --p_size;
+  }
+
+  // NOTE: it would be a good idea to hash the resulting random data using SHA-256 or similar.
+  return 1;
+}
+
+}
+
+void setup()
+{
+  Scout.setup();
+
+  Serial.print("Testing ecc\n");
+
+  uECC_set_rng(&RNG);
+}
+
+void loop() {
+  uint8_t l_private1[uECC_BYTES];
+  uint8_t l_private2[uECC_BYTES];
+
+  uint8_t l_public1[uECC_BYTES * 2];
+  uint8_t l_public2[uECC_BYTES * 2];
+
+  uint8_t l_secret1[uECC_BYTES];
+  uint8_t l_secret2[uECC_BYTES];
+
+  unsigned long a = millis();
+  uECC_make_key(l_public1, l_private1);
+  unsigned long b = millis();
+
+  Serial.print("Made key 1 in "); Serial.println(b-a);
+  a = millis();
+  uECC_make_key(l_public2, l_private2);
+  b = millis();
+  Serial.print("Made key 2 in "); Serial.println(b-a);
+
+  a = millis();
+  int r = uECC_shared_secret(l_public2, l_private1, l_secret1);
+  b = millis();
+  Serial.print("Shared secret 1 in "); Serial.println(b-a);
+  if(!r)
+  {
+    Serial.print("shared_secret() failed (1)\n");
+    return;
+  }
+
+  a = millis();
+  r = uECC_shared_secret(l_public1, l_private2, l_secret2);
+  b = millis();
+  Serial.print("Shared secret 2 in "); Serial.println(b-a);
+  if(!r)
+  {
+    Serial.print("shared_secret() failed (2)\n");
+    return;
+  }
+
+  if(memcmp(l_secret1, l_secret2, sizeof(l_secret1)) != 0)
+  {
+    Serial.print("Shared secrets are not identical!\n");
+  }
+  else
+  {
+    Serial.print("Shared secrets are identical\n");
+  }
+}
+


Revert "Initial Commit of File"

Revert "Initial Commit of File"

This reverts commit c4b1c350951e4c1143acff83833cf008455f8f10.

error: pathspec 'electrical/Pause' did not match any file(s) known to git
error: pathspec 'Switch/pause_switch.ino' did not match any file(s) known to git


Moved to this folder.

Moved to this folder.

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

--- examples/SimpleLibDemo/SimpleLibDemo.ino
+++ examples/SimpleLibDemo/SimpleLibDemo.ino
@@ -0,0 +1,66 @@
+#include <Serial.h>
+#include <Wire.h>
+#include <TEA5767N.h>
+
+TEA5767N radio = TEA5767N();
+
+void setup() {
+
+  //Sets the radio station
+  radio.selectFrequency(89.1);
+  delay(2000);
+
+  radio.mute();
+  delay(2000);
+  radio.turnTheSoundBackOn();
+  delay(2000);
+
+  //Observation: At this point your Serial Monitor window should be open.
+
+  radio.muteRight();
+  delay(2000);
+  Serial.println(radio.isStereo() ? "Stereo" : "Mono");
+  radio.turnTheRightSoundBackOn();
+  delay(2000);
+  radio.muteLeft();
+  Serial.println(radio.isStereo() ? "Stereo" : "Mono");
+  delay(2000);
+  radio.turnTheLeftSoundBackOn();
+  delay(2000);
+
+  //Turns the radio off
+  radio.setStandByOn();
+  delay(2000);
+  radio.setStandByOff();
+
+  radio.selectFrequency(107.9);
+  radio.setSearchUp();
+  radio.setSearchMidStopLevel();
+  radio.searchNext();
+  while(!radio.isReady()) {
+    Serial.println("Search in progress...");
+  }
+  if (radio.isBandLimitReached()) {
+     Serial.println("Band Limit Reached, searching down...");
+     radio.setSearchDown();
+     radio.searchNext();
+  }
+  delay(2000);
+
+  //Reading the status
+  //Read frequenci in MHz
+  Serial.println(radio.readFrequencyInMHz(), 1);
+  //Shows reception signal level
+  Serial.println(radio.getSignalLevel());
+  //Reception stereo or mono?
+  Serial.println(radio.isStereo() ? "Stereo" : "Mono");
+  //Ready for new instructions? Done with frequency selection and search?
+  Serial.println(radio.isReady() ? "Ready" : "Not ready");
+  //Has reached superior or inferior band limit?
+  Serial.println(radio.isBandLimitReached() ? "Limit reached" : "Limit not reached");
+}
+
+void loop() {
+
+}
+


Legger til indekserte variabler

Legger til indekserte variabler

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/DivineChili/Arduino-For-Noobs.git/'


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,36 @@
+#include <MudbusYun.h>
+#include <Bridge.h>
+#include <YunClient.h>
+#include <YunServer.h>
+#include <SPI.h>
+
+MudbusYun Mb;
+
+void setup() {
+  delay(10000);
+  Bridge.begin();
+  pinMode(13, OUTPUT);
+}
+
+void loop() {
+  Mb.Run(); // start MbTcp subroutine
+  delay(1000);
+
+  Mb.R[0] = 0;
+  Mb.R[1] = 1;
+  Mb.R[2] = 2;
+  Mb.R[3] = 3;
+  Mb.R[4] = 4;
+  Mb.R[5] = 5;
+  Mb.R[6] = 6;
+  Mb.R[7] = 7;
+
+  if   (!Mb.C[7]) {
+    digitalWrite(13, HIGH);
+  }
+  else {
+    digitalWrite(13, LOW);
+  }
+
+
+}


Update src.ino

Update src.ino

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


counter fix to rainbow

counter fix to rainbow

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/stewartadam/lulzsaber.git/'


latest version of script

latest version of script

Currently not working because ram limitations of UNO, upping the ante to a mega...

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

--- sheild_sdlog_gps_color_v3/sheild_sdlog_gps_color_v3.ino
+++ sheild_sdlog_gps_color_v3/sheild_sdlog_gps_color_v3.ino
@@ -0,0 +1,252 @@
+#include <SPI.h>
+#include <Adafruit_GPS.h>
+#include <SoftwareSerial.h>
+#include <SD.h>
+#include "Adafruit_TCS34725.h"
+#include <avr/sleep.h>
+
+// Ladyada's logger modified by Bill Greiman to use the SdFat library
+//
+// This code shows how to listen to the GPS module in an interrupt
+// which allows the program to have more 'freedom' - just parse
+// when a new NMEA sentence is available! Then access data when
+// desired.
+//
+// Tested and works great with the Adafruit Ultimate GPS Shield
+// using MTK33x9 chipset
+//    ------> http://www.adafruit.com/products/
+// Pick one up today at the Adafruit electronics shop
+// and help support open source hardware & software! -ada
+// Fllybob added 10 sec logging option
+SoftwareSerial mySerial(8, 7);
+Adafruit_GPS GPS(&mySerial);
+
+// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
+// Set to 'true' if you want to debug and listen to the raw GPS sentences
+#define GPSECHO  true
+/* set to true to only log to SD when GPS has a fix, for debugging, keep it false */
+#define LOG_FIXONLY false
+
+// this keeps track of whether we're using the interrupt
+// off by default!
+boolean usingInterrupt = false;
+void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
+
+// Set the pins used
+#define chipSelect 10
+#define ledPin 13
+
+File logfile;
+
+// read a Hex value and return the decimal equivalent
+uint8_t parseHex(char c) {
+  if (c < '0')
+    return 0;
+  if (c <= '9')
+    return c - '0';
+  if (c < 'A')
+    return 0;
+  if (c <= 'F')
+    return (c - 'A')+10;
+}
+
+// blink out an error code
+void error(uint8_t errno) {
+  /*
+  if (SD.errorCode()) {
+   putstring("SD error: ");
+   Serial.print(card.errorCode(), HEX);
+   Serial.print(',');
+   Serial.println(card.errorData(), HEX);
+   }
+   */
+  while(1) {
+    uint8_t i;
+    for (i=0; i<errno; i++) {
+      digitalWrite(ledPin, HIGH);
+      delay(100);
+      digitalWrite(ledPin, LOW);
+      delay(100);
+    }
+    for (i=errno; i<10; i++) {
+      delay(200);
+    }
+  }
+}
+
+Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);
+
+void setup() {
+  // for Leonardos, if you want to debug SD issues, uncomment this line
+  // to see serial output
+  //while (!Serial);
+
+  if (tcs.begin()) {
+    Serial.println("Found sensor");
+  } else {
+    Serial.println("No TCS34725 found ... check your connections");
+    while (1);
+  }
+
+  tcs.setInterrupt(true);
+
+  // connect at 115200 so we can read the GPS fast enough and echo without dropping chars
+  // also spit it out
+  Serial.begin(115200);
+  Serial.println("\r\nUltimate GPSlogger Shield");
+  pinMode(ledPin, OUTPUT);
+
+  // make sure that the default chip select pin is set to
+  // output, even if you don't use it:
+  pinMode(10, OUTPUT);
+
+  // see if the card is present and can be initialized:
+  //if (!SD.begin(chipSelect, 11, 12, 13)) {
+  if (!SD.begin(chipSelect)) {      // if you're using an UNO, you can use this line instead
+    Serial.println("Card init. failed!");
+    error(2);
+  }
+  char filename[15];
+  strcpy(filename, "GPSLOG00.CSV");
+  for (uint8_t i = 0; i < 100; i++) {
+    filename[6] = '0' + i/10;
+    filename[7] = '0' + i%10;
+    // create if does not exist, do not open existing, write, sync after write
+    if (! SD.exists(filename)) {
+      break;
+    }
+  }
+
+  logfile = SD.open(filename, FILE_WRITE);
+  if( ! logfile ) {
+    Serial.print("Couldnt create ");
+    Serial.println(filename);
+    error(3);
+  }
+  Serial.print("Writing to ");
+  Serial.println(filename);
+  //logfile.println("Time, Date, Latitude, Longitude, Elevation, Speed (Knots), Angle, Satellites");
+  //logfile.flush();
+
+  // connect to the GPS at the desired rate
+  GPS.begin(9600);
+
+  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
+  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
+  // uncomment this line to turn on only the "minimum recommended" data
+  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
+  // For logging data, we don't suggest using anything but either RMC only or RMC+GGA
+  // to keep the log files at a reasonable size
+  // Set the update rate
+  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);   // 100 millihertz (once every 10 seconds), 1Hz or 5Hz update rate
+
+  // Turn off updates on antenna status, if the firmware permits it
+  GPS.sendCommand(PGCMD_NOANTENNA);
+
+  // the nice thing about this code is you can have a timer0 interrupt go off
+  // every 1 millisecond, and read data from the GPS for you. that makes the
+  // loop code a heck of a lot easier!
+  useInterrupt(true);
+
+  Serial.println("Ready!");
+}
+
+
+// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
+SIGNAL(TIMER0_COMPA_vect) {
+  char c = GPS.read();
+  // if you want to debug, this is a good time to do it!
+  #ifdef UDR0
+      if (GPSECHO)
+        if (c) UDR0 = c;
+      // writing direct to UDR0 is much much faster than Serial.print
+      // but only one character can be written at a time.
+  #endif
+}
+
+void useInterrupt(boolean v) {
+  if (v) {
+    // Timer0 is already used for millis() - we'll just interrupt somewhere
+    // in the middle and call the "Compare A" function above
+    OCR0A = 0xAF;
+    TIMSK0 |= _BV(OCIE0A);
+    usingInterrupt = true;
+  }
+  else {
+    // do not call the interrupt function COMPA anymore
+    TIMSK0 &= ~_BV(OCIE0A);
+    usingInterrupt = false;
+  }
+}
+
+void loop() {
+  if (! usingInterrupt) {
+    // read data from the GPS in the 'main loop'
+    char c = GPS.read();
+    // if you want to debug, this is a good time to do it!
+    if (GPSECHO)
+      if (c) Serial.print(c);
+  }
+
+  // if a sentence is received, we can check the checksum, parse it...
+  if (GPS.newNMEAreceived()) {
+    // a tricky thing here is if we print the NMEA sentence, or data
+    // we end up not listening and catching other sentences!
+    // so be very wary if using OUTPUT_ALLDATA and trying to print out data
+
+    // Don't call lastNMEA more than once between parse calls!  Calling lastNMEA
+    // will clear the received flag and can cause very subtle race conditions if
+    // new data comes in before parse is called again.
+    char *stringptr = GPS.lastNMEA();
+
+    if (!GPS.parse(stringptr))   // this also sets the newNMEAreceived() flag to false
+      return;  // we can fail to parse a sentence in which case we should just wait for another
+
+    // Sentence parsed!
+    Serial.println("OK");
+    if (LOG_FIXONLY && !GPS.fix) {
+      Serial.print("No Fix");
+      return;
+    }
+
+    // Rad. lets log it!
+    Serial.println("Log");
+
+    logfile.print(GPS.hour, DEC);
+    logfile.print(':');
+    logfile.print(GPS.minute, DEC);
+    logfile.print(':');
+    logfile.print(GPS.seconds, DEC);
+    logfile.print('.');
+    logfile.print(GPS.milliseconds);
+    logfile.print(",");
+
+    logfile.print(GPS.month, DEC);
+    logfile.print('/');
+    logfile.print(GPS.day, DEC);
+    logfile.print("/20");
+    logfile.print(GPS.year, DEC);
+    logfile.print(",");
+
+    logfile.print(GPS.latitude, 4);
+    logfile.print(GPS.lat);
+    logfile.print(",");
+    logfile.print(GPS.longitude, 4);
+    logfile.print(GPS.lon);
+    logfile.print(",");
+    logfile.print(GPS.altitude);
+    logfile.print(",");
+    logfile.print(GPS.speed);
+    logfile.print(",");
+    logfile.print(GPS.angle);
+    logfile.print(",");
+    logfile.println((int)GPS.satellites);
+    logfile.flush();
+    Serial.println("success.");
+    Serial.println();
+  }
+}
+
+
+/* End code */
+


Create platform3.ino

Create platform3.ino

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

--- home/harland/platform3.ino
+++ home/harland/platform3.ino
@@ -0,0 +1,380 @@
+#include <Servo.h>
+
+/*
+for azul mobile platform running on mega board
+which has:
+parallax pings
+i/r sensors
+servo motor drivers
+eacon sensor
+compass HMC5883L
+april 20,2016
+ */
+
+#include <Wire.h>
+#include <SPI.h>
+#include <HMC5883L.h>
+HMC5883L compass;
+#include <Servo.h>
+Servo servoR; // create servo object to control a servo
+Servo servoL; // create servo object to control a servo
+#include <SoftwareSerial.h>
+SoftwareSerial LedSerial(12, 13); // RX2=12 and TX2=13   RX3=63 and TX3=64  RX1=45 and TX1=46
+
+
+String serdata = "";
+// I/R sensors data  turns out this data is not very good
+int distcen = 0;
+int distright = 0;
+int distleft = 0;
+// ping sensors left and right  info very good
+int DistPingRight = 0;
+int DistPingLeft = 0;
+// input routine
+String cmd;
+String sBuffer = "";
+String sResp = "?";
+// motors are controlled like servo
+int OldSpeed = 90;   // storage of last speed for stopping
+int speed = 90;
+int wheeloffsetR = 0;   // try to adjust for different speed motors
+int wheeloffsetL = 0;
+
+int AnalogPinCount = 5;     // number of channels in use
+const int AnalogPins [] =
+{
+  0,  // back center i/r sensor higher number is closer above 400 around 12 inches
+  1,  // front right i/r sensor
+  2,  // front left  i/r sensor
+  3,  // battery voltage 14.8v= 1008cnt and 12.7v=865cnt
+  4,
+  5,
+  6,
+  7,
+  8,
+  9,
+  10,
+  11,
+  12,
+  13,
+};
+
+int OutputPinCount = 4;     // number of channels in use
+const int MaOutputPins [] =
+{
+  4,   // servo motor wheel right
+  2,   // servo motor wheel left
+  3,
+  5,
+  6,
+  7,   // ping right rear
+  8,   // ping left rear
+  9,
+  10,
+  11,  // ping center front
+  12,  // ping left front
+  13,  // ping right front
+};
+
+int PingPinCount = 5;     // number of channels in use
+const int PingPin [] =
+{
+  7,   // ping rear right
+  8,   // ping rear left
+  11,  // ping front center
+  12,  // ping front left
+  13,  // ping front right
+};
+
+
+// could calculate this by #define OutPinCount (sizeof (MaOutputPins) / sizeof (MaOutputPins [0]))
+
+void setup()
+{
+  int i;
+  for (i = 0; i < OutputPinCount; i++)
+  {
+    pinMode (MaOutputPins [i], OUTPUT);     // set to output mode
+    digitalWrite (MaOutputPins [i], LOW);  // set chip enable off
+  }
+// setup SPI channel
+// SPI.begin();         		            // wake up the SPI bus.
+// SPI.setBitOrder(MSBFIRST);  	      // wants data most significant byte first
+// SPI.setDataMode(SPI_MODE3);          //  Set for clock rising edge
+// SPI.setClockDivider(SPI_CLOCK_DIV64);    //  Set clock divider (optional)
+// servo setup pins
+  servoR.attach(MaOutputPins [0]);
+  servoL.attach(MaOutputPins [1]);
+  Wire.begin();                        // Start the I2C interface.
+  compass = HMC5883L();                // Construct a new HMC5883 compass.
+  setupHMC5883L();                    //setup the HMC5883L
+  LedSerial.begin(2400);            // separate board that controls lights
+  LedSerial.print( "!DC16");     // all leds off board address
+  LedSerial.print( B00 );     // statusLo controls OUT1..OUT8, statusHi controls OUT9..OUT16  1 bit = On, 0 bit = Off
+  LedSerial.println( "X");     // end of string
+  Serial.begin (57600);             // setup Serial port at 57,600 baud
+  Serial.println(" platform Ver. 4-20-2016");
+}
+
+// main loop only watches serial input
+void loop()
+{
+  char c;
+  if (Serial.available () > 0)
+  {
+    while (Serial.available () > 0)
+    {
+      delay (10);
+      c = Serial.read ();
+      if (c == '\r')
+      {
+        ProcessCommand ();
+        sBuffer = "";
+        continue;
+      }
+      sBuffer += c;             // make string
+    }
+  }
+//  delay (50);
+}
+
+void ProcessCommand ()
+{
+  sResp = " ";                    // may use this later
+  if (sBuffer.length () > 0)
+  {
+    sBuffer.toUpperCase ();
+//    Serial.println(sBuffer);
+    switch (sBuffer [0])            // look at first character in string
+    {
+      case 'A':
+        ReadAnalog();
+        delay(1);
+        break;
+      case 'P':
+        ReadPing();
+        delay(1);
+        break;
+      case 'C':
+        ReadCompass();
+        delay(1);
+        break;
+      case 'F':         // go forward
+        ProcessRestCmd (sBuffer.substring (1));
+        if (speed > 55){
+          Serial.println("wrong spd");
+        }
+        MrtFwd( speed );
+        break;
+      case 'B':         // go backward
+        ProcessRestCmd (sBuffer.substring (1));
+        if (speed > 55){
+          Serial.println("wrong spd");
+        }
+        MrtRev( speed );
+        break;
+      case 'R':         // turn right
+        ProcessRestCmd (sBuffer.substring (1));
+        if (speed > 55){
+          Serial.println("wrong spd");
+        }
+        TurnRight( speed );
+        break;
+      case 'L':         // turn left
+        ProcessRestCmd (sBuffer.substring (1));
+       if (speed > 55){
+          Serial.println("wrong spd");
+        }
+        TurnLeft( speed );
+        break;
+      case 'M':         // move forward looking at sensors
+        ProcessRestCmd (sBuffer.substring (1));
+       if (speed > 55){
+          Serial.println("wrong spd");
+        }
+        MoveFwd( speed );
+        break;
+      case 'S':
+        MrtStop();
+        break;
+     case '?':
+        Serial.println("Help  ver. 04-20-2016");
+        Serial.println("P ping distance readings ");
+        Serial.println("A analog readings ");
+        Serial.println("C compass not working ");
+        Serial.println("F forward motors 0 to 50 ");
+        Serial.println("B reverse motors 0 to 50 ");
+        Serial.println("R turn right 0 to 50");
+        Serial.println("L turn left 0 to 50");
+        break;
+    }
+//  Serial.println (sResp);           // Prompts
+  Serial.println (">");
+  }
+}
+
+void ProcessRestCmd (String NumCmd)
+{
+  long speed1;
+  speed1 = NumCmd.toInt ();
+  speed = (speed1);                    // save number int
+//  Serial.println(speed);
+}
+
+
+void ReadAnalog(){
+ int reading;                        // reading from a to d
+ float voltage;                       // voltage calculated from a to d
+ for (int x=0; x < AnalogPinCount; x++){
+   reading = analogRead(AnalogPins[x]);        // get raw number
+   Serial.print("A");
+   Serial.print(x);
+   Serial.print("=");
+   Serial.print(reading);         // show raw number
+   Serial.print(",");
+//   Serial.print("cnt, ");
+//   voltage = reading * 5.0;
+//   voltage /= 1024.0;
+//   voltage = 0.00488 * reading;        // 5 / 1024 = .00488
+//   Serial.print(voltage);         // show voltage calculated
+//   Serial.print("v, ");
+ }
+ Serial.println();
+}
+
+void ReadPing(){
+  long duration, inches, cm;
+
+ for (int x=0; x < PingPinCount; x++){
+  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
+  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
+  pinMode(PingPin[x], OUTPUT);
+  digitalWrite(PingPin[x], LOW);
+  delayMicroseconds(2);
+  digitalWrite(PingPin[x], HIGH);
+  delayMicroseconds(5);
+  digitalWrite(PingPin[x], LOW);
+  // The same pin is used to read the signal from the PING))): a HIGH
+  // pulse whose duration is the time (in microseconds) from the sending
+  // of the ping to the reception of its echo off of an object.
+  pinMode(PingPin[x], INPUT);
+  duration = pulseIn(PingPin[x], HIGH);
+  // convert the time into a distance
+  inches = microsecondsToInches(duration);
+  Serial.print("P");
+  Serial.print(x);
+  Serial.print("=");
+  Serial.print(inches);
+  Serial.print(",");
+//  Serial.print("in, ");
+ }
+  Serial.println();
+}
+
+long microsecondsToInches(long microseconds) {
+  // According to Parallax's datasheet for the PING))), there are
+  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
+  // second).  This gives the distance travelled by the ping, outbound
+  // and return, so we divide by 2 to get the distance of the obstacle.
+  return microseconds / 74 / 2;
+}
+
+void ReadCompass(){
+  MagnetometerScaled scaled = compass.ReadScaledAxis();
+  int MilliGauss_OnThe_XAxis = scaled.XAxis;
+  float heading = atan2(scaled.YAxis, scaled.XAxis);
+  float declinationAngle = 0.0457;
+  heading += declinationAngle;
+  if(heading < 0)
+    heading += 2*PI;
+  if(heading > 2*PI)
+    heading -= 2*PI;
+  float headingDegrees = heading * 180/M_PI;
+//  Output(headingDegrees);
+  Serial.println(headingDegrees);
+  delay(500);     //jhs 5sec
+}
+
+void Output(float headingDegrees)
+{
+   Serial.print("Head Deg=");
+   Serial.print(headingDegrees);
+   Serial.println("\t");
+}
+
+void setupHMC5883L(){
+  //Setup the HMC5883L, and check for errors
+  int error;
+  error = compass.SetScale(1.3); //Set the scale of the compass.
+  if(error != 0) Serial.println(compass.GetErrorText(error)); //check if there is an error, and print if so
+
+  error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
+  if(error != 0) Serial.println(compass.GetErrorText(error)); //check if there is an error, and print if so
+}
+
+void MrtStop(){                     // motors stop at 90
+      while(OldSpeed > 90){         // want slow stop
+        speed = OldSpeed - 1;
+        OldSpeed = speed;
+        servoR.write(speed);
+        servoL.write(speed);
+        delay(50);
+//        Serial.println(speed);   // make sure working right
+      }
+      while(OldSpeed < 90){
+        speed = OldSpeed + 1;
+        OldSpeed = speed;
+        servoR.write(speed);
+        servoL.write(speed);
+        delay(50);
+//        Serial.println(speed);   // make sure working right
+      }
+      servoR.write(90);           // all stop for sure
+      servoL.write(90);
+}
+
+void MrtFwd( int speed ){
+     OldSpeed = speed + 90;           //storing for stopping
+     servoR.write(90 + speed + wheeloffsetR);   // try to adjust for different speed motors
+     servoL.write(90 + speed + wheeloffsetL);
+}
+
+void MrtRev( int speed ){
+     OldSpeed = 90 - speed;
+     servoR.write(90 - speed + wheeloffsetR);
+     servoL.write(90 - speed + wheeloffsetL);
+     int ir0=100;
+     while( ir0<400 ){
+        ir0 = analogRead(AnalogPins[0]);        // check i/r sensor back
+        delay(50);
+     }
+//      ReadAnalog();        // just checking to see if working
+      MrtStop();
+}
+
+void TurnLeft( int speed ){
+     servoR.write(90 - speed);
+     servoL.write(speed + 90);
+}
+
+void TurnRight( int speed ){
+     servoR.write(speed + 90);
+     servoL.write(90 - speed);     // reverse direction
+}
+
+void MoveFwd( int speed ){
+     OldSpeed = speed + 90;           //storing for stopping
+     servoR.write(90 + speed + wheeloffsetR);
+     servoL.write(90 + speed + wheeloffsetL);
+     int ir1=100;
+     int ir2=100;
+      while( (ir1<400) && (ir2<400) ){
+        ir1 = analogRead(AnalogPins[1]);        // check i/r sensors front 1,2
+        delay(30);
+        ir2 = analogRead(AnalogPins[2]);
+        delay(30);
+     }
+//      ReadAnalog();        // just checking to see if working
+      MrtStop();
+}
+


Initial commit

Initial commit

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

--- Arduino/main.ino/main.ino.ino
+++ Arduino/main.ino/main.ino.ino
@@ -0,0 +1,55 @@
+
+//PWM Setup for RC Controller
+volatile long rc_throttle; // pwm value for the throttle input
+volatile long rc_throttle_count; // temporary variable used for counting the length of the pwm signal
+
+volatile long rc_roll; // servo value
+volatile long count1; // temporary variable for servo1
+
+volatile long servo2; // servo value
+volatile long count2; // temporary variable for servo2
+
+volatile long servo3; // servo value
+volatile long count3; // temporary variable for servo3
+
+void handleInterrupt_P2()
+{
+  if(int0)
+    count0=micros(); // we got a positive edge
+  else
+    servo0=micros()-count0; // Negative edge: get pulsewidth
+}
+
+void handleInterrupt_P3()
+{
+  if(int1)
+    count1=micros(); // we got a positive edge
+  else
+    servo1=micros()-count1; // Negative edge: get pulsewidth
+}
+
+void handleInterrupt_P18()
+{
+  if(int2)
+    count2=micros(); // we got a positive edge
+  else
+    servo2=micros()-count2; // Negative edge: get pulsewidth
+}
+
+  void handleInterrupt_P19()
+{
+  if(int3)
+    count3=micros(); // we got a positive edge
+  else
+    servo3=micros()-count3; // Negative edge: get pulsewidth
+}
+
+void setup() {
+  // put your setup code here, to run once:
+
+}
+
+void loop() {
+  // put your main code here, to run repeatedly:
+
+}


Comments werent correct

Comments werent correct

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/ivegotasthma/washmashine.git/'


ino file

ino file

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

--- robo_JS_setup.ino
+++ robo_JS_setup.ino
@@ -0,0 +1,87 @@
+
+int forwardInPin = A0;               // variable forwardInPin to analog input 0
+int backInPin = A2;                  // variable backInPin to analog input 2
+int leftOutPin = 8;                  // variable forwardInPin to analog input 0
+int rightOutPin = 12;                // variable forwardInPin to analog input 0
+int led = 13;
+
+
+void setup()
+{
+  pinMode(forwardInPin, INPUT);      // sets the analog pin as input
+  pinMode(leftOutPin, OUTPUT);       // sets the pin as output
+  pinMode(rightOutPin, OUTPUT);      // sets the pin as output
+  pinMode(led, OUTPUT);
+}
+
+void loop() //forward for 1 sec
+{
+    //forward
+    analogWrite(forwardInPin, 255);       // turns on forward power
+    digitalWrite(leftOutPin, LOW);     // left pulls in
+    digitalWrite(rightOutPin, LOW);    // right pulls in
+    delay(500);                         // waits for a second
+
+    // indecator light
+    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(1000);               // wait for a second
+    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+
+        //right 90
+    analogWrite(forwardInPin, 255);       // turns on forward power
+    digitalWrite(leftOutPin, HIGH);     // left pulls in
+    digitalWrite(rightOutPin, LOW);    // right pulls in
+    delay(428);                         // time of turn
+
+        // indecator light X2 to indicate rest
+    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(1000);               // wait for a second
+    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+    delay(1000);               // wait for a second
+    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(1000);               // wait for a second
+    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+
+
+        //    wait
+    analogWrite(forwardInPin, 0);       // turns on forward power
+    digitalWrite(leftOutPin, LOW);     // left pulls in
+    digitalWrite(rightOutPin, LOW);    // right pulls in
+    delay(5000);                         // waits for 5 seconds
+
+    // indecator light
+    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(1000);               // wait for a second
+    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+
+
+        //    left 90
+    analogWrite(forwardInPin, 255);
+    digitalWrite(leftOutPin, LOW);     // left does not pull in
+    digitalWrite(rightOutPin, HIGH);    // right pulls in
+    delay(428);                         // time of turn
+
+        // indecator light X2 to indicate rest
+    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(1000);               // wait for a second
+    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+    delay(1000);               // wait for a second
+    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(1000);               // wait for a second
+    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+    delay(1000);               // wait for a second
+
+        //    wait
+    analogWrite(forwardInPin, 0);       // turns on forward power
+    digitalWrite(leftOutPin, LOW);     // left dosen't pulls in
+    digitalWrite(rightOutPin, LOW);    // right dosen't pulls in
+    delay(5000);                       // waits for 5 seconds
+
+    // indecator light
+    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
+    delay(1000);               // wait for a second
+    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
+    delay(1000);               // wait for a second
+
+}
+


Adding code for reals

Adding code for reals

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

--- Roomba.ino
+++ Roomba.ino
@@ -0,0 +1,123 @@
+/*
+This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
+It won't work with v1.x motor shields! Only for the v2's with built in PWM
+control
+
+For use with the Adafruit Motor Shield v2
+---->  http://www.adafruit.com/products/1438
+*/
+
+#include <Wire.h>
+#include <Adafruit_MotorShield.h>
+#include "utility/Adafruit_PWMServoDriver.h"
+
+Adafruit_MotorShield AFMS = Adafruit_MotorShield();
+
+Adafruit_DCMotor *motorA = AFMS.getMotor(1);
+Adafruit_DCMotor *motorB = AFMS.getMotor(2);
+
+int trigPin = 4;
+int echoPin = 2;
+long duration; long distance;
+
+long lastThree[3];
+
+int basespeed = 110;
+
+
+void setup() {
+  Serial.begin(9600);           // set up Serial library at 9600 bps
+
+  AFMS.begin();  // create with the default frequency 1.6KHz
+
+  // Set the speed to start, from 0 (off) to 255 (max speed)
+  motorA->setSpeed(144);
+  motorA->run(FORWARD);
+  motorB->setSpeed(144);
+  motorB->run(FORWARD);
+
+  // turn on motor
+  motorA->run(RELEASE);
+  motorB->run(RELEASE);
+
+  pinMode(trigPin, OUTPUT);
+  pinMode(echoPin, INPUT);
+
+}
+
+void changeNums(long newReading) {
+  lastThree[0] = lastThree[1];
+  lastThree[1] = lastThree[2];
+  lastThree[2] = newReading;
+}
+
+long average() {
+  long sum = lastThree[0] + lastThree[1] + lastThree[2];
+  return sum/3;
+}
+
+void loop() {
+  uint8_t i;
+  digitalWrite(trigPin, LOW);
+  delayMicroseconds(2);
+
+  digitalWrite(trigPin, HIGH);
+  delayMicroseconds(10);
+  digitalWrite(trigPin, LOW);
+
+  duration = pulseIn(echoPin, HIGH);
+  distance = (duration/2)/29.1;
+  int speed; int duration;
+
+  changeNums(distance);
+  long avg = average();
+  Serial.print("New dist: ");
+  Serial.print(distance);
+  Serial.println(" cm");
+  Serial.print(avg);
+  Serial.println(" cm");
+
+  if (avg == 0) {
+    Serial.println("Out of range");
+    speed = random(0,basespeed);
+    Serial.println(speed);
+    motorA->setSpeed(speed);
+    motorB->setSpeed(speed);
+    motorA->run(FORWARD);
+    motorB->run(FORWARD);
+  } else if (avg <= 15) {
+    Serial.println("Too close! Get away!");
+    motorA->setSpeed(0);
+    motorB->setSpeed(0);
+    motorA->run(BACKWARD);
+    motorB->run(BACKWARD);
+    delay(400);
+
+    duration = random(400,1000);
+    motorA->setSpeed(basespeed);
+    motorB->setSpeed(basespeed);
+    motorA->run(FORWARD);
+    motorB->run(BACKWARD);
+
+    delay(duration);
+    motorA->setSpeed(0);
+    motorB->setSpeed(0);
+    motorA->run(FORWARD);
+    motorB->run(FORWARD);
+
+  } else if (avg <= 30) {
+    Serial.println("Slow down. Grab the wall.");
+    motorA->setSpeed(basespeed/2);
+    motorB->setSpeed(basespeed/2);
+    motorA->run(FORWARD);
+    motorB->run(FORWARD);
+  } else {
+    Serial.println("I'm good.");
+    motorA->setSpeed(basespeed);
+    motorB->setSpeed(basespeed);
+    motorA->run(FORWARD);
+    motorB->run(FORWARD);
+  }
+
+  delay(10);
+}


EEPROM examination util

EEPROM examination util

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

--- utils/eeprom_read/eeprom_read.ino
+++ utils/eeprom_read/eeprom_read.ino
@@ -0,0 +1,31 @@
+#include <EEPROM.h>
+
+// start reading from the first byte (address 0) of the EEPROM
+unsigned int address = 0;
+byte value;
+
+void setup()
+{
+
+  Serial.begin(115200);
+}
+
+void loop()
+{
+    // read a byte from the current address of the EEPROM
+    value = EEPROM.read(address);
+
+    Serial.print(address);
+    Serial.print("\t");
+    Serial.print(value, DEC);
+    Serial.println();
+
+
+    address = address + 1;
+    if (address == 100)
+    {
+        address = 0;
+    }
+
+    delay(250);
+}


Starting off

Starting off

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/MichalMares/Ardularm.git/'


RedbotBoard Sample code

RedbotBoard Sample code

for motors

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

--- RedBotBoard/RedBotBoard_MotorSample/RedBotBoard_MotorSample.ino
+++ RedBotBoard/RedBotBoard_MotorSample/RedBotBoard_MotorSample.ino
@@ -0,0 +1,53 @@
+
+//This is a simple version of some RedBotBoard motor code.
+// by Urban Reininger urban@ross.org http://github.com/urbanatwork/  2014-01-14
+// Done in part of the Ross School's Arduino Robotics course http://www.ross.org
+
+
+// Include the RebBot libraries. This allows you to use RodBot specific commands like "RedBotMotor"
+#include <RedBot.h>
+
+// Renames
+RedBotMotor motor;
+
+void setup(){
+// Call the motor control class. This only needs to be done once
+// and indeed SHOULD only be done once!
+
+// Speed levels for looking for line and following once it's found. Go
+//  too fast and you're liable to lose the line.
+#define forwardSpeed   200
+#define backwardSpeed  200
+}
+
+void loop(){
+// Just sit there for 2 seconds for dramtic effect!
+delay(2000);
+
+ // Make the right motor go forward at the speed defined.
+ motor.rightDrive(forwardSpeed);
+ delay(300); // do the previous command for .3 seconds
+
+  // Make the right motor brake (stop)
+ motor.rightBrake();
+ delay(300); // do the previous command for .3 seconds
+
+  // Make the left motor go forward at the speed defined.
+ motor.leftDrive(forwardSpeed);
+ delay(200); // do the previous command for .2 seconds
+
+  // Make the left motor brake (stop)
+ motor.leftBrake();
+ delay(200); //do the previous command for .2 seconds
+
+}
+
+    /*
+     * If _speed_ is a positive integer, drives both motors forward, and if
+     * _speed_ is a negative integer, drives both motors backward. In either
+     * case, the motors are driven at the absolute value at _speed_. Allowable
+     * values for _speed_ are -255 to 255 inclusive, however values in -75 to 0
+     * and 0 to 75 inclusive may not provide enough torque to start the motor
+     * turning.
+
+     */


added multiple events for tiles device (2 buttons version)

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


Basic hardware test

Basic hardware test

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

--- arduino-test/arduino-test.ino
+++ arduino-test/arduino-test.ino
@@ -0,0 +1,55 @@
+#include "base64.hpp"
+
+typedef uint8_t u8;
+
+u8 input_buffer[128];
+u8 input_length;
+u8 output_buffer[128];
+u8 output_length;
+u8 hex_buffer[384];
+u8 hex_length;
+
+// Convert an unsigned integer to a hex value
+u8 hex(u8 u) {
+  if(u < 10) return '0' + u;
+  if(u < 16) return 'a' - 10 + u;
+  return 0xff;
+}
+
+void setup() {
+  input_length = 0;
+
+  Serial.begin(115200);
+}
+
+void loop() {
+  u8 next = Serial.read();
+
+  if(next == 0xff) {
+    delay(1);
+  }
+  else if(next == '\n') {
+    if(input_length > 2 && input_buffer[0] == 'e' && input_buffer[1] == ' ') {
+      encode_base64(input_buffer + 2, input_length - 2, output_buffer);
+      Serial.println((char *) output_buffer);
+      input_length = 0;
+    } else if (input_length > 2 && input_buffer[0] == 'd' && input_buffer[1] == ' ') {
+      output_length = decode_base64(input_buffer + 2, input_length - 2, output_buffer);
+      for(u8 i = 0; i < output_length; ++i) {
+        hex_buffer[3*i    ] = hex(output_buffer[i] / 16);
+        hex_buffer[3*i + 1] = hex(output_buffer[i] % 16);
+        hex_buffer[3*i + 2] = ' ';
+      }
+      hex_buffer[3*output_length] = 0;
+      Serial.println((char *) hex_buffer);
+      input_length = 0;
+    } else {
+      Serial.println("To encode: e STRING");
+      Serial.println("To decode: d BASE64");
+      input_length = 0;
+    }
+  }
+  else {
+    input_buffer[input_length++] = next;
+  }
+}


Partial non-working connectivity test.

Partial non-working connectivity test.

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

--- Elcano_C2_Connectivity_Test/Elcano_C2_Connectivity_Test.ino
+++ Elcano_C2_Connectivity_Test/Elcano_C2_Connectivity_Test.ino
@@ -0,0 +1,130 @@
+/*
+Test board connectivity by driving one end of each board trace in a pattern,
+and checking for the same value on the other end.
+
+We'll use one or more Arduino Megas as test controllers.  In each, we will...
+
+Identify one connector on each PC board trace as an "input" to the system under
+test (SUT).  Identify the remaining connectors on that same trace as outputs for
+that trace.
+
+Setup:
+
+Connect one Arduino output to each of the SUT "inputs".  Connect one Arduino input to
+each of the SUT "outputs".  These connections can be made by way of the breadboard.
+
+Set all the Arduino outputs to tri-state, output.
+Set all the Arduino inputs to pull-up, input.
+
+Test procedure:
+
+Set one Arduino output low.  (Others remain tri-stated).
+Check that the Arduino inputs on the same trace are low and the rest high.
+
+Go on to the next output.
+
+Be very careful that only one pin is driven low at a time, and that the rest are
+tri-stated.  Otherwise -- if we were to set the other traces to high, and there
+was a solder bridge, it would short the driving pin to power.
+*/
+
+// Represent one connection on the PC board and its corresponding Arduino
+// pin as the Arduino pin number and the name of the connection on the
+// PC board.  Names of connections have the format:
+// <Component name>_<Pin name>
+// (Component == one item with pin names, e.g. a header or chip.)
+// For now, we are using names from the spreadsheet, but we are unable to
+// locate these on the schematic.
+class Connection {
+  public:
+  char* name;   // Connection name formatted as described above.
+  uint8_t pin;  // Pin on the Arduino conducting the test.
+  Connection(): name(0), pin(0) {}
+  Connection(char* n, uint8_t p) {
+    name = n;
+    pin = p;
+  }
+};
+
+// A trace on the PC board may have more than two connection points.  We want
+// to test all of them, so will drive one connection and check the signal at
+// the others.  Represent a trace as a struct with one Arduino pin as output
+// and a list of Arduino pins as inputs.
+class Trace {
+  public:
+  char* trace_name;                 // Trace name on the spreadsheet / schematic.
+  Connection* pin_out;        // Connection that will drive the trace.
+  Connection** pin_in_list;  // The other connections on the trace.
+  Trace(char* n, Connection* po, Connection** pl) {
+    trace_name = n;
+    pin_out = po;
+    pin_in_list = pl;
+  }
+};
+
+// Declare traces
+Connection C6_A04("C6_A04", A0);
+Connection C4_R09("C4_R09", 13);
+Connection C3_R09("C3_R09", 14);
+Connection* c1[] = {&C4_R09, &C3_R09};
+Trace R_RNG("R_RNG", &C6_A04, c1);
+Connection C6_A05("C6_A05", A1);
+Connection X1_7("X1_7", 15);
+Connection* c2[] = {&X1_7};
+Trace CRS_BRK("CRS_BRK", &C6_A05, c2);
+Connection C6_A06("C6_A06", A2);
+Connection X1_6("X1_6", 16);
+Connection* c3[] = {&X1_6};
+Trace CRS_STR("CRS_STR", &C6_A06, c3);
+
+// List of traces.
+Trace traces[] = {
+  R_RNG,
+  CRS_BRK,
+  CRS_STR
+};
+
+int num_traces = sizeof(traces) / sizeof(struct Trace);
+
+void set_pins(Connection** clist, int value) {
+  int num_pins = sizeof(clist) / sizeof(Connection*);
+  for (int i=0; i < num_pins; i++) {
+    Connection* c = clist[i];
+    pinMode(c->pin, INPUT_PULLUP);
+  }
+}
+
+// Initialize the pins.
+void setup() {
+  for (int i=0; i < num_traces; i++) {
+    Trace trace = traces[i];
+    pinMode((trace.pin_out)->pin, INPUT);  // INPUT is tri-stated
+    Connection** other_ends = trace.pin_in_list;
+    set_pins(other_ends, INPUT_PULLUP);
+    /*
+    int num_ends = sizeof(other_ends) / sizeof(Connection*);
+    for (int i=0; i < num_ends; i++) {
+      Connection* other_end = other_ends[i];
+      pinMode(other_end->pin, INPUT_PULLUP);
+    }
+    */
+  }
+}
+
+void loop() {
+  for (int i=0; i < num_traces; i++) {
+    struct Trace trace = traces[i];
+    uint8_t pin = (trace.pin_out)->pin;
+    pinMode(pin, OUTPUT);
+    digitalWrite(pin, 0);
+    delay(1);
+    // Check that the current trace ends are low.
+
+    // Check that the other trace ends are high.
+
+    // Put the test connections back as they were.
+    pinMode((trace.pin_out)->pin, INPUT);
+  }
+
+  // Could wait here for serial input -- we don't need to loop.
+}