Added files via upload

Added files via upload

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

--- NLMS_AEC/MicAquire_Rev9.ino.ino
+++ NLMS_AEC/MicAquire_Rev9.ino.ino
@@ -0,0 +1,133 @@
+
+//
+// Microphone to Speaker output
+#define NUMEL(x) (sizeof(x)/sizeof((x)[0])) // retuns/calculates the size of an array
+
+#include "NLMS2.h"
+#include <Audio.h>
+#include <Wire.h>
+#include <SPI.h>
+#include <SD.h>
+#include <SerialFlash.h>
+
+//*****functions**********
+void getBuffer1();
+void playData();
+void displayData();
+void NLMS_AEC1();
+int64_t dotp();
+
+
+// GUItool: begin automatically generated code
+AudioInputI2S            Mic;           //microphone
+AudioPlayQueue           MicMem;         //queue for microphone
+AudioRecordQueue         Memory;
+AudioOutputI2S           headphones;           //output
+AudioConnection          patchCord1(Mic, 0, Memory, 0);
+AudioConnection          patchCord2(MicMem, 0, headphones,0);
+AudioConnection          patchCord3(MicMem, 0, headphones,1);
+AudioControlSGTL5000     sgtl5000_1;     //xy=339.6666564941406,285.6666488647461
+
+const int numBlocks = 8; //min block size is 2!!!!!!
+const int lFilt = numBlocks-1;
+const int gg = lFilt*128;
+int16_t *pAddr; //pointer to 128 block of getBuffer
+int16_t lblock = numBlocks*128; //length of arrays
+int16_t ablock[128*numBlocks];  // set an array block
+int16_t error[128];
+int16_t *Perror;
+int16_t *pablock; // pointer to an array block
+int16_t *pp; // pointer to getBuffer
+int n;
+unsigned long time1; // time variable
+
+
+//***************NMLS const and settings*************************
+const int16_t numTaps = gg;
+int64_t mu = 1;
+int32_t mu0 = 0;
+int8_t psi = 1;
+int32_t w[numTaps];
+int32_t *pw; // pointer to w
+int16_t yhat = 0;
+//int64_t xtdl = 1;
+int16_t y12 = gg/2;
+int i = 0;
+
+//define input/source
+const int micInput = AUDIO_INPUT_MIC;
+
+void setup() {
+  mu = 34359738368*mu;  // scale mu
+  memset(w,0,numTaps);
+  memset(ablock,100,128*numBlocks*2);
+  memset(error,0,128*2);
+  //initialize pointers for NLMS
+  pw = w;
+  Perror = error;
+  Serial.begin(9600); // initiate baud rate for serial comm.
+  AudioMemory(8); // allocate # of audio memory (each block has 128 sample of data)
+  sgtl5000_1.enable(); // enalbe
+  sgtl5000_1.volume(0.5); // output volume
+  sgtl5000_1.inputSelect(micInput); //input selection (mic or line in)
+  sgtl5000_1.micGain(30); // mic gain
+  //set array values to zero
+  pablock = ablock; // assign pointer to array
+  delay(1000);
+}
+
+
+//***************************MAIN LOOP********************************************************************
+void loop() {
+Serial.println(micros()); // print time
+getBuffer1(numBlocks); //returns pointer to the buffered dat
+//print sample to serial plotter
+//displayData(pablock); // print data to serial plotter
+//NLMS_AEC(pablock,pablock);
+//NLMS_AEC(pablock,pablock,Perror,pw,gg,mu,4,pxtdl);
+//for(int i = gg; i<gg+128;i+=1){
+//  Serial.println(ablock[i]);
+//}
+}
+
+
+//*********************************************************************************************************
+// print data to serial plotter
+void displayData(int16_t * data){
+  for(int i = 0; i<128*numBlocks;i++){
+  Serial.println(*(data+i));
+  }
+}
+// play data to speaker
+void playData(void){
+    pAddr = MicMem.getBuffer(); //get pointer to 128 array playBuffer
+    // take one block from buffer array (ablock) and copy it to playBuffer pointer
+    // play that block
+    memcpy((byte*)pAddr,(byte*)error,256);
+    MicMem.playBuffer();
+}
+
+// buffer an array with samples from Microphone
+// function receives and array and integer indicating number of blocks
+void getBuffer1(int x){
+  Memory.begin(); // begin putting sample data into memory
+  int l = 0;
+  memcpy((byte*)pablock,(byte*)pablock+256,256*(x-1));
+  // put 128 blocks of sample into an array size of 128*(number of blocks)
+    while(l == 0){ // wait until block samples are available
+      if(Memory.available() ==1) {// if availabe copy 128 block to array and get out of while loop
+        //read one 128 block of samples and copy it into array
+        memcpy((byte*)pablock+(256*(x-1)),Memory.readBuffer(),256);
+        Memory.freeBuffer(); // free buffer memory
+        l = 1; // set n to 1 to get out of while loop
+      }//end if
+    }//end while
+    l = 0;
+   Memory.clear(); // clear all audio memory
+   Memory.end();
+   NLMS_AEC(pablock,pablock,Perror,pw,gg,mu,5,1);
+   playData(); // play 128 block from buffered array
+//   return ablock; // regurn pointer to array
+}
+
+


Create USB_PS3_Example.ino

Create USB_PS3_Example.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/nitricx/Tank_Automation.git/'


midicontroller1

midicontroller1

first shot at a homebrew controller

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

--- midicontroller1/midicontroller1.ino
+++ midicontroller1/midicontroller1.ino
@@ -0,0 +1,96 @@
+#include <Encoder.h> // Include the Encoder library.
+// This must be done before the Control Surface library.
+#include <Control_Surface.h> // Include the Control Surface library
+
+
+USBMIDI_Interface midi;
+
+
+
+
+// Instantiate a CCButton object
+CCButton button = {
+  // Push button on pin 5:
+  5,
+  // General Purpose Controller #1 on MIDI channel 1:
+  {MIDI_CC::General_Purpose_Controller_5, CHANNEL_1},
+};
+
+
+
+
+// Instantiate a CCRotaryEncoder object
+CCRotaryEncoder enc = {
+  {2, 3},       // pins
+  MCU::V_POT_4, // MIDI address (CC number + optional channel)
+  1,            // optional multiplier if the control isn't fast enough
+};
+
+
+
+// Instantiate a CCPotentiometer object
+CCPotentiometer potentiometer0 = {
+  A0,                                   // Analog pin connected to potentiometer
+  {MIDI_CC::Channel_Volume, CHANNEL_1}, // Channel volume of channel 1
+};
+CCPotentiometer potentiometer1 = {
+  A1,                                   // Analog pin connected to potentiometer
+  {MIDI_CC::General_Purpose_Controller_1, CHANNEL_1}, // General_Purpose_Controller_1 of channel 1
+};
+CCPotentiometer potentiometer2 = {
+  A2,                                   // Analog pin connected to potentiometer
+  {MIDI_CC::General_Purpose_Controller_2, CHANNEL_1}, // General_Purpose_Controller_2 of channel 1
+};
+CCPotentiometer potentiometer3 = {
+  A3,                                   // Analog pin connected to potentiometer
+  {MIDI_CC::General_Purpose_Controller_3, CHANNEL_1}, // General_Purpose_Controller_3 of channel 1
+};
+
+
+
+// The note numbers corresponding to the buttons in the matrix
+const int noteOffset = 36;
+const AddressMatrix<4, 3> addresses = {{
+  {72-noteOffset, 73-noteOffset, 74-noteOffset},
+  {75-noteOffset, 76-noteOffset, 77-noteOffset},
+  {78-noteOffset, 79-noteOffset, 80-noteOffset},
+  {81-noteOffset, 82-noteOffset, 83-noteOffset},
+}};
+
+NoteButtonMatrix<4, 3> buttonmatrix = {
+  {10, 16, 14, 15}, // row pins
+  {9, 8, 7},    // column pins
+  addresses,    // address matrix
+  CHANNEL_1,    // channel and cable number
+};
+
+
+analog_t reversePot(analog_t raw) {
+    // map the value from [minimumValue, maximumValue] to [0, 16383]
+    return map(raw, 0, 16383, 16383, 0);
+}
+
+void setup() {
+  potentiometer0.map(reversePot);
+  potentiometer1.map(reversePot);
+  potentiometer2.map(reversePot);
+  potentiometer3.map(reversePot);
+
+  // Select the correct relative MIDI CC mode.
+  // Options:
+  //   - TWOS_COMPLEMENT (default)
+  //   - BINARY_OFFSET
+  //   - SIGN_MAGNITUDE
+  // Aliases:
+  //   - REAPER_RELATIVE_1
+  //   - REAPER_RELATIVE_2
+  //   - REAPER_RELATIVE_3
+  //   - TRACKTION_RELATIVE
+  //   - MACKIE_CONTROL_RELATIVE
+  RelativeCCSender::setMode(relativeCCmode::MACKIE_CONTROL_RELATIVE);
+  Control_Surface.begin();
+}
+
+void loop() {
+  Control_Surface.loop();
+}


Created automatic switch example

Created automatic switch example

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

--- examples/auto_switch/auto_switch.ino
+++ examples/auto_switch/auto_switch.ino
@@ -0,0 +1,27 @@
+#include "particle-dst.h"
+
+DST dst;
+
+dst_limit_t beginning;
+dst_limit_t end;
+
+void setup() {
+  Serial.begin(9600);
+
+  beginning.hour = 2;
+  beginning.day = 3; // tuesday
+  beginning.month = 2; // february
+  beginning.occurrence = 2;
+
+  end.hour = 3;
+  end.day = 4; // wednesday
+  end.month = 10; // october
+  end.occurrence = 2;
+
+  dst.begin(beginning, end, 1);
+  dst.automatic(true);
+}
+
+void loop() {
+
+}


Add IR sensor readings

Add IR sensor readings

Distance (in centimeters) read by IR sensor

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/tms1337/inverted-pendulum.git/'


REV11 minimal test

REV11 minimal test

error: pathspec 'Arduino/hardware/REV11/testsuite/20170110/REV11Minimal/REV11Minimal.ino' did not match any file(s) known to git

