Adds animations.ino

Adds animations.ino

void animation_boot () {
  oled.drawString("[    ]", (RGB_OLED_WIDTH-FONT_X*5)/2, RGB_OLED_HEIGHT/2-FONT_Y/2, 1, COLOR_BLUE);
  delay(200);
  oled.drawString("[|   ]", (RGB_OLED_WIDTH-FONT_X*5)/2, RGB_OLED_HEIGHT/2-FONT_Y/2, 1, COLOR_BLUE);
  delay(200);
  oled.drawString("[||  ]", (RGB_OLED_WIDTH-FONT_X*5)/2, RGB_OLED_HEIGHT/2-FONT_Y/2, 1, COLOR_BLUE);
  delay(200);
  oled.drawString("[||| ]", (RGB_OLED_WIDTH-FONT_X*5)/2, RGB_OLED_HEIGHT/2-FONT_Y/2, 1, COLOR_BLUE);
  delay(200);
  oled.drawString("[||||]", (RGB_OLED_WIDTH-FONT_X*5)/2, RGB_OLED_HEIGHT/2-FONT_Y/2, 1, COLOR_BLUE);
  delay(200);
  oled.drawString("[||||]", (RGB_OLED_WIDTH-FONT_X*5)/2, RGB_OLED_HEIGHT/2-FONT_Y/2, 1, COLOR_BLACK);
  oled.drawString("READY!", (RGB_OLED_WIDTH-FONT_X*5)/2, RGB_OLED_HEIGHT/2-FONT_Y/2, 1, COLOR_BLUE);
  delay(1000);
}

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


Tested code

Tested code

#define HANDLING 0.5

int motorPins[2][2] = {{5, 6}, {9, 10}};
int xAxis, yAxis, mag, left, right;
char c;

void setup() {
  Init();
}

void loop() {

  String line = ReadLine();
  UpdateAxis(&xAxis, &yAxis, line);
  mag = sqrt(xAxis * xAxis + yAxis * yAxis);
  mag = constrain(mag, 0, 127);

  ToDifferentialDrive(xAxis, yAxis);

  DriveMotor(0, left, 128);
  DriveMotor(1, right, 128);

  Serial.print(left);
  Serial.print('\t');
  Serial.println(right);

}

void Init()
{
  Serial.begin(9600);
  Serial.println("ready");
  for (int i = 0; i < 2; i++)
  {
    for (int j = 0; j < 2; j++)
    {
      pinMode(motorPins[i][j], OUTPUT);
      digitalWrite(motorPins[i][j], LOW);
    }
  }

}

void DriveMotor(int motor, int spd, int maxSpeed)
{
  spd = 255 * ((double)spd / maxSpeed);

  Serial.print(spd);
  Serial.print(" === \t");
  if (spd > 0)
  {
    analogWrite(motorPins[motor][0], spd);
    digitalWrite(motorPins[motor][1], LOW);
  }
  else
  {
    analogWrite(motorPins[motor][0], (255 + spd));
    digitalWrite(motorPins[motor][1], HIGH);
  }

}

void StopMotor(int motor)
{
  digitalWrite(motorPins[motor][0], LOW);
  digitalWrite(motorPins[motor][1], LOW);
}

String ReadLine()
{
  String s;
  char c;

  while (1)
  {
    if (Serial.available())
    {
      c = Serial.read();
      if (c == '*')
      {
        continue;
      }
      else if (c == '#')
      {
        return s;
      }
      else
      {
        s += c;
      }
    }
  }

}

void UpdateAxis(int *x, int *y, String s)
{
  String s1, s2;
  bool comma;

  if (s.length() != 3) return;

  *x = (int)(byte)s[0] - 127;
  *y = (int)(byte)s[2] - 127;
}

void ToDifferentialDrive(int x, int y)
{
  if (y > 0)
  {
    if (x < 0)
    {
      left = mag + (HANDLING * x);
      right = mag;
    }
    else
    {
      left = mag;
      right = mag - (HANDLING * x);
    }
  }
  else
  {
    if (x < 0)
    {
      left = -mag;
      right = -mag - x;
    }
    else
    {
      left = -mag + x;
      right = -mag;
    }
  }
}

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


arduino calibration code

arduino calibration code

/*
Author: Pietro Pennestri'
Mail:pietro.pennestri@gmail.com
Website: http://www.pennestri.me
Date: May 2nd 2015

Description:
Calibration of an MQ3 shield on arduino board.
The voltage is displayed when the sensor is exposed at a known
alcohol concentration. Temperature is also recorded
for future adjustments.
*/

int mq3_analogPin = A5; // connected to the output pin of MQ3
int val;
int tempPin = 1;
unsigned long time;
unsigned long time_in_second;
void setup(){
  Serial.begin(9600); // open serial at 9600 bps
}

void loop()
{
  // give ample warmup time for readings to stabilize
  float arduino_voltage = 5 ;
  int mq3_value = analogRead(mq3_analogPin);
  float voltage = mq3_value * (arduino_voltage / 1023.0);

  // get temperature
  val = analogRead(tempPin);
  float mv = ( val/1024.0)*5000;
  float temperature = mv/10; // celsius

  //tieme
  time = millis();
  time_in_second = time/1000 ;

  //Serial.print("Voltage=");
  Serial.print(voltage);
  Serial.print("*");
  //Serial.print(" Temperature(C): ");
  Serial.print(temperature);
  Serial.print("*");
  //Serial.print(" Time(S): ");
  Serial.print(time_in_second);
  Serial.print("\n");

  delay(1000);    //slow down output
}

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


Added ReadAnalogVoltage example

Added ReadAnalogVoltage example

/*
  ReadAnalogVoltage
  Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

 This example code is in the public domain.
 */

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
}

error: pathspec 'build/shared/examples/1.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino' did not match any file(s) known to git


Rewired sticks to only go from LOW to HIGH

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/simonlovgren/Arduino-Flight-TX.git/'


feat: add photon code

feat: add photon code

int light = 0;
float temp = 0;
char light_str[10];
char temp_str[10];
int led = D7;

void setup() {
    pinMode(led, OUTPUT);                 // http://docs.spark.io/firmware/#setup-pinmode
    Spark.variable("light", &light, INT); // http://docs.spark.io/firmware/#spark-variable
    pinMode(A0, INPUT);                   // LDR is linked to this analog pin
    pinMode(A1, INPUT);                   // LM35 is linked to this analog pin
}

void loop() {
    light = analogRead(A0);
    sprintf(light_str, "%i", light);
    Spark.publish("getLight", light_str, PRIVATE);

    int sensorValue = analogRead(A1);
    temp = convertTempReading(sensorValue);
    sprintf(temp_str, "%.1f", temp);
    Spark.publish("getTemp", temp_str, PRIVATE);

    // for easy debugging, we turn on / off the LED with each publish
    digitalWrite(led, HIGH);
    delay(200);
    digitalWrite(led, LOW);
    delay(1800);
}

float convertTempReading(int sensorValue) {
    // Converts sensorValue in voltage/Kelvin value
    float voltage = ((sensorValue / 4096.0) * 3.3);

    // Converts to Kelvin
    float kelvinValue = (voltage * 100);
    //float celsiusValue = kelvinValue - 273.15;

    return kelvinValue;
}

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


Adding init Arduino file.

Adding init Arduino file.

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


reworked for using D Latches

reworked for using D Latches

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/mule-ear/shiny-spice.git/'


beauty

beauty

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


Create MPU6050_MotionDetect.ino

Create MPU6050_MotionDetect.ino

Arduino sketch to config and read the MPU6050 motion detect registers. Code uses the MPU6050 library by Jeff Rowberg.

// I2C device class (I2Cdev) demonstration Arduino sketch for MPU6050 class
// 10/7/2011 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
//     2011-10-07 - initial release

/* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2011 Jeff Rowberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"
#include "SPI.h"

// I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "MPU60X0.h"

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for InvenSense evaluation board)
// AD0 high = 0x69
MPU60X0 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;
int8_t threshold, count;
float temp;
bool zero_detect;
bool TurnOnZI = false;

bool XnegMD, XposMD, YnegMD, YposMD, ZnegMD, ZposMD;

#define LED_PIN 13
bool blinkState = false;

void setup() {
    // join I2C bus (I2Cdev library doesn't do this automatically)
    Wire.begin();

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(38400);

    // initialize device
    //Serial.println("Initializing I2C devices...");
    accelgyro.initialize();

    // verify connection
    //Serial.println("Testing device connections...");
    //Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");

    //Set up zero motion

    /** Get accelerometer power-on delay.
    * The accelerometer data path provides samples to the sensor registers, Motion
    * detection, Zero Motion detection, and Free Fall detection modules. The
    * signal path contains filters which must be flushed on wake-up with new
    * samples before the detection modules begin operations. The default wake-up
    * delay, of 4ms can be lengthened by up to 3ms. This additional delay is
    * specified in ACCEL_ON_DELAY in units of 1 LSB = 1 ms. The user may select
    * any value above zero unless instructed otherwise by InvenSense. Please refer
    * to Section 8 of the MPU-6000/MPU-6050 Product Specification document for
    * further information regarding the detection modules.
    * @return Current accelerometer power-on delay
    * @see MPU60X0_RA_MOT_DETECT_CTRL
    * @see MPU60X0_DETECT_ACCEL_ON_DELAY_BIT
    */
    accelgyro.setAccelerometerPowerOnDelay(3);

    /** Get Zero Motion Detection interrupt enabled status.
    * Will be set 0 for disabled, 1 for enabled.
    * @return Current interrupt enabled status
    * @see MPU60X0_RA_INT_ENABLE
    * @see MPU60X0_INTERRUPT_ZMOT_BIT
    **/
    accelgyro.setIntZeroMotionEnabled(TurnOnZI);

    /** Get the high-pass filter configuration.
    * The DHPF is a filter module in the path leading to motion detectors (Free
    * Fall, Motion threshold, and Zero Motion). The high pass filter output is not
    * available to the data registers (see Figure in Section 8 of the MPU-6000/
    * MPU-6050 Product Specification document).
    *
    * The high pass filter has three modes:
    *    Reset: The filter output settles to zero within one sample. This
    *           effectively disables the high pass filter. This mode may be toggled
    *           to quickly settle the filter.
    *
    *    On:    The high pass filter will pass signals above the cut off frequency.
    *
    *    Hold:  When triggered, the filter holds the present sample. The filter
    *           output will be the difference between the input sample and the held
    *           sample.
    *
    * ACCEL_HPF | Filter Mode | Cut-off Frequency
    * ----------+-------------+------------------
    * 0         | Reset       | None
    * 1         | On          | 5Hz
    * 2         | On          | 2.5Hz
    * 3         | On          | 1.25Hz
    * 4         | On          | 0.63Hz
    * 7         | Hold        | None
    * </pre>
    *
    * @return Current high-pass filter configuration
    * @see MPU60X0_DHPF_RESET
    * @see MPU60X0_RA_ACCEL_CONFIG
    */
    //DEBUG_PRINTLN("Setting DHPF bandwidth to 5Hz...");
    accelgyro.setDHPFMode(1);

    /** Get motion detection event acceleration threshold.
    * This register configures the detection threshold for Motion interrupt
    * generation. The unit of MOT_THR is 1LSB = 2mg. Motion is detected when the
    * absolute value of any of the accelerometer measurements exceeds this Motion
    * detection threshold. This condition increments the Motion detection duration
    * counter (Register 32). The Motion detection interrupt is triggered when the
    * Motion Detection counter reaches the time count specified in MOT_DUR
    * (Register 32).
    *
    * The Motion interrupt will indicate the axis and polarity of detected motion
    * in MOT_DETECT_STATUS (Register 97).
    *
    * For more details on the Motion detection interrupt, see Section 8.3 of the
    * MPU-6000/MPU-6050 Product Specification document as well as Registers 56 and
    * 58 of this document.
    *
    * @return Current motion detection acceleration threshold value (LSB = 2mg)
    * @see MPU60X0_RA_MOT_THR
    */
    //Serial.println("Setting motion detection threshold to 2...");
    accelgyro.setMotionDetectionThreshold(2);

    /** Get zero motion detection event acceleration threshold.
    * This register configures the detection threshold for Zero Motion interrupt
    * generation. The unit of ZRMOT_THR is 1LSB = 2mg. Zero Motion is detected when
    * the absolute value of the accelerometer measurements for the 3 axes are each
    * less than the detection threshold. This condition increments the Zero Motion
    * duration counter (Register 34). The Zero Motion interrupt is triggered when
    * the Zero Motion duration counter reaches the time count specified in
    * ZRMOT_DUR (Register 34).
    *
    * Unlike Free Fall or Motion detection, Zero Motion detection triggers an
    * interrupt both when Zero Motion is first detected and when Zero Motion is no
    * longer detected.
    *
    * When a zero motion event is detected, a Zero Motion Status will be indicated
    * in the MOT_DETECT_STATUS register (Register 97). When a motion-to-zero-motion
    * condition is detected, the status bit is set to 1. When a zero-motion-to-
    * motion condition is detected, the status bit is set to 0.
    *
    * For more details on the Zero Motion detection interrupt, see Section 8.4 of
    * the MPU-6000/MPU-6050 Product Specification document as well as Registers 56
    * and 58 of this document.
    *
    * @return Current zero motion detection acceleration threshold value (LSB = 2mg)
    * @see MPU60X0_RA_ZRMOT_THR
    */
    //Serial.println("Setting zero-motion detection threshold to 156...");
    accelgyro.setZeroMotionDetectionThreshold(2);

    /** Get motion detection event duration threshold.
    * This register configures the duration counter threshold for Motion interrupt
    * generation. The duration counter ticks at 1 kHz, therefore MOT_DUR has a unit
    * of 1LSB = 1ms. The Motion detection duration counter increments when the
    * absolute value of any of the accelerometer measurements exceeds the Motion
    * detection threshold (Register 31). The Motion detection interrupt is
    * triggered when the Motion detection counter reaches the time count specified
    * in this register.
    *
    * For more details on the Motion detection interrupt, see Section 8.3 of the
    * MPU-6000/MPU-6050 Product Specification document.
    *
    * @return Current motion detection duration threshold value (LSB = 1ms)
    * @see MPU60X0_RA_MOT_DUR
    */
    //Serial.println("Setting motion detection duration to 80...");
    accelgyro.setMotionDetectionDuration(40);

    /** Get zero motion detection event duration threshold.
    * This register configures the duration counter threshold for Zero Motion
    * interrupt generation. The duration counter ticks at 16 Hz, therefore
    * ZRMOT_DUR has a unit of 1 LSB = 64 ms. The Zero Motion duration counter
    * increments while the absolute value of the accelerometer measurements are
    * each less than the detection threshold (Register 33). The Zero Motion
    * interrupt is triggered when the Zero Motion duration counter reaches the time
    * count specified in this register.
    *
    * For more details on the Zero Motion detection interrupt, see Section 8.4 of
    * the MPU-6000/MPU-6050 Product Specification document, as well as Registers 56
    * and 58 of this document.
    *
    * @return Current zero motion detection duration threshold value (LSB = 64ms)
    * @see MPU60X0_RA_ZRMOT_DUR
    */
    //Serial.println("Setting zero-motion detection duration to 0...");
    accelgyro.setZeroMotionDetectionDuration(1);

    // configure Arduino LED for
    pinMode(LED_PIN, OUTPUT);
}

void loop() {
    // read raw accel/gyro measurements from device
    //Serial.println("Getting raw accwl/gyro measurements");
    accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

    //Serial.println("Getting Motion indicators, count and threshold");

    XnegMD = accelgyro.getXNegMotionDetected();
    XposMD = accelgyro.getXPosMotionDetected();
    YnegMD = accelgyro.getYNegMotionDetected();
    YposMD = accelgyro.getYPosMotionDetected();
    ZnegMD = accelgyro.getZNegMotionDetected();
    ZposMD = accelgyro.getZPosMotionDetected();

    zero_detect = accelgyro.getIntMotionStatus();
    threshold = accelgyro.getZeroMotionDetectionThreshold();

    //Serial.println("Got to count");
    //count = accelgyro.getMotionDetectionCounterDecrement();

    /** Get current internal temperature.
    * @return Temperature reading in 16-bit 2's complement format
    * @see MPU60X0_RA_TEMP_OUT_H
    */
    //Serial.println("Getting Die Temperature");
    temp=(accelgyro.getTemperature()/340.)+36.53;

    /*  The accelerometer and gyroscope measurements are explained in the MPU-6050
    * datasheet in the GYRO_CONFIG and ACCEL_CONFIG register descriptions (sections 4.4
    * and 4.5 on pages 14 and 15). The scale of each depends on the sensitivity settings
    * chosen, which can be one of +/- 2, 4, 8, or 16g for the accelerometer and one of
    * +/- 250, 500, 1000, or 2000 deg/sec for the gyroscope. The accelerometer produces data
    * in units of acceleration (distance over time2), and the gyroscope produces data in units
    * of rotational velocity (rotation distance over time).
    *
    * The output scale for any setting is [-32768, +32767] for each of the six axes. The default
    * setting in the I2Cdevlib class is +/- 2g for the accel and +/- 250 deg/sec for the gyro. If
    * the device is perfectly level and not moving, then:
    * 		X/Y accel axes should read 0
    * 		Z accel axis should read 1g, which is +16384 at a sensitivity of 2g
    * 		X/Y/Z gyro axes should read 0
    *
    * In reality, the accel axes won't read exactly 0 since it is difficult to be perfectly level
    * and there is some noise/error, and the gyros will also not read exactly 0 for the same reason
    * (noise/error).
    */

    // these methods (and a few others) are also available
    //accelgyro.getAcceleration(&ax, &ay, &az);
    //accelgyro.getRotation(&gx, &gy, &gz);

    Serial.print(temp);Serial.print(",");
    Serial.print(ax/16384.); Serial.print(",");
    Serial.print(ay/16384.); Serial.print(",");
    Serial.print(az/16384.); Serial.print(",");
    Serial.print(gx/131.072); Serial.print(",");
    Serial.print(gy/131.072); Serial.print(",");
    Serial.print(gz/131.072); Serial.print(",");
    Serial.print(zero_detect); Serial.print(",");
	Serial.print(XnegMD); Serial.print(",");
	Serial.println(XposMD);

    // display tab-separated accel/gyro x/y/z values
    /*
    Serial.print("a/g:\t");
    Serial.print(ax/16384.); Serial.print("\t");
    Serial.print(ay/16384.); Serial.print("\t");
    Serial.print(az/16384.); Serial.print("\t");
    Serial.print(gx/131.072); Serial.print("\t");
    Serial.print(gy/131.072); Serial.print("\t");
    Serial.println(gz/131.072);

    Serial.print("DieTemp:\t");Serial.println(temp);

    Serial.print("ZeroMotion(97):\t");
    Serial.print(zero_detect); Serial.print("\t");
    Serial.print("Count: \t");Serial.print(count); Serial.print("\t");
    Serial.print(XnegMD); Serial.print("\t");
    Serial.print(XposMD); Serial.print("\t");
    Serial.print(YnegMD); Serial.print("\t");
    Serial.print(YposMD); Serial.print("\t");
    Serial.print(ZnegMD); Serial.print("\t");
    Serial.println(ZposMD);
    */

    delay(80);

    // blink LED to indicate activity
    blinkState = !blinkState;
    digitalWrite(LED_PIN, blinkState);
}

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


Added files via upload

Added files via upload

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
int c=0;
uint8_t CK_A = 0, CK_B = 0;
void setup() {
Serial.begin(57600);
mySerial.begin(9600);
Serial.read();
}
void ubx_checksum(byte ubx_data)
{
  CK_A+=ubx_data;
  CK_B+=CK_A;
}
void loop()
{
  mySerial.write(Serial);
}

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


Add Arduino sketch used for observation measurement

#include <SPI.h>
#include <Ethernet.h>

// Input pins
const int insideTempPin = A0;
const int photoresistorPin = A1;
const int thermistorPin = A2;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0x9A, 0xFC };
IPAddress ip(192, 168, 1, 10);

// Initialize the Ethernet server library
// with the IP address and port you want to use
EthernetServer server(80);

/* A reading from the ADC might give one value at one sample and then a little
   different the next time around. To eliminate noisy readings, we can sample
   the ADC pin a few times and then average the samples to get something more
   solid. This constant is utilized in the readThermistor function.
   */
const int SAMPLE_NUMBER = 10;

/* In order to use the Beta equation, we must know our other resistor
   within our resistor divider. If you are using something with large tolerance,
   like at 5% or even 1%, measure it and place your result here in ohms. */
const double BALANCE_RESISTOR = 9800.0;

// This helps calculate the thermistor's resistance (check article for details).
const double MAX_ADC = 1023.0;

/* This is thermistor dependent and it should be in the datasheet, or refer to the
   article for how to calculate it using the Beta equation.
   I had to do this, but I would try to get a thermistor with a known
   beta if you want to avoid empirical calculations. */
const double BETA = 3379.1;

/* This is also needed for the conversion equation as "typical" room temperature
   is needed as an input. */
const double ROOM_TEMP = 298.15;   // room temperature in Kelvin

/* Thermistors will have a typical resistance at room temperature so write this
   down here. Again, needed for conversion equations. */