--- Arduino/hardware/REV11/testsuite/20170110/REV11Minimal/REV11Minimal.ino
+++ Arduino/hardware/REV11/testsuite/20170110/REV11Minimal/REV11Minimal.ino
@@ -0,0 +1,258 @@
+/*
+The OpenTRV project licenses this file to you
+under the Apache Licence, Version 2.0 (the "Licence");
+you may not use this file except in compliance
+with the Licence. You may obtain a copy of the Licence at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the Licence is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the Licence for the
+specific language governing permissions and limitations
+under the Licence.
+
+Author(s) / Copyright (s): Deniz Erbilgin 2017
+*/
+/**
+ * Minimal REV11 config for testing power consumption.
+ * Aim is to:
+ *     - init GPIO pins to safe mode.
+ *     - init peripherals to safe low power mode.
+ *     - loop endlessly.
+ */
+
+// INCLUDES & DEFINES
+// Debug output flag
+#define DEBUG
+// REV11 as Sensor with secure TX.
+#define CONFIG_REV11_SECURE_SENSOR //XXX
+// Get defaults for valve applications.
+#include <OTV0p2_valve_ENABLE_defaults.h>
+// All-in-one valve unit (DORM1).
+#include <OTV0p2_CONFIG_REV11.h>
+// I/O pin allocation and setup: include ahead of I/O module headers.
+#include <OTV0p2_Board_IO_Config.h>
+// OTV0p2Base Libraries
+#include <OTV0p2Base.h>
+// Radio Libraries
+//#include <OTRadioLink.h>
+#include <OTRFM23BLink.h>
+// RadValve libraries
+#include <OTRadValve.h>
+
+
+// Debugging output
+#ifndef DEBUG
+#define DEBUG_SERIAL_PRINT(s) // Do nothing.
+#define DEBUG_SERIAL_PRINTFMT(s, format) // Do nothing.
+#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) // Do nothing.
+#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) // Do nothing.
+#define DEBUG_SERIAL_PRINTLN() // Do nothing.
+#define DEBUG_SERIAL_TIMESTAMP() // Do nothing.
+#else
+// Send simple string or numeric to serial port and wait for it to have been sent.
+// Make sure that Serial.begin() has been invoked, etc.
+#define DEBUG_SERIAL_PRINT(s) { OTV0P2BASE::serialPrintAndFlush(s); }
+#define DEBUG_SERIAL_PRINTFMT(s, fmt) { OTV0P2BASE::serialPrintAndFlush((s), (fmt)); }
+#define DEBUG_SERIAL_PRINT_FLASHSTRING(fs) { OTV0P2BASE::serialPrintAndFlush(F(fs)); }
+#define DEBUG_SERIAL_PRINTLN_FLASHSTRING(fs) { OTV0P2BASE::serialPrintlnAndFlush(F(fs)); }
+#define DEBUG_SERIAL_PRINTLN() { OTV0P2BASE::serialPrintlnAndFlush(); }
+// Print timestamp with no newline in format: MinutesSinceMidnight:Seconds:SubCycleTime
+extern void _debug_serial_timestamp();
+#define DEBUG_SERIAL_TIMESTAMP() _debug_serial_timestamp()
+#endif // DEBUG
+
+// OBJECTS & VARIABLES
+/**
+ * Peripherals present on REV7
+ * - Pot        Set input to Hi-Z?  +
+ * - PHT        IO_POWER_UP LOW
+ * - Encoder    IO_POWER_UP LOW
+ * - LED        Set pin HIGH?
+ * - Button     Set to INPUT
+ * - H-Bridge   Control pins HIGH, Current sense set to input.  +
+ * - SHT21      read() once.        +
+ * - RFM23B     ??                  +
+ * - XTAL       Setup and leave running?
+ * - UART       Disable
+ */
+
+/**
+ * Dummy Types
+ */
+// Placeholder class with dummy static status methods to reduce code complexity.
+typedef OTV0P2BASE::DummySensorOccupancyTracker OccupancyTracker;
+
+/**
+ * Supply Voltage instance
+ */
+// Sensor for supply (eg battery) voltage in millivolts.
+// Singleton implementation/instance.
+OTV0P2BASE::SupplyVoltageCentiVolts Supply_cV;
+
+/*
+ * Radio instance
+ */
+static constexpr bool RFM23B_allowRX = false;
+
+static constexpr uint8_t RFM23B_RX_QUEUE_SIZE = OTRFM23BLink::DEFAULT_RFM23B_RX_QUEUE_CAPACITY;
+static constexpr int8_t RFM23B_IRQ_PIN = -1;// PIN_RFM_NIRQ;
+OTRFM23BLink::OTRFM23BLink<OTV0P2BASE::V0p2_PIN_SPI_nSS, RFM23B_IRQ_PIN, RFM23B_RX_QUEUE_SIZE, RFM23B_allowRX> PrimaryRadio;
+// Pick an appropriate radio config for RFM23 (if it is the primary radio).
+// Nodes talking on fast GFSK channel 0.
+static const uint8_t nPrimaryRadioChannels = 1;
+static const OTRadioLink::OTRadioChannelConfig RFM23BConfigs[nPrimaryRadioChannels] = {
+    // GFSK channel 0 full config, RX/TX, not in itself secure.
+    OTRadioLink::OTRadioChannelConfig(OTRFM23BLink::StandardRegSettingsGFSK57600, true), };
+
+/*
+ * SHT21 instance
+ */
+OTV0P2BASE::RoomTemperatureC16_SHT21 TemperatureC16; // SHT21 impl.
+
+// HUMIDITY_SENSOR_SUPPORT is defined if at least one humidity sensor has support compiled in.
+// Simple implementations can assume that the sensor will be present if defined;
+// more sophisticated implementations may wish to make run-time checks.
+// If SHT21 support is enabled at compile-time then its humidity sensor may be used at run-time.
+// Singleton implementation/instance.
+typedef OTV0P2BASE::HumiditySensorSHT21 RelHumidity_t;
+RelHumidity_t RelHumidity;
+
+/**
+ * Ambient Light Sensor
+ */
+typedef OTV0P2BASE::SensorAmbientLight AmbientLight;
+// Singleton implementation/instance.
+AmbientLight AmbLight;
+
+// FUNCTIONS
+
+/**
+ * Panic Functions
+ */
+// Indicate that the system is broken in an obvious way (distress flashing the main LED).
+// DOES NOT RETURN.
+// Tries to turn off most stuff safely that will benefit from doing so, but nothing too complex.
+// Tries not to use lots of energy so as to keep distress beacon running for a while.
+void panic()
+{
+    // Reset radio and go into low-power mode.
+    PrimaryRadio.panicShutdown();
+    // Power down almost everything else...
+    OTV0P2BASE::minimisePowerWithoutSleep();
+    pinMode(OTV0P2BASE::LED_HEATCALL_L, OUTPUT);
+    for( ; ; )
+    {
+        OTV0P2BASE::LED_HEATCALL_ON();
+        OTV0P2BASE::nap(WDTO_15MS);
+        OTV0P2BASE::LED_HEATCALL_OFF();
+        OTV0P2BASE::nap(WDTO_120MS);
+    }
+}
+// Panic with fixed message.
+void panic(const __FlashStringHelper *s)
+{
+    OTV0P2BASE::serialPrintlnAndFlush(); // Start new line to highlight error.  // May fail.
+    OTV0P2BASE::serialPrintAndFlush('!'); // Indicate error with leading '!' // May fail.
+    OTV0P2BASE::serialPrintlnAndFlush(s); // Print supplied detail text. // May fail.
+    panic();
+}
+
+
+/**
+ * @brief   Set pins and on-board peripherals to safe low power state.
+ */
+
+
+//========================================
+// SETUP
+//========================================
+
+// Setup routine: runs once after reset.
+// Does some limited board self-test and will panic() if anything is obviously broken.
+void setup()
+{
+    // Set appropriate low-power states, interrupts, etc, ASAP.
+    OTV0P2BASE::powerSetup();
+    // IO setup for safety, and to avoid pins floating.
+    OTV0P2BASE::IOSetup();
+
+    OTV0P2BASE::serialPrintAndFlush(F("\r\nOpenTRV: ")); // Leading CRLF to clear leading junk, eg from bootloader.
+    V0p2Base_serialPrintlnBuildVersion();
+
+    OTV0P2BASE::LED_HEATCALL_ON();
+
+    // Give plenty of time for the XTal to settle.
+    delay(1000);
+
+    // Have 32678Hz clock at least running before going any further.
+    // Check that the slow clock is running reasonably OK, and tune the fast one to it.
+    if(!::OTV0P2BASE::HWTEST::calibrateInternalOscWithExtOsc()) { panic(F("Xtal")); } // Async clock not running or can't tune.
+//    if(!::OTV0P2BASE::HWTEST::check32768HzOsc()) { panic(F("xtal")); } // Async clock not running correctly.
+
+    // Initialise the radio, if configured, ASAP because it can suck a lot of power until properly initialised.
+    PrimaryRadio.preinit(NULL);
+    // Check that the radio is correctly connected; panic if not...
+    if(!PrimaryRadio.configure(nPrimaryRadioChannels, RFM23BConfigs) || !PrimaryRadio.begin()) { panic(F("r1")); }
+
+    // Collect full set of environmental values before entering loop() in normal mode.
+    // This should also help ensure that sensors are properly initialised.
+
+    // No external sensors are *assumed* present if running alt main loop
+    // This may mean that the alt loop/POST will have to initialise them explicitly,
+    // and the initial seed entropy may be marginally reduced also.
+    const int cV = Supply_cV.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("V: ");
+    DEBUG_SERIAL_PRINT(cV);
+    DEBUG_SERIAL_PRINTLN();
+    const int heat = TemperatureC16.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("T: ");
+    DEBUG_SERIAL_PRINT(heat);
+    DEBUG_SERIAL_PRINTLN();
+    const uint8_t rh = RelHumidity.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("RH%: ");
+    DEBUG_SERIAL_PRINT(rh);
+    DEBUG_SERIAL_PRINTLN();
+    const int light = AmbLight.read();
+    DEBUG_SERIAL_PRINT_FLASHSTRING("L: ");
+    DEBUG_SERIAL_PRINT(light);
+    DEBUG_SERIAL_PRINTLN();
+
+    // Initialised: turn main/heatcall UI LED off.
+    OTV0P2BASE::LED_HEATCALL_OFF();
+
+    // Do OpenTRV-specific (late) setup.
+    PrimaryRadio.listen(false);
+
+    // Long delay after everything set up to allow a non-sleep power measurement.
+    delay(10000);
+}
+
+
+//========================================
+// MAIN LOOP
+//========================================
+/**
+ * @brief   Sleep in low power mode if not sleeping.
+ */
+void loop()
+{
+    // Ensure that serial I/O is off while sleeping.
+    OTV0P2BASE::powerDownSerial();
+    // Power down most stuff (except radio for hub RX).
+    OTV0P2BASE::minimisePowerWithoutSleep();
+    // Normal long minimal-power sleep until wake-up interrupt.
+    // Rely on interrupt to force quick loop round to I/O poll.
+    OTV0P2BASE::sleepUntilInt();
+}
+
+
+
+/**
+ * @note    Power consumption figures (all in mA).
+ * Date/commit:         Device: Wake (Sleep) @ Voltage
+ * 20161111/0e6ec96     REV7:   1.5 (1.1) @ 2.5 V       REV11:  0.45 (0.03) @ 2.5 V
+ * 20161111/f2eed5e     REV7:   0.46 (0.04) @ 2.5 V
+ */


upload utilities folder

upload utilities folder

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

--- utils/TestLCDdim/TestLCDdim.ino
+++ utils/TestLCDdim/TestLCDdim.ino
@@ -0,0 +1,35 @@
+// test LCD screen dimensions with 2 pots connected on A0 and A1 (x, y)
+
+#include <UTFT.h>
+#define DEBUG 0
+
+
+int x, y;
+
+UTFT lcd(CTE32HR,38,39,40,41);
+
+void setup(){
+  lcd.InitLCD();
+  if(DEBUG)Serial.begin(9600);
+  lcd.fillScr(VGA_BLACK);
+}
+
+void loop(){
+  x = analogRead(A0);
+  y = analogRead(A1);
+
+  if(DEBUG){
+    Serial.print("x: ");
+    Serial.print(x);
+    Serial.print(" | y: ");
+    Serial.println(y);
+  }
+
+
+//  lcd.fillScr(VGA_BLACK);
+  //lcd.clrScr();
+  lcd.setColor(VGA_GREEN);
+  lcd.fillRect(0, 0, x, y);
+
+  delay(50);
+}


Integrated bucket wheel driver code into Ros

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

--- src/BucketWheelDriver/BucketWheelDriver.ino
+++ src/BucketWheelDriver/BucketWheelDriver.ino
@@ -0,0 +1,167 @@
+/* BucketWheelActuationDriver
+Authors: Derek Schumacher, Fatima Dominguez, Jaimiey Sears
+Begins by assuming the bucket wheel is at its lowest point (100%)
+The user can specify a percentage to actuate to (0-100%)
+The circuit uses HSI power screws and Microstep Driver- M6128 :
+DIP Switch: [111001] (1 = down, 0 = up)
+[current: 1.25; Microstep = 1 (Full-step)]
+Send an 's' or 'S' to e-stop screw movement
+The wiring scheme for the HSI power screws:
+Red (A+)
+Red/White (A-)
+Green (B+)
+Green/white (B-)
+PUL+ (pin 9)
+DIR+ (pin 8)
+PUL- and DIR- grounded
+ENA+ connected to ground
+ENA- connected to pin 10 (+5V when turning, otherwise 0V)
+*/
+
+#include <ros.h>
+#include <std_msgs/Int16.h>
+
+#define ERROR_OUT_OF_RANGE -1
+
+int DIRECTION_PIN = 8;
+int PULSE_PIN = 9;
+int ENABLE = 10;
+
+//31914 steps translates to roughly (under) 100% top to bottom
+#define FULL_STEPS 31914
+//int stepCount = 0;
+int desiredPercent = 0;
+
+//double onePercent = FULL_STEPS/100.0;
+//int desiredStep = 0;
+int DELAY = 10;
+
+//double currentPercent = 100;
+int currentSteps = FULL_STEPS;
+
+//variable which disables all motor movement when set to TRUE.
+boolean e_stop = false;
+
+// This node handle represents this arduino
+ros::NodeHandle bucketWheelDriverNode;
+
+void newManualCommandCallback(const std_msgs::Int16& newManualCommand)
+{
+  int steps = newManualCommand.data;
+  actuate(steps);
+}
+ros::Subscriber<std_msgs/Int16> commandSubscriber("BucketWheelCommand", &newManualCommandCallback);
+
+
+void setup() {
+  bucketWheelDriverNode.initNode();
+  bucketWheelDriverNode.subscribe(commandSubscriber);
+
+
+  pinMode(DIRECTION_PIN, OUTPUT);
+  pinMode(PULSE_PIN, OUTPUT);
+  pinMode(ENABLE, OUTPUT);
+  //  digitalWrite(ENABLE, HIGH); //the motor should not make loud screeching
+  Serial.begin(9600);
+  Serial.println("Send position to go to (percent):");
+  printPosition();
+}//setup
+
+void loop() {
+
+  if (Serial.available())
+  {
+    int readValue = Serial.parseInt();
+    moveToPercent(readValue);
+
+  }
+  e_stop = false;
+
+  //Sync with ROS
+  bucketWheelDriverNode.spinOnce(); // Check for subscriber update/update timestamp
+
+}//loop
+
+//moves the wheel the down the number of steps specified
+//negative steps will be interpred as moving the wheel up.
+void actuate(int steps) {
+  //enable the controller
+  digitalWrite(ENABLE, LOW);
+
+  int dir = 0;
+  //select which direction to go
+  if (steps > 0) {
+    digitalWrite(DIRECTION_PIN, LOW);
+    dir = 1;
+  }
+  else {
+    digitalWrite(DIRECTION_PIN, HIGH);
+    dir = -1;
+  }
+
+  for(int i = 0; i < abs(steps); i++) {
+    //leave if we say so
+    interrupt();
+    if (e_stop) break;
+
+    //send pulse to controller
+    delayMicroseconds(DELAY);
+    digitalWrite(PULSE_PIN, HIGH);
+    delayMicroseconds(DELAY);
+    digitalWrite(PULSE_PIN, LOW);
+
+    //update and print position as we move
+    currentSteps += dir;
+    if (i%500 == 0) printPosition();
+
+    //wait for 100 ms
+    delayMicroseconds(1000000);
+  }
+  //report final position
+  printPosition();
+
+  digitalWrite(ENABLE, HIGH);
+}
+
+//used to read any commands that have been recieved
+void interrupt() {
+  if (Serial.available()) {
+    char command = Serial.read();
+    switch (command) {
+      case 's':
+        e_stop = true;
+        break;
+      case 'S':
+        e_stop = true;
+        break;
+    }
+  }
+}
+
+//short subroutine to print the current actuation position of the bucketwheel
+void printPosition() {
+  Serial.print("Current Position:\t");
+  Serial.print(toPercent(currentSteps), DEC);
+  Serial.println("%");
+}
+
+
+//moves to the given percent from the current position
+int moveToPercent(int percent){
+  //error check
+  if (percent > 100 || percent < 0) return ERROR_OUT_OF_RANGE;
+
+  //calculate number of steps and move.
+  int stepsToMove = int(-(toPercent(currentSteps) - percent)/100.0 * FULL_STEPS);
+  Serial.print("Moving to ");
+  Serial.print(percent, DEC);
+  Serial.print("% from ");
+  Serial.print(toPercent(currentSteps), DEC);
+  Serial.println("%");
+  actuate(stepsToMove);
+}
+
+//takes a position in steps and converts it to a percentage
+double toPercent(int steps) {
+  return steps*100.0/FULL_STEPS;
+}


original commit

original commit

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