const double RESISTOR_ROOM_TEMP = 10000.0;

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

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // An HTTP request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // If you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: application/json");
          client.println("Connection: close");
          client.println();
          client.print("{\"inside_temp\":");
          client.print(readTemperature());
          client.print(", \"inside_light\":");
          client.print(analogRead(photoresistorPin));
          client.print(", \"outside_temp\":");
          client.print(readThermistor());
          client.println("}");
          break;
        }
        if (c == '\n') {
          // You're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // You've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // Give the web browser time to receive the data
    delay(1);
    // Close the connection:
    client.stop();
  }
}

/**
 * Reads the voltage from TMP36 sensor.
 * Returns the temperature in degrees Celsius.
 */
float readTemperature() {
  float voltage = (analogRead(insideTempPin) / 1024.0) * 5.0;
  return (voltage - 0.5) * 100;
}

// The code below is from https://www.allaboutcircuits.com/projects/measuring-temperature-with-an-ntc-thermistor/
/**
This function reads the analog pin as shown below. Converts voltage signal
to a digital representation with analog to digital conversion. However, this is
done multiple times so that we can average it to eliminate measurement errors.
This averaged number is then used to calculate the resistance of the thermistor.
After this, the resistance is used to calculate the temperature of the
thermistor. Finally, the temperature is converted to celsius. Please refer to
the allaboutcircuits.com article for the specifics and general theory of this
process.

Quick Schematic in case you are too lazy to look at the site :P

          (Ground) ----\/\/\/-------|-------\/\/\/---- V_supply
                     R_balance      |     R_thermistor
                                    |
                               Analog Pin
*/
double readThermistor() {
  // variables that live in this function
  double rThermistor = 0;            // Holds thermistor resistance value
  double tKelvin     = 0;            // Holds calculated temperature
  double tCelsius    = 0;            // Hold temperature in celsius
  double adcAverage  = 0;            // Holds the average voltage measurement
  int adcSamples[SAMPLE_NUMBER];  // Array to hold each voltage measurement

  /* Calculate thermistor's average resistance:
     As mentioned in the top of the code, we will sample the ADC pin a few times
     to get a bunch of samples. A slight delay is added to properly have the
     analogRead function sample properly */

  for (int i = 0; i < SAMPLE_NUMBER; i++) {
    adcSamples[i] = analogRead(thermistorPin);  // read from pin and store
    delay(10);        // wait 10 milliseconds
  }

  /* Then, we will simply average all of those samples up for a "stiffer"
     measurement. */
  for (int i = 0; i < SAMPLE_NUMBER; i++) {
    adcAverage += adcSamples[i];      // add all samples up . . .
  }
  adcAverage /= SAMPLE_NUMBER;        // . . . average it w/ divide

  /* Here we calculate the thermistor’s resistance using the equation
     discussed in the article. */
  rThermistor = BALANCE_RESISTOR * ( (MAX_ADC / adcAverage) - 1);

  /* Here is where the Beta equation is used, but it is different
     from what the article describes. Don't worry! It has been rearranged
     algebraically to give a "better" looking formula. I encourage you
     to try to manipulate the equation from the article yourself to get
     better at algebra. And if not, just use what is shown here and take it
     for granted or input the formula directly from the article, exactly
     as it is shown. Either way will work! */
  tKelvin = (BETA * ROOM_TEMP) /
            (BETA + (ROOM_TEMP * log(rThermistor / RESISTOR_ROOM_TEMP)));

  /* I will use the units of Celsius to indicate temperature. I did this
     just so I can see the typical room temperature, which is 25 degrees
     Celsius, when I first try the program out. I prefer Fahrenheit, but
     I leave it up to you to either change this function, or create
     another function which converts between the two units. */
  tCelsius = tKelvin - 273.15;  // convert kelvin to celsius

  return tCelsius;    // Return the temperature in Celsius
}

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


Added Arduino Firmware

Added Arduino Firmware

#include <CommandHandler.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>

#define turnSpeed 150
#define turnDelay 500
#define stopDelay 500
#define debug
int currentSpeed = 0;
#define maxSpeed 150
#define FORWARDMOTOR 4
#define TURNMOTOR 1

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
Adafruit_DCMotor *backMotor = AFMS.getMotor(4);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);

CommandHandler ch;

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

}

void loop() {
  // put your main code here, to run repeatedly:
  //readCommand();
  Serial.println("I am ready");
  while(Serial.available()){
    //parseCommand();
    readCommand();
  }

}

//--------------------------Turning Motor-------------------------------
//Green left, blue right
//Default for turning right

void turn( char direct )
{
  if ( direct == 'r' )
  {
    myMotor->run(FORWARD);
  }
  else {
    myMotor->run(BACKWARD);
  }
  myMotor->setSpeed(turnSpeed);
}

//Stop Turning
void stopTurn() {
  myMotor->run(RELEASE);
  delay(stopDelay);
}

//----------------------Movement Motor---------------------------------

//Move forward while ramping speed
void moveForward( char direct ) {
  if (direct == 'f')
  {
    backMotor->run(FORWARD);

    for (currentSpeed = 0; currentSpeed < maxSpeed; currentSpeed++) {
      backMotor->setSpeed(currentSpeed);
    }
  }
  else
  {
    backMotor->run(BACKWARD);

    for (currentSpeed = 0;  currentSpeed < maxSpeed; currentSpeed++) {
      backMotor->setSpeed(currentSpeed);
    }

  }

}

//Stop moving the back motor
void stopMovement( ) {

  for ( currentSpeed = maxSpeed; currentSpeed > 0; currentSpeed--) {
    backMotor->setSpeed(currentSpeed);
  }

  delay(stopDelay);

}

//---------------------------------Communicating with the Arduino using commands--------------------------------------
//LEGACY CODE DONT TOUCH
void readCommand( ) {

  char command = Serial.read( );

  switch (command) {
    case 'f':
      moveForward(command);
      break;

    case 'b':
      //moveBackward(command);
      break;

    case 'r':
      //turnRight();
      break;

    case 'l':
      //turnLeft();
      break;

    case 's':
      stopMovement();
      break;

    case 'i':
      stopTurn();
      break;
  }

}

//------------------------FLOW---------------------------------
/*
  1. Read the Serial through parseCommand
  2. Parse the motor, direction and delay
  3. Send to commandHandler
  4. commandHandler executes the program.

*/

//Parse the command sent in to the appropriate motor
/*
  Pattern:
  "#/x/time."
  # is for motor number (1 is turn, 4 is back)
  x is for command: [f,b,r,l]
  time is in milliseconds, 4 digits

*/
void parseCommand( )
{
  String command = Serial.readString();

  if (command == NULL) {
    return;
  }

  //String command = "1f1000";
  //End of the char array is always the null character \0
  char actualCommands[7];
  command.toCharArray(actualCommands, 7);
  int motor = actualCommands[0] - '0';
  char direct = actualCommands[1];
  String delayTime;

  for (int i = 2; i < 7; i++)
  {
    delayTime.concat(actualCommands[i]);
  }
   int parsedTime = delayTime.toInt();
  //commandHandler(motor, direct, delayTime.toInt());

  #ifdef debug
    Serial.print("Motor: ");
    Serial.print(motor);
    Serial.print(" Direction: ");
    Serial.print(direct);
    Serial.print(" Delay :");
    Serial.println(parsedTime);
  #endif

  ch.sendCommand( motor, direct, parsedTime);
}

/* LEGACY CODE DO NOT TOUCH
void commandHandler( int motor, char direct, int delayTime )
{
  if ( direct == 's' )
  {
    stopMovement();
  }
  else {
    if (motor == FORWARDMOTOR)
    {
      moveForward(direct);
      delay(delayTime);
    }
    else if (motor == TURNMOTOR)
    {
      turn(direct);
      delay(delayTime);

    }
    else {
      Serial.println("error in commandHandler");
      return;
    }
  }

}
*/

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


Basic sanity check using the serial monitor

String inputString = "";
bool recMessage = false;

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

  //wait for some serial connection
   while (!Serial);
   Serial.println("--- Serial Connection Established ---");
}

void loop() {
  //consume everything in the serial buffer
  while (Serial.available())
  {
    char inChar = Serial.read();
    if (inChar != '~'){
        inputString += inChar;
    }
    else{
        recMessage = true;
    }
  }

  if (recMessage){
      Serial.print("Arduino received: ");
      Serial.println(inputString);
      inputString = "";
      recMessage = false;
  }
}

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


fix bugs

fix bugs

pt_remote controlled car/pt_remote controlled car.ino

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


Add databaseAppendAllRecords()

Add databaseAppendAllRecords()

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/TheGum/Arduino-Elevator-Chip-System.git/'


Add the arduino file

Add the arduino file

Add the arduino file that supports fingerprint capture

const int lock=9;
const int led =13;
int id = 0;
int button=4;
boolean doorState=false;

#include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
#include <EEPROM.h>

//this is the program we shall be using
//his too
int getFingerprintIDez();

// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
SoftwareSerial mySerial(2, 3);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()
{
  pinMode(13, OUTPUT);
  pinMode(button, OUTPUT);
  pinMode(lock, OUTPUT);
  Serial.begin(9600);
  //Serial.println("fingertest");

  // set the data rate for the sensor serial port
  finger.begin(57600);

  if (finger.verifyPassword()) {
    //Serial.println("Found fingerprint sensor!");
  } else {
    //Serial.println("Did not find fingerprint sensor :(");
    while (1);
  }
  //Serial.println("Waiting for valid finger...");
}

void loop()                     // run over and over again
{
 // Serial.println("Type in the ID # you want to save this finger as...");
int condition=0;
char c;
      //you can replace with this later => condition=(digitalRead(button))

      if(condition=(Serial.available()>0))
      {
      id=(EEPROM.read(1)+1);
      getFingerprintEnroll(id);
      Serial.end();
      Serial.begin(9600);
      }
      else
        {
          getFingerprintID();
          delay(50);            //don't ned to run this at full speed.
        }
}

uint8_t getFingerprintID()
{
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      //Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      //Serial.println("0");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("IE");//IE- IMAGING ERROR
      return p;
    default:

      Serial.print("UE");

      Serial.println("");
      return p;

  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      //Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:

      Serial.print("Could not find fingerprint features");

      Serial.println("");
      return p;
    case FINGERPRINT_INVALIDIMAGE:

      Serial.print("Could not find fingerprint features");

      Serial.println("");
      return p;
    default:
      Serial.println("UE");//Unknown Error
      return p;
  }

  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK)
  {
    //To find a print match
    //Serial.println("Found a print match!");
    digitalWrite(13, HIGH);
    delay(300);
    digitalWrite(13, LOW);
  }
  else if (p == FINGERPRINT_PACKETRECIEVEERR)
  {
    Serial.println("Communication error");
    return p;
  }
  else if (p == FINGERPRINT_NOTFOUND)
  {
    //no match found
    Serial.print("");

    Serial.print("NM");//NO MATCH

    Serial.println("");

    digitalWrite(13, HIGH);
    delay(150);
    digitalWrite(13, LOW);
    delay(150);
    digitalWrite(13, HIGH);
    delay(150);
    digitalWrite(13, LOW);
    return p;

  }
  else
  {
    Serial.println("UE");
    return p;
  }

  // found a match!
  //Serial.println("Found ID #");
  Serial.print("");

  Serial.print(finger.fingerID);

  Serial.println("");
  //confidence
  //Serial.println(finger.confidence);
  doorLock();
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;

  // found a match!
  Serial.print("Found ID #");
  Serial.print(" "+finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  return finger.fingerID;

}
void doorLock(){
  if(doorState==false){
    digitalWrite(lock, HIGH);
    doorState=true;
  delay(2500);
  digitalWrite(lock, LOW);
  }
}

uint8_t getFingerprintEnroll(int id)
{
 Serial.print("");

 Serial.print("NW");// NW-Expected id of next enrolling finger

 Serial.println("");

 Serial.print(id);

  Serial.println("");

  int p = -1;
  //waiting to enroll finger
   Serial.print(" ");

  Serial.print("WF");//WF - waiting to enroll finger

   Serial.println("");

  while (p != FINGERPRINT_OK)
  {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
      //mike when image is taken
      //Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
     // Serial.println(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("IE");//Imaging error
      break;
    default:
    //mike When error is unknown
      //Serial.println("Unknown error");
      break;

    }
  }
  // OK success!

  p = finger.image2Tz(1);
  switch (p) {
    case FINGERPRINT_OK:
    //mike when image is converted
    //  Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:

      Serial.print("Could not find fingerprint features");

      Serial.println("");
      return p;
    case FINGERPRINT_INVALIDIMAGE:

      Serial.print("Could not find fingerprint features");

      Serial.println("");
      return p;
    default:
      Serial.println("UE"); // Unknown Error
      return p;
  }
  //mike remove finger
   Serial.print("");

  Serial.print("RF"); // RF - remove finger

   Serial.println("");

  delay(2000);
  p = 0;
  while (p != FINGERPRINT_NOFINGER) {
    p = finger.getImage();
  }

  p = -1;
  //mike place the same finger again
   Serial.print("");

  Serial.print("PF");//PF - place the same finger again

  Serial.println("");

  while (p != FINGERPRINT_OK) {
    p = finger.getImage();
    switch (p) {
    case FINGERPRINT_OK:
    //mike image taken
     Serial.print("");

      Serial.print("IT"); //IT - Image Taken

      Serial.println("");
      break;
    case FINGERPRINT_NOFINGER:
      //Serial.print(".");
      break;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      break;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      break;
    default:

      Serial.print("UE");

      Serial.println("");

      break;
    }
  }

  // OK success!

  p = finger.image2Tz(2);
  switch (p) {
    case FINGERPRINT_OK:
    //mike image converted
      //Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:

      Serial.print("Could not find fingerprint features");

      Serial.println("");
      return p;
    case FINGERPRINT_INVALIDIMAGE:

      Serial.print("Could not find fingerprint features");

      Serial.println("");
      return p;
    default:
      Serial.println("UE");// UE - Unknown error
      return p;
  }

  // OK converted!
  p = finger.createModel();
  if (p == FINGERPRINT_OK)
  {
    //mike when prints have matched during taking the finger print comparison
     Serial.print("");

    Serial.print("PM");//PM - Prints Matched

    Serial.println("");
    //return p;
  }
  else if (p == FINGERPRINT_PACKETRECIEVEERR)
  {
    Serial.println("Communication error");
    return p;
  }
  else if (p == FINGERPRINT_ENROLLMISMATCH)
  {
    //this is to show finger prints did not match when comparing the two finger prints during registration
    //mike Fingerprints did not match
    Serial.println("FN");// FN -Finger prints did not match
    return p;
  }
  else
  {
    Serial.println("UE");//Unknown error
    return p;
  }
   Serial.print("");

    //This is the id is ** part of the program
  //Serial.print("ID");

    //Serial.println("");

  Serial.print("IS");
    Serial.println("");

  id=0;
  id=EEPROM.read(1)+1;
  Serial.print(" ");

  Serial.print(id);

  Serial.println("");

  p = finger.storeModel(id);

  if (p == FINGERPRINT_OK)
  {
    //This is to store the image, in my case it will show the id of the finger print
    //Serial.println("Stored!");
    EEPROM.write(1, id);
  }
  else if (p == FINGERPRINT_PACKETRECIEVEERR)
  {
    Serial.println("Communication error");
    return p;
  }
  else if (p == FINGERPRINT_BADLOCATION)
  {
    Serial.println("Could not store in that location");
    return p;
  }
  else if (p == FINGERPRINT_FLASHERR)
  {
    Serial.println("Error writing to flash");
    return p;
  } else
  {

    Serial.print("UE");

    Serial.println("");
    return p;
  }
}

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


preliminary version of arduino code

preliminary version of arduino code

#include "DualVNH5019MotorShield.h"

DualVNH5019MotorShield md;

void setup() {
  Serial.begin(19200);
  Serial.setTimeout(3000);
  md.init();
}

void stopMotors() {
  md.setSpeeds(0, 0);
}

void loop() {
  int i;
  int dataPos;
  byte receivedData[12];

  int bytesReceived = Serial.readBytes(receivedData, 8);
  if (bytesReceived < 8) {
    // Incomplete or missing communications.
    // Stop motors and wait for valid message.
    stopMotors();
    return;
  }

  // Copy first 4 bytes to end of array, to make it easier
  // to search for the sync bytes.
  for (i = 0; i < 4; i++) {
    receivedData[8 + i] = receivedData[i];
  }

  // Find sync bytes.
  for (i = 0; i < 8; i++) {
    if (receivedData[i] == 0x7f &&
        receivedData[i+1] == 0x7f &&
        receivedData[i+2] == 0x80 &&
        receivedData[i+3] == 0x80) {
      // Found sync bytes.
      dataPos = (i+4)%8;
      break;
    }
  }

  if (i == 8) {
    // Sync bytes not found. Wait for a valid message.
    stopMotors();
    return;
  }

  // Valid message found. Decode it and send to motor.
  short leftPos = receivedData[dataPos] |
      (((short)receivedData[dataPos+1]) << 8);
  short rightPos = receivedData[dataPos+2] |
      (((short)receivedData[dataPos+3]) << 8);
  md.setSpeeds(rightPos, leftPos);
}

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


Implmented TTA and refactored byte sending method

#include <scheduler.h>

// constants won't change. They're used here to
// set pin numbers:
const int button_pin = 2;
const int servo_x_pin = 0;
const int servo_out_pin = 9;
const int IR_pin = 13;

volatile unsigned bit_seq = 0; // Byte we're trying to transmit
volatile int bit_index = 0; // Index of byte b we're comparing against.

void setupTimer3(){
  //Clear timer config.
  TCCR3A = 0;
  TCCR3B = 0;
  //Set to CTC (mode 4)
  TCCR3B |= (1<<WGM32);

  //Set prescaller to 1
  TCCR3B |= (1<<CS30);

  //Set TOP value (500 us seconds)
   OCR3A = 8000;
}

void setupPWMTimer(){
  //PWM
  //Clear timer config
  TCCR1A = 0;
  TCCR1B = 0;
  TIMSK1 &= ~(1<<OCIE1C);
  //Set to Fast PWM (mode 15)
  TCCR1A |= (1<<WGM10) | (1<<WGM11);
  TCCR1B |= (1<<WGM12) | (1<<WGM13);

  //Enable output C.
  TCCR1A |= (1<<COM1C1);
  //No prescaler
  TCCR1B |= (1<<CS10);

  OCR1A = 420;  //38KHz
  OCR1C = 210;  //50% duty cycle
  TCCR1A &= ~(1<<COM1C1); // have the IR transmitter off at first
}

void check_button(){
  // read the state of the switch into a local variable:
  int val = analogRead(button_pin);
  if( val < 10 ){
     transmit('D');
  }
}

void handle_servo(){
  int val = analogRead(servo_x_pin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 500, 2500);     // scale it to use it with the servo (value between 0 and 180)

 //http://www.robotshop.com/blog/en/arduino-5-minute-tutorials-lesson-5-servo-motors-3636
  digitalWrite(servo_out_pin,HIGH);
  delayMicroseconds(val);
  digitalWrite(servo_out_pin,LOW);
}

void transmit(byte _b) {
  // debug
  digitalWrite(10, HIGH);

  // set global values for the interrupt handler
  bit_seq = _b;

  // set the byte sequence to send
  // the 1,0 header bits
  bit_seq <<= 2;
  bit_seq += 1;

  // start from lower order bit first
  bit_index = 0;

  cli();

  //Enable interupt A for timer 3.
  TIMSK3 |= (1<<OCIE3A);
  // Clear interrupt;
  TIFR3 |= (1<<OCF3A);
  //Set timer to 0 (optional here).
  TCNT3 = 0;

  sei();
}

// interrupt handler for the IR transmitter
ISR(TIMER3_COMPA_vect)
{
  if( bit_index < 10 ){
    // we still have bits to send

    if( (bit_seq & ( 1 << bit_index )) != 0){
        // bit is set to one
        // turn on the IRT
        TCCR1A |= (1<<COM1C1);
    }else {
        // bit is set to zero
        // turn off the IRT
        TCCR1A &= ~(1<<COM1C1);
    }

    // increment the bit index
    bit_index++;
  }else{
    // all of the bytes have been sent.
    // turn off the IRT
    TCCR1A &= ~(1<<COM1C1);

    // disable this interrupt
    TIMSK3 ^= (1<<OCIE3A);
    TCNT3 = 0;

    // debug
    digitalWrite(10, LOW);
  }
}

void setup() {
  pinMode(button_pin, INPUT);
  pinMode(servo_x_pin, INPUT);
  pinMode(servo_out_pin, OUTPUT);
  pinMode(IR_pin, OUTPUT);
  Serial.begin(9600);

  setupTimer3();
  setupPWMTimer();

  Scheduler_Init();
  Scheduler_StartTask(0,20,check_button);
  Scheduler_StartTask(5,20,handle_servo);

  // debug pins
  pinMode(10, OUTPUT);

}
void idle(uint32_t idle_period){
  delay(idle_period);
}

void loop() {
  uint32_t idle_period = Scheduler_Dispatch();
  if( idle_period){
     idle(idle_period);
  }
}

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


Issue #1 'Moisture Bad Reading' solved