--- OneWireTSRP.ino
+++ OneWireTSRP.ino
@@ -0,0 +1,183 @@
+#include <Dhcp.h>
+#include <Dns.h>
+#include <Ethernet.h>
+#include <EthernetClient.h>
+#include <EthernetServer.h>
+#include <EthernetUdp.h>
+#include <util.h>
+
+#include <SPI.h>
+#include <OneWire.h>
+
+// OneWire DS18S20, DS18B20, DS1822 Temperature Example
+//
+// http://www.pjrc.com/teensy/td_libs_OneWire.html
+//
+// The DallasTemperature library can do all this work for you!
+// http://milesburton.com/Dallas_Temperature_Control_Library
+
+OneWire  ds(23);  // on pin 10 (a 4.7K resistor is necessary)
+
+int requestID = 1;
+
+byte mac[] = { 0xDE, 0xAD, 0xBE, 0x5c, 0x7d, 0x0c };
+
+char packetBuffer[512];
+
+PROGMEM prog_char *loopPacket1 = "{\"path\":\"/api/v1/thing/reporting\",\"requestID\":\"";
+PROGMEM prog_char *loopPacket2 = "\",\"things\": {\"/device/climate/1wire/temperature\": {\"prototype\": {\"device\": {\"name\": \"DS1820\",\"maker\": \"Dallas Semiconductor\"},\"name\": \"true\",\"status\": [\"present\",\"absent\",\"recent\"],\"properties\": {\"temperature\": \"celsius\"}},\"instances\": [{\"name\": \"";
+PROGMEM prog_char *loopPacket3 = "\",\"status\": \"present\",\"unit\": {\"serial\": \"";
+PROGMEM prog_char *loopPacket4 = "\",\"udn\": \"1wire:";
+PROGMEM prog_char *loopPacket5 = "\"},\"info\": {\"temperature\":";
+PROGMEM prog_char *loopPacket6 = "}}]}}}";
+
+EthernetUDP udp;
+IPAddress ip(224,192,32,20);
+unsigned int port = 22601;
+
+void setup() {
+  Serial.begin(9600);
+  Serial.println("Starting...");
+  while(!Serial) { }
+
+  Serial.println("Waiting for DHCP address.");
+  if (Ethernet.begin(mac) == 0) {
+    Serial.println("Error: Failed to configure Ethernet using DHCP");
+    while(1) {  }
+  }
+
+  udp.beginMulti(ip,port);
+
+}
+
+  byte data[12];
+  byte addr[8];
+
+void loop() {
+    requestID = requestID + 1;
+
+    char buffer[12];
+  byte i;
+  byte present = 0;
+  byte type_s;
+  float celsius, fahrenheit;
+
+  if ( !ds.search(addr)) {
+    Serial.println("No more addresses.");
+    Serial.println();
+    ds.reset_search();
+    delay(250);
+    return;
+  }
+
+  Serial.print("ROM =");
+  for( i = 0; i < 8; i++) {
+    Serial.write(' ');
+    Serial.print(addr[i], HEX);
+  }
+
+  if (OneWire::crc8(addr, 7) != addr[7]) {
+      Serial.println("CRC is not valid!");
+      return;
+  }
+  Serial.println();
+
+  // the first ROM byte indicates which chip
+  switch (addr[0]) {
+    case 0x10:
+      Serial.println("  Chip = DS18S20");  // or old DS1820
+      type_s = 1;
+      break;
+    case 0x28:
+      Serial.println("  Chip = DS18B20");
+      type_s = 0;
+      break;
+    case 0x22:
+      Serial.println("  Chip = DS1822");
+      type_s = 0;
+      break;
+    default:
+      Serial.println("Device is not a DS18x20 family device.");
+      return;
+  }
+
+  ds.reset();
+  ds.select(addr);
+  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
+
+  delay(1000);     // maybe 750ms is enough, maybe not
+  // we might do a ds.depower() here, but the reset will take care of it.
+
+  present = ds.reset();
+  ds.select(addr);
+  ds.write(0xBE);         // Read Scratchpad
+
+  Serial.print("  Data = ");
+  Serial.print(present, HEX);
+  Serial.print(" ");
+  for ( i = 0; i < 9; i++) {           // we need 9 bytes
+    data[i] = ds.read();
+    Serial.print(data[i], HEX);
+    Serial.print(" ");
+  }
+  Serial.print(" CRC=");
+  Serial.print(OneWire::crc8(data, 8), HEX);
+  Serial.println();
+
+  // Convert the data to actual temperature
+  // because the result is a 16 bit signed integer, it should
+  // be stored to an "int16_t" type, which is always 16 bits
+  // even when compiled on a 32 bit processor.
+  int16_t raw = (data[1] << 8) | data[0];
+  if (type_s) {
+    raw = raw << 3; // 9 bit resolution default
+    if (data[7] == 0x10) {
+      // "count remain" gives full 12 bit resolution
+      raw = (raw & 0xFFF0) + 12 - data[6];
+    }
+  } else {
+    byte cfg = (data[4] & 0x60);
+    // at lower res, the low bits are undefined, so let's zero them
+    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
+    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
+    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
+    //// default is 12 bit resolution, 750 ms conversion time
+  }
+  celsius = (float)raw / 16.0;
+  fahrenheit = celsius * 1.8 + 32.0;
+  Serial.print("  Temperature = ");
+  Serial.print(celsius);
+  Serial.print(" Celsius, ");
+  Serial.print(fahrenheit);
+  Serial.println(" Fahrenheit");
+
+    strcpy(packetBuffer,(char*)pgm_read_word(&loopPacket1) );
+    strcat(packetBuffer, itoa( requestID, buffer, 10) );
+    strcat(packetBuffer,(char*)pgm_read_word(&loopPacket2) );
+    if (addr[7] == 0x10) strcat(packetBuffer, "ds1820");
+    else if (addr[7] == 0x28) strcat(packetBuffer, "ds18b20");
+    else if (addr[7] == 0x22) strcat(packetBuffer, "ds1822");
+    else strcat(packetBuffer, "ds????");
+    strcat(packetBuffer,(char*)pgm_read_word(&loopPacket3) );
+    for (byte thisByte = 0; thisByte < 7; thisByte++) {
+      sprintf(buffer, "%02x", addr[thisByte] );
+      strcat(packetBuffer, buffer);
+    }
+    strcat(packetBuffer,(char*)pgm_read_word(&loopPacket4) );
+    for (byte thisByte = 0; thisByte < 7; thisByte++) {
+      sprintf(buffer, "%02x", addr[thisByte] );
+      strcat(packetBuffer, buffer);
+    }
+    strcat(packetBuffer,(char*)pgm_read_word(&loopPacket5) );
+    sprintf(packetBuffer + strlen(packetBuffer), "%4.2f", celsius);
+    strcat(packetBuffer,(char*)pgm_read_word(&loopPacket6) );
+
+
+    Serial.println(packetBuffer);
+    udp.beginPacket(udp.remoteIP(), udp.remotePort());
+    udp.write(packetBuffer);
+    udp.endPacket();
+
+  delay(2000);
+}
+


Added methods

Added methods

Added methods for writing to LCD screen, reading from ADS1115

--- DataLogger/DataLogger.ino
+++ DataLogger/DataLogger.ino
@@ -26,12 +26,12 @@
   */

 //The Wire library allows communication with I2C / TWI devices.
-#include <Wire.h>
+#include <Wire.h> //V1.0

 //The ADS1015 library facilitates reading from the ADS1115.
-#include <Adafruit_ADS1015.h>
+#include <Adafruit_ADS1015.h> //V1.1

-//The LiquidCrystal library (by Juan Hernandez, aka juanh0238) facilitates usage of the
+//The LiquidCrystal library, by Juan Hernandez (juanh0238) facilitates usage of the
 //LCD screen using a shift register via SPI.
 #include <LiquidCrystal.h>

@@ -40,16 +40,18 @@

 //Set pins for MISO/MOSI/SS/PP
 const int lcdSS = 2; //SS for LCD
+LiquidCrystal lcd(2);
 const int sdSS = 10; //SS for SD card R/W
 const int MOSIpin = 11; //MOSI pin
 const int MISOpin = 12; //MISO pin
 const int clk = 13; //Clock pin
 const int PP = 5; //Peristaltic pump pin

+Adafruit_ADS1115 ads1115;
+Adafruit_ADS1115 ads(0x48); //Sets base address

-float cVoltage = 0.0; //Conductivity meter voltage
-
-LiquidCrystal lcd(2);
+int16_t cVoltage; //16 bit variable reading from ADC's A0
+String result; //String containing data from ADC

 void setup() {
   //Set pin modes
@@ -63,13 +65,31 @@
   //Initialize communication processes
   Serial.begin(9600); //Sets baud rate
   lcd.begin(16,2); //Initializes LCD with # of rows and columns
-//  ads.begin(); //Initializes ADC
-  lcd.print("Hello, world!");
+  ads1115.begin(); //Initializes ADC
+  lcd.print(""); //Print nothing to LCD to calibrate
 }

 void loop() {
-  // set the cursor to column 0, line 1
-  // (note: line 1 is the second row, since counting begins with 0):
-  lcd.setCursor(0, 1);
-  lcd.print("Test");
+  writeResult();
 }
+
+void LCDwrite(String s, String s2){
+  lcd.setCursor(0, 0);
+  lcd.print(s);
+  lcd.setCursor(0,1);
+  lcd.print(s2 + " mV");
+}
+
+void readADS() {
+  cVoltage = ads1115.readADC_Differential_0_1();
+  result = cVoltage;
+}
+
+void writeResult(){
+  readADS();
+  delay(500);
+  LCDwrite("Hello", result);
+}
+
+
+


Add LedStrip sample

Add LedStrip sample

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

--- examples/LedStrip/LedStrip.ino
+++ examples/LedStrip/LedStrip.ino
@@ -0,0 +1,53 @@
+#include <Homie.h>
+
+const unsigned char NUMBER_OF_LED = 4;
+const unsigned char LED_PINS[NUMBER_OF_LED] = { 16, 5, 4, 0 };
+
+bool stripHandler(String, String); // forward declaration (needed for Arduino <= 1.6.8)
+HomieNode stripNode("ledstrip", "ledstrip", stripHandler, true); // last true: subscribe to all properties
+
+bool stripHandler(String property, String value) {
+  for (int i = 0; i < property.length(); i++) {
+    if (!isDigit(property.charAt(i))) {
+      return false;
+    }
+  }
+
+  int ledIndex = property.toInt();
+  if (ledIndex < 0 || ledIndex > NUMBER_OF_LED - 1) {
+    return false;
+  }
+
+  if (value == "true") {
+    digitalWrite(LED_PINS[ledIndex], HIGH);
+    Homie.setNodeProperty(stripNode, String(ledIndex), "true"); // Update the state of the led
+    Serial.print("Led ");
+    Serial.print(ledIndex);
+    Serial.println(" is on");
+  } else if (value == "false") {
+    digitalWrite(LED_PINS[ledIndex], LOW);
+    Homie.setNodeProperty(stripNode, String(ledIndex), "false");
+    Serial.print("Led ");
+    Serial.print(ledIndex);
+    Serial.println(" is off");
+  } else {
+    return false;
+  }
+
+  return true;
+}
+
+void setup() {
+  for (int i = 0; i < NUMBER_OF_LED; i++) {
+    pinMode(LED_PINS[i], INPUT);
+    digitalWrite(LED_PINS[i], LOW);
+  }
+
+  Homie.setFirmware("awesome-ledstrip", "1.0.0");
+  Homie.registerNode(stripNode);
+  Homie.setup();
+}
+
+void loop() {
+  Homie.loop();
+}


Changed the name. Slidebright.ino to SlideBright.ino, because of Arduino IDE

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