Issue #1 'Moisture Bad Reading' solved

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/franciscoalario/GoldenAnt.git/'


Added boilerplate

Added boilerplate

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


Add project resources for Mote

Add project resources for Mote

Project resources ships external build files required (primarily
for testing)

#include <SoftwareSerial.h>

// software serial #2: RX = digital pin 8, TX = digital pin 9
// on the Mega, use other pins instead, since 8 and 9 don't work on the Mega
SoftwareSerial portTwo(8, 9);

void setup() {

  pinMode(LED_BUILTIN, OUTPUT);

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Start each software serial portm
  portTwo.begin(9600);

  digitalWrite(LED_BUILTIN, LOW);
}

void loop() {

  // Now listen on the second port
  portTwo.listen();
  // while there is data coming in, read it
  // and send to the hardware serial port:
  Serial.println("Data from port two:");
  while (portTwo.available() > 0) {
    char inByte = portTwo.read();
    delay(500);
    Serial.write(inByte);
  }
}

error: pathspec 'projects/C7C.Atamo.Dusty.Mote_0_0_2/resources/Testing/TU_SH_DpUart_external_op.ino' did not match any file(s) known to git


Added new mqtt relay sketch

Added new mqtt relay sketch

error: pathspec 'Home' did not match any file(s) known to git
error: pathspec 'Automation/Sketches/RelayControl/RelayControl.ino' did not match any file(s) known to git


Bluetooth CAN message parsing

Bluetooth CAN message parsing

int  LED = 13;      // LED pin

void setup() {
  Serial.begin(9600); // initialization
  pinMode(LED, OUTPUT);
  Serial.println("Press 1 to LED ON or 0 to LED OFF...");
}

void loop() {
  if (Serial.available() >= 3) {  // if the data came

      char str_id[4];
      Serial.readBytes(str_id, 4); // read id
      Serial.print("ID: ");
      for(int i = 0; i < 3; i++) Serial.print(str_id[i]);

      char dlc_str[2];
      Serial.readBytes(dlc_str, 2);
      Serial.print("\ndlc: ");
      Serial.print(dlc_str[0]);
      Serial.println(dlc_str[1]);
      int dlc = dlc_str[0] - '0';
      dlc << 4;
      dlc += dlc_str[1] - '0';
      Serial.print("int dlc: ");
      Serial.println(dlc);

      char data[16];
      Serial.readBytes(data, dlc*2); // read data
      Serial.print("Data: ");
      for(int i = 0; i < dlc*2; i+=2)
      {
        Serial.print("0x");
        Serial.print(data[i]);
        Serial.print(data[i+1]);
        Serial.print(", ");
      }

      Serial.println("\n-----------------------\n");

    delay(100);
  }
}

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


Added comments to the power supply program and took out some unused variables.

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/upperman/Wireless-Led-Display.git/'


Added sensor board node firmware

Added sensor board node firmware

#include <RFM69.h>  // from lowpowerlab
#include <SPI.h>
#include <SPIFlash.h> //get it here: https://www.github.com/lowpowerlab/spiflash
#include <Arduino.h>
#include <Wire.h>
#include "Adafruit_SHT31.h"
#include "SparkFunMPL3115A2.h"
#include <Adafruit_Sensor.h>  // from Adafruit's github
#include <Adafruit_TSL2561_U.h>
#include <avr/sleep.h>
#include <avr/wdt.h>

// define node parameters
char node[] = "2";
#define NODEID        2 // same sa above - must be unique for each node on same network (range up to 254, 255 is used for broadcast)
#define GATEWAYID     1
#define NETWORKID     101
#define FREQUENCY     RF69_915MHZ //Match this with the version of your Moteino! (others: RF69_433MHZ, RF69_868MHZ)
#define ENCRYPTKEY    "Tt-Mh=SQ#dn#JY3_" //has to be same 16 characters/bytes on all nodes, not more not less!
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define LED             9

// define objects
RFM69 radio;
MPL3115A2 myPressure;
Adafruit_SHT31 sht31 = Adafruit_SHT31();
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);

// define IAQ core global variables
#define iaqaddress 0x5A
uint16_t co2;
uint8_t statu;
int32_t resistance;
uint16_t tvoc;

// define MICS-4514 global variables
#define PRE_PIN          8
#define VNOX_PIN         A1
#define VRED_PIN         A2
#define PRE_HEAT_SECONDS 10
int vnox_value = 0;
int vred_value = 0;

// define TSL2561 global variables
long lux;
float bar;
int sound;
float co;
float no2;

char dataPacket[150];

ISR(WDT_vect)  // Interrupt service routine for WatchDog Timer
{
  wdt_disable();  // disable watchdog
}

void setup()
{
  pinMode(10, OUTPUT);
  Serial.begin(115200);
  Serial.println("Setup");

  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);

  pinMode(9, OUTPUT);  // pin 9 controls LED
  pinMode(5, OUTPUT);   // pin 5 controls power to all sensors
  digitalWrite(5, HIGH);  // turn all sensors on
  delay(10);

  pinMode(PRE_PIN, OUTPUT);  // set preheater pin for mics4514 gas sensor
  Serial.print("MICS-4514 Preheating...");
  // Wait for preheating
  digitalWrite(PRE_PIN, 1);
  delay(PRE_HEAT_SECONDS * 1000);
  digitalWrite(PRE_PIN, 0);
  Serial.println("Done");
}

void sleep()
{
  //Serial.println("Going to Sleep");
  Serial.flush(); // empty the send buffer, before continue with; going to sleep

  digitalWrite(A1, LOW); // turn off UV sensor

  radio.sleep();

  cli();          // stop interrupts
  MCUSR = 0;
  WDTCSR  = (1<<WDCE | 1<<WDE);     // watchdog change enable
  WDTCSR  = 1<<WDIE | (1<<WDP3) | (0<<WDP2) | (0<<WDP1) | (1<<WDP0); // set  prescaler to 8 second
  sei();  // enable global interrupts

  byte _ADCSRA = ADCSRA;  // save ADC state
  ADCSRA &= ~(1 << ADEN);

  asm("wdr");
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  cli();
  //PORTD |= (1<<PORTD4); //Activate pullup on pin 4
  //PCICR |= (1<<PCIE2);
  //PCMSK2 |= (1<<PCINT20);
  sleep_enable();
  sleep_bod_disable();
  sei();
  sleep_cpu();

  sleep_disable();
  sei();

  ADCSRA = _ADCSRA; // restore ADC state (enable ADC)
  delay(1);

  //ADCSRA &= (1 << ADEN);
}

void loop()
{
  sleep();

  readSensors();

  Serial.println(dataPacket);
  Serial.println(strlen(dataPacket));
  delay(50);

  // send datapacket
  radio.sendWithRetry(GATEWAYID, dataPacket, strlen(dataPacket), 5, 100);  // send data, retry 5 times with delay of 100ms between each retry
  dataPacket[0] = (char)0; // clearing first byte of char array clears the array

  /*
  // blink LED after sending to give visual indication on the board
  digitalWrite(9, HIGH);
  delay(50);
  digitalWrite(9, LOW);
  */
  fadeLED();
}

void readSensors()
{

   //T/RH
  sht31.begin(0x44);
  float temp = sht31.readTemperature();
  float rh = sht31.readHumidity();

  //light
  tsl.begin();
  tsl.enableAutoRange(true);
  //tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);      /* fast but low resolution */
  tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS);  /* medium resolution and speed   */
  // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */
  sensors_event_t event;
  tsl.getEvent(&event);
  if (event.light)
    lux = event.light;
  else
    lux = -1;

  // IAQ core
  Wire.requestFrom(iaqaddress, 9);
  co2 = (Wire.read()<< 8 | Wire.read());
  statu = Wire.read();
  resistance = (Wire.read()& 0x00)| (Wire.read()<<16)| (Wire.read()<<8| Wire.read());
  tvoc = (Wire.read()<<8 | Wire.read());

  // ADMP401 mic for sound level
  sound = analogRead(A0);  // read sound levels

  // MPL3115A2 air pressure sensor
  myPressure.begin(); // Get pressure sensor online
  //Configure the sensor
  //myPressure.setModeAltimeter(); // Measure altitude above sea level in meters
  myPressure.setModeBarometer(); // Measure pressure in Pascals from 20 to 110 kPa

  myPressure.setOversampleRate(7); // Set Oversample to the recommended 128
  myPressure.enableEventFlags(); // Enable all three pressure and temp event flags
  delay(10);

  float pressure = myPressure.readPressure();
  float temperature = myPressure.readTempF();

  //const int station_elevation_ft = 5374; //Must be obtained with a GPS unit
  //float station_elevation_m = station_elevation_ft * 0.3048; //I'm going to hard code this
  const int station_elevation_m = 181; //Chicago
  //1 pascal = 0.01 millibars
  pressure /= 100; //pressure is now in millibars

  float part1 = pressure - 0.3; //Part 1 of formula

  const float part2 = 8.42288 / 100000.0;
  float part3 = pow((pressure - 0.3), 0.190284);
  float part4 = (float)station_elevation_m / part3;
  float part5 = (1.0 + (part2 * part4));
  float part6 = pow(part5, (1.0/0.190284));
  float altimeter_setting_pressure_mb = part1 * part6; //Output is now in adjusted millibars
  bar = altimeter_setting_pressure_mb * 0.02953;

  // MICS 4514 CO/NO2 gas sensor
  // Read analog values, print them out, and wait
  vnox_value = analogRead(VNOX_PIN);
  vred_value = analogRead(VRED_PIN);
  co = readCO();
  no2 = readNO2();

  // define character arrays for all variables
  //char _i[4];
  char _t[7];
  char _h[7];
  char _c[7];
  char _o[7];
  char _g[7];
  char _l[7];
  char _n[7];
  char _s[7];
  char _v[7];

  // convert all flaoting point and integer variables into character arrays
  //dtostrf(nodeID, 2, 0, _i);
  dtostrf(temp, 3, 1, _t);  // this function converts float into char array. 3 is minimum width, 2 is decimal precision
  dtostrf(rh, 3, 1, _h);
  dtostrf(co2, 3, 0, _c);
  dtostrf(co, 1, 0, _o);
  dtostrf(bar, 3, 2, _g);
  dtostrf(lux, 1, 0, _l);
  dtostrf(no2, 1, 0, _n);
  dtostrf(sound, 1, 0, _s);
  dtostrf(tvoc, 1, 0, _v);
  delay(50);

  dataPacket[0] = 0;  // first value of dataPacket should be a 0

  // create datapacket by combining all character arrays into a large character array
  strcat(dataPacket, "i:");
  strcat(dataPacket, node);
  strcat(dataPacket, ",t:");
  strcat(dataPacket, _t);
  strcat(dataPacket, ",h:");
  strcat(dataPacket, _h);
  strcat(dataPacket, ",c:");
  strcat(dataPacket, _c);
  strcat(dataPacket, ",o:");
  strcat(dataPacket, _o);
  strcat(dataPacket, ",g:");
  strcat(dataPacket, _g);
  strcat(dataPacket, ",l:");
  strcat(dataPacket, _l);
  strcat(dataPacket, ",n:");
  strcat(dataPacket, _n);
  strcat(dataPacket, ",s:");
  strcat(dataPacket, _s);
  strcat(dataPacket, ",v:");
  strcat(dataPacket, _v);
  delay(50);
}

float readCO()
{
  float adc = analogRead(VNOX_PIN);
  float Rs = 47000.0/(1023.0/adc);
  float R0 = 82000.0;
  float ratio = Rs/R0;
  float concentration = ((-181.4)*log(ratio))-97.469;
  //Serial.println(adc);
  //Serial.println(Rs);
  //Serial.println(R0);
  //Serial.println(ratio);
  if(concentration>0)
  {
    return concentration;
  }
  else
  {
    return 0;
  }
}

float readNO2()
{
  float adc = analogRead(VRED_PIN);
  float Rs = 22000.0/(1023.0/adc);
  float R0 = 350.0;
  float ratio = Rs/R0;
  float concentration = (124.28*log(ratio))-270.37;
  //Serial.println(adc);
  //Serial.println(Rs);
  //Serial.println(R0);
  //Serial.println(ratio);
  if(concentration>0)
  {
    return concentration;
  }
  else
  {
    return 0;
  }
}

// interpolate the UV intensity (from voltage vs intensity graph in datasheet)
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

void fadeLED()
{
  int brightness = 0;
  int fadeAmount = 5;
  for(int i=0; i<510; i=i+5)  // 255 is max analog value, 255 * 2 = 510
  {
    analogWrite(9, brightness);  // pin 9 is LED

    // change the brightness for next time through the loop:
    brightness = brightness + fadeAmount;  // increment brightness level by 5 each time (0 is lowest, 255 is highest)

    // reverse the direction of the fading at the ends of the fade:
    if (brightness <= 0 || brightness >= 255)
    {
      fadeAmount = -fadeAmount;
    }
    // wait for 20-30 milliseconds to see the dimming effect
    delay(20);
  }
  digitalWrite(9, LOW); // switch LED off at the end of fade
}

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


Update PushNotification.ino

Update PushNotification.ino

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * Simple push notification example
 *
 * App dashboard setup:
 *   Push widget
 *
 * Connect a button to pin 2 and GND...
 * Pressing this button will also push a message! ;)
 *
 **************************************************************/
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

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

SimpleTimer timer;

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

  while (!Blynk.connect()) {
    // Wait until connected
  }

  // Notify immediately on startup
  Blynk.notify("Device started");

  // Setup a function to be called every minute
  timer.setInterval(60000L, notifyUptime);

  // Setup notification button on pin 2
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), notifyOnButtonPress, CHANGE);
}

void notifyUptime()
{
  long uptime = millis() / 60000L;

  // Actually send the message.
  // Note:
  //   We allow 1 notification per minute for now.
  Blynk.notify(String("Running for ") + uptime + " minutes.");
}

void notifyOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(2);
  if (isButtonPressed) {
    BLYNK_LOG("Button is pressed.");

    Blynk.notify("Yaaay... button is pressed!");
  }
}

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

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * Simple push notification example
 *
 * App dashboard setup:
 *   Push widget
 *
 * Connect a button to pin 2 and GND...
 * Pressing this button will also push a message! ;)
 *
 **************************************************************/
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

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

SimpleTimer timer;

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

  while (!Blynk.connect()) {
    // Wait until connected
  }

  // Notify immediately on startup
  Blynk.notify("Device started");

  // Setup a function to be called every minute
  timer.setInterval(60000L, notifyUptime);

  // Setup notification button on pin 2
  pinMode(2, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(0, notifyOnButtonPress, CHANGE);
}

void notifyUptime()
{
  long uptime = millis() / 60000L;

  // Actually send the message.
  // Note:
  //   We allow 1 notification per minute for now.
  Blynk.notify(String("Running for ") + uptime + " minutes.");
}

void notifyOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(2);
  if (isButtonPressed) {
    BLYNK_LOG("Button is pressed.");

    Blynk.notify("Yaaay... button is pressed!");
  }
}

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


arduino test file

arduino test file

int pwmPin1 = 3;
int pwmPin2 = 5;
int pwmPin3 = 6;
int pwmPin4 = 9;

int irPin = 10;
int incomingByte = 0;

void setup() {

  /* Initialize Serial at a 9600 baud rate */
  Serial.begin(9600);

  /* Configure PWM pins */
  pinMode(pwmPin1, OUTPUT);
  pinMode(pwmPin2, OUTPUT);
  pinMode(pwmPin3, OUTPUT);
  pinMode(pwmPin4, OUTPUT);

  /* Configure IR range finders */
  pinMode(irPin, INPUT);

}

void loop() {

}

/* Read IR value of specified pin */
void readIR(int pin) {

  int val = analogRead(pin);
  getDistance(val);
}

/* 4 + 1023/Value */
float getDistance(int val) {

  float dist;
  //dist = 4 + 5 * 1023.0/(float)val;
  dist = 12343.85 * pow(val, -1.15);
  Serial.println(dist);
  return dist;
}

/* Handles receiving serial communication */
void recvSerial() {

    if (Serial.available() > 0) {
        incomingByte = Serial.read();
        Serial.print("received: ");
        Serial.println(incomingByte, DEC);
    }
}

/* Function to drive given PWM pin given value */
void writePWM(int pin, float value) {

  analogWrite(pin, value);
}

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


commit

commit

//#include <SPI.h>
#include <QueueArray.h>
//#include <Phpoc.h>

#define DATA_SIZE 100
#define TREE_SIZE 50
//#define QN 6

// 핀번호 설정
int echo[4] = { 2, 8, 7, 5 };
int trig[4] = { 3, 9, 6, 4 };

// 거리
float distance[4];

// Bound, standard diviationl
float lowerbound[4], upperbound[4];
//PhpocClient client;
// global avg (벽과의 거리)
//float real_avg = 0;

// initial times
int times = 0;

int cnt = 0;
int data_cnt = 0;
bool isNewLine = false;

//QueueArray <float> Q[4];
//QueueArray <float> D;
float ar[16];
int index = 0;
//float Qsum[4] = {0,};
//float Qavg[4] = {0,};
bool first = false;
bool last = false;
bool sw = true;

int seq = 1;

int vote[TREE_SIZE];

void setup() {
  Serial.begin(250000);
  //  while (!Serial)
  //    ;
  //  Serial.println("Sending GET request to web server");
  //  Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
  for (int i = 0; i < 4; i++) {
    pinMode(trig[i], OUTPUT);
    pinMode(echo[i], INPUT);
  }
  //    lowerbound[0] = 88 - 4;
  //    lowerbound[1] = 88 - 4;
  //    lowerbound[2] = 88 - 4;
  //    lowerbound[3] = 88 - 4;
  //    upperbound[0] = 88 + 4;
  //    upperbound[1] = 88 + 4;
  //    upperbound[2] = 88 + 4;
  //    upperbound[3] = 88 + 4;
  lowerbound[0] = 83.08;
  lowerbound[1] = 83.35;
  lowerbound[2] = 82.82;
  lowerbound[3] = 83.34;
  upperbound[0] = 91.39;
  upperbound[1] = 91.66;
  upperbound[2] = 91.13;
  upperbound[3] = 91.65;
}

//void initialize(int init_time) {
//  if (times < init_time) {
//    for (int i = 0; i < 4; i++) {
//      arr[i][times] = distance[i];
//    }
//  }
//}

//void calculate_bound(int init_time) {
//  float sum[4] = {0,}, avg[4], stddv[4], sig = 0;
//
//  for (int i = 0; i < 4; i++) {
//    for (int j = 10; j < init_time; j++) {
//      sum[i] += arr[i][j];
//    }
//    avg[i] = sum[i] / (init_time - 10);
//    sum[i] = 0;
//  }
//
//  for (int i = 0; i < 4; i++) {
//    for (int j = 10; j < init_time; j++) {
//      sum[i] += pow(arr[i][j] - avg[i], 2);
//    }
//    stddv[i] = sqrt(sum[i] / (init_time - 10)) * 12;
//  }
//
//  for (int i = 0; i < 4; i++) {
//    if (stddv[i] > sig) sig = stddv[i];
//  }
//
//  for (int i = 0; i < 4; i++) {
//    lowerbound[i] = avg[i] - sig;
//    upperbound[i] = avg[i] + sig;
//  }
//
//  for (int i = 0; i < 4; i++) {
//    real_avg += avg[i];
//  }
//  real_avg /= 4;
//  lowerbound[0] = 83.08;
//  lowerbound[1] = 83.35;
//  lowerbound[2] = 82.82;
//  lowerbound[3] = 83.34;
//  upperbound[0] = 91.39;
//  upperbound[1] = 91.66;
//  upperbound[2] = 91.13;
//  upperbound[3] = 91.65;
//  //  for (int i = 0; i < 4; i++) {
//  //    lowerbound[i] = real_avg - sig;
//  //    upperbound[i] = real_avg + sig;
//  //  }
//}

bool isInBound(int i) {
  if (distance[i] > lowerbound[i] && distance[i] < upperbound[i]) return true;
  else return false;
}