--- SlideBright.ino
+++ SlideBright.ino
@@ -0,0 +1,953 @@
+/*
+** SlideBright - Firmware for the overengineered Hexbright flashlight.
+**               Hexbright: http://hexbright.com/
+**                                ~ Tobias Jäger <Tobias.Jaeger@slidetex.de>
+**
+**
+** Based on darcbright by Robert Quattlebaum <darco@deepdarc.com>
+**
+** List of Modes:
+**  * 3-brightnesse-level mode (43,175,500)
+**  * momentary mode
+**  * strobe mode
+**  * ajust-brightness-by-roll mode
+*/
+
+/*
+Accelorometer axies:
+
+(x,y,z)
+
+If the flashlight is facing straight up:
+  (0, 21, 0)
+
+If the flashlight is facing straight down:
+  (0, -21, 0)
+
+If the flashlight is battery-up:
+  (0, 0, -21)
+
+If the flashlight is battery-down:
+  (0, 0, 21)
+
+If the flashlight is logo-up:
+  (-21, 0, 0)
+
+If the flashlight is logo-down:
+  (21, 0, 0)
+
+*/
+
+#include <math.h>
+#include <Wire.h>
+#include <EEPROM.h>
+#include "pt.h"
+#include <avr/wdt.h>
+
+// Settings
+#define VOLTAGE_NOMINAL               3330
+#define VOLTAGE_LOW                   3100
+#define OVERTEMP_SHUTDOWN_C           60
+#define OVERTEMP_THROTTLE_C           50
+#define OVERTEMP_SHUTDOWN             (OVERTEMP_SHUTDOWN_C*10+500)
+#define OVERTEMP_THROTTLE             (OVERTEMP_THROTTLE_C*10+500)
+#define BUTTON_BRIGHTNESS_THRESHOLD   1000 // time in ms, after which a button press turns off
+#define BUTTON_DEBOUNCE               20
+#define POWER_ON_BUTTON_THRESHOLD     150 // Period of time button initially needs to be held to keep the light on.
+
+#define BRT_MIN_LUMEN          4
+#define BRT_MED_LUMEN          255                        // 175 lumens
+#define BRT_LOW_LUMEN          (BRT_MED_LUMEN/4)            // 43 lumens
+#define BRT_MAX_LUMEN          (BRT_MED_LUMEN+(3*255))    // 500 lumens
+
+
+
+// Constants
+#define ACC_ADDRESS             0x4C
+#define ACC_REG_XOUT            0
+#define ACC_REG_YOUT            1
+#define ACC_REG_ZOUT            2
+#define ACC_REG_TILT            3
+#define ACC_REG_INTS            6
+#define ACC_REG_MODE            7
+
+// Pin assignments
+#define DPIN_RLED_SW            2
+#define DPIN_GLED               5
+#define DPIN_PWR                8
+#define DPIN_DRV_MODE           9
+#define DPIN_DRV_EN             10
+#define DPIN_ACC_INT            3
+#define APIN_TEMP               0
+#define APIN_CHARGE             3
+
+// Interrupts
+#define INT_SW                  0
+#define INT_ACC                 1
+
+// State
+byte light_mode;
+unsigned short overtemp_max;
+unsigned short amount_current;
+unsigned short amount_begin;
+unsigned short amount_end;
+unsigned short amount_fade_duration;
+unsigned long amount_fade_start;
+byte amount_flash,amount_off;
+
+// Protothread States
+struct pt fade_control_pt;
+struct pt power_pt;
+struct pt button_led_pt;
+
+// Mode Protothread States
+struct pt light_pt;
+struct pt light_momentary_pt;
+struct pt light_blinky_pt;
+struct pt light_knob_pt;
+
+// Variables updated every loop
+bool button_is_pressed;
+unsigned long button_pressed_time;
+unsigned long button_released_time;
+unsigned long button_pressed_duration;
+unsigned long button_released_duration;
+short vcc_current;
+short vcc_filter_table[3];
+short vcc_filtered;
+short temp_filter_table[3];
+short temp_filtered;
+short temp_current;
+enum {
+    BATT_DISCHARGING,
+    BATT_CHARGING,
+    BATT_CHARGED,
+} batt_state;
+unsigned long time_current;
+float angle_pitch;
+float angle_roll;
+
+#define PT_WAIT_FOR_PERIOD(pt,x) \
+    lastTime =  time_current; \
+    PT_WAIT_UNTIL(pt, (time_current-lastTime) > (x));
+
+bool orientation_enabled;
+
+void
+enable_orientation(void) {
+  pinMode(DPIN_ACC_INT,  INPUT);
+  digitalWrite(DPIN_ACC_INT,  HIGH);
+
+  // Configure accelerometer
+  static const byte config[] = {
+    ACC_REG_INTS,  // First register (see next line)
+    0xE4,  // Interrupts: shakes, taps
+    0x00,  // Mode: not enabled yet
+    0x00,  // Sample rate: 120 Hz
+    0x0F,  // Tap threshold
+    0x10   // Tap debounce samples
+  };
+  Wire.beginTransmission(ACC_ADDRESS);
+  Wire.write(config, sizeof(config));
+  Wire.endTransmission();
+
+  // Enable accelerometer
+  static const byte enable[] = {ACC_REG_MODE, 0x01};  // Mode: active!
+  Wire.beginTransmission(ACC_ADDRESS);
+  Wire.write(enable, sizeof(enable));
+  Wire.endTransmission();
+
+  orientation_enabled = 1;
+}
+
+void
+update_loop_variables(void) {
+  static char i;
+
+  // Time stamp for this loop cycle.
+  time_current = millis();
+
+  // Grab the voltage and the temperature.
+  vcc_filter_table[i] = vcc_current = readVcc();
+  temp_filter_table[i] = analogRead(APIN_TEMP);
+
+  temp_current = temp_filter_table[i]*(long)vcc_current/1024;
+
+  vcc_filtered = median_short(vcc_filter_table[0],vcc_filter_table[1],vcc_filter_table[2]);
+
+  temp_filtered *= 7;
+  temp_filtered += median_short(temp_filter_table[0],temp_filter_table[1],temp_filter_table[2])*(long)vcc_filtered/1024;
+  temp_filtered /= 8;
+
+  if(++i==3)
+    i=0;
+
+  // Read out the state of but button.
+  {
+    bool prev_value = digitalRead(DPIN_RLED_SW);
+    pinMode(DPIN_RLED_SW,  INPUT);
+    digitalWrite(DPIN_RLED_SW, 0);
+    button_is_pressed = digitalRead(DPIN_RLED_SW);
+    pinMode(DPIN_RLED_SW,  OUTPUT);
+    digitalWrite(DPIN_RLED_SW, prev_value);
+  }
+
+  if(button_is_pressed) {
+    button_released_time = time_current;
+    button_pressed_duration = time_current - button_pressed_time;
+  } else {
+    button_pressed_time = time_current;
+    button_released_duration = time_current - button_released_time;
+    button_pressed_duration = 0;
+  }
+
+  short chargeState = analogRead(APIN_CHARGE);
+
+  if (chargeState < 128) {  // Low - charging
+    batt_state = BATT_CHARGING;
+  } else if (chargeState > 768) {  // High - fully charged.
+    batt_state = BATT_CHARGED;
+  } else {  // Hi-Z - Not charging, not pulged in.
+    // But if the voltage is over 3.4 volts, then we know we are plugged in.
+    if(vcc_current>3400)
+      batt_state = BATT_CHARGING;
+    else
+      batt_state = BATT_DISCHARGING;
+  }
+
+  if(orientation_enabled) {
+    char acc[3];
+    readAccelFiltered(acc);
+    angle_roll = atan2(acc[0],acc[2]);
+    angle_pitch = atan2(acc[1],sqrt(acc[0]*acc[0]+acc[2]*acc[2]));
+  }
+
+  // Check if the accelerometer wants to interrupt
+//  byte tapped = 0, shaked = 0;
+//  if (!digitalRead(DPIN_ACC_INT)) {
+//    Wire.beginTransmission(ACC_ADDRESS);
+//    Wire.write(ACC_REG_TILT);
+//    Wire.endTransmission(false);       // End, but do not stop!
+//    Wire.requestFrom(ACC_ADDRESS, 1);  // This one stops.
+//    byte tilt = Wire.read();
+//
+//    if (time-lastAccTime > 500) {
+//      lastAccTime = time;
+//
+//      tapped = !!(tilt & 0x20);
+//      shaked = !!(tilt & 0x80);
+//
+//      if (tapped) Serial.println("Tap!");
+//      if (shaked) Serial.println("Shake!");
+//    }
+//  }
+}
+
+
+short
+readVcc(void) {
+  short result;
+  // Read 1.1V reference against AVcc
+  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
+  delay(2); // Wait for Vref to settle
+  noInterrupts();
+  ADCSRA |= _BV(ADSC); // Convert
+  while (bit_is_set(ADCSRA,ADSC));
+  interrupts();
+  result = ADCL;
+  result |= ADCH<<8;
+  result = 1126400L / result; // Back-calculate AVcc in mV
+  return result;
+}
+
+void readAccel(char *acc)
+{
+  while (1)
+  {
+    Wire.beginTransmission(ACC_ADDRESS);
+    Wire.write(ACC_REG_XOUT);
+    Wire.endTransmission(false);       // End, but do not stop!
+    Wire.requestFrom(ACC_ADDRESS, 3);  // This one stops.
+
+    for (int i = 0; i < 3; i++)
+    {
+      if (!Wire.available())
+        continue;
+      acc[i] = Wire.read();
+      if (acc[i] & 0x40)  // Indicates failed read; redo!
+        continue;
+      if (acc[i] & 0x20)  // Sign-extend
+        acc[i] |= 0xC0;
+    }
+    break;
+  }
+}
+
+void readAccelFiltered(char *acc_filtered) {
+  static char acc[3][3];
+  static char i;
+  readAccel(acc[i++]);
+  if(i==3)
+    i=0;
+  acc_filtered[0] = median_char(acc[0][0],acc[1][0],acc[2][0]);
+  acc_filtered[1] = median_char(acc[0][1],acc[1][1],acc[2][1]);
+  acc_filtered[2] = median_char(acc[0][2],acc[1][2],acc[2][2]);
+}
+
+
+/* Returns the median value of the given three parameters */
+char median_char(char a, char b, char c) {
+    if(a<c) {
+        if(b<a) {
+            return a;
+        } else if(c<b) {
+            return c;
+        }
+    } else {
+        if(a<b) {
+            return a;
+        } else if(b<c) {
+            return c;
+        }
+    }
+    return b;
+}
+short median_short(short a, short b, short c) {
+    if(a<c) {
+        if(b<a) {
+            return a;
+        } else if(c<b) {
+            return c;
+        }
+    } else {
+        if(a<b) {
+            return a;
+        } else if(b<c) {
+            return c;
+        }
+    }
+    return b;
+}
+
+
+void
+retrieve_settings(void) {
+  byte data[4];
+  data[0] = EEPROM.read(0);
+  data[1] = EEPROM.read(1);
+  data[2] = EEPROM.read(2);
+  data[3] = EEPROM.read(3);
+  if(data[0] == (byte)~(data[1]^data[2]^data[3] + sizeof(data))) {
+    light_mode = data[1];
+    if(light_mode) {
+      set_amount(data[2]+((unsigned short)data[3]<<8));
+    }
+    Serial.println("Settings retrieved");
+  }
+}
+
+void
+save_settings(void) {
+  byte data[4];
+  data[1] = light_mode;
+  data[2] = (byte)amount_current;
+  data[3] = (amount_current>>8);
+  data[0] = ~(data[1]^data[2]^data[3] + sizeof(data));
+  EEPROM.write(0,data[0]);
+  EEPROM.write(1,data[1]);
+  EEPROM.write(2,data[2]);
+  EEPROM.write(3,data[3]);
+}
+
+void set_brightness(unsigned short b) {
+  noInterrupts();
+  if(b<=255) {
+    digitalWrite(DPIN_DRV_MODE, LOW);
+    analogWrite(DPIN_DRV_EN, b);
+  } else if(b<=BRT_MAX_LUMEN) {
+    analogWrite(DPIN_DRV_MODE, ((long)b-BRT_MED_LUMEN)*255/((long)BRT_MAX_LUMEN-BRT_MED_LUMEN));
+    digitalWrite(DPIN_DRV_EN, HIGH);
+  } else {
+    digitalWrite(DPIN_DRV_EN, HIGH);
+    digitalWrite(DPIN_DRV_MODE, HIGH);
+  }
+  interrupts();
+}
+
+void
+set_amount(unsigned short amount) {
+  amount_current = amount_begin = amount_end = amount;
+  amount_fade_duration = 0;
+  amount_off = 0;
+
+  set_brightness(amount_current);
+  pinMode(DPIN_PWR, OUTPUT);
+  if(time_current<POWER_ON_BUTTON_THRESHOLD || amount_current==0)
+    digitalWrite(DPIN_PWR, LOW);
+  else
+    digitalWrite(DPIN_PWR, HIGH);
+}
+
+void
+fade_to_amount(unsigned short amount, unsigned short fade_duration) {
+  amount_begin = amount_current;
+  amount_end = amount;
+  amount_fade_duration = fade_duration;
+  amount_fade_start = millis();
+  amount_off = 0;
+}
+
+PT_THREAD(fade_control_pt_func(struct pt *pt))
+{
+  static long fade_time;
+
+  PT_BEGIN(pt);
+
+  do {
+    PT_YIELD(pt);
+
+    if(amount_flash) {
+      analogWrite(DPIN_DRV_EN, 0);
+      fade_time =  time_current;
+      PT_WAIT_UNTIL(pt, (time_current-fade_time) > (100));
+    }
+
+    amount_flash = 0;
+
+    fade_time = time_current - amount_fade_start;
+
+    if(fade_time >= amount_fade_duration) {
+      if(amount_current != amount_end) {
+        amount_current = amount_end;
+      }
+    } else {
+      amount_current = (((long)amount_end - (long)amount_begin)*fade_time)/amount_fade_duration + amount_begin;
+    }
+
+    pinMode(DPIN_PWR, OUTPUT);
+    if(time_current<POWER_ON_BUTTON_THRESHOLD || amount_current==0)
+      digitalWrite(DPIN_PWR, LOW);
+    else
+      digitalWrite(DPIN_PWR, HIGH);
+
+    if(amount_current>overtemp_max) {
+      amount_current = overtemp_max;
+    }
+
+    set_brightness(amount_off?0:amount_current);
+  } while(1);
+
+  PT_END(pt);
+}
+
+PT_THREAD(button_led_pt_func(struct pt *pt))
+{
+  PT_BEGIN(pt);
+
+  do {
+    switch(batt_state) {
+    case BATT_CHARGING:
+      {
+        const unsigned long pulseTime = time_current;
+        // Smoothly pulse the green LED over a two-second interval,
+        // as if it were "breathing". This is the charging indication.
+        byte pulse = ((pulseTime>>2)&0xFF);
+        pulse = ((pulse * pulse) >> 8);
+        pulse = ((pulseTime>>2)&0x0100)?0xFF-pulse:pulse;
+        analogWrite(DPIN_GLED, pulse);
+      }
+      if(overtemp_max<BRT_MAX_LUMEN) {
+        digitalWrite(DPIN_RLED_SW, (time_current&0x03FF)>0x01FF?LOW:HIGH);
+      } else {
+        digitalWrite(DPIN_RLED_SW, LOW);
+      }
+      break;
+    case BATT_CHARGED:
+      // Solid green LED.
+      digitalWrite(DPIN_GLED, HIGH);
+      if(overtemp_max<BRT_MAX_LUMEN) {
+        digitalWrite(DPIN_RLED_SW, (time_current&0x03FF)>0x01FF?LOW:HIGH);
+      } else {
+        digitalWrite(DPIN_RLED_SW, LOW);
+      }
+      break;
+    case BATT_DISCHARGING:
+      // Blink the indicator LED now and then.
+      if(overtemp_max<BRT_MAX_LUMEN) {
+        digitalWrite(DPIN_RLED_SW, (time_current&0x03FF)>50?LOW:HIGH);
+        digitalWrite(DPIN_GLED, LOW);
+      } else {
+        digitalWrite(DPIN_GLED, (time_current&0x03FF)>10?LOW:HIGH);
+        digitalWrite(DPIN_RLED_SW, LOW);
+      }
+      break;
+    }
+    PT_YIELD(pt);
+  } while(1);
+
+  PT_END(pt);
+}
+
+PT_THREAD(power_pt_func(struct pt *pt))
+{
+  static unsigned short count;
+  count++;
+  PT_BEGIN(pt);
+
+  overtemp_max = BRT_MAX_LUMEN;
+  do {
+    // Check the temperature sensor
+    {
+      static bool low_power_condition = false;
+      static uint8_t anti_flicker = 255;
+
+      if(temp_filtered > OVERTEMP_SHUTDOWN) {
+        if(amount_current)
+          Serial.println("Overheat shutdown!");
+        set_amount(0);
+        digitalWrite(DPIN_DRV_MODE, LOW);
+        digitalWrite(DPIN_DRV_EN, LOW);
+        digitalWrite(DPIN_PWR, LOW);
+      }
+
+      if(low_power_condition || (vcc_current<VOLTAGE_LOW)) {
+        if(!low_power_condition) {
+          overtemp_max = amount_current;
+        }
+        low_power_condition = true;
+        if((vcc_filtered < VOLTAGE_LOW) && (overtemp_max > BRT_MIN_LUMEN)) {
+          digitalWrite(DPIN_DRV_EN, LOW);
+          digitalWrite(DPIN_DRV_MODE, LOW);
+          analogWrite(DPIN_DRV_EN,BRT_MIN_LUMEN);
+          overtemp_max = overtemp_max/2 + BRT_MIN_LUMEN;
+          anti_flicker = 0;
+        }
+      }
+
+      if(anti_flicker == 255) {
+        if((vcc_filtered > VOLTAGE_NOMINAL+50) && (overtemp_max != BRT_MAX_LUMEN))
+          overtemp_max++;
+          anti_flicker -= 10;
+      } else {
+        anti_flicker++;
+      }
+
+      if(temp_filtered > OVERTEMP_THROTTLE) {
+        short new_max = (256-((temp_filtered-OVERTEMP_THROTTLE)*2)<<2)-1;
+        if((overtemp_max>BRT_MIN_LUMEN) && (new_max<(signed)overtemp_max)) {
+          overtemp_max--;
+          anti_flicker = 0;
+        }
+      }
+
+      static unsigned long lastStatTime;
+      if(time_current-lastStatTime > 1000) {
+        while(time_current-lastStatTime > 1000)
+          lastStatTime += 1000;
+
+        Serial.print("stat: ");
+        Serial.print(time_current);
+
+        switch(batt_state) {
+        case BATT_CHARGING:
+          Serial.print(" [CHARGING]");
+          break;
+        case BATT_CHARGED:
+          Serial.print(" [CHARGED]");
+          break;
+        case BATT_DISCHARGING:
+          Serial.print(" [BATTERY]");
+          break;
+        }
+
+        Serial.print(" lHz=");
+        Serial.print(count);
+        count = 0;
+
+        Serial.print(" duty=");
+        Serial.print(amount_current);
+
+        Serial.print(" Vcc=");
+        Serial.print(vcc_filtered);
+        Serial.print("mv");
+
+        Serial.print(" Temp=");
+        Serial.print((temp_filtered-500)/10.0f);
+        Serial.print("C");
+
+        if(orientation_enabled) {
+          Serial.print(" roll=");
+          Serial.print(angle_roll);
+
+          Serial.print(" pitch=");
+          Serial.print(angle_pitch);
+        }
+
+        if(overtemp_max<BRT_MAX_LUMEN) {
+          Serial.print(" THRTTL=");
+          Serial.print(overtemp_max);
+        }
+        Serial.println("");
+        }
+    }
+
+    PT_YIELD(pt);
+  } while(1);
+
+  PT_END(pt);
+}
+
+PT_THREAD(light_momentary_pt_func(struct pt *pt))
+{
+  // If more than two minutes go by without the user
+  // pressing a button, then go ahead and shut down.
+  if(button_released_duration > 120000) {
+    pinMode(DPIN_PWR, OUTPUT);
+    digitalWrite(DPIN_PWR, LOW);
+  }
+
+  PT_BEGIN(pt);
+
+  do {
+    pinMode(DPIN_PWR, OUTPUT);
+    digitalWrite(DPIN_PWR, HIGH);
+    amount_off = 0;
+
+    PT_WAIT_UNTIL(pt, !button_is_pressed);
+
+    amount_off = 1;
+
+    PT_WAIT_UNTIL(pt, button_is_pressed);
+  } while(amount_current);
+
+  PT_END(pt);
+}
+
+PT_THREAD(light_blinky_pt_func(struct pt *pt))
+{
+  PT_BEGIN(pt);
+
+  PT_WAIT_UNTIL(pt, !button_is_pressed && (button_released_duration > BUTTON_DEBOUNCE));
+  button_pressed_duration = 0;
+
+  do {
+    amount_off = !((time_current&0xFF)<=64) || !((time_current&0x1F)<=16);
+    PT_YIELD(pt);
+  } while(amount_current && (button_pressed_duration<BUTTON_DEBOUNCE));
+
+  amount_off = 0;
+  PT_WAIT_UNTIL(pt,!button_is_pressed);
+
+  PT_END(pt);
+}
+
+PT_THREAD(light_knob_pt_func(struct pt *pt))
+{
+  static unsigned long lastTime;
+  static float lastKnobAngle, knob;
+
+  PT_BEGIN(pt);
+
+  enable_orientation();
+
+  // Set the initial knob value based on our current light bightness level.
+  knob = sqrt((float)amount_current/(float)BRT_MAX_LUMEN);
+
+  // Wait for the user to let go of the button.
+  PT_WAIT_UNTIL(pt,!button_is_pressed);
+
+  // Wait for a brief moment for any vibrations to stabalize.
+  PT_WAIT_FOR_PERIOD(pt,50);
+
+  lastKnobAngle = angle_roll;
+
+  do {
+    {
+      // Make apparent brightness changes linear by squaring the
+      // value and dividing back down into range.  This gives us
+      // a gamma correction of 2.0, which is close enough.
+      unsigned short bright = (uint16_t)(knob * knob * BRT_MAX_LUMEN);
+
+      // Avoid ever appearing off in this mode!
+      if (bright < BRT_MIN_LUMEN) bright = BRT_MIN_LUMEN;
+
+      if((amount_current != amount_end) || abs((int16_t)(amount_end-bright)) > 4)
+        fade_to_amount(bright,100);
+    }
+
+    PT_WAIT_FOR_PERIOD(pt,50);
+
+    {
+      #define DEG_TO_RAD(x)    ((PI*(x))/180.0f)
+      float change = angle_roll - lastKnobAngle;
+      lastKnobAngle = angle_roll;
+
+      // Don't bother updating our brightness reading if our angle isn't good.
+      if(abs(angle_pitch) < DEG_TO_RAD(60)) {
+        if (change >  PI) change -= 2.0f*PI;
+        if (change < -PI) change += 2.0f*PI;
+        knob += change / -7.0f;
+        if (knob < 0) knob = 0;
+        if (knob > 1) knob = 1;
+      }
+    }
+  } while(amount_current && (button_pressed_duration<BUTTON_DEBOUNCE));
+
+  PT_WAIT_UNTIL(pt,!button_is_pressed);
+
+  PT_END(pt);
+}
+
+PT_THREAD(light_pt_func(struct pt *pt))
+{
+  static unsigned long lastTime;
+  static byte level;
+
+  PT_BEGIN(pt);
+
+  // Estimate what the current brighness level is closest to.
+  if(amount_current < (BRT_LOW_LUMEN/2)) {
+    level = 0;
+  } else if(amount_current < (BRT_MED_LUMEN/2)) {
+    level = 1;
+  } else if(amount_current < (BRT_MAX_LUMEN/2)) {
+    level = 2;
+  } else {
+    level = 3;
+  }
+
+  button_released_time = time_current;
+  button_released_duration = 0;
+
+  Serial.println("Starting light thread.");
+  do {
+    PT_WAIT_UNTIL(pt, button_is_pressed && (button_pressed_duration > BUTTON_DEBOUNCE));
+
+    if(!amount_current || (button_released_duration<BUTTON_BRIGHTNESS_THRESHOLD)) {
+      level++;
+      level &= 3;
+      Serial.print("intensity=");
+      Serial.println(level);
+    } else {
+      Serial.println("turning off");
+      level = 0;
+    }
+
+    switch(level) {
+    case 0:
+      break;
+
+    case 1:
+      fade_to_amount(BRT_LOW_LUMEN,250);
+      break;
+
+    case 2:
+      fade_to_amount(BRT_MED_LUMEN,500);
+      break;
+
+    case 3:
+      fade_to_amount(BRT_MAX_LUMEN,500);
+      break;
+    }
+
+    PT_WAIT_UNTIL(pt, !button_is_pressed && (button_released_duration > BUTTON_DEBOUNCE));
+
+    if(!level)
+      fade_to_amount(0,500);
+  } while(1);
+
+  PT_END(pt);
+}
+
+void
+check_serial_port(void)
+{
+  // Check the serial port
+  if(Serial.available()) {
+    char c = Serial.read();
+    switch(c) {
+    case '+':
+      if(BRT_MAX_LUMEN-amount_current<BRT_MIN_LUMEN)
+        set_amount(BRT_MAX_LUMEN);
+      else
+        set_amount(amount_current+BRT_MIN_LUMEN);
+      break;
+
+    case '-':
+      if(amount_current<BRT_MIN_LUMEN)
+        set_amount(0);
+      else
+        set_amount(amount_current-BRT_MIN_LUMEN);
+      break;
+
+    case 'X':
+    case 'x': set_amount(0); break;
+    case 'H':
+    case 'h': set_amount(BRT_MAX_LUMEN); amount_off = 0; break;
+
+    case '0': light_mode = 0; amount_off = 0; break;
+    case '1': light_mode = 1; amount_off = 0; break;
+    case '2': light_mode = 2; amount_off = 0; break;
+    case '3': light_mode = 3; amount_off = 0; break;
+    case '4': light_mode = 4; amount_off = 0; break;
+    case '5': light_mode = 5; amount_off = 0; break;
+
+    case 'R':
+      // Let the watchdog reset us.
+      Serial.println("Rebooting");
+      wdt_enable(WDTO_15MS);
+      while(1) { }
+      break;
+      /*
+    case 'C':
+    case 'c': Serial.println("+------+---------------------+");
+              Serial.println("| +    | increase brightness |");
+              Serial.println("| -    | decrease brightness |");
+              Serial.println("| x/X  | turn light off      |");
+              Serial.println("| h/H  | max brightness      |");
+              Serial.println("| 0..5 | set light_mode      |");
+              Serial.println("| c/C  | list commands       |");
+              Serial.println("| R    | reboot              |");
+              Serial.println("+------+---------------------+");
+    */
+    default:
+      break;
+    }
+  }
+}
+
+void
+setup(void)
+{
+  // Set our watchdog to kill us if we don't
+  // check in every two seconds.
+  wdt_enable(WDTO_2S);
+
+  // We just powered on!  That means either we got plugged
+  // into USB, or (more likely) the user is pressing the
+  // power button.  We need to pull up the enable pin of
+  // the regulator very soon so we don't lose power.
+
+  // We don't pull the pin high here quite yet because
+  // we will do that when we transition out of MODE_OFF,
+  // somewhere in the main loop. Delaying this as long
+  // as possible acts like a debounce for accidental button
+  // taps.
+  pinMode(DPIN_PWR,      INPUT);
+  digitalWrite(DPIN_PWR, LOW);
+
+  // Initialize GPIO
+  pinMode(DPIN_RLED_SW,  INPUT);
+  pinMode(DPIN_GLED,     OUTPUT);
+  pinMode(DPIN_DRV_MODE, OUTPUT);
+  pinMode(DPIN_DRV_EN,   OUTPUT);
+  digitalWrite(DPIN_DRV_MODE, LOW);
+  digitalWrite(DPIN_DRV_EN,   LOW);
+
+  // Initialize serial busses
+  Serial.begin(9600);
+  Wire.begin();
+
+  button_released_time = millis();
+  button_pressed_time = millis();
+
+  update_loop_variables();
+  update_loop_variables();
+  update_loop_variables();
+
+  // Don't bother loading the settings if we are connected to USB.
+  // Only load the settings when we are running from the battery.
+  if (batt_state == BATT_DISCHARGING) {
+    retrieve_settings();
+  }
+
+  Serial.println("Powered up!");
+}
+
+void
+loop(void)
+{
+  static unsigned long lastTime;
+  unsigned long time = millis();
+
+  // Reset the watchdog timer
+  wdt_reset();
+
+  update_loop_variables();
+
+  check_serial_port();
+
+  button_led_pt_func(&button_led_pt);
+
+  power_pt_func(&power_pt);
+
+  fade_control_pt_func(&fade_control_pt);
+
+#define NUMBER_OF_MODES    (4)
+
+  static byte last_mode;
+  static byte save_mode;
+  if((button_pressed_duration > 2048+1024+512*NUMBER_OF_MODES+1024)) {
+    if(save_mode == 1) {
+      amount_off = 1;
+      save_settings();
+      amount_off = 0;
+      save_mode = 2;
+    }
+  } else if((button_pressed_duration > 2048+1024+512*NUMBER_OF_MODES)) {
+    amount_off = ((button_pressed_duration/64) & 1);
+    if(save_mode == 0) {
+      save_mode = 1;
+      last_mode = 0;
+    }
+  } else if((button_pressed_duration > 2048)) {
+    byte selected_mode = (button_pressed_duration-2048)/512 + 1;
+    amount_off = 0;
+    if(selected_mode-1>=light_mode) {
+      selected_mode++;
+    }
+    if(selected_mode > NUMBER_OF_MODES)
+      selected_mode = NUMBER_OF_MODES;
+    if(selected_mode-1==light_mode)
+      selected_mode--;
+    if(selected_mode != last_mode) {
+      amount_flash = 1;
+      last_mode = selected_mode;
+      Serial.print("Mode selected: ");
+      Serial.println(selected_mode-1);
+    }
+  } else {
+    char thread_status;
+    if(save_mode) {
+      save_mode = 0;
+      amount_off = 0;
+      button_pressed_duration = 0;
+      button_released_duration = 0;
+    }
+    if(last_mode) {
+      light_mode = last_mode-1;
+      last_mode = 0;
+      Serial.print("Mode change: ");
+      Serial.println(light_mode);
+      PT_INIT(&light_pt);
+      PT_INIT(&light_momentary_pt);
+      PT_INIT(&light_blinky_pt);
+      PT_INIT(&light_knob_pt);
+    }
+    switch(light_mode) {
+      default:
+      case 0: thread_status = light_momentary_pt_func(&light_momentary_pt); break;
+      case 1: thread_status = light_pt_func(&light_pt); break;
+      case 2: thread_status = light_blinky_pt_func(&light_blinky_pt); break;
+      case 3: thread_status = light_knob_pt_func(&light_knob_pt); break;
+    }
+    if(!PT_SCHEDULE(thread_status)) {
+      light_mode = 0;
+      fade_to_amount(0,500);
+    }
+  }
+
+  return;
+}
+
+


Create mdns.ino

Create mdns.ino

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

--- firmware/examples/mdns.ino
+++ firmware/examples/mdns.ino
@@ -0,0 +1,44 @@
+#include "MDNS.h"
+
+#define HTTP_PORT 80
+
+MDNS mdns;
+
+String html = "
Ok!
";
+
+TCPServer server = TCPServer(HTTP_PORT);
+
+void setup() {
+    bool success = mdns.setHostname("core-1");
+
+    if (success) {
+        success = mdns.setService("_http._tcp", HTTP_PORT, "Core 1");
+    }
+
+    if (success) {
+        success = mdns.addTXTEntry("coreid", "1");
+    }
+
+    if (success) {
+        success = mdns.begin();
+    }
+
+    if (success) {
+        Spark.publish("mdns/setup", "success");
+    } else {
+        Spark.publish("mdns/setup", "error");
+    }
+}
+
+void loop() {
+    mdns.processQueries();
+
+    TCPClient client = server.available();
+
+    if (client){
+        client.println(html);
+        client.println();
+        client.flush();
+        client.stop();
+    }
+}


Change to foxy-head-2020.

Change to foxy-head-2020.

Clara visited 20/08/2020 and we changed to swivel to a slowly driven set
of movements.

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/JulianNicholls/Arduino.git/'