void process(int i) {
  if (i==2 || i==5 || i==7 || i==8 || i==9 || i==10 || i==12 || i==17 || i==19 || i==26 || i==27 || i==29 || i==30 || i==41 || i==48){
    i=-1;
  }
  if (i == 0) { // 보선
    if (ar[3] < 62.25) {
      vote[i] = -1;
    } else {
      if (ar[1] < 81.12) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
  else if (i == 1) { // 채린
    if (ar[2] < 83.495) {
      vote[i] = 1;
    } else {
      if (ar[7] < 86.635) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
    else if (i == 2) { // 조서
      if (ar[6] < 79.23) {
        vote[i] = 1;
      } else {
        if (ar[0] < 87.26) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
    else if (i == 3) { // 두상
      if (ar[11] < 48.25) {
        if (ar[4] < 43) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      } else {
        if (ar[2] < 87.105) {
          vote[i] = 1;
        } else {
          if (ar[3] < 55.455) {
            vote[i] = -1;
          } else {
            vote[i] = 1;
          }
        }
      }
    }
  else if (i == 4) { // 기욱
    if (ar[7] < 34) {
      vote[i] = -1;
    } else {
      if (ar[3] < 61.65) {
        vote[i] = -1;
      } else {
        if (ar[1] < 47.245) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  }
    else if (i == 5) { // 형진
      if (ar[1] < 77.63) {
        if (ar[4] < 59.38) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      } else {
        if (ar[13] < 89.58) {
          if (ar[3] < 39.175) {
            vote[i] = -1;
          } else {
            vote[i] = 1;
          }
        } else {
          vote[i] = -1;
        }
      }
    }
  else if (i == 6) { // 종호
    if (ar[2] < 63.795) {
      vote[i] = 1;
    } else {
      if (ar[0] < 75.42) {
        vote[i] = 1;
      } else {
        if (ar[4] < 67.845) {
          vote[i] = 1;
        } else {
          if (ar[7] < 87.94) {
            vote[i] = -1;
          } else {
            vote[i] = 1;
          }
        }
      }
    }
  }
  else if (i == 7) { // 지식
    if (ar[1] < 81.185) {
      vote[i] = -1;
    } else {
      if (ar[3] < 55.27) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
    else if (i == 8) { // 지원
      if (ar[7] < 45.3) {
        if (ar[0] < 86.7) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      } else {
        vote[i] = 1;
      }
    }
    else if (i == 9) { // 광선
      if (ar[2] < 86.925) {
        vote[i] = 1;
      } else {
        if (ar[4] < 43.56) {
          vote[i] = 1;
        } else {
          if (ar[8] < 87.645) {
            vote[i] = -1;
          } else {
            vote[i] = 1;
          }
        }
      }
    }
    else if (i == 10) { // 남진
      if (ar[3] < 50.35) {
        vote[i] = -1;
      } else {
        if (ar[1] < 32.015) {
          vote[i] = -1;
        } else {
          if (ar[5] < 89.8) {
            vote[i] = 1;
          } else {
            vote[i] = -1;
          }
        }
      }
    }
  else if (i == 11) { // 소현
    if (ar[3] < 75.715) {
      vote[i] = -1;
    } else {
      if (ar[3] < 90.3) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 12) { // 성준
    if (ar[7] < 48.025) {
      vote[i] = -1;
    } else {
      if (ar[5] < 64.835) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
    else if (i == 13) { // 성민
      if (ar[7] < 49.08) {
        if (ar[0] < 47.06) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      } else {
        vote[i] = 1;
      }
    }
  else if (i == 14) { // 상우
    if (ar[1] < 81.21) {
      if (ar[0] < 76.17) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[3] < 81.225) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
  else if (i == 15) { // 영준
    if (ar[6] < 62.33) {
      if (ar[1] < 88.91) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[4] < 69.625) {
        vote[i] = 1;
      } else {
        if (ar[0] < 78.07) {
          vote[i] = 1;
        } else {
          if (ar[2] < 88.865) {
            vote[i] = -1;
          } else {
            vote[i] = 1;
          }
        }
      }
    }
  }
  else if (i == 16) { // 영송
    if (ar[3] < 75.25) {
      vote[i] = -1;
    } else {
      if (ar[1] < 61.875) {
        vote[i] = -1;
      } else {
        if (ar[1] < 89.465) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
    else if (i == 17) { // 유성
      if (ar[11] < 29.615) {
        if (ar[0] < 87.48) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      } else {
        if (ar[1] < 78.645) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  else if (i == 18) { // 승연
    if (ar[2] < 51.29) {
      if (ar[1] < 43.005) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    } else {
      if (ar[2] < 88.565) {
        if (ar[0] < 68.315) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      } else {
        vote[i] = 1;
      }
    }
  }
    else if (i == 19) { // 용욱
      if (ar[7] < 40.145) {
        if (ar[6] < 42.94) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      } else {
        if (ar[15] < 33.16) {
          if (ar[5] < 86.505) {
            vote[i] = 1;
          } else {
            vote[i] = -1;
          }
        } else {
          vote[i] = 1;
        }
      }
    }
  else if (i == 20) { // 김현중
    if (ar[3] < 86.605) {
      if (ar[2] < 57.8) {
        vote[i] = 1;
      } else {
        if (ar[6] < 40.42) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    } else {
      if (ar[1] < 59.46) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
  else if (i == 21) { // 장영준
    if (ar[7] < 81.99) {
      if (ar[14] < 43.185) {
        vote[i] = 1;
      } else {
        if (ar[0] < 81.265) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    } else {
      if (ar[1] < 90.145) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 22) { // 주병
    if (ar[4] < 77.095) {
      if (ar[1] < 94.82) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[8] < 16.45) {
        vote[i] = 1;
      } else {
        if (ar[2] < 65.125) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
  else if (i == 23) { // 원균
    if (ar[7] < 60.91) {
      if (ar[0] < 51.18) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[14] < 86.355) {
        vote[i] = 1;
      } else {
        if (ar[5] < 86.23) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  }
  else if (i == 24) { // 지영
    if (ar[6] < 62.33) {
      if (ar[1] < 88.91) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[4] < 69.625) {
        vote[i] = 1;
      } else {
        if (ar[0] < 78.07) {
          vote[i] = 1;
        } else {
          if (ar[2] < 88.865) {
            vote[i] = -1;
          } else {
            vote[i] = 1;
          }
        }
      }
    }
  }
  else if (i == 25) { // 규봉
    if (ar[6] < 52.785) {
      if (ar[13] < 26.455) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    } else {
      if (ar[0] < 76.335) {
        vote[i] = 1;
      } else {
        if (ar[8] < 89.33) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  }
    else if (i == 26) { // 진용
      if (ar[12] < 29.46) {
        if (ar[3] < 38.565) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      } else {
        if (ar[4] < 37.44) {
          vote[i] = 1;
        } else {
          if (ar[8] < 29.02) {
            vote[i] = 1;
          } else {
            vote[i] = -1;
          }
        }
      }
    }
    else if (i == 27) { // 경나?
      if (ar[7] < 40.44) {
        vote[i] = -1;
      } else {
        if (ar[3] < 35.905) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  else if (i == 28) {
    if (ar[3] < 81.64) {
      if (ar[0] < 50.085) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[1] < 80.765) {
        vote[i] = -1;
      } else {
        if (ar[1] < 89.66) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
  else if (i == 29) {
    if (ar[7] < 41.715) {
      vote[i] = -1;
    } else {
      if (ar[1] < 86.76) {
        vote[i] = -1;
      } else {
        if (ar[3] < 64.51) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  }
  else if (i == 30) {
    if (ar[3] < 46.68) {
      vote[i] = -1;
    } else {
      if (ar[2] < 86.555) {
        vote[i] = 1;
      } else {
        if (ar[0] < 78.215) {
          vote[i] = 1;
        } else {
          if (ar[3] < 65.625) {
            vote[i] = 1;
          } else {
            vote[i] = -1;
          }
        }
      }
    }
  }
  else if (i == 31) {
    if (ar[4] < 80.99) {
      if (ar[3] < 45.485) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    } else {
      if (ar[2] < 81.355) {
        vote[i] = 1;
      } else {
        if (ar[0] < 64.835) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
  else if (i == 32) {
    if (ar[7] < 69.09) {
      if (ar[2] < 74.935) {
        if (ar[1] < 59.635) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      } else {
        vote[i] = -1;
      }
    } else {
      vote[i] = 1;
    }
  }
  else if (i == 33) {
    if (ar[6] < 79.955) {
      if (ar[1] < 90.88) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[4] < 56.625) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 34) {
    if (ar[3] < 79.925) {
      if (ar[4] < 75.775) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[1] < 75.685) {
        vote[i] = -1;
      } else {
        if (ar[2] < 87.795) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
  else if (i == 35) {
    if (ar[7] < 46.985) {
      vote[i] = -1;
    } else {
      if (ar[0] < 86.755) {
        vote[i] = 1;
      } else {
        if (ar[1] < 87.785) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  }
  else if (i == 36) {
    if (ar[4] < 86.545) {
      vote[i] = 1;
    } else {
      if (ar[2] < 81.535) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 37) {
    if (ar[2] < 86.51) {
      if (ar[6] < 87.74) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[0] < 82) {
        vote[i] = 1;
      } else {
        if (ar[7] < 87.76) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  }
  else if (i == 38) {
    if (ar[4] < 79.465) {
      if (ar[1] < 45.99) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    } else {
      if (ar[6] < 75.765) {
        vote[i] = 1;
      } else {
        if (ar[0] < 84.38) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
  else if (i == 39) {
    if (ar[4] < 71.125) {
      if (ar[7] < 36.985) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    } else {
      if (ar[0] < 75.86) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 40) {
    if (ar[0] < 86.595) {
      vote[i] = 1;
    } else {
      if (ar[2] < 75.555) {
        vote[i] = 1;
      } else {
        if (ar[2] < 87.485) {
          if (ar[6] < 55.33) {
            vote[i] = 1;
          } else {
            vote[i] = -1;
          }
        } else {
          vote[i] = 1;
        }
      }
    }
  }
  else if (i == 41) {
    if (ar[3] < 78.005) {
      if (ar[0] < 57.29) {
        vote[i] = 1;
      } else {
        if (ar[4] < 28.145) {
          vote[i] = 1;
        } else {
          vote[i] = 1;
        }
      }
    } else {
      if (ar[6] < 87.055) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 42) {
    if (ar[3] < 81.665) {
      if (ar[2] < 86.285) {
        vote[i] = 1;
      } else {
        if (ar[2] < 88.895) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    } else {
      if (ar[5] < 71.495) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
  else if (i == 43) {
    if (ar[4] < 86.72) {
      if (ar[5] < 54.95) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    } else {
      if (ar[2] < 81.78) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 44) {
    if (ar[6] < 86.28) {
      if (ar[1] < 89.655) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[0] < 86.59) {
        vote[i] = 1;
      } else {
        if (ar[2] < 62.425) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
  else if (i == 45) {
    if (ar[6] < 86.295) {
      if (ar[1] < 53.585) {
        vote[i] = -1;
      } else {
        if (ar[1] < 89.69) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    } else {
      if (ar[6] < 87.32) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
  else if (i == 46) {
    if (ar[6] < 79.27) {
      if (ar[3] < 35.905) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    } else {
      if (ar[2] < 70.465) {
        vote[i] = 1;
      } else {
        if (ar[0] < 65.68) {
          vote[i] = 1;
        } else {
          vote[i] = -1;
        }
      }
    }
  }
  else if (i == 47) {
    if (ar[2] < 84.245) {
      vote[i] = 1;
    } else {
      if (ar[4] < 64.175) {
        vote[i] = 1;
      } else {
        if (ar[2] < 88.625) {
          vote[i] = -1;
        } else {
          vote[i] = 1;
        }
      }
    }
  }
  else if (i == 48) {
    if (ar[7] < 43.52) {
      if (ar[2] < 60.06) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[2] < 87.24) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    }
  }
  else if (i == 49) {
    if (ar[7] < 59.045) {
      if (ar[4] < 60.62) {
        vote[i] = 1;
      } else {
        vote[i] = -1;
      }
    } else {
      if (ar[5] < 65.57) {
        vote[i] = -1;
      } else {
        vote[i] = 1;
      }
    }
  }
}

void print_value() {
  //  Serial.print(times);
  //  Serial.print("\t");

  //  if (times > 30 && (!isInBound(0) || !isInBound(1) || !isInBound(2) || !isInBound(3))) {
  //    if (index < 40) {
  //      //      ar[index++] = Qavg[0];
  //      //      ar[index++] = Qavg[1];
  //      //      ar[index++] = Qavg[2];
  //      //      ar[index++] = Qavg[3];
  //    }
  //    isNewLine = false;
  //    data_cnt += 4;
  //  }

  //  for (int i = 0; i < 4; i++) {
  //    Q[i].push(distance[i]);
  //    Qsum[i] += distance[i];
  //  }
  //
  //  if (Q[0].count() == QN + 1) {
  //    for (int i = 0; i < 4; i++) {
  //      Qsum[i] -= Q[i].pop();
  //    }
  //  }
  //
  //  for (int i = 0; i < 4; i++)
  //    Qavg[i] = Qsum[i] / Q[i].count();

  if (isInBound(0) && isInBound(1) && isInBound(2) && isInBound(3) && !isNewLine) {
    cnt++;
  } else {
    cnt = 0;
  }

  if (cnt == 3) {
    cnt = 0;
    if (ar[12] != 0 || ar[13] != 0 || ar[14] != 0 || ar[15] != 0) {
      for (int i = 0; i < TREE_SIZE; i++) {
        process(i);
      }
      int sum = 0;
      int out = 0, in = 0;
      for (int i = 0; i < TREE_SIZE; i++) {
        Serial.print(vote[i]);
        Serial.print("\t");
        if (vote[i] == -1) out++;
        else if (vote[i] == 1) in++;
        sum += vote[i];
        vote[i] = 0;
      }
      Serial.println("\t");
      Serial.println("\t");
      Serial.print("IN  :  ");
      Serial.print(in);
      Serial.print("\t");
      Serial.print("OUT  :  ");
      Serial.print(out);
      Serial.print("\t");
      Serial.print("RESULT  :  ");
      Serial.print(sum);
      Serial.println("\t");
      Serial.println("\t");
      in = 0; out = 0; sum = 0;
    }
    for (int i = 0; i < 16; i++) {
      ar[i] = 0;
    }

    //    if (sw) {
    //      for (int i = 0; i < DATA_SIZE - data_cnt; i++) {
    //        Serial.print('0');
    //        Serial.print("\t");
    //      }
    //      Serial.println();
    //    }
    data_cnt = 0;
    isNewLine = true;
    index = 0;
  }

  //  if (!isInBound(0) || !isInBound(1) || !isInBound(2) || !isInBound(3)) {
  //    if (!first && D.count() < 12) {
  //      D.push(Qavg[0]);
  //      D.push(Qavg[1]);
  //      D.push(Qavg[2]);
  //      D.push(Qavg[3]);
  //    }
  //    if (!first && D.count() == 12) {
  //      for (int i = 0; i < 12; i++) ar[i] = D.pop();
  //      first = true;
  //      //      Serial.println("First On!");
  //    }
  //    if (first && !last) {
  //      D.push(Qavg[0]);
  //      D.push(Qavg[1]);
  //      D.push(Qavg[2]);
  //      D.push(Qavg[3]);
  //      if (D.count() > 12) for (int i = 0; i < 4; i++) D.pop();
  //    }
  //  }
  //
  //  if (first && !last && cnt == 2) {
  //    for (int i = 12; i < 24; i++) ar[i] = D.pop();
  //    last = true;
  //  }
  //  if (first && last) {
  //    process();
  //  }
  //  if (cnt == 2) {
  //    for (int i = 0; i < 24; i++) ar[i] = 0;
  //    isNewLine = true;
  //    cnt = 0;
  //    first = false;
  //    last = false;
  //  }

//  if (!isInBound(0) || !isInBound(1) || !isInBound(2) || !isInBound(3)) {
//    if (index < 14) {
//      for (int i = 0; i < 4; i++) {
//        if (distance[i] == 120.0) {
//          ar[index++] = 0;
//        } else {
//          ar[index++] = distance[i];
//        }
//      }
//    }
    for (int i = 0; i < 4; i++) {
      //    if (!isInBound(i)) {
            Serial.print(distance[i]);
            Serial.print("\t");
      //    }
    }
    data_cnt += 4;
    isNewLine = false;
    //    for (int i = 0; i < 4; i++) {
    //      //    if (!isInBound(i)) {
    //      Serial.print(lowerbound[i]);
    //      Serial.print("\t");
    //      //    }
    //    }
    //    for (int i = 0; i < 4; i++) {
    //      //    if (!isInBound(i)) {
    //      Serial.print(upperbound[i]);
    //      Serial.print("\t");
    //      //    }
    //    }
            Serial.println();
//  }
}

float getDistance(int i) {
  float result, du;
  digitalWrite(trig[i], HIGH);
  delay(5);
  digitalWrite(trig[i], LOW);
  du = pulseIn(echo[i], HIGH);
  //  result = ((float)(340 * du) / 10000) / 2;
  result = du / 58.2;
  if (result > 120) result = 120; // 튀는 값 120으로 보정
  return result;
}

//float getMedian(float a, float b, float c) {
//  float A = a, B = b, C = c;
//  if (b >= a && a >= c) return A;
//  if (c >= a && a >= b) return A;
//  if (a >= b && b >= c) return B;
//  if (c >= b && b >= a) return B;
//  if (a >= c && c >= b) return C;
//  if (b >= c && c >= a) return C;
//}

void loop() {
  int num = 1;

  for (int i = 0; i < 4; i++) distance[i] = getDistance(i);

  // 바운드 계산을 위한 초기값 (벽) 거리 측정
  //  initialize(30);

  // 바운드 계산
  //  if (times == 30) calculate_bound(30);

  // 출력
  print_value();

  if (Serial.available()) {
    Serial.read();
    sw = !sw;
  }

  times++;
}

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


Circle version lamp

Circle version lamp

#import <FastLED.h>
struct CRGB leds[N_LEDS];

void setup() {
  FastLED.addLeds<WS2812B, 7, GRB>(leds, 93);
  FastLED.setMaxPowerInVoltsAndMilliamps(5,3000);
}

int rings[6] = { 32, 24, 16, 12, 8, 1 };
int frame = 0;

void loop() {
  int offset = 0;
  for(int ring = 0; ring < 6; ring++) {
    int pixels = rings[ring];
    // frame steps the ring around, ring * 3 off-sets each ring 3 pixels
    uint8_t rainbowStart = frame + ring * 3;
    int rainbowDelta = 255 / pixels;
    fill_rainbow(&(leds[offset]), pixels, rainbowStart, rainbowDelta);
    offset += pixels;
  }
  EVERY_N_MILLISECONDS(5) { frame++; }
  FastLED.show();
}

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


Revert to saved.

Revert to saved.

/**
 * @file CosaBitSet.ino
 * @version 1.0
 *
 * @section License
 * Copyright (C) 2013, Mikael Patel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA  02111-1307  USA
 *
 * @section Description
 * Demonstrate Cosa BitSet class.
 *
 * This file is part of the Arduino Che Cosa project.
 */

#include "Cosa/BitSet.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/Memory.h"
#include "Cosa/Trace.hh"
#include "Cosa/IOStream/Driver/UART.hh"

enum {
  RED,
  GREEN,
  BLUE,
  YELLOW,
  MAGENTA,
  CYAN
};

void setup()
{
  BitSet<68> a, b;

  uart.begin(9600);
  trace.begin(&uart, PSTR("CosaBitSet: started"));
  Watchdog::begin();

  TRACE(free_memory());
  TRACE(sizeof(a));

  // Check that the bitset is empty
  ASSERT(b.isempty());
  ASSERT(a == b);

  // Add and remove elements
  ASSERT(!b[GREEN]);
  b += GREEN;
  ASSERT(b[GREEN]);
  b -= GREEN;
  ASSERT(!b[GREEN]);
  b += RED;
  b += CYAN;
  ASSERT(b[RED] && b[CYAN]);
  trace << PSTR("B0:") << b << endl;

  // Assign and check that they are equal
  a = b;
  ASSERT(a == b);
  trace << PSTR("A0:") << a << endl;

  // Add element and another bitset
  a += a.members() / 2;
  trace << PSTR("A1:") << a << endl;

  // Try adding element outside the bitset
  b += 67;
  b += 68;
  b += 100;
  trace << PSTR("B1:") << b << endl;
  ASSERT(b[RED] && b[CYAN] && b[67]);
  ASSERT(!b[68] && !b[100]);

  // Remove bitset and the last element
  b -= a;
  b -= 67;
  trace << PSTR("B2:") << b << endl;
  ASSERT(b.isempty());
  for (uint16_t i = 4; i < b.members(); i += 5)
    b += i;
  trace << PSTR("B3:") << b << endl;
}

void loop()
{
  ASSERT(true == false);
}

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


Create testAllInputHandlers.ino

Create testAllInputHandlers.ino

/*

This is a sketch testing all the different types of handlers
The global input handler will always be triggered.
Setting lightnode1/property1/ will trigger the node input handler.
Setting lightnode2/property1/ will trigger the property input handler.

*/

#include <Arduino.h>
#include <Homie.h>

bool globalInputHandler(const HomieNode& node, const HomieRange& range, const String& property, const String& value) {
  Homie.getLogger() << "Global input handler. Received on node " << node.getId() << ": " << property << " = " << value << endl;
  return false;
}

bool nodeInputHandler(const HomieRange & range, const String & property, const String & value) {
  Homie.getLogger() << "Node input handler. Received on property " << property << " value: " << value;
  return true;
}

bool propertyInputHandler(const HomieRange& range, const String& value) {
  Homie.getLogger() << "Property input handler. Receveived value: " << value;
  return true;
}

HomieNode lightNode1("lightnode1", "Light Node One Name","switch", false, 0 , 0, &nodeInputHandler);
HomieNode lightNode2("lightnode2", "Light Two One Name","switch");

void setup() {
  Serial.begin(115200);
  Serial << endl << endl;
  Homie_setFirmware("Test all input handlers", "0.0.1");
  lightNode1.advertise("property1").setName("ln1 First property").setDatatype("boolean").settable();
  lightNode2.advertise("property1").setName("ln2 First property").setDatatype("boolean").settable(propertyInputHandler);
  Homie.setGlobalInputHandler(globalInputHandler);
  Homie.setup();
}

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

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