testing led strip

testing led strip

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


Six channels Leonardo code added

Six channels Leonardo code added

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


Added ESP gw

Added ESP gw

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/werar/iothome.git/'


New example

New example

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

--- examples/CustomView/CustomView.ino
+++ examples/CustomView/CustomView.ino
@@ -0,0 +1,40 @@
+/*
+  Custom view example
+
+ A simple web server that hosts files from SD card.
+
+ Circuit:
+ * Ethernet shield attached to pins 10, 11, 12, 13
+
+ created 27.11.2015
+ by Szymon Zmilczak
+ */
+
+#include <Ethernet.h>
+#include <MiniApache.h>
+
+byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // MAC address from Ethernet shield sticker under board
+IPAddress ip(192, 168, 0, 179); // IP address, may need to be changed depending on network
+MiniApache apache(80); // Create a server at port 80
+
+void setup(){
+    Serial.begin(9600); // Serial for debugging
+    pinMode(10, OUTPUT);
+    digitalWrite(10, HIGH); // Disable Ethernet chip
+    Ethernet.begin(mac, ip);  // Initialize Ethernet device
+    apache.begin("/served", 4); // Initialize MiniApache server: served path and SD card pin
+}
+
+void loop() {
+  if(apache.PendingRequest()){ // Check for pending request
+    if (apache.RequestIs("/test")){ // Check if request path is equal to /test
+      apache.PrintHeader(); // Start response
+      // equivalent to PrintHeader(200, "OK", "text/html", false); -  200 (OK) response of text/html type, not cached
+      apache.client.print("Test succesfull"); // Write response
+      apache.ReportClientServed(); // Finish response
+    }
+  }
+  apache.ProcessRequest();
+}
+
+


example for firmware check

example for firmware check

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

--- examples/firmware_check/firmware_check.ino
+++ examples/firmware_check/firmware_check.ino
@@ -0,0 +1,72 @@
+/*
+ * ----------------------------------------------------------------------------
+ * This is a MFRC522 library example; see https://github.com/miguelbalboa/rfid
+ * for further details and other examples.
+ *
+ * NOTE: The library file MFRC522.h has a lot of useful info. The functions are
+ * documented in MFRC522.cpp. Please read it.
+ *
+ * Released into the public domain.
+ * ----------------------------------------------------------------------------
+ * Example sketch/program showing how to test your firmware.
+ *
+ * Typical pin layout used:
+ * -----------------------------------------------------------------------------------------
+ *             MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino
+ *             Reader/PCD   Uno           Mega      Nano v3    Leonardo/Micro   Pro Micro
+ * Signal      Pin          Pin           Pin       Pin        Pin              Pin
+ * -----------------------------------------------------------------------------------------
+ * RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST
+ * SPI SS      SDA(SS)      10            53        D10        10               10
+ * SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16
+ * SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14
+ * SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15
+ */
+
+#include <SPI.h>
+#include <MFRC522.h>
+
+#define RST_PIN         9          // Configurable, see typical pin layout above
+#define SS_PIN          10         // Configurable, see typical pin layout above
+
+MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance.
+
+void setup() {
+  Serial.begin(9600);   // Initialize serial communications with the PC
+  while (!Serial);      // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
+  SPI.begin();          // Init SPI bus
+  mfrc522.PCD_Init();   // Init MFRC522 module
+
+  Serial.println(F("*****************************"));
+  Serial.println(F("MFRC522 Digital self test"));
+  Serial.println(F("*****************************"));
+  ShowReaderDetails();  // Show details of PCD - MFRC522 Card Reader details
+  Serial.println(F("Performing test..."));
+  bool result = mfrc522.PCD_PerformSelfTest();
+  Serial.println(F("-----------------------------"));
+  Serial.print(F("Result: "));
+  if (result)
+    Serial.println(F("OK"));
+  else
+    Serial.println(F("defect or unknown"));
+  Serial.println();
+}
+
+void loop() {} // nothing to do
+
+void ShowReaderDetails() {
+  // Get the MFRC522 firmware version
+  byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
+  Serial.print(F("Firmware Version: 0x"));
+  Serial.print(v, HEX);
+  if (v == 0x91)
+    Serial.print(F(" = v1.0"));
+  else if (v == 0x92)
+    Serial.print(F(" = v2.0"));
+  else
+    Serial.print(F(" = (unknown)"));
+  Serial.println();
+  // When 0x00 or 0xFF is returned, communication probably failed
+  if ((v == 0x00) || (v == 0xFF))
+    Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
+}


Adding Arduino test sketch to check bubbling occurs when asked.

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

--- arduino/bubble_trigger_test/bubble_trigger_test.ino
+++ arduino/bubble_trigger_test/bubble_trigger_test.ino
@@ -0,0 +1,72 @@
+/* BubbleTriggerTest
+*
+*  copyright Becky Stewart, Anti-Alias Labs
+*  becky@antialiaslabs.com
+*
+*  Tests that bubbling is occurring correctly by cycling
+*  through bubbling.
+*/
+
+// pins
+int greenStatusLED = 6;
+int yellowStatusLED = 5;
+int relay1 = 2;
+int relay2 = 3;
+
+// other variables
+int bubbleTime = 150;
+int bubbleThrottle = 5000;
+
+void setup() {
+  // set up pin modes
+  pinMode( greenStatusLED, OUTPUT );
+  pinMode( yellowStatusLED, OUTPUT );
+  pinMode( relay1, OUTPUT );
+  pinMode( relay2, OUTPUT );
+
+  // start serial
+  //Serial.begin( 9600 );
+  //while( !Serial );
+
+  // print welcome message at startup
+  //Serial.println( "Testing the bubbler");
+
+}
+
+void loop() {
+
+  // bubble a test series
+  //Serial.println("...bubbles");
+  bubble();
+
+  delay( 500 );
+
+  bubble();
+
+
+  delay( 30000 );
+}
+
+void bubble() {
+  // turn on status LED
+  digitalWrite( greenStatusLED, HIGH );
+  digitalWrite( yellowStatusLED, LOW );
+
+  // trigger relay
+  digitalWrite( relay1, HIGH );
+  digitalWrite( relay2, HIGH );
+
+  // wait to create bubbles
+  delay( bubbleTime );
+
+  // stop relay
+  digitalWrite( relay1, LOW );
+  digitalWrite( relay2, LOW );
+
+  // update status LEDs
+  digitalWrite( greenStatusLED, LOW);
+  digitalWrite( yellowStatusLED, HIGH);
+
+  // wait to throttle bubbling
+  delay( bubbleThrottle );
+}


versionmejorada

versionmejorada

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/DigitalesSED/ProyectoFinal.git/'


Create BH1750FVI_4Wire.ino

Create BH1750FVI_4Wire.ino

Added a new very simple example with just 4 wires (VCC,GND,SDA,SCL)

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

--- examples/BH1750FVI_4Wire/BH1750FVI_4Wire.ino
+++ examples/BH1750FVI_4Wire/BH1750FVI_4Wire.ino
@@ -0,0 +1,40 @@
+/*
+  This example uses only 4 wires to test the BH1750 Light sensor
+
+  Connecting the sensor to a NodeMCU ESP8266:
+  VCC  <-> 3V3
+  GND  <-> GND
+  SDA  <-> D2
+  SCL  <-> D1
+
+  Connecting the sensor to a Arduino UNO:
+  VCC  <-> 3V3
+  GND  <-> GND
+  SDA  <-> A4/SDA
+  SCL  <-> A5/SCL
+
+  Connecting the sensor to a Arduino DUE:
+  VCC  <-> 3V3
+  GND  <-> GND
+  SDA  <-> D20/SDA
+  SCL  <-> D21/SCL
+*/
+
+#include <BH1750FVI.h>
+
+// Create the Lightsensor instance
+BH1750FVI LightSensor(BH1750FVI::k_DevModeContLowRes);
+
+void setup()
+{
+  Serial.begin(115200);
+  LightSensor.begin();
+}
+
+void loop()
+{
+  uint16_t lux = LightSensor.GetLightIntensity();
+  Serial.print("Light: ");
+  Serial.println(lux);
+  delay(250);
+}


display on nokia screen with arduino -ac

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

--- code/pbdisplay/pcdtestAug22serialinputangle/pcdtestAug22serialinputangle.ino
+++ code/pbdisplay/pcdtestAug22serialinputangle/pcdtestAug22serialinputangle.ino
@@ -0,0 +1,406 @@
+/*********************************************************************
+This is an example sketch for our Monochrome Nokia 5110 LCD Displays
+
+  Pick one up today in the adafruit shop!
+  ------> http://www.adafruit.com/products/338
+
+These displays use SPI to communicate, 4 or 5 pins are required to
+interface
+
+Adafruit invests time and resources providing this open source code,
+please support Adafruit and open-source hardware by purchasing
+products from Adafruit!
+
+Written by Limor Fried/Ladyada  for Adafruit Industries.
+BSD license, check license.txt for more information
+All text above, and the splash screen must be included in any redistribution
+*********************************************************************/
+
+#include <SPI.h>
+#include <Adafruit_GFX.h>
+#include <Adafruit_PCD8544.h>
+#include <math.h>
+
+// Software SPI (slower updates, more flexible pin options):
+// pin 7 - Serial clock out (SCLK)
+// pin 6 - Serial data out (DIN)
+// pin 5 - Data/Command select (D/C)
+// pin 4 - LCD chip select (CS)
+// pin 3 - LCD reset (RST)
+Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
+
+// Hardware SPI (faster, but must use certain hardware pins):
+// SCK is LCD serial clock (SCLK) - this is pin 13 on Arduino Uno
+// MOSI is LCD DIN - this is pin 11 on an Arduino Uno
+// pin 5 - Data/Command select (D/C)
+// pin 4 - LCD chip select (CS)
+// pin 3 - LCD reset (RST)
+// Adafruit_PCD8544 display = Adafruit_PCD8544(5, 4, 3);
+// Note with hardware SPI MISO and SS pins aren't used but will still be read
+// and written to during SPI transfer.  Be careful sharing these pins!
+
+#define NUMFLAKES 10
+#define XPOS 0
+#define YPOS 1
+#define DELTAY 2
+
+
+#define LOGO16_GLCD_HEIGHT 16
+#define LOGO16_GLCD_WIDTH  16
+
+static const unsigned char PROGMEM logo16_glcd_bmp[] =
+{ B00000000, B11000000,
+  B00000001, B11000000,
+  B00000001, B11000000,
+  B00000011, B11100000,
+  B11110011, B11100000,
+  B11111110, B11111000,
+  B01111110, B11111111,
+  B00110011, B10011111,
+  B00011111, B11111100,
+  B00001101, B01110000,
+  B00011011, B10100000,
+  B00111111, B11100000,
+  B00111111, B11110000,
+  B01111100, B11110000,
+  B01110000, B01110000,
+  B00000000, B00110000 };
+
+void setup()   {
+  Serial.begin(9600);
+
+  display.begin();
+  // init done
+
+  // you can change the contrast around to adapt the display
+  // for the best viewing!
+  display.setContrast(50);
+
+  display.display(); // show splashscreen
+  delay(2000);
+  display.clearDisplay();   // clears the screen and buffer
+
+  // draw a single pixel
+  display.drawPixel(10, 10, BLACK);
+  display.display();
+  delay(2000);
+  display.clearDisplay();
+
+//  // draw many lines
+//  //testdrawline();
+//  //display.display();
+//  //delay(2000);
+//  //display.clearDisplay();
+//
+//  // draw rectangles
+//  testdrawrect();
+//  display.display();
+//  delay(2000);
+//  display.clearDisplay();
+//
+//  // draw multiple rectangles
+//  testfillrect();
+//  display.display();
+//  delay(2000);
+//  display.clearDisplay();
+//
+//  // draw mulitple circles
+//  testdrawcircle();
+//  display.display();
+//  delay(2000);
+//  display.clearDisplay();
+
+  // draw a circle, 10 pixel radius
+  display.fillCircle(display.width()/2, display.height()/2, 10, BLACK);
+  display.display();
+  delay(2000);
+  display.clearDisplay();
+//
+//  testdrawroundrect();
+//  delay(2000);
+//  display.clearDisplay();
+//
+//  testfillroundrect();
+//  delay(2000);
+//  display.clearDisplay();
+//
+//  testdrawtriangle();
+//  delay(2000);
+//  display.clearDisplay();
+//
+//  testfilltriangle();
+//  delay(2000);
+//  display.clearDisplay();
+//
+  // draw the first ~12 characters in the font
+  testdrawchar();
+  display.display();
+  delay(2000);
+  display.clearDisplay();
+
+  // text display tests
+  //display.setTextSize(1);
+//  display.setTextColor(BLACK);
+//  display.setCursor(0,0);
+//  display.println("Hello, world!");
+//  display.setTextColor(WHITE, BLACK); // 'inverted' text
+//  display.println(3.141592);
+//  display.setTextSize(2);
+//  display.setTextColor(BLACK);
+//  display.print("0x"); display.println(0xDEADBEEF, HEX);
+//  display.display();
+//  delay(2000);
+//
+//  // rotation example
+//  display.clearDisplay();
+//  display.setRotation(1);  // rotate 90 degrees counter clockwise, can also use values of 2 and 3 to go further.
+//  display.setTextSize(1);
+//  display.setTextColor(BLACK);
+//  display.setCursor(0,0);
+//  display.println("Rotation");
+//  display.setTextSize(2);
+//  display.println("Example!");
+//  display.display();
+//  delay(2000);
+
+  // revert back to no rotation
+  display.setRotation(0);
+
+  // miniature bitmap display
+  //display.clearDisplay();
+  //display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);
+  //display.display();
+
+  // invert the display
+  //display.invertDisplay(true);
+  //delay(1000);
+  //display.invertDisplay(false);
+  //delay(1000);
+
+  // draw a bitmap icon and 'animate' movement
+  //testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT);
+   // Wait for serial to come in, then clear display and go to echo
+   display.fillCircle(display.width()/2, display.width()/2, 2, BLACK);
+   display.display();
+   delay(2000);
+   display.clearDisplay();
+
+   while (! Serial); // Wait until Serial is ready
+}
+
+
+// Loop turns the display into a local serial monitor echo.
+// Type to the Arduino from the serial monitor, and it'll echo
+// what you type on the display. Type ~ to clear the display.
+void loop()
+{
+
+  int16_t x0 = display.width()/2;
+  int16_t y0 = display.height()/2;
+  display.fillCircle(x0, y0, 0.5, BLACK);
+  display.display();
+
+  int16_t r =20;
+
+  double theta=0;
+  double DEGREES_TO_RADIANS = 2*PI/360;
+
+  if (Serial.available())
+  {
+    int angle = Serial.parseInt();
+
+    theta = angle*DEGREES_TO_RADIANS;
+    double delta_x = r*cos(theta);
+    double delta_y = r*sin(theta);
+    int16_t x1 = x0+ (int)delta_x;
+    int16_t y1 = y0+ (int)delta_y;
+
+    // draw a circle, 2 pixel radius
+    display.fillCircle(x1, y1, 2, BLACK);
+    display.display();
+    // draw a line
+    display.drawLine(x0, y0, x1, y1, BLACK);
+    display.display();
+    delay(1000);
+    display.clearDisplay();
+    display.fillCircle(x0, y0, 0.5, BLACK);
+    display.display();
+
+  }
+}
+
+
+void testdrawbitmap(const uint8_t *bitmap, uint8_t w, uint8_t h) {
+  uint8_t icons[NUMFLAKES][3];
+  randomSeed(666);     // whatever seed
+
+  // initialize
+  for (uint8_t f=0; f< NUMFLAKES; f++) {
+    icons[f][XPOS] = random(display.width());
+    icons[f][YPOS] = 0;
+    icons[f][DELTAY] = random(5) + 1;
+
+    Serial.print("x: ");
+    Serial.print(icons[f][XPOS], DEC);
+    Serial.print(" y: ");
+    Serial.print(icons[f][YPOS], DEC);
+    Serial.print(" dy: ");
+    Serial.println(icons[f][DELTAY], DEC);
+  }
+
+  while (1) {
+    // draw each icon
+    for (uint8_t f=0; f< NUMFLAKES; f++) {
+      display.drawBitmap(icons[f][XPOS], icons[f][YPOS], logo16_glcd_bmp, w, h, BLACK);
+    }
+    display.display();
+    delay(200);
+
+    // then erase it + move it
+    for (uint8_t f=0; f< NUMFLAKES; f++) {
+      display.drawBitmap(icons[f][XPOS], icons[f][YPOS],  logo16_glcd_bmp, w, h, WHITE);
+      // move it
+      icons[f][YPOS] += icons[f][DELTAY];
+      // if its gone, reinit
+      if (icons[f][YPOS] > display.height()) {
+	icons[f][XPOS] = random(display.width());
+	icons[f][YPOS] = 0;
+	icons[f][DELTAY] = random(5) + 1;
+      }
+    }
+   }
+}
+
+
+void testdrawchar(void) {
+  display.setTextSize(1);
+  display.setTextColor(BLACK);
+  display.setCursor(0,0);
+
+  for (uint8_t i=0; i < 168; i++) {
+    if (i == '\n') continue;
+    display.write(i);
+    //if ((i > 0) && (i % 14 == 0))
+      //display.println();
+  }
+  display.display();
+}
+
+void testdrawcircle(void) {
+  for (int16_t i=0; i<display.height(); i+=2) {
+    display.drawCircle(display.width()/2, display.height()/2, i, BLACK);
+    display.display();
+  }
+}
+
+void testfillrect(void) {
+  uint8_t color = 1;
+  for (int16_t i=0; i<display.height()/2; i+=3) {
+    // alternate colors
+    display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
+    display.display();
+    color++;
+  }
+}
+
+void testdrawtriangle(void) {
+  for (int16_t i=0; i<min(display.width(),display.height())/2; i+=5) {
+    display.drawTriangle(display.width()/2, display.height()/2-i,
+                     display.width()/2-i, display.height()/2+i,
+                     display.width()/2+i, display.height()/2+i, BLACK);
+    display.display();
+  }
+}
+
+void testfilltriangle(void) {
+  uint8_t color = BLACK;
+  for (int16_t i=min(display.width(),display.height())/2; i>0; i-=5) {
+    display.fillTriangle(display.width()/2, display.height()/2-i,
+                     display.width()/2-i, display.height()/2+i,
+                     display.width()/2+i, display.height()/2+i, color);
+    if (color == WHITE) color = BLACK;
+    else color = WHITE;
+    display.display();
+  }
+}
+
+void testdrawroundrect(void) {
+  for (int16_t i=0; i<display.height()/2-2; i+=2) {
+    display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, BLACK);
+    display.display();
+  }
+}
+
+void testfillroundrect(void) {
+  uint8_t color = BLACK;
+  for (int16_t i=0; i<display.height()/2-2; i+=2) {
+    display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i, display.height()/4, color);
+    if (color == WHITE) color = BLACK;
+    else color = WHITE;
+    display.display();
+  }
+}
+
+void testdrawrect(void) {
+  for (int16_t i=0; i<display.height()/2; i+=2) {
+    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, BLACK);
+    display.display();
+  }
+}
+
+void testdrawoneline() {
+  for (int16_t i=0; i<display.width(); i+=4) {
+    display.drawLine(0, 0, i, display.height()-1, BLACK);
+    display.display();
+  }
+  for (int16_t i=0; i<display.height(); i+=4) {
+    display.drawLine(0, 0, display.width()-1, i, BLACK);
+    display.display();
+  }
+  delay(250);
+}
+
+void testdrawline() {
+  for (int16_t i=0; i<display.width(); i+=4) {
+    display.drawLine(0, 0, i, display.height()-1, BLACK);
+    display.display();
+  }
+  for (int16_t i=0; i<display.height(); i+=4) {
+    display.drawLine(0, 0, display.width()-1, i, BLACK);
+    display.display();
+  }
+  delay(250);
+
+  display.clearDisplay();
+  for (int16_t i=0; i<display.width(); i+=4) {
+    display.drawLine(0, display.height()-1, i, 0, BLACK);
+    display.display();
+  }
+  for (int8_t i=display.height()-1; i>=0; i-=4) {
+    display.drawLine(0, display.height()-1, display.width()-1, i, BLACK);
+    display.display();
+  }
+  delay(250);
+
+  display.clearDisplay();
+  for (int16_t i=display.width()-1; i>=0; i-=4) {
+    display.drawLine(display.width()-1, display.height()-1, i, 0, BLACK);
+    display.display();
+  }
+  for (int16_t i=display.height()-1; i>=0; i-=4) {
+    display.drawLine(display.width()-1, display.height()-1, 0, i, BLACK);
+    display.display();
+  }
+  delay(250);
+
+  display.clearDisplay();
+  for (int16_t i=0; i<display.height(); i+=4) {
+    display.drawLine(display.width()-1, 0, 0, i, BLACK);
+    display.display();
+  }
+  for (int16_t i=0; i<display.width(); i+=4) {
+    display.drawLine(display.width()-1, 0, i, display.height()-1, BLACK);
+    display.display();
+  }
+  delay(250);
+}


Add Arduino - MQ7, Temperature Sensor

Add Arduino - MQ7, Temperature Sensor

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

--- Arduino/arduino_source/arduino_source.ino
+++ Arduino/arduino_source/arduino_source.ino
@@ -0,0 +1,210 @@
+#include <DHT11.h>
+#include <SoftwareSerial.h>
+
+//SoftwareSerial BTSerial(10, 11); // BLE(TXD) - RX(Arduino - 10) | BLE(RXD) - TX(Arduino - 11)
+
+                                   // Serial1 (Arduino - Mega)
+                                   // BLE(TXD) - RX(Arduino - 19) | BLE(RXD) - TX(Arduino - 18)
+uint8_t buffer[256];
+uint8_t index = 0;
+
+// 3.3 v
+//int Magnetic_Value = 0;
+//int Magnetic_PIN = 2;   // Digital
+//int Flame_Value = 0;
+//int Flame_PIN = 5;      // Digital
+
+
+// no Voltage
+int LEDGREEN_PIN = 9;        // Digital
+int LEDRED_PIN = 10;        // Digital
+
+// 5.0v
+int CO_Value = 100;
+int CO_PIN = 3;         // Analog
+int Buzzer_PIN = 12;    // Digital
+
+int DHT_PIN=4;          // Digital
+DHT11 dht11(DHT_PIN);
+
+
+void setup(){
+//  pinMode(Magnetic_PIN, INPUT);
+  //pinMode(Flame_PIN, INPUT);
+  pinMode(Buzzer_PIN,OUTPUT);
+  pinMode(LEDGREEN_PIN, OUTPUT);
+  pinMode(LEDRED_PIN, OUTPUT);
+
+  //pinMode(13, OUTPUT);
+//  Buzzer_OFF();
+
+  Serial.begin(9600);        //Arduino Bluetooth - PC Serial
+  Serial1.begin(9600);
+  // PC   ==  Serial1.begin(115200);    //Arduino Bluetooth - Bluetooth connect Device
+  // using Putty set baudrate
+  Serial.println("Ready..");
+
+}
+
+void loop(){
+
+
+  // 불꽃 발생시  0, 평상 시 1 반환
+  //Flame_Check();
+
+  // 문 닫혀있을 경우(자석 붙어있음) 0, 열려있을 경우(자석 떨어짐) 1 반환
+  //Magnetic_Check();
+
+  // 라이터 가스 주입 시 500 이상 유지 평사시 300 ~ 500 미만 사이 유지
+  CO_Check();
+  Serial.println("temp");
+ Temp_Check();
+  Serial.print("index=");
+  Serial.println(index);
+
+  Serial1.write(buffer,index);
+   for(uint8_t i = 0; i< index; i++){
+     Serial.println(buffer[i]);
+     delay(50);
+   }
+
+
+   delay(50);
+
+  index = 0;
+}
+
+
+// 불꽃 발생시  0, 평상 시 1 반환
+/*void Flame_Check(){
+  Flame_Value = digitalRead(Flame_PIN);
+
+  if(Flame_Value == HIGH){
+    Buzzer_OFF();
+    ColorLed_OFF();
+    buffer[index++] = 's';
+  }else{
+    ColorLed_ON();
+    //Buzzer_ON();
+    buffer[index++] = 'f';
+  }
+  Serial.print("FlameValue : \r ");
+  Serial.print(Flame_Value, DEC);
+  Serial.println("\n");
+  delay(50);
+
+  Flame_Value = 0;
+}
+
+// 문 닫혀있을 경우(자석 붙어있음) 0, 열려있을 경우(자석 떨어짐) 1 반환
+void Magnetic_Check(){
+  Magnetic_Value = digitalRead(Magnetic_PIN);
+
+  if(Magnetic_Value == HIGH){
+    ColorLed_ON();
+   buffer[index++] = 'o';
+  }else{
+    ColorLed_OFF();
+   buffer[index++] = 'c';
+  }
+  Serial.print("MagneticValue : \r ");
+  Serial.print(Magnetic_Value, DEC);
+  Serial.println("\n");
+  delay(50);
+
+  Magnetic_Value = 0;
+}
+*/
+// 라이터 가스 주입 시 500 이상 유지 평사시 300 ~ 500 미만 사이 유지
+void CO_Check(){
+  CO_Value = analogRead(CO_PIN) * 3;
+/*
+  // 1단계_안전(~400)
+  if(CO_Value < 400) {
+    ColorLed_ON();
+    buffer[index++] = 'a';
+  }
+  // 2단계 (400~600)
+  else if (CO_Value >= 400 && CO_Value < 600) {
+    buffer[index++] = 'b';
+  }
+  // 3단계 (600~1000)
+  else if (CO_Value >= 600 && CO_Value < 1000) {
+    buffer[index++] = 'c';
+  }
+  else {
+    ColorLed_OFF();
+    buffer[index++] = 'd';
+  }*/
+
+
+
+
+  Serial.print("CO_Value : \r ");
+  Serial.print(CO_Value, DEC);
+  Serial.println("\n");
+  Serial.println(index);
+
+  pack32(CO_Value,buffer);
+
+  delay(50);
+
+  CO_Value = 0;
+
+
+}
+
+void pack32(uint32_t val,uint8_t *dest)
+{
+        dest[index++] = (val & 0xff000000) >> 24;
+        dest[index++] = (val & 0x00ff0000) >> 16;
+        dest[index++] = (val & 0x0000ff00) >>  8;
+        dest[index++] = (val & 0x000000ff)      ;
+}
+
+
+
+void Temp_Check(){
+  int err;
+  float temp,humi;
+
+
+  if((err=dht11.read(temp,humi))==0)
+  {
+    buffer[index++] = temp;
+   // buffer[index++] = humi;
+  }
+
+    Serial.print(temp);
+
+  delay(DHT11_RETRY_DELAY); //delay for reread
+}
+/*
+void Buzzer_ON(){
+  int i;
+    for(i=0;i<80;i++){ //output sound of one frequency
+      digitalWrite(Buzzer_PIN,HIGH);//make a sound
+      delay(1);//delay 1ms
+      digitalWrite(Buzzer_PIN,LOW);//silient
+      delay(1);//delay 1ms
+    }
+    for(i=0;i<300;i++) {//output sound of another frequency
+      digitalWrite(Buzzer_PIN,HIGH);//make a sound
+      delay(2);//delay 2ms
+      digitalWrite(Buzzer_PIN,LOW);//silient
+      delay(2);//delay 2ms
+    }
+}
+void Buzzer_OFF(){
+   digitalWrite(Buzzer_PIN,LOW);
+}
+
+// RED 점멸
+void ColorLed_ON(){
+  digitalWrite(LEDGREEN_PIN,HIGH);
+}
+
+// GREEN 점멸
+void ColorLed_OFF(){
+  digitalWrite(LEDGREEN_PIN, LOW);
+}*/


add version 3.10

add version 3.10

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

--- soundSynth.ino
+++ soundSynth.ino
@@ -0,0 +1,181 @@
+#include "CapacitiveSensor.h"
+
+CapacitiveSensor cs_7_8 = CapacitiveSensor(7, 8);
+CapacitiveSensor cs_7_9 = CapacitiveSensor(7, 9);
+CapacitiveSensor cs_7_10 = CapacitiveSensor(7, 10);
+CapacitiveSensor cs_7_11 = CapacitiveSensor(7, 11);
+CapacitiveSensor cs_7_12 = CapacitiveSensor(7, 12);
+
+
+void setup() {
+  // put your setup code here, to run once:
+
+  pinMode(2, INPUT);
+  pinMode(3, INPUT);
+  pinMode(4, INPUT);
+  pinMode(5, INPUT);
+  pinMode(6, INPUT);
+  pinMode(13, OUTPUT);
+  // CAPACITIVE SENSOR
+/*  pinMode(7, INPUT);
+  pinMode(8, INPUT);
+  pinMode(9, INPUT);
+  pinMode(10, INPUT);
+  pinMode(11, INPUT);
+  pinMode(12, INPUT);
+
+  */
+
+  cs_7_8.set_CS_AutocaL_Millis(0xFFFFFFFF);
+  cs_7_9.set_CS_AutocaL_Millis(0xFFFFFFFF);
+  cs_7_10.set_CS_AutocaL_Millis(0xFFFFFFFF);
+  cs_7_11.set_CS_AutocaL_Millis(0xFFFFFFFF);
+  cs_7_12.set_CS_AutocaL_Millis(0xFFFFFFFF);
+
+}
+
+
+
+void loop() {
+
+  int scale = map(analogRead(0), 0, 1023, 0, 4);
+  int len = analogRead(5) + 50;
+  float t1 = 220;
+  float t2 = 246.94;
+  float t3 = 277.18;
+  float t4 = 293.66;
+  float t5 = 329.63;
+
+  long total0 = cs_7_8.capacitiveSensor(30);
+  long total1 = cs_7_9.capacitiveSensor(30);
+  long total2 = cs_7_10.capacitiveSensor(30);
+  long total3 = cs_7_11.capacitiveSensor(30);
+  long total4 = cs_7_12.capacitiveSensor(30);
+
+  long sens = 500;
+
+
+  if (scale == 0) {
+
+    t1 = 220;
+    t2 = 246.94;
+    t3 = 277.18;
+    t4 = 293.66;
+    t5 = 329.63;
+  }
+  if (scale == 1) {
+
+
+    t1 = 261.63;
+    t2 = 293.66;
+    t3 = 329.63;
+    t4 = 349.23;
+    t5 = 392.00;
+  }
+  if (scale == 2) {
+
+
+    t1 = 293.66;
+    t2 = 329.63;
+    t3 = 349.23;
+    t4 = 392.00;
+    t5 = 440.00;
+  }
+  if (scale == 3) {
+
+
+    t1 = 349.23;
+    t2 = 392.00;
+    t3 = 440.00;
+    t4 = 466.16;
+    t5 = 523.25;
+  }
+  if (scale == 4) {
+
+    t1 = 392.00;
+    t2 = 440.00;
+    t3 = 493.88;
+    t4 = 523.25;
+    t5 = 587.33;
+  }
+
+
+
+  if (total0 > sens) {
+    tone(13, t1);
+    delay(len);
+    noTone(13);
+
+
+  }
+
+  if (total1 > sens) {
+    tone(13, t2);
+    delay(len);
+    noTone(13);
+
+
+  }
+  if (total2 > sens) {
+    tone(13, t3);
+    delay(len);
+    noTone(13);
+
+
+  }
+  if (total3 > sens) {
+    tone(13, t4);
+    delay(len);
+    noTone(13);
+
+
+  }
+  if (total4 > sens) {
+    tone(13, t5);
+    delay(len);
+    noTone(13);
+  }
+
+// regular buttons
+if (digitalRead(2) == HIGH) {
+    tone(13, t1);
+    delay(len);
+    noTone(13);
+
+
+  }
+
+  if (digitalRead(3) == HIGH) {
+    tone(13, t2);
+    delay(len);
+    noTone(13);
+
+
+  }
+  if (digitalRead(4) == HIGH) {
+    tone(13, t3);
+    delay(len);
+    noTone(13);
+
+
+  }
+  if (digitalRead(5) == HIGH) {
+    tone(13, t4);
+    delay(len);
+    noTone(13);
+
+
+  }
+  if (digitalRead(6) == HIGH) {
+    tone(13, t5);
+    delay(len);
+    noTone(13);
+  }
+
+
+
+
+
+
+
+}


Added VernierAnalogStore sketch.

Added VernierAnalogStore sketch.

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

--- VernierAnalogStore/VernierAnalogStore.ino
+++ VernierAnalogStore/VernierAnalogStore.ino
@@ -0,0 +1,183 @@
+/*
+VernierAnalogStore
+Reads a Vernier analog (BTA) Sensor connected to pin A0 of the Arduino and and stores  the data in the non-volatile EEPROM memory of the Arduino.
+This sketch displays the time and sensor readings on the Serial Monitor.
+As written, the readings will be displayed every half second.
+Change the variable TimeBetweenReadings to change the rate.
+Change the variable NumberOfReadings to change the number of data points to take.
+ See www.vernier.com/arduino for more information, especially for information on how this sketch can be used to collect remote data with the Arduino away from a computer.
+ Thanks to B. Huang, for help on this program, especially the structure of a program to store and retrieve data.
+*/
+int buttonPin= 12; // analog input pin to use as a digital input
+int ledPin1= 13; // digital output pin for LED 1 indicator
+int debounce= 20; // ms debounce period to prevent flickering when pressing or releasing the button
+int holdTime= 2000; // ms hold period: how long to wait for press+hold event
+#include <EEPROM.h>
+int base = 0;  // the base address in EEPROM for data storage
+// note first two bytes store the number of points collected
+// Button variables
+int buttonVal = 0; // value read from button
+int buttonLast = 1; // buffered value of the button's previous state
+long btnDnTime; // time the button was pressed down
+long btnUpTime; // time the button was released
+boolean ignoreUp = false; // whether to ignore the button release because the click+hold was triggered
+boolean ledVal1 = false; // state of LED 1
+int AnalogDataPin = A1; // this may be changed depending on circuit wiring
+int Count;
+float Voltage;
+float SensorReading;
+unsigned long Time;
+long unsigned int TimeBetweenReadings = 500; //in ms
+int NumberOfPoints= 511;
+///////////////////////////////////
+String SensorName = "Dual-Range Force Sensor";
+String Measurement = "Force";
+String ShortMeasurement = "F"; // this is a shortened version of the label
+String Units = "Newtons";
+float Intercept = 12.25;
+float Slope = -4.9;
+///////////////////////////////////
+void setup()
+{
+// Set button input pin
+pinMode(buttonPin, INPUT);
+digitalWrite(buttonPin, HIGH);
+pinMode(AnalogDataPin, INPUT);
+pinMode(ledPin1, OUTPUT);// Set LED output pin
+Serial.begin(9600);
+Serial.println("VernierAnalogStore sketch");
+Serial.println("Press and hold to collect new data");
+Serial.println("Press button briefly to read data stored in EEPROM");
+Serial.println("and send it to the Serial Monitor");
+Serial.println(" ");
+}
+void loop()
+{
+digitalWrite(ledPin1, false);
+// Read the state of the button
+buttonVal = digitalRead(buttonPin);// button down is low
+// Test for button pressed and store the down time
+if (buttonVal == LOW && buttonLast == HIGH && (millis() - btnUpTime) > long(debounce))
+{ //button pressed
+  btnDnTime = millis();// note time of press
+}
+// Test for button release and store the up time
+if (buttonVal == HIGH && buttonLast == LOW && (millis() - btnDnTime) > long(debounce))
+{
+  if (ignoreUp == false) ReadEEPROMData();// read data from EEPROM and send to Serial Monitor
+  else ignoreUp = false;
+btnUpTime = millis();// note time of button release
+}
+// Test for button held down for longer than the hold time
+if (buttonVal == LOW && (millis() - btnDnTime) > long(holdTime))
+{
+CollectData(); //collect new data
+ignoreUp = true;
+btnDnTime = millis(); // get new button down time
+}
+buttonLast = buttonVal;
+}
+//=================================================
+// Events to trigger by click and press+hold
+void ReadEEPROMData()// //Send data to Serial Monitor
+{
+  ledVal1 = !ledVal1;
+  digitalWrite(ledPin1, true);
+  int NumberOfPointsRead;// local variable
+  Serial.println("Send Data to Serial Monitor");
+  Serial.println(" ");
+  int Sample = 0;// local variables
+  int i = 0;
+  int addr = base+ 2; //starting address of memory for data storage
+  //note addr is laterincremented
+  NumberOfPointsRead = EEPROM.read(base) + EEPROM.read(base+ 1)*256;
+  Serial.println( "Vernier Format 2");
+  Serial.print(NumberOfPointsRead);
+  Serial.print(" readings taken with a Vernier ");
+  Serial.println(SensorName);
+  Serial.println("Data Set From Arduino");
+  Serial.print("Time");
+  Serial.print("\t");                // print a tab character
+  Serial.println(Measurement);
+  Serial.print("T");
+  Serial.print("\t");                // print a tab character
+  Serial.println(ShortMeasurement);
+  Serial.print("s");
+  Serial.print("\t");                // print a tab character
+  Serial.println(Units);
+  for (i = 0; i <(NumberOfPointsRead)*2; i+=2)
+   {
+    Count = EEPROM.read(base+2 + i) | EEPROM.read(base+2 + i + 1) << 8;
+    //the print below does the division first to avoid overflows
+    Serial.print(i/2/1000.0*TimeBetweenReadings);
+    Serial.print("\t");                // print a tab character
+    Voltage = Count  * (5.0/ 1024);
+    SensorReading= Intercept + Voltage * Slope;
+    Serial.println(SensorReading);
+  }
+Serial.println(" ");
+Serial.println("Press and hold button to collect new data ");
+Serial.println(" ");
+digitalWrite(ledPin1, false); //turn off LED
+//end of send data to Serial Monitor
+}
+void CollectData() //Collect Data
+{
+ledVal1 = !ledVal1;
+Serial.begin(9600);
+Serial.println("Collecting Data...");
+Serial.println(" ");
+int Sample = 0;// local variable
+unsigned long StartTime =0;
+int addr = base+ 2; //starting address of memory for data storage
+//note addr is later incremented
+ Serial.println( "Vernier Format 2");
+  Serial.print(NumberOfPoints);
+  Serial.print(" readings taken with a Vernier ");
+  Serial.println(SensorName);
+  Serial.println("Data Set From Arduino");
+  Serial.print("Reading");
+  Serial.print("\t");
+  Serial.print("Time");
+  Serial.print("\t");                // print a tab character
+  Serial.println(Measurement);
+  Serial.print("n");
+  Serial.print("\t");
+  Serial.print("T");
+  Serial.print("\t");                // print a tab character
+  Serial.println(ShortMeasurement);
+  Serial.print("#");
+  Serial.print("\t");
+  Serial.print("s");                // print a tab character
+  Serial.print("\t");
+  Serial.println(Units);
+  StartTime = millis();// time of last reading in ms
+  for (Sample=0;Sample<NumberOfPoints;Sample++)
+  {digitalWrite(ledPin1, true);
+    Serial.print(Sample);
+    Serial.print("\t");
+    //the print below does the division first to avoid overflows
+    Serial.print(Sample/1000.0*TimeBetweenReadings);
+    Serial.print("\t");
+    Count= analogRead(A1);
+    Voltage = Count * (5.0/ 1024);
+    SensorReading = Intercept + Voltage * Slope;
+    Serial.println(SensorReading);
+    EEPROM.write(addr, lowByte(Count));
+    EEPROM.write(addr + 1, highByte(Count));
+    addr +=2;  //increment address pointer twice
+   delay (TimeBetweenReadings/2);//these lines are to give a blink to the LED
+   digitalWrite(ledPin1, false);
+   delay (TimeBetweenReadings/2);
+  }
+//the number of points is stored at base and base+1;
+//data starts at the next two bytes (base=2 and base+3, etc);
+EEPROM.write(base+ 0, lowByte(NumberOfPoints));
+EEPROM.write(base + 1, highByte(NumberOfPoints));
+Serial.println(" ");
+Serial.println("Press button briefly to send data to Serial Monitor");
+Serial.println("Press and hold to collect new data");
+Serial.println(" ");
+digitalWrite(ledPin1, false);
+};//end of Data Collect
+