MCP23017 16 Pin Port Expander over I2C: Example project added

#include <Wire.h>
#include "Adafruit_MCP23017.h"

// Basic pin reading and pullup test for the MCP23017 I/O expander
// public domain!

// Connect pin #12 of the expander to Analog 5 (i2c clock)
// Connect pin #13 of the expander to Analog 4 (i2c data)
// Connect pins #15, 16 and 17 of the expander to ground (address selection)
// Connect pin #9 of the expander to 5V (power)
// Connect pin #10 of the expander to ground (common ground)
// Connect pin #18 through a ~10kohm resistor to 5V (reset pin, active low)

// Output #0 is on pin 21 so connect an LED or whatever from that to ground

Adafruit_MCP23017 mcp;

void setup() {
  mcp.begin();      // use default address 0

  mcp.pinMode(0, OUTPUT); // GPA0
  mcp.pinMode(1, OUTPUT); // GPA1
  mcp.pinMode(6, OUTPUT); // GPA6
  mcp.pinMode(7, OUTPUT); // GPA7

  mcp.pinMode(8, OUTPUT); // GPB0
  mcp.pinMode(9, OUTPUT); // GPB1
  mcp.pinMode(14, OUTPUT); // GPB6
  mcp.pinMode(15, OUTPUT); // GPB7
}

// flip the pin #0 up and down

void loop() {
  delay(500);

  mcp.digitalWrite(0, HIGH);
  mcp.digitalWrite(1, HIGH);
  mcp.digitalWrite(6, HIGH);
  mcp.digitalWrite(7, HIGH);

   mcp.digitalWrite(8, LOW);
   mcp.digitalWrite(9, LOW);
  mcp.digitalWrite(14, LOW);
  mcp.digitalWrite(15, LOW);

  delay(500);

  mcp.digitalWrite(0, LOW);
  mcp.digitalWrite(1, LOW);
  mcp.digitalWrite(6, LOW);
  mcp.digitalWrite(7, LOW);

  mcp.digitalWrite(8, HIGH);
  mcp.digitalWrite(9, HIGH);
  mcp.digitalWrite(14, HIGH);
  mcp.digitalWrite(15, HIGH);
}

error: pathspec 'portexpander-MCP23017-ESP_Blink/MCP23017-ESP-PortExpander-Blink.ino' did not match any file(s) known to git


Add MQTT-SN over serial bridge example

Add MQTT-SN over serial bridge example

/*
  Basic MQTT-SN over Serial Bridge example
  (experimental)

   Setup:
   - Sends the MQTT-SN packages not over the nRF24L01+ Transceiver but over SoftwareSerial to a PC
   - On the PC run the Serial Port Bridge from https://github.com/njh/mqtt-sn-tools to forward them via TCP to a MQTT-SN Broker

   Function:
   - reads a string from Serial and publishes the PUBLISH_TOPIC ("Bt/Ex/PubSub/Out") topic
   - subscribes to the SUBSCRIBE_TOPIC ("Bt/Ex/PubSub/In") topic and writes the reiceived data to the Serial
*/

#include <SPI.h>
#include <BtMqttSn.h>
#include <SoftwareSerial.h>

//-----

#define CLIENT_NODE_ID 1
#define GATEWAY_NODE_ID 0

#define CLIENT_ID "BtMqttPupSubExample"
#define PUBLISH_TOPIC "Bt/Ex/PubSub/Out"
#define SUBSCRIBE_TOPIC "Bt/Ex/PubSub/In"

//-----

class SerialPacketSocket : public Bt::I_RfPacketSocket {

   public:
      SerialPacketSocket(Stream& iStream): mStream(&iStream) {
      }

      virtual bool send(uint8_t* iPayload, size_t iSize, uint8_t iNodeId ) {
         return mStream->write(iPayload,iSize) == iSize;
      }

      virtual int32_t receive(uint8_t* oPayload, size_t iMaxSize, uint8_t* oNodeId) {
         BT_LOG_DEBUG_AND_PARAMETER("SerialPacketSocket::receive available = ",mStream->available());
         if(mStream->available() < 1) {
            return 0;
         }
         uint8_t length = mStream->read();
         if(length == 0x01) {
            BT_LOG_DEBUG("Messages with length over 255 not supported");
            // todo cleanup/flush stream
            return 0;
         }
         if(length > iMaxSize) {
            BT_LOG_DEBUG("oPayload buffer too small");
            // todo cleanup/flush stream
            return 0;
         }

         *oNodeId = GATEWAY_NODE_ID;
         oPayload[0] = length;
         mStream->readBytes(oPayload+1, length-1);

         BT_LOG_DEBUG_AND_PARAMETER("SerialPacketSocket::receive return length = ", length);
         return length;
      }

      virtual bool available() {
         return mStream->available() > 0;
      }

      virtual void suspend() {
      }

      virtual void resume() {
      }

   private:
      Stream* mStream;
};

//-----

// Comment the next line if the board has a second hardware serial
SoftwareSerial Serial1(10, 11);

SerialPacketSocket serialPacketSocket(Serial1);
Bt::MqttSnClient client(serialPacketSocket, GATEWAY_NODE_ID, CLIENT_ID, &subscribeCallback);

void setup() {
   while (!Serial);
   Serial.begin(9600);
   Serial1.begin(9600);
   Serial << endl << endl << endl << "*** MQTT-SN PubSub example ***" << endl;
   Serial << endl;
   Serial << " - Node      = " << CLIENT_NODE_ID << endl;
   Serial << " - Pup-Topic = " << PUBLISH_TOPIC << endl;
   Serial << " - Sub-Topic = " << SUBSCRIBE_TOPIC << endl;
   Serial << "try connect ..." << endl;

   while (!client.connect(30)) {
      Serial << "... connect failed ..." << endl;
      delay(1000);
      Serial << "... retry connect ..." << endl;
   }

   Serial << "... connected" << endl;

   Serial << "subscribe" << endl;

   client.subscribe(SUBSCRIBE_TOPIC);

   Serial << "out> <Start>" << endl;

   client.publish(PUBLISH_TOPIC,"<Start>");

}

void loop() {
   client.loop();
   if (Serial.available()) {
      String out = readString();
      Serial << "out> " << out << endl;
      client.publish(PUBLISH_TOPIC,out.c_str());
      if (out == String("<quit>")) {
         quit();
      }
   }
}

void subscribeCallback(const char* iTopic, const char*  iData) {
  Serial << "in> " << iData << endl;
}

String readString() {
  Serial.setTimeout(10);
  String string = Serial.readString();
  Serial.setTimeout(1000);
  return string;
}

void quit() {
   Serial << "<quit>" << endl;
   client.disconnect();
   Serial << "Hit reboot" << endl;
   while(true){}
}

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


First iteration of moving robot with right-hand-at-the-wall maze solving logic.

#include <Servo.h>

#define STOP_BUTTON 1
#define DOWN_BUTTON 0
#define UP_BUTTON 2

#define DIST_IN_F 19
int dist_f = 0;
#define DIST_IN_L 20
int dist_l = 0;
#define DIST_IN_R 21
int dist_r = 0;

#define MOTOR_OUT_L 17
#define MOTOR_OUT_R 16

Servo wheel_left;
int speed_left = 0;
int left_zero = 94;
int left_fwd_max = 130;
int left_rw_max = 55;
int left_mapped;

Servo wheel_right;
int speed_right = 0;
int right_zero = 93;
int right_fwd_max = 55;
int right_rw_max = 130;
int right_mapped;

int speed = 0;
int dir = 0;

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);

  wheel_left.attach(MOTOR_OUT_L);
  wheel_right.attach(MOTOR_OUT_R);

  pinMode(STOP_BUTTON, INPUT_PULLUP);
  pinMode(DOWN_BUTTON, INPUT_PULLUP);
  pinMode(UP_BUTTON, INPUT_PULLUP);

  Serial.begin(9600);
}

void loop() {
  dist_f = analogRead(DIST_IN_F);
  dist_l = analogRead(DIST_IN_L);
  dist_r = analogRead(DIST_IN_R);
  dir = 0;
  dir += map(
    dist_r, 0, 300, 90, -90);

  dir += map(
      dist_f, 0, 300, 0, -90);

  left_mapped = map_speed(
    map(dir, -90, 0, 0, 100),
    left_rw_max, left_zero, left_fwd_max);
  right_mapped = map_speed(
    map(dir, 0, 90, 100, 0),
    right_rw_max, right_zero, right_fwd_max);

  // Serial.print(" left: ");
  // Serial.print(left_mapped);
  // Serial.print(" right: ");
  // Serial.println(right_mapped);

  wheel_right.write(right_mapped);
  wheel_left.write(left_mapped);

}

int map_speed(int v, int mi, int zero, int ma)
{
  if (v < 0)
    return map(v, -100, 0, mi, zero);
  else
    return map(v, 0, 100, zero, ma);
}

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


Receiver code for one way communication between two arduinos

#include <SPI.h>
#include "RF24.h"

RF24 myRadio (7, 8);
struct package
{
  int id=0;
  float temperature = 0.0;
  char  text[100] ="empty";
};

byte addresses[][6] = {"0"};

typedef struct package Package;
Package data;

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

  myRadio.begin();
  myRadio.setChannel(115);
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate( RF24_250KBPS ) ;
  myRadio.openReadingPipe(1, addresses[0]);
  myRadio.startListening();
}

void loop()
{

  if ( myRadio.available())
  {
    while (myRadio.available())
    {
      myRadio.read( &data, sizeof(data) );
    }
    Serial.print("\nPackage:");
    Serial.print(data.id);
    Serial.print("\n");
    Serial.println(data.temperature);
    Serial.println(data.text);
  }

}

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


arduino code added

arduino code added

String command = "";
boolean minus = false;
int PWM_array[2] = {0, 0};
int index = 0;

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

  // motor channels setup
  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(8, OUTPUT);
}

void loop() {
  read_command();
  go();
  delay(100);
  PWM_array[0] = 0;
  PWM_array[1] = 0;
}

void read_command() {
  while (Serial.available() > 0) {
    int c = Serial.read();
    if (isDigit(c)) {
      command += (char)c;
    } else if (c == ' ') {
      if (minus) {
        PWM_array[index] = command.toInt()*-1;
      } else {
        PWM_array[index] = command.toInt();
      }
      index += 1;
      minus = false;
      command = "";
      Serial.println(PWM_array[0]);
      Serial.println(PWM_array[1]);
    } else if (c == '-') {
      minus = true;
    }
  }
  index = 0;
}

void go() {
  // Motor channel A
  int val1 = PWM_array[0];
  if (val1 > 0) {
    digitalWrite(12, HIGH); // forward direction
  } else if (val1 == 0) {
    digitalWrite(9, HIGH);
  } else {
    digitalWrite(12, LOW); // backward direction
  }
  digitalWrite(9, LOW);  // disengage brake
  analogWrite(3, val1);  // speed

  // Motor channel B
  int val2 = PWM_array[1];
  if (val2 > 0) {
    digitalWrite(13, HIGH); // forward direction
  } else if (val1 == 0) {
    digitalWrite(8, HIGH);
  } else {
    digitalWrite(13, LOW); // backward direction
  }
  digitalWrite(8, LOW);  // disengage brake
  analogWrite(11, val2);  // speed
}

void brake() {
  digitalWrite(9, HIGH);  // engage brake of channel A
  digitalWrite(8, HIGH);  // engage brake of channel B
}

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


requests coming to YunServer do not start with a slash any more

// Possible commands are listed here:
//
// "digital/13"     -> digitalRead(13)
// "digital/13/1"   -> digitalWrite(13, HIGH)
// "analog/2/123"   -> analogWrite(2, 123)
// "analog/2"       -> analogRead(2)
// "mode/13/input"  -> pinMode(13, INPUT)
// "mode/13/output" -> pinMode(13, OUTPUT)

#include <Bridge.h>
#include <YunServer.h>

// Listen on port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server(5555);

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

  // Bridge startup
  pinMode(13,OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);

  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  server.listenOnLocalhost();
  server.begin();
}

void loop() {
  // Get clients coming from server
  YunClient client = server.accept();

  // There is a new client?
  if (client) {
    // Process request
    process(client);

    // Close connection and free resources.
    client.stop();
  }

  delay(50); // Poll every 50ms
}

void process(YunClient client) {
  // read the command
  String command = client.readStringUntil('/');

  // is "digital" command?
  if (command == "digital") {
    digitalCommand(client);
  }

  // is "analog" command?
  if (command == "analog") {
    analogCommand(client);
  }

  // is "mode" command?
  if (command == "mode") {
    modeCommand(client);
  }
}

void digitalCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/digital/13/1"
  if (client.read() == '/') {
    value = client.parseInt();
    digitalWrite(pin, value);
  }
  else {
    value = digitalRead(pin);
  }

  // Send feedback to client
  client.print(F("Pin D"));
  client.print(pin);
  client.print(F(" set to "));
  client.println(value);

  // Update datastore key with the current pin value
  String key = "D";
  key += pin;
  Bridge.put(key, String(value));
}

void analogCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/analog/5/120"
  if (client.read() == '/') {
    // Read value and execute command
    value = client.parseInt();
    analogWrite(pin, value);

    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" set to analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "D";
    key += pin;
    Bridge.put(key, String(value));
  }
  else {
    // Read analog pin
    value = analogRead(pin);

    // Send feedback to client
    client.print(F("Pin A"));
    client.print(pin);
    client.print(F(" reads analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "A";
    key += pin;
    Bridge.put(key, String(value));
  }
}

void modeCommand(YunClient client) {
  int pin;

  // Read pin number
  pin = client.parseInt();

  // If the next character is not a '/' we have a malformed URL
  if (client.read() != '/') {
    client.println(F("error"));
    return;
  }

  String mode = client.readStringUntil('\r');

  if (mode == "input") {
    pinMode(pin, INPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as INPUT!"));
    return;
  }

  if (mode == "output") {
    pinMode(pin, OUTPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as OUTPUT!"));
    return;
  }

  client.print(F("error: invalid mode "));
  client.print(mode);
}

// Possible commands are listed here:
//
// "digital/13"     -> digitalRead(13)
// "digital/13/1"   -> digitalWrite(13, HIGH)
// "analog/2/123"   -> analogWrite(2, 123)
// "analog/2"       -> analogRead(2)
// "mode/13/input"  -> pinMode(13, INPUT)
// "mode/13/output" -> pinMode(13, OUTPUT)

#include <Bridge.h>
#include <YunServer.h>

// Listen on port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server(5555);

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

  // Bridge startup
  pinMode(13,OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);

  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  server.listenOnLocalhost();
  server.begin();
}

void loop() {
  // Get clients coming from server
  YunClient client = server.accept();

  // There is a new client?
  if (client) {
    // Process request
    process(client);

    // Close connection and free resources.
    client.stop();
  }

  delay(50); // Poll every 50ms
}

void process(YunClient client) {
  // discard the first slash '/' character from the URL
  client.read();

  // read the command
  String command = client.readStringUntil('/');

  // is "digital" command?
  if (command == "digital") {
    digitalCommand(client);
  }

  // is "analog" command?
  if (command == "analog") {
    analogCommand(client);
  }

  // is "mode" command?
  if (command == "mode") {
    modeCommand(client);
  }
}

void digitalCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/digital/13/1"
  if (client.read() == '/') {
    value = client.parseInt();
    digitalWrite(pin, value);
  }
  else {
    value = digitalRead(pin);
  }

  // Send feedback to client
  client.print(F("Pin D"));
  client.print(pin);
  client.print(F(" set to "));
  client.println(value);

  // Update datastore key with the current pin value
  String key = "D";
  key += pin;
  Bridge.put(key, String(value));
}

void analogCommand(YunClient client) {
  int pin, value;

  // Read pin number
  pin = client.parseInt();

  // If the next character is a '/' it means we have an URL
  // with a value like: "/analog/5/120"
  if (client.read() == '/') {
    // Read value and execute command
    value = client.parseInt();
    analogWrite(pin, value);

    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" set to analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "D";
    key += pin;
    Bridge.put(key, String(value));
  }
  else {
    // Read analog pin
    value = analogRead(pin);

    // Send feedback to client
    client.print(F("Pin A"));
    client.print(pin);
    client.print(F(" reads analog "));
    client.println(value);

    // Update datastore key with the current pin value
    String key = "A";
    key += pin;
    Bridge.put(key, String(value));
  }
}

void modeCommand(YunClient client) {
  int pin;

  // Read pin number
  pin = client.parseInt();

  // If the next character is not a '/' we have a malformed URL
  if (client.read() != '/') {
    client.println(F("error"));
    return;
  }

  String mode = client.readStringUntil('\r');

  if (mode == "input") {
    pinMode(pin, INPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as INPUT!"));
    return;
  }

  if (mode == "output") {
    pinMode(pin, OUTPUT);
    // Send feedback to client
    client.print(F("Pin D"));
    client.print(pin);
    client.print(F(" configured as OUTPUT!"));
    return;
  }

  client.print(F("error: invalid mode "));
  client.print(mode);
}


Added joystick mouse control example in libraries/Mouse/examples

/*
  JoystickMouseControl

 Controls the mouse from a joystick on an Arduino Leonardo.
 Uses a pushbutton to turn on and off mouse control.

 The mouse movement is always relative. This sketch reads
 two analog inputs that range from 0 to 1023 (or less on either end)
 and translates them into ranges of -60 to 60.
 The sketch assumes that the joystick resting values are around the
 middle of the range, but that they vary within a threshold.

 WARNING:  When you use the Mouse.move() command, the Arduino takes
 over your mouse!  Make sure you have control before you use the command.
 This sketch includes a pushbutton to toggle the mouse control state, so
 you can turn on and off mouse control.

 created 15 Sept 2011
 by Tom Igoe

 this code is in the public domain

 */

// set pin numbers for switch, joystick axes, and LED:
const int switchPin = 6;      // switch to turn on and off mouse control
const int xAxis = A1;         // joystick X axis
const int yAxis = A2;         // joystick Y axis
const int ledPin = 5;         // Mouse control LED

// parameters for reading the joystick:
int range = 12;               // output range of X or Y movement
int responseDelay = 2;       // response delay of the mouse, in ms
int threshold = range/4;      // resting threshold
int center = range/2;         // resting position value
int minima[] = {
  1023, 1023};                // actual analogRead minima for {x, y}
int maxima[] = {
  0,0};                       // actual analogRead maxima for {x, y}
int axis[] = {
  xAxis, yAxis};              // pin numbers for {x, y}
int mouseReading[2];          // final mouse readings for {x, y}

boolean mouseIsActive = false;    // whether or not to control the mouse
int lastSwitchState = LOW;        // previous switch state

void setup() {
  pinMode(switchPin, INPUT);       // the switch pin
  pinMode(ledPin, OUTPUT);         // the LED pin
}

void loop() {
  // read the switch:
  int switchState = digitalRead(switchPin);
  // if it's changed and it's high, toggle the mouse state:
  if (switchState != lastSwitchState) {
    if (switchState == HIGH) {
      mouseIsActive = !mouseIsActive;
  // turn on LED to indicate mouse state:
  digitalWrite(ledPin, mouseIsActive);
    }
  }
  // save switch state for next comparison:
  lastSwitchState = switchState;

// read and scale the two axes:
  int xReading = readAxis(0);
  int yReading = readAxis(1);

// if the mouse control state is active, move the mouse:
  if (mouseIsActive) {
    Mouse.move(xReading, yReading, 0);
  }
  delay(responseDelay);
}

/*
  reads an axis (0 or 1 for x or y) and scales the
  analog input range to a range from 0 to <range>
*/

int readAxis(int axisNumber) {
  int distance = 0;    // distance from center of the output range

  // read the analog input:
  int reading = analogRead(axis[axisNumber]);

// of the current reading exceeds the max or min for this axis,
// reset the max or min:
  if (reading < minima[axisNumber]) {
    minima[axisNumber] = reading;
  }
  if (reading > maxima[axisNumber]) {
    maxima[axisNumber] = reading;
  }

  // map the reading from the analog input range to the output range:
  reading = map(reading, minima[axisNumber], maxima[axisNumber], 0, range);

 // if the output reading is outside from the
 // rest position threshold,  use it:
  if (abs(reading - center) > threshold) {
    distance = (reading - center);
  }

  // the Y axis needs to be inverted in order to
  // map the movemment correctly:
  if (axisNumber == 1) {
    distance = -distance;
  }

  // return the distance for this axis:
  return distance;
}

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


Update CoinWallet.ino

Update CoinWallet.ino

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


Add documentation and printing

Add documentation and printing

Simple updates to assist in readability and debugging.

LIDAR Data Extraction/LidarCommands/Currently Used/lidar_servo_test/lidar_servo_test.ino

error: pathspec 'LIDAR' did not match any file(s) known to git
error: pathspec 'Data' did not match any file(s) known to git
error: pathspec 'Extraction/LidarCommands/Currently' did not match any file(s) known to git
error: pathspec 'Used/lidar_servo_test/lidar_servo_test.ino' did not match any file(s) known to git


Fixed merge conflict.

Fixed merge conflict.

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/FirstBuild/pizzaduino.git/'


操作コマンドが増えたことに合わせてサンプルを修正

操作コマンドが増えたことに合わせてサンプルを修正

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/rmswimkktt/RedLightSenderNEC.git/'


goAhead detection

goAhead detection

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


added multiple locations

added multiple locations

error: pathspec 'Microcontroller' did not match any file(s) known to git
error: pathspec 'Code/libraries/my_lib/examples/base_uno_w_lib/base_uno_w_lib.ino' did not match any file(s) known to git


CamelCasingTillYouDrop

CamelCasingTillYouDrop

void bas(int offset)
{

                                                                /* Print a message to the LCD.*/
  lcd.setCursor(offset, 0);                                     /* where the cursur wil be*/
  lcd.print(line1.substring((offset<0)? offset * -1: 0));       /* The stubstring is a function that removes characters from your string so it works negative('removing') by itself,
                                                                 * if you'd give it a nagative value it can't work, so if the given variable, called offset(coming from the startposition)
                                                                 * is smaller than 0, it will make it positive for the substring. If not it will make it 0, meaning it wont delete characters
                                                                 * from the string(line). Please mind that substring is one word, not two! (sub - string). So no camelcasing here */
  lcd.setCursor(offset, 1);                                     /* (note: line 1 is the second row, since counting begins with 0):*/
  lcd.print(line2.substring((offset<0)? offset * -1: 0));       /* same as explanation above O lcd.print line 1''*/
  delay(700);
}

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


implemented backwards / all motor control

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


added arduino code to talk to PCA

added arduino code to talk to PCA

/*
 Code to talk to our PCA9685 PWM multiplexer using our arduino via I2c

//sgillen - stole a lot of this code from this adafruit repo https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library for a board they sell with this chip on it.
//had to change the mode flags to get it to work using the internal oscilator

*/

#include <Wire.h>

#define PCA9685_MODE1 0x0
#define PCA9685_PRESCALE 0xFE

#define PCA9Address 0xFF // Device address in which is also included the 8th bit for selecting the mode, read in this case.
#define allCall 0xE0 //address for "all call" which should turn all LEDs on

#define LED0_ON_L 0x6
#define LED0_ON_H 0x7
#define LED0_OFF_L 0x8
#define LED0_OFF_H 0x9

int freq = 1400; //pretty arbitrary, max is 1600

uint8_t read8(uint8_t addr) {
  Wire.beginTransmission(PCA9Address);
  Wire.write(addr);
  Wire.endTransmission();

  Wire.requestFrom((uint8_t)PCA9Address, (uint8_t)1);
  return Wire.read();
}

void write8(uint8_t addr, uint8_t d) {
  Wire.beginTransmission(PCA9Address);
  Wire.write(addr);
  Wire.write(d);
  Wire.endTransmission();
}

void setup() {
  Wire.begin(); // Initiate th1e Wire library
  Serial.begin(9600);
  delay(100);

  Serial.print("Attempting to set freq ");
  Serial.println(freq);
  freq *= 0.9;  // Correct for overshoot in the frequency setting (see issue #11).
  float prescaleval = 25000000;
  prescaleval /= 4096;
  prescaleval /= freq;
  prescaleval -= 1;

  uint8_t prescale = floor(prescaleval + 0.5);

  uint8_t oldmode = read8(PCA9685_MODE1);
  uint8_t oldmode2 = read8(PCA9685_MODE1 + 1);

  Serial.println("old mode was");
  Serial.println(oldmode);
  Serial.println(oldmode2);

  uint8_t newmode = 0x21;
  write8(PCA9685_MODE1, newmode); // go to sleep
  write8(PCA9685_PRESCALE, prescale); // set the prescaler
  //write8(PCA9685_MODE1, oldmode);
  //delay(5);
  //write8(PCA9685_MODE1, oldmode | 0xa1);

  oldmode = read8(PCA9685_MODE1);
  oldmode2 = read8(PCA9685_MODE1 + 1);

  Serial.println("new mode is");
  Serial.println(oldmode);
  Serial.println(oldmode2);

}
void loop() {

  uint16_t on = 1;
  uint16_t off = 2000;

  Wire.beginTransmission(PCA9Address);
  Wire.write(LED0_ON_L+4);
  Wire.write(on);
  Wire.write(on>>8);
  Wire.write(off);
  Wire.write(off>>8);
  Wire.endTransmission();

  delay(1000);

  Serial.println(read8(LED0_ON_L +4));
  Serial.println(read8(LED0_ON_H+4));

  Serial.println();

  Serial.println(read8(LED0_OFF_L+4));
  Serial.println(read8(LED0_OFF_H+4));

}

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


test sim800

test sim800

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/ada/ws.git/'


added teensy code

added teensy code

int led = 14;

void setup() {

Serial.begin(19200);

pinMode(led, OUTPUT);

}
String inData = "";

void loop() {

while (Serial.available() > 0) {
  char received = Serial.read();
  inData.concat(received);

    if (received == '\n') {
    }
}
if (inData == "led\n") {
  digitalWrite(led, HIGH);
  inData == "";
  }
if (inData == "ledoff\n") {
  digitalWrite(led, LOW);
  inData == "";
  }
}

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


Blink LED on Jeenod port 4

Blink LED on Jeenod port 4

/**
 * Blink an LED on the DIO pin of JeeNode header 4.
 * This uses standard Arduino pin assignments with
 * no power management.
 *
 * 2015-08-14 <bill@jamimi.com> http://opensource.org/licenses/mit-license.php
 */

#define LED_PIN 7

void setup() {
  pinMode(LED_PIN, OUTPUT);
}

void loop () {
  digitalWrite(LED_PIN, 1);
  delay(50);
  digitalWrite(LED_PIN, 0);
  delay(10000);
}

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


No Interrupts at all

No Interrupts at all

Goes back to checking for releasing solenoids, as interrupts caused
freezes.
Has a heartbeat (red LED).
Fixed an error in setShooterAngle where servo 3 couldn't be controlled.
Offsets were re-done.

//ENGR 421 Team 4
//2013

//Written by Dean Reading

/*******************************************************************************************/
// Changelog
/*******************************************************************************************
 * Version control can now be handled by GitHub...
 *
 * Version 0.2
 * Included a timeout when waiting for a character.
 * Added the sendMessage function to communicate with laptop.
 * Added in error messages for invalid command IDs, shooter numbers and angles.
 * Added in lower and upper limits to the angles that can be used.
 *
 *
 * Version 0.1
 * Includes command receiving and execution, with 'Aim' and 'Shoot' commands.
 * <angle> input is a byte that should range from 0 to 180, with 90 being pointing forward.
 * All DC motor pins are set up and PWM is created.
 * setShooterAngle, releaseBall and checkSolenoids functions are included.
 * 'GO' & 0x80 is sent to indicate game start.
 *
 *
 */

/*
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 // Pre-Start
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 */

// Pins
/*******************************************************************************************/
//Motors
#define pinMotor1 5
#define pinMotor2 2
#define pinMotor3 3

#define pinServo1 46
#define pinServo2 45
#define pinServo3 44

#define pinSolenoid1 4
#define pinSolenoid2 6
#define pinSolenoid3 7

//Interface Panel
#define pinPot A0

#define pinLEDY1 26
#define pinLEDY2 24
#define pinLEDY3 22

#define pinLEDR 30
#define pinLEDB 32
#define pinLEDG 28

#define pinButton1 20
#define pinButton2 19
#define pinButton3 18

#define pinConfig1 17
#define pinConfig2 21

//Arbiter
#define pinArbiter 52

// Programmable Parameters
/*******************************************************************************************/
#define DEBUG 1 //Defining DEBUG turns ON debugging messages

#define killMsgSend 0 //Prevents the arduino from sending the functional messages to the laptop

#define commsTimeout 200 //The maximum time that a received serial command can take, in mS

#define ballReleaseTime1 30 //The time that the solenoid needs to be activated for to release a ball, in mS
#define ballReleaseTime2 24
#define ballReleaseTime3 22

//#define ballReleaseInt floor((ballReleaseTime1*125)/8) //The number of 64uS needed to get to ballReleaseTime

#define angleLowest 65 //The minimum allowable angle
#define angleHighest 115 //The maximum allowable angle

#define motorLevel1 202 //PWM levls for the motors
#define motorLevel2 169
#define motorLevel3 206

#define offset1 -2 //offset angles for each servo
#define offset2 -12
#define offset3 -5

// Libraries & Objects
/*******************************************************************************************/
#include <Servo.h>
Servo servo1; //Declare 3 instances of servo objects
Servo servo2;
Servo servo3;

//Function Prototypes
void sendMessage (byte CMD,byte in1 = 255, byte in2 = 255, byte in3 = 255);

// Constants
/*******************************************************************************************/
byte commandLength[255]; //The number of data bytes for each command type for serial comms
const byte solenoidPins[] = {
  0,pinSolenoid1,pinSolenoid2,pinSolenoid3}; //A map for the solenoid pins
const byte motorPins[] = {
  0,pinMotor1,pinMotor2,pinMotor3}; //A map for the solenoid pins
const byte ledPinsY[] = {
  0,pinLEDY1,pinLEDY2,pinLEDY3}; //A map for the yellow LEDs
const byte ledPins[] = {
  0,pinLEDR,pinLEDB,pinLEDG}; //A map for the R B and G LEDs
const byte buttonPins[] = {
  0,pinButton1,pinButton2,pinButton3}; //A map for the three momentary buttons

const byte OCIE4[] = {
  0, OCIE4A, OCIE4B, OCIE4C}; //A map for the locations of the output compare interrupt enable bit locations
volatile byte *ptrOCR4H[] = {
  0, &OCR4AH, &OCR4BH, &OCR4CH}; //Maps for the locations of the high and low output compare value byte locations
volatile byte *ptrOCR4L[] = {
  0, &OCR4AL, &OCR4BL, &OCR4CL};
volatile boolean buttonPressed[] = {
  0, 0, 0, 0};
unsigned long lastButtonPress; //Saves the last time that a button was pressed

const byte motorLevel[] = {
  0,motorLevel1,motorLevel2,motorLevel3}; //Individual PWM signal levels for each motor
const unsigned int ballReleaseTime[] = {
  0, ballReleaseTime1, ballReleaseTime2, ballReleaseTime3};
char offset[] = {
  0,offset1,offset2,offset3}; //servo offsets

// Global Variables
/*******************************************************************************************/
byte commandID=0;
byte bytesRemaining; //
char buffer[5];
unsigned long timer; //A multi-purpose timer

int counter=0;

unsigned long ballReleaseTimer[4]; //Saves when the last ball was released.
boolean ballReleasing[] = {
  0,0,0,0}; //Indicates whether we are in the process of releasing a ball

/*
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 // Setup
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 */
void setup(){

  // Constants
  /*******************************************************************************************/
  commandLength[1]=2;
  commandLength[2]=1;
  commandLength[3]=2;

  commandLength[0x80]=0;
  commandLength[0x81]=0;
  commandLength[0xE0]=1;
  commandLength[0xE1]=1;
  commandLength[0xE2]=2;

  // Pin Modes and Setup
  /*******************************************************************************************/
  for (byte i=1;i<4;i++){
    pinMode(motorPins[i],OUTPUT);
    pinMode(solenoidPins[i],OUTPUT);

    analogWrite(motorPins[i],motorLevel[i]); //Set the PWM signal for the motor
    digitalWrite(solenoidPins[i],LOW); //Ensure the solenoid is low

    pinMode(ledPins[i],OUTPUT); //Set the LED pins as outputs
    pinMode(ledPinsY[i],OUTPUT);
    pinMode(buttonPins[i],INPUT_PULLUP); //Set the button pins as inputs pulled high
  }

  //Set the config switch pins as inputs pulled high
  pinMode(pinConfig1,INPUT_PULLUP);
  pinMode(pinConfig2,INPUT_PULLUP);
  pinMode(pinArbiter,INPUT_PULLUP);

  // Other Setup Code
  /*******************************************************************************************/
  Serial.begin(9600);
  Serial.setTimeout(commsTimeout);
#if DEBUG==1
  Serial.println("Arduino Start");
#endif

  //Attach the servo objects
  servo1.attach(pinServo1,429,2571); //Include the maximum and minimum pulse widths.
  servo2.attach(pinServo2,429,2571);
  servo3.attach(pinServo3,429,2571);

  //Run a test pattern on the LEDs
  float num = 200; //mS
  for (byte i=0;i<6;i++){
    for (byte j=1;j<4;j++){
      digitalWrite(ledPinsY[j],HIGH);
      delay(num);
      num=num*0.93;
      digitalWrite(ledPinsY[j],LOW);
    }
    for (byte j=3;j>0;j--){
      digitalWrite(ledPins[j],HIGH);
      delay(num);
      num=num*0.93;
      digitalWrite(ledPins[j],LOW);
    }
  }

  //Run a servo test
  for (byte k=1; k<4; k++){
    setShooterAngle(k,angleLowest);
  }
  delay(500);
  for (byte k=1; k<4; k++){
    setShooterAngle(k,angleHighest);
  }
  delay(500);
  for (byte k=1; k<4; k++){
    setShooterAngle(k,angleLowest);
    delay(167);
  }
  delay(167);
  for (byte k=3; k>0; k--){
    setShooterAngle(k,angleHighest);
    delay(167);
  }
  delay(167);

  //Set all servos to 90 degrees
  for (byte k=1; k<4; k++){
    setShooterAngle(k,90);
  }

  //Wait until 'Game Start' signal is sent from the arbiter
#if DEBUG==1
  Serial.println("Waiting for arbiter to activate");
#endif
  while(digitalRead(pinArbiter)==HIGH){  //Wait until the pin goes low
    while (Serial.available()) {
      Serial.read(); //Clear any serial characters.
    }
  }
  //Send 'Game Start' message to laptop
  sendMessage(0x80);
#if DEBUG==1
  Serial.println("GAME START received");
#endif

}

/*
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 // Loop
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 */
void loop(){
  checkSerial(); //Check for incoming commands, and execute them

  checkSolenoids(); //Check to see if any solenoids need deactivating

  //Increment a counter for the heartbeat
  counter++;
  if (counter>=15000){
    counter=0;
    digitalWrite(ledPins[1],!digitalRead(ledPins[1]));
  }

  //Check if the arbiter has signalled that the game is over
  if(digitalRead(pinArbiter)==HIGH){
    sendMessage(0x81);
#if DEBUG==1
    Serial.println("GAME STOP received");
#endif
    while(digitalRead(pinArbiter)==HIGH){
      while (Serial.available()) {
        Serial.read(); //Clear any serial characters.
      }
    } //Wait until the pin goes low
    sendMessage(0x80);
#if DEBUG==1
    Serial.println("GAME START received");
#endif
  }

}

/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
/*checkSerial
/*******************************************************************************************/
void checkSerial(){
  if (Serial.available()) {
    //Search for the initization sequence
    if (Serial.read()=='G'){
      timer=millis()+commsTimeout;
      while (!Serial.available()){ //Wait until another character is available
        if (millis()>timer) { //Exit the loop if we don't receive another character
          break;
        }
      }
      if (Serial.peek()=='O'){
        Serial.read(); //Remove the 'O' from the serial buffer.
        //Initialization Sequence detected!

#if DEBUG==1
        Serial.println("'G O' found!");
#endif

        timer=millis()+commsTimeout;
        while (!Serial.available()){ //Wait until another character is available
          if (millis()>timer) { //Exit the loop if we don't receive another character
            break;
          }
        }
        commandID=Serial.read(); //This byte is the command ID

        //Now, read the required number of data bytes into the array 'buffer'
        Serial.readBytes(buffer,commandLength[commandID]);

        //Execute the command
        executeCommand();
      }
    }
  }
}

/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
/*executeCommand
/*******************************************************************************************/
//This function executes whatever the necessary action is, as told by the command and data
//received through serial comms
void executeCommand(){
  switch (commandID){
  case 1:
    //Aim shooter <db1> to angle defined by <db2>
    setShooterAngle(buffer[0],(byte) buffer[1]);
    break;
  case 2:
    //Release a ball on shooter <db1>
    releaseBall(buffer[0]);
    break;
  case 3:
    //Change servo angle offset
    offset[buffer[0]]=(char) buffer[1]; //Changed to a signed byte
  default:
#if DEBUG==1
    Serial.print("Unrecognized command ID: ");
    Serial.println(commandID);
#endif
    //Send error feedback to laptop
    sendMessage(0xE0,commandID);
    digitalWrite(ledPinsY[1],HIGH); //Light up the error LED
  }
}

/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
/*setShooterAngle
/*******************************************************************************************/
//This function changes the servo signal for shooter <shooterNum> to the angle defined by
// <angle>.  <angle> is a byte that ranges from 180, which maps from 900 to 2100 mS.
void setShooterAngle(byte shooterNum, byte angle){

  //  unsigned int output =   (((unsigned int) angle-1)*137)/29+900; // 137/29 = 4.724 = 1200/254, the scaling factor to get to uS

#if DEBUG==1
  Serial.print("Setting shooter ");
  Serial.print(shooterNum);
  Serial.print(" to ");
  Serial.println(angle);
#endif

  //Set the servo output.  Use a switch statement to use the correct servo object.
  if (angle<angleLowest || angle>angleHighest) {
    //The angle is invalid! Don't move the shooter, and send error feedback
#if DEBUG==1
    Serial.print("Invalid Angle: ");
    Serial.println(angle);
#endif
    sendMessage(0xE2,shooterNum,angle);
    digitalWrite(ledPinsY[3],HIGH); //Light up the error LED
  }
  else{
    //Apply the angle offset
    angle += offset[shooterNum];
    switch (shooterNum) {
    case 1:
      servo1.write(angle);
      break;
    case 2:
      servo2.write(angle);
      break;
    case 3:
      servo3.write(angle);
      break;
    default:
#if DEBUG==1
      Serial.print("Unrecognized shooter Num: ");
      Serial.println(shooterNum);
#endif
      //Send unrecognized shooter num feedback to laptop
      sendMessage(0xE1,shooterNum);
      digitalWrite(ledPinsY[2],HIGH); //Light up the error LED
    }
  }
}

/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
/*releaseBall
/*******************************************************************************************/
//This function releases one BB (hopefully) from shooter <shooterNum>
void releaseBall(byte shooterNum) {
#if DEBUG==1
  Serial.print("Releasing ball from shooter: ");
  Serial.println(shooterNum);
#endif

  if (shooterNum<1 || shooterNum>3) { //Check that the shooter number is valid
    //Shooter number is invalid
#if DEBUG==1
    Serial.print("Unrecognized shooter Num: ");
    Serial.println(shooterNum);
#endif
    //Send unrecognized shooter num feedback to laptop
    sendMessage(0xE1,shooterNum);
    digitalWrite(ledPinsY[2],HIGH); //Light up the error LED
  }
  else{
    digitalWrite(solenoidPins[shooterNum],HIGH); //Activate the solenoid: open the passage
    //digitalWrite(ledPins[shooterNum],HIGH); //Turn on the respective LED

    ballReleaseTimer[shooterNum]=millis()+ballReleaseTime[shooterNum]; //Set the timer for deactivating the solenoid
    ballReleasing[shooterNum]=1; //Indicate that we are releasing a ball
  }
}

/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
/*checkSolenoids
/*******************************************************************************************/
//Check whether there are any solenoids that need to be deactivated
void checkSolenoids(){
  for (byte i=1;i<4;i++){ //Check all 3 solenoids
    if (ballReleasing[i]==1){ //If a ball is currently being released
      if (millis()>ballReleaseTimer[i]){ //If enough time has passed
        digitalWrite(solenoidPins[i],LOW); //Deactivate the solenoid: close the passage
        //digitalWrite(ledPins[i],LOW); //Turn off the respective LED

        ballReleasing[i]=0; //Indicate that the ball is no longer being released
#if DEBUG==1
        Serial.print("Deactivating solenoid: ");
        Serial.println(i);
#endif
      }
    }
  }
}

/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
/*sendMessage
/*******************************************************************************************/
//This function sends commands to the laptop.  It has optional inputs.
void sendMessage (byte CMD,byte in1, byte in2, byte in3) {
#if killMsgSend==0
  Serial.print("GO");
  if (commandLength[CMD]>0){
    Serial.print(in1);
    if (commandLength[CMD]>1){
      Serial.print(in2);
      if (commandLength[CMD]>2){
        Serial.print(in3);
      }
    }
  }
  Serial.println(); //Print a new line character
#endif
}

/*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
/*Timer Interrupt Service Routines
/*******************************************************************************************/
ISR(TIMER4_COMPA_vect){
  //Turn off the interrupts
  TIMSK4 &= 255 - _BV(OCIE4A);

  digitalWrite(solenoidPins[1],LOW); //Deactivate the solenoid: close the BB passage
  digitalWrite(ledPins[1],LOW); //Turn off the respective LED
#if DEBUG==1
  Serial.println("Deactivating solenoid: 1");
#endif
}

ISR(TIMER4_COMPB_vect){
  //Turn off the interrupts
  TIMSK4 &= 255 - _BV(OCIE4B);

  digitalWrite(solenoidPins[2],LOW); //Deactivate the solenoid: close the BB passage
  digitalWrite(ledPins[2],LOW); //Turn off the respective LED
#if DEBUG==1
  Serial.println("Deactivating solenoid: 2");
#endif
}

ISR(TIMER4_COMPC_vect){
  //Turn off the interrupts
  TIMSK4 &= 255 - _BV(OCIE4C);

  digitalWrite(solenoidPins[3],LOW); //Deactivate the solenoid: close the BB passage
  digitalWrite(ledPins[3],LOW); //Turn off the respective LED
#if DEBUG==1
  Serial.println("Deactivating solenoid: 3");
#endif
}

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


hmm, the endstops seem to be somewhat considered …

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/'


add operator button arduino sketch

add operator button arduino sketch

const int buttons[] = {2, 3, 4, 5, 6, 7}

void setup() {
  for(int i=0; i < 6; i++)
  {
    pinMode(buttons[i], INPUT);
  }
}

void loop() {
  for(int i=0; i<6; i++)
  {
    s = digitalRead(buttons[i]);

    // button is on
    if(s == HIGH)
    {
      Serial.println(i+1);
      delay(1000); // debounce
    }

  }
}

error: pathspec 'control-scheme/operator/operator.ino' did not match any file(s) known to git


Optimise data types

Optimise data types

Also show how to use `sizeof` operator properly

fatal: remote error: upload-pack: not our ref e64e92b2114f22f7289b0c94bae99c4f45a915f9
fatal: the remote end hung up unexpectedly


ok, at least we can listen to interrupts …


arduino sketch with blinking led

arduino sketch with blinking led

/* TODO */

#include <Bridge.h>
#include <Console.h>
#include "MsTimer2.h"

// pins
const byte firePin = 2;
const byte failInPin = 3;
const byte failOutPin = 4;
const byte statusPin = 13;

void setup() {
  // external pullup
  pinMode(firePin, INPUT);
  // internal pullup
  pinMode(failInPin, INPUT_PULLUP);
  // relay normally open with external pullup
  pinMode(failOutPin, OUTPUT);
  // internal LED
  pinMode(statusPin, OUTPUT);

  Bridge.begin();
  Console.begin();
  Console.println("console started");
}

void toggleLed() {
  // change output of led
  static byte out = HIGH;
  digitalWrite(statusPin, out);
  out = !out;
}

// status codes
const byte ALARM = 0;
const byte FAILURE = 1;
const byte FAILURE_INTERNET = 2;
const byte FAILURE_TWILIO = 3;
const byte OK = 10;

byte getState(){
  // Get current state and return it.
  // FAILURE_INTERNET: failure internet - TODO
  // FAILURE_TWILIO: failure twilio   - TODO
  byte fire = digitalRead(firePin);
  byte failure = digitalRead(failInPin);
  delay(50); // debounce
  if (fire == 1 && digitalRead(firePin) == 1) return ALARM;
  else if (failure == 0 && digitalRead(failInPin) == 0) return FAILURE;
  else return OK;
}

void loop() {
  static byte currentState;
  static byte previousState = 10;
  // get current state
  currentState = getState();
  if (currentState != previousState) {
    switch (currentState) {
      case ALARM:
        Console.println("BRANN");
        MsTimer2::stop();
        MsTimer2::set(100, toggleLed);
        MsTimer2::start();
        break;

      case FAILURE:
        Console.println("FEIL");
        MsTimer2::stop();
        MsTimer2::set(1000, toggleLed);
        MsTimer2::start();
        break;

      case OK:
        Console.println("OK");
        MsTimer2::stop();
        digitalWrite(statusPin, LOW);
    } // end switch state
  } // end if state change
  previousState = currentState;
}

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


Add WiFiNINA, Arduino MKR WiFi 1010 support

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

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

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

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

 *************************************************************
  This example shows how to use Arduino MKR 1010
  to connect your project to Blynk.

  Note: This requires WiFiNINA library
    from http://librarymanager/all#WiFiNINA

  Feel free to apply it to any other example. It's simple!
 *************************************************************/

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

#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

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

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

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

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


Added test example sketch

Added test example sketch

/**************************************************************************/
/*!
    @file     DMXFadeTest.ino
    @author   Claude Heintz
    @license  BSD (see LXESP8266DMX LICENSE)
    @copyright 2015 by Claude Heintz

    Simple Fade test of RESP8266 DMX Driver
    @section  HISTORY

    v1.0 - First release
*/
/**************************************************************************/
#include <LXESP8266UARTDMX.h>

// LX8266DMXOutput instance
LX8266DMXOutput* dmx_output = new LX8266DMXOutput();

uint8_t level = 0;

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);
  Serial.begin(9600);
  Serial.setDebugOutput(1); //use uart0 for debugging

  delay(1000);        //avoid boot print??
  dmx_output->start();
}

/************************************************************************

  The main loop fades the levels of addresses 7 and 8 to full

*************************************************************************/

void loop() {
 dmx_output->setSlot(7,level);
 dmx_output->setSlot(8,level);
 delay(50);
 level++;
}

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


COH-66: basic serial test done and OK on REV2.

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/Denzo77/OTRadioLink.git/'


Create dragino_reco_temp.ino

Create dragino_reco_temp.ino

#include <SPI.h>
#include <PubSubClient.h>
#include <YunClient.h>
#include <string.h>
#include "DHT.h"

unsigned long time;
//int out2 = 2;
int out3 = 3;
int out4 = 4;
int out6 = 6;

#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

char message_buff[100];
char message_buff2[100];

////Please here paste info from "devinfo"////////////////
#define IOTUSERNAME "iiiiiiiii"
#define IOTPASSWORD "ppppppp"
#define IOTDEVICE "dddddddd"
#define USERNAME "uuuuuuuuu"
/////////////////////////////////////////////////////////

String id_sensor = "dragino1";

////from here dont' modify anything///////////////////////////////////////////////

#define TOPIC  "redlibre/iot/"USERNAME"/"IOTDEVICE"/"IOTUSERNAME"/iot/control/"
#define STATUS "redlibre/iot/"USERNAME"/"IOTDEVICE"/"IOTUSERNAME"/status/"
#define IOTID USERNAME"/"IOTDEVICE

IPAddress server(190, 97, 169, 126);

void callback(char* topic, byte* payload, unsigned int length);

YunClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);

void callback(char* topic, byte* payload, unsigned int length) {

  int i = 0;
   for(i=0; i<length; i++) {
    message_buff[i] = payload[i];
  }
  message_buff[i] = '\0';

  String msgString = String(message_buff);

/*if (msgString.equals("gpio2on")) {
  digitalWrite(out2, HIGH);}

else if (msgString.equals("gpio2off")) {
  digitalWrite(out2, LOW);}

else */

if (msgString.equals("gpio3on")) {
  digitalWrite(out3, HIGH);}

else if (msgString.equals("gpio3off")) {
  digitalWrite(out3, LOW);}

else if (msgString.equals("gpio4on")) {
  digitalWrite(out4, HIGH);}

else if (msgString.equals("gpio3off")) {
  digitalWrite(out4, LOW);}

else if (msgString.equals("gpio6on")) {
  digitalWrite(out6, HIGH);}

else if (msgString.equals("gpio6off")) {
  digitalWrite(out6, LOW);}

}

long lastReconnectAttempt = 0;

boolean reconnect() {
  if (client.connect(IOTID, IOTUSERNAME, IOTPASSWORD)) {

    client.publish(STATUS,"hello - re-authenticated!!");
     client.subscribe(TOPIC);
  }
  return client.connected();
}

void setup()
{
  client.setServer(server, 1883);
  client.setCallback(callback);
  Bridge.begin();
  lastReconnectAttempt = 0;

  //pinMode(out2, OUTPUT);
  pinMode(out3, OUTPUT);
  pinMode(out4, OUTPUT);
  pinMode(out6, OUTPUT);

dht.begin();
}

void loop()
{
 float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (!client.connected()) {
    long now = millis();
    if (now - lastReconnectAttempt > 5000) {
      lastReconnectAttempt = now;
      // Attempt to reconnect
      if (reconnect()) {
        lastReconnectAttempt = 0;
      }
    }
  } else {
    // Client connected

if (millis() > (time + 15000)) {
       time = millis();

String pubString = "" + String(t) + "," + String(h) + "," + id_sensor + "";
   pubString.toCharArray(message_buff2, pubString.length()+1);
   client.publish(STATUS,message_buff2);

}
    client.loop();
  }

}

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


small changes

small changes

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


adding in the full source with bargraph.

#include <QueueArray.h>

#include <Wire.h> // Include the I2C library (required)
#include <SparkFunSX1509.h> // Include SX1509 library

// SX1509 I2C address (set by ADDR1 and ADDR0 (00 by default):
const byte SX1509_ADDRESS = 0x3E;  // SX1509 I2C address
SX1509 io; // Create an SX1509 object to be used throughout

// bargraph helper variables
int seq_1_current = 0;  // current led in sequence 1
const int num_led = 15; // total number of leds in bar graph

// SX1509 pin definitions for the leds on the graph:
const byte SX1509_BAR_01 = 0;
const byte SX1509_BAR_02 = 1;
const byte SX1509_BAR_03 = 2;
const byte SX1509_BAR_04 = 3;
const byte SX1509_BAR_05 = 4;
const byte SX1509_BAR_06 = 5;
const byte SX1509_BAR_07 = 6;
const byte SX1509_BAR_08 = 7;
const byte SX1509_BAR_09 = 8;
const byte SX1509_BAR_10 = 9;
const byte SX1509_BAR_11 = 10;
const byte SX1509_BAR_12 = 11;
const byte SX1509_BAR_13 = 12;
const byte SX1509_BAR_14 = 13;
const byte SX1509_BAR_15 = 14;

// for the sound board
#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"

#include <Adafruit_NeoPixel.h>

// for led triggers
#define HIGH 0x1
#define LOW  0x0

// neopixel pins / setup
#define NEO_POWER 2 // for cyclotron and powercell
Adafruit_NeoPixel powerStick = Adafruit_NeoPixel(48, NEO_POWER, NEO_GRB + NEO_KHZ800);

#define NEO_NOSE 3 // for nose of wand
Adafruit_NeoPixel noseJewel = Adafruit_NeoPixel(7, NEO_NOSE, NEO_GRB + NEO_KHZ800);

#define NEO_WAND 4 // for nose of wand
Adafruit_NeoPixel wandLights = Adafruit_NeoPixel(4, NEO_WAND, NEO_GRB + NEO_KHZ800);

// LED indexes into the neopixel powerstick chain for the cyclotron
const int powercellLedCount = 14;                                         // total number of led's in the animation
const int powercellIndexOffset = 1;                                       // first led offset into the led chain for the animation

int c1Start = 16;
int c1End = 22;
int c2Start = 23;
int c2End = 29;
int c3Start = 30;
int c3End = 36;
int c4Start = 37;
int c4End = 43;
int ventStart = 44;
int ventEnd = 47;

// inputs for switches and buttons
const int THEME_SWITCH = 5;
const int STARTUP_SWITCH = 6;
const int SAFETY_SWITCH = 7;
const int FIRE_BUTTON = 8;

// soundboard pins and setup
#define SFX_RST 9
#define SFX_RX 10
#define SFX_TX 11
const int ACT = 12;    // this allows us to know if the audio is playing

SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);
Adafruit_Soundboard sfx = Adafruit_Soundboard( &ss, NULL, SFX_RST);

// ##############################
// available options
// ##############################
const bool useGameCyclotronEffect = true;   // set this to true to get the fading previous cyclotron light in the idle sequence
const bool useCyclotronFadeInEffect = false; // Instead of the yellow alternate flashing on boot/vent this fades the cyclotron in from off to red
const bool useDialogTracks = true;          // set to true if you want the dialog tracks to play after firing for 5 seconds

// Possible Pack states
bool powerBooted = false;   // has the pack booted up
bool isFiring = false;      // keeps track of the firing state
bool shouldWarn = false;    // track the warning state for alert audio
bool shuttingDown = false;  // is the pack in the process of shutting down
bool poweredDown = true;    // is the pack powered down
bool venting = false;       // is the pack venting

// physical switch states
bool startup = false;
bool theme = false;
bool safety = false;
bool fire = false;
bool warning = false;

// audio track names on soundboard
char startupTrack[] =   "T00     WAV";
char blastTrack[] =     "T01     WAV";
char endTrack[] =       "T02     WAV";
char idleTrack[] =      "T03     WAV";
char shutdownTrack[] =  "T04     WAV";
char clickTrack[] =     "T05     WAV";
char chargeTrack[] =    "T06     WAV";
char warnTrack[] =      "T07     WAV";
char ventTrack[] =      "T08     WAV";
char texTrack[] =       "T09     WAV";
char choreTrack[] =     "T10     WAV";
char toolsTrack[] =     "T11     WAV";
char listenTrack[] =    "T12     WAV";
char thatTrack[] =      "T13     WAV";
char neutronizedTrack[]="T14     WAV";
char boxTrack[] =       "T15     WAV";
char themeTrack[] =     "T16     OGG";

// this queue holds a shuffled list of dialog tracks we can pull from so we don't
// play the same ones twice
QueueArray <int> dialogQueue;
int numDialog = 7;

// timer trigger times/states
unsigned long firingStateMillis;
const int firingWarmWaitTime = 5000;  // how long to hold down fire for lights to speed up
const int firingWarnWaitTime = 10000;  // how long to hold down fire before warning sounds

// Arduino setup function
void setup() {
  // softwareserial at 9600 baud for the audio board
  ss.begin(9600);

  // see if we have the soundboard
  // If we fail to communicate, loop forever for now but it would be nice to warn the user somehow
  if (!sfx.reset()) {
    while (1);
  }

  // set act modes for the fx board
  pinMode(ACT, INPUT);

  // configure nose jewel
  noseJewel.begin();
  noseJewel.setBrightness(100);
  noseJewel.show(); // Initialize all pixels to 'off'

  // configure powercell/cyclotron
  powerStick.begin();
  powerStick.setBrightness(75);
  powerStick.show(); // Initialize all pixels to 'off'

  // configure wand lights
  wandLights.begin();
  wandLights.setBrightness(75);
  wandLights.show();

  // set the modes for the switches/buttons
  pinMode(THEME_SWITCH, INPUT);
  digitalWrite(THEME_SWITCH, HIGH);
  pinMode(STARTUP_SWITCH, INPUT);
  digitalWrite(STARTUP_SWITCH, HIGH);
  pinMode(SAFETY_SWITCH, INPUT);
  digitalWrite(SAFETY_SWITCH, HIGH);
  pinMode(FIRE_BUTTON, INPUT);
  digitalWrite(FIRE_BUTTON, HIGH);

  // Call io.begin(<address>) to initialize the SX1509. If it
  // successfully communicates, it'll return 1.
  if (!io.begin(SX1509_ADDRESS)) {
    while (1) ; // If we fail to communicate, loop forever for now but it would be nice to warn the user somehow
  }

  // configuration for the bargraph LED's
  io.pinMode(SX1509_BAR_01, OUTPUT);
  io.pinMode(SX1509_BAR_02, OUTPUT);
  io.pinMode(SX1509_BAR_03, OUTPUT);
  io.pinMode(SX1509_BAR_04, OUTPUT);
  io.pinMode(SX1509_BAR_05, OUTPUT);
  io.pinMode(SX1509_BAR_06, OUTPUT);
  io.pinMode(SX1509_BAR_07, OUTPUT);
  io.pinMode(SX1509_BAR_08, OUTPUT);
  io.pinMode(SX1509_BAR_09, OUTPUT);
  io.pinMode(SX1509_BAR_10, OUTPUT);
  io.pinMode(SX1509_BAR_11, OUTPUT);
  io.pinMode(SX1509_BAR_12, OUTPUT);
  io.pinMode(SX1509_BAR_13, OUTPUT);
  io.pinMode(SX1509_BAR_14, OUTPUT);
  io.pinMode(SX1509_BAR_15, OUTPUT);

  // set everything off initially
  shutdown_leds();
}

/* ************* Audio Board Helper Functions ************* */
// helper function to play a track by name on the audio board
void playAudio( char* trackname, int playing ) {
  // stop track if one is going
  if (playing == 0) {
    sfx.stop();
  }

  // now go play
  if (sfx.playTrack(trackname)) {
    sfx.unpause();
  }
}

void playDialogTrack( int playing ){
  // if the queue is empty reseed it
  if ( dialogQueue.isEmpty() ){
    for (int i=1; i<=numDialog; i++){
      dialogQueue.enqueue(i);
    }
  }

  switch (dialogQueue.dequeue()){
    case (1):
      playAudio(texTrack, playing);
      break;
    case (2):
      playAudio(listenTrack, playing);
      break;
    case (3):
      playAudio(choreTrack, playing);
      break;
    case (4):
      playAudio(boxTrack, playing);
      break;
    case (5):
      playAudio(thatTrack, playing);
      break;
    case (6):
      playAudio(neutronizedTrack, playing);
      break;
    case (7):
      playAudio(toolsTrack, playing);
      break;
    default:
      playAudio(endTrack, playing);
      break;
  }
}

/* ************* Main Loop ************* */
int cyclotronRunningFadeOut = 255;  // we reset this variable every time we change the cyclotron index so the fade effect works
int cyclotronRunningFadeIn = 0;     // we reset this to 0 to fade the cyclotron in from nothing

// intervals that can be adjusted in real time to speed up animations
int pwr_interval = 60;        // interval at which to cycle lights for the powercell. We update this in the loop to speed up the animation so must be declared here (milliseconds)
int cyc_interval = 1000;      // interval at which to cycle lights for the cyclotron.
int cyc_fade_interval = 15;   // fade the inactive cyclotron to light to nothing
int firing_interval = 40;     // interval at which to cycle firing lights on the bargraph. We update this in the loop to speed up the animation so must be declared here (milliseconds).

void loop() {
  // get the current time
  int currentMillis = millis();

  // find out of the audio board is playing audio
  int playing = digitalRead(ACT);

  // get the current switch states
  int theme_switch = digitalRead(THEME_SWITCH);

  // if the theme switch has recently changed from off to on we
  // should play the full ghostbusters theme song
  if (theme_switch == 1) {
    if (theme == false) {
      playAudio(themeTrack, playing);
      theme = true;
    }
  } else {
    theme = false;
  }

  int startup_switch = digitalRead(STARTUP_SWITCH);
  int safety_switch = digitalRead(SAFETY_SWITCH);
  int fire_button = digitalRead(FIRE_BUTTON);

  // while the startup switch is set on
  if (startup_switch == 1) {
    // in general we always try to play the idle sound if started
    if (playing == 1 && startup == true) {
      playAudio(idleTrack, playing);
    }

    // choose the right powercell animation sequence for booted/on
    if ( powerBooted == true ) {
      // standard idle power sequence for the pack
      poweredDown = false;
      shuttingDown = false;
      venting = false;
      setWandLightState(3, 0, 0); //set sloblow red
      setVentLightState(ventStart, ventEnd, 2);
      powerSequenceOne(currentMillis, pwr_interval, cyc_interval, cyc_fade_interval);
    } else {
      // boot up the pack. powerSequenceBoot will set powerBooted when complete
      powerSequenceBoot(currentMillis);
      setWandLightState(3, 7, currentMillis);   //set sloblow red blinking
    }

    // if we are not started up we should play the startup sound and begin the boot sequence
    if (startup == false) {
      startup = true;
      playAudio(startupTrack, playing);

      // get the current safety switch state
      if (safety_switch == 1 && safety == false) {
        safety = true;
      }
    }

    if( startup == true && safety_switch == 1 ){
      if( venting == false && powerBooted == true ){
        setWandLightState(1, 2, 0);    //  set back light orange
        setWandLightState(2, 1, 0);    //  set body led white
      }else{
        setWandLightState(1, 4, 0);    //  set back light off
        setWandLightState(2, 4, 0);    //  set body led off
      }

      // if the safety switch is set off then we can fire when the button is pressed
      if ( fire_button == 0) {
        // if the button is just pressed we clear all led's to start the firing animations
        if ( isFiring == false ) {
          shutdown_leds();
          isFiring = true;
        }

        // show the firing bargraph sequence
        barGraphSequenceTwo(currentMillis);

        // strobe the nose pixels
        fireStrobe(currentMillis);

        // now powercell/cyclotron/wand lights
        // if this is the first time reset some variables and play the blast track
        if (fire == false) {
          shouldWarn = false;
          fire = true;
          firingStateMillis = millis();
          playAudio(blastTrack, playing);
        } else {
          // find out what our timing is
          long diff = millis() - firingStateMillis;

          if ( diff > firingWarnWaitTime) { // if we are in the fire warn interval
            pwr_interval = 10;      // speed up the powercell animation
            firing_interval = 20;   // speed up the bar graph animation
            cyc_interval = 50;      // really speed up cyclotron
            cyc_fade_interval = 5;  // speed up the fade of the cyclotron
            if (playing == 1 || shouldWarn == false ) {
              shouldWarn = true;
              playAudio(warnTrack, playing); // play the firing track with the warning
            }
            setWandLightState(0, 8, currentMillis);    // set top light red flashing fast
          } else if ( diff > firingWarmWaitTime) { // if we are in the dialog playing interval
            pwr_interval = 30;      // speed up the powercell animation
            firing_interval = 30;   // speed up the bar graph animation
            cyc_interval = 200;     // speed up cyclotron
            cyc_fade_interval = 10; // speed up the fade of the cyclotron
            if (playing == 1) {
              playAudio(blastTrack, playing); // play the normal blast track
            }
            setWandLightState(0, 6, currentMillis);    // set top light orange flashing
          }
        }
      } else { // if we were firing and are no longer reset the leds
        if ( isFiring == true ) {
          shutdown_leds();
          isFiring = false;
        }

        // and do the standard bargraph sequence
        barGraphSequenceOne(currentMillis);

        if (fire == true) { // if we were firing let's reset the animations and play the correct final firing track
          clearFireStrobe();
          setWandLightState(0, 4, currentMillis);    // set top light off

          pwr_interval = 60;
          firing_interval = 40;
          cyc_interval = 1000;
          cyc_fade_interval = 15;
          fire = false;

          // see if we've been firing long enough to get the dialog or vent sounds
          long diff = millis() - firingStateMillis;

          if ( diff > firingWarnWaitTime) { // if we are past the warning let's vent the pack
            playAudio(ventTrack, playing);
            venting = true;
            clearPowerStrip(); // play the boot animation on the powercell
          } else if ( diff > firingWarmWaitTime) { // if in the dialog time play the dialog in sequence
            if( useDialogTracks == true ){
              playDialogTrack(playing);
            }else{
              playAudio(endTrack, playing);
            }
          } else {
            playAudio(endTrack, playing);
          }
        }
      }

      // if the safety was just changed play the click track
      if (safety == false) {
        safety = true;
        playAudio(chargeTrack, playing);
      }
    } else {
      // if the safety is switched off play the click track
      if (safety == true) {
        setWandLightState(1, 4, 0);    // set back light off
        setWandLightState(2, 4, 0);    // set body off
        safety = false;
        playAudio(clickTrack, playing);
      }
    }
  } else { // if we are powering down
    if( poweredDown == false ){
      if( shuttingDown == false ){
        playAudio(shutdownTrack, playing); // play the pack shutdown track
        shuttingDown = true;
      }
      cyclotronRunningFadeOut = 255;
      powerSequenceShutdown(currentMillis);
    }else{
      if (startup == true) { // if started reset the variables
        clearPowerStrip(); // clear all led's
        shutdown_leds();
        startup = false;
        safety = false;
        fire = false;
      }
    }
  }
  delay(1);
}

/*************** Wand Light Helpers *********************/
unsigned long prevFlashMillis = 0; // last time we changed a powercell light in the idle sequence
bool flashState = false;
const int wandFastFlashInterval = 100; // interval at which we flash the top led on the wand
const int wandMediumFlashInterval = 500; // interval at which we flash the top led on the wand

void setWandLightState(int lednum, int state, int currentMillis){
  switch ( state ) {
    case 0: // set led red
      wandLights.setPixelColor(lednum, wandLights.Color(255, 0, 0));
      break;
    case 1: // set led white
      wandLights.setPixelColor(lednum, wandLights.Color(255, 255, 255));
      break;
    case 2: // set led orange
      wandLights.setPixelColor(lednum, wandLights.Color(255, 127, 0));
      break;
    case 3: // set led blue
      wandLights.setPixelColor(lednum, wandLights.Color(0, 0, 255));
      break;
    case 4: // set led off
      wandLights.setPixelColor(lednum, 0);
      break;
    case 5: // fast white flashing
      if (currentMillis - prevFlashMillis > wandFastFlashInterval) {
        prevFlashMillis = currentMillis;
        if( flashState == false ){
          wandLights.setPixelColor(lednum, wandLights.Color(255, 255, 255));
          flashState = true;
        }else{
          wandLights.setPixelColor(lednum, 0);
          flashState = false;
        }
      }
      break;
    case 6: // slower orange flashing
      if (currentMillis - prevFlashMillis > wandMediumFlashInterval) {
        prevFlashMillis = currentMillis;
        if( flashState == false ){
          wandLights.setPixelColor(lednum, wandLights.Color(255, 127, 0));
          flashState = true;
        }else{
          wandLights.setPixelColor(lednum, 0);
          flashState = false;
        }
      }
      break;
    case 7: // medium red flashing
      if (currentMillis - prevFlashMillis > wandMediumFlashInterval) {
        prevFlashMillis = currentMillis;
        if( flashState == false ){
          wandLights.setPixelColor(lednum, wandLights.Color(255, 0, 0));
          flashState = true;
        }else{
          wandLights.setPixelColor(lednum, 0);
          flashState = false;
        }
      }
      break;
    case 8: // fast red flashing
      if (currentMillis - prevFlashMillis > wandFastFlashInterval) {
        prevFlashMillis = currentMillis;
        if( flashState == false ){
          wandLights.setPixelColor(lednum, wandLights.Color(255, 0, 0));
          flashState = true;
        }else{
          wandLights.setPixelColor(lednum, 0);
          flashState = false;
        }
      }
      break;
  }

  wandLights.show();
}

/*************** Vent Light *************************/
void setVentLightState(int startLed, int endLed, int state ){
  switch ( state ) {
    case 0: // set all leds to white
      for(int i=startLed; i <= endLed; i++) {
        powerStick.setPixelColor(i, powerStick.Color(255, 255, 255));
      }
      break;
    case 1: // set all leds to blue
      for(int i=startLed; i <= endLed; i++) {
        powerStick.setPixelColor(i, powerStick.Color(0, 0, 255));
      }
      break;
    case 2: // set all leds off
      for(int i=startLed; i <= endLed; i++) {
        powerStick.setPixelColor(i, 0);
      }
      break;
  }
}

/*************** Powercell/Cyclotron Animations *********************/
// timer helpers and intervals for the animations
unsigned long prevPwrBootMillis = 0;    // the last time we changed a powercell light in the boot sequence
const int pwr_boot_interval = 60;       // interval at which to cycle lights (milliseconds). Adjust this if

unsigned long prevCycBootMillis = 0;    // the last time we changed a cyclotron light in the boot sequence
const int cyc_boot_interval = 500;      // interval at which to cycle lights (milliseconds).
const int cyc_boot_alt_interval = 600;      // interval at which to cycle lights (milliseconds).

unsigned long prevShtdMillis = 0;       // last time we changed a light in the idle sequence
const int pwr_shutdown_interval = 200;  // interval at which to cycle lights (milliseconds).

unsigned long prevPwrMillis = 0;        // last time we changed a powercell light in the idle sequence
unsigned long prevCycMillis = 0;        // last time we changed a cyclotron light in the idle sequence
unsigned long prevFadeCycMillis = 0;    // last time we changed a cyclotron light in the idle sequence

// LED tracking variables
const int powerSeqTotal = powercellLedCount;                              // total number of led's for powercell 0 based
int powerSeqNum = powercellIndexOffset;                                   // current running powercell sequence led
int powerShutdownSeqNum = powercellLedCount - powercellIndexOffset;       // shutdown sequence counts down

// animation level trackers for the boot and shutdown
int currentBootLevel = powercellIndexOffset;                              // current powercell boot level sequence led
int currentLightLevel = powercellLedCount - powercellIndexOffset;         // current powercell boot light sequence led

void setCyclotronLightState(int startLed, int endLed, int state ){
  switch ( state ) {
    case 0: // set all leds to red
      for(int i=startLed; i <= endLed; i++) {
        powerStick.setPixelColor(i, powerStick.Color(255, 0, 0));
      }
      break;
    case 1: // set all leds to orange
      for(int i=startLed; i <= endLed; i++) {
        powerStick.setPixelColor(i, powerStick.Color(255, 106, 0));
      }
      break;
    case 2: // set all leds off
      for(int i=startLed; i <= endLed; i++) {
        powerStick.setPixelColor(i, 0);
      }
      break;
    case 3: // fade all leds from red
      for(int i=startLed; i <= endLed; i++) {
        if( cyclotronRunningFadeOut >= 0 ){
          powerStick.setPixelColor(i, 255 * cyclotronRunningFadeOut/255, 0, 0);
          cyclotronRunningFadeOut--;
        }else{
          powerStick.setPixelColor(i, 0);
        }
      }
      break;
    case 4: // fade all leds to red
      for(int i=startLed; i <= endLed; i++) {
        if( cyclotronRunningFadeIn < 255 ){
          powerStick.setPixelColor(i, 255 * cyclotronRunningFadeIn/255, 0, 0);
          cyclotronRunningFadeIn++;
        }else{
          powerStick.setPixelColor(i, powerStick.Color(255, 0, 0));
        }
      }
      break;
  }
}

// shuts off and resets the powercell/cyclotron leds
void clearPowerStrip() {
  // reset vars
  powerBooted = false;
  poweredDown = true;
  powerSeqNum = powercellIndexOffset;
  powerShutdownSeqNum = powercellLedCount - powercellIndexOffset;
  currentLightLevel = powercellLedCount;
  currentBootLevel = powercellIndexOffset;
  cyclotronRunningFadeIn = 0;

  // shutoff the leds
  for ( int i = 0; i <= c4End; i++) {
    powerStick.setPixelColor(i, 0);
  }
  powerStick.show();

  for ( int j=0; j<=3; j++ ){
    wandLights.setPixelColor(j, 0);
  }
  wandLights.show();

  if( venting == true ){
    setVentLightState(ventStart, ventEnd, 0);
  }
}

// boot animation on the powercell/cyclotron
bool reverseBootCyclotron = false;
void powerSequenceBoot(int currentMillis) {
  bool doUpdate = false;

  // START CYCLOTRON
  if( useCyclotronFadeInEffect == false ){
    if (currentMillis - prevCycBootMillis > cyc_boot_interval) {
      prevCycBootMillis = currentMillis;

      if( reverseBootCyclotron == false ){
        setCyclotronLightState(c1Start, c1End, 1);
        setCyclotronLightState(c2Start, c2End, 2);
        setCyclotronLightState(c3Start, c3End, 1);
        setCyclotronLightState(c4Start, c4End, 2);

        doUpdate = true;
        reverseBootCyclotron = true;
      }else{
        setCyclotronLightState(c1Start, c1End, 2);
        setCyclotronLightState(c2Start, c2End, 1);
        setCyclotronLightState(c3Start, c3End, 2);
        setCyclotronLightState(c4Start, c4End, 1);

        doUpdate = true;
        reverseBootCyclotron = false;
      }
    }
  }else{
    if (currentMillis - prevCycBootMillis > cyc_boot_alt_interval) {
      prevCycBootMillis = currentMillis;
      setCyclotronLightState(c1Start, c4End, 4);
      doUpdate = true;
    }
  }
  // END CYCLOTRON

  if (currentMillis - prevPwrBootMillis > pwr_boot_interval) {
    // save the last time you blinked the LED
    prevPwrBootMillis = currentMillis;

    // START POWERCELL
    if( currentBootLevel != powerSeqTotal ){
      if( currentBootLevel == currentLightLevel){
        if(currentLightLevel+1 <= powerSeqTotal){
          powerStick.setPixelColor(currentLightLevel+1, 0);
        }
        powerStick.setPixelColor(currentBootLevel, powerStick.Color(0, 0, 255));
        currentLightLevel = powerSeqTotal;
        currentBootLevel++;
      }else{
        if(currentLightLevel+1 <= powerSeqTotal){
          powerStick.setPixelColor(currentLightLevel+1, 0);
        }
        powerStick.setPixelColor(currentLightLevel, powerStick.Color(0, 0, 255));
        currentLightLevel--;
      }
      doUpdate = true;
    }else{
      powerBooted = true;
      currentBootLevel = powercellIndexOffset;
      currentLightLevel = powercellLedCount - powercellIndexOffset;
    }
    // END POWERCELL
  }

  // if we have changed an led
  if( doUpdate == true ){
    powerStick.show(); // commit all of the changes
  }
}

// idle/firing animation for the powercell/cyclotron
int cycOrder = 0;     // which cyclotron led will be lit next
int cycFading = -1;   // which cyclotron led is fading out for game style
void powerSequenceOne(int currentMillis, int anispeed, int cycspeed, int cycfadespeed) {
  bool doUpdate = false;  // keep track of if we changed something so we only update on changes

  // START CYCLOTRON
  if( useGameCyclotronEffect == true ){ // if we are doing the video game style cyclotron
    if (currentMillis - prevCycMillis > cycspeed) {
      prevCycMillis = currentMillis;

      switch ( cycOrder ) {
        case 0:
          setCyclotronLightState(c1Start, c1End, 0);
          setCyclotronLightState(c2Start, c2End, 2);
          setCyclotronLightState(c3Start, c3End, 2);
          cycFading = 0;
          cyclotronRunningFadeOut = 255;
          cycOrder = 1;
          break;
        case 1:
          setCyclotronLightState(c2Start, c2End, 0);
          setCyclotronLightState(c3Start, c3End, 2);
          setCyclotronLightState(c4Start, c4End, 2);
          cycFading = 1;
          cyclotronRunningFadeOut = 255;
          cycOrder = 2;
          break;
        case 2:
          setCyclotronLightState(c1Start, c1End, 2);
          setCyclotronLightState(c3Start, c3End, 0);
          setCyclotronLightState(c4Start, c4End, 2);
          cycFading = 2;
          cyclotronRunningFadeOut = 255;
          cycOrder = 3;
          break;
        case 3:
          setCyclotronLightState(c1Start, c1End, 2);
          setCyclotronLightState(c2Start, c2End, 2);
          setCyclotronLightState(c4Start, c4End, 0);
          cycFading = 3;
          cyclotronRunningFadeOut = 255;
          cycOrder = 0;
          break;
      }

      doUpdate = true;
    }

    // now figure out the fading light
    if( currentMillis - prevFadeCycMillis > cycfadespeed ){
      prevFadeCycMillis = currentMillis;
      if( cycFading != -1 ){
        switch ( cycFading ) {
          case 0:
            setCyclotronLightState(c4Start, c4End, 3);
            break;
          case 1:
            setCyclotronLightState(c1Start, c1End, 3);
            break;
          case 2:
            setCyclotronLightState(c2Start, c2End, 3);
            break;
          case 3:
            setCyclotronLightState(c3Start, c3End, 3);
            break;
        }
        doUpdate = true;
      }
    }
  }else{ // otherwise this is the standard version
    if (currentMillis - prevCycMillis > cycspeed) {
      prevCycMillis = currentMillis;

      switch ( cycOrder ) {
        case 0:
          setCyclotronLightState(c4Start, c4End, 2);
          setCyclotronLightState(c1Start, c1End, 0);
          setCyclotronLightState(c2Start, c2End, 2);
          setCyclotronLightState(c3Start, c3End, 2);
          cycFading = 0;
          cyclotronRunningFadeOut = 255;
          cycOrder = 1;
          break;
        case 1:
          setCyclotronLightState(c1Start, c1End, 2);
          setCyclotronLightState(c2Start, c2End, 0);
          setCyclotronLightState(c3Start, c3End, 2);
          setCyclotronLightState(c4Start, c4End, 2);
          cycFading = 1;
          cyclotronRunningFadeOut = 255;
          cycOrder = 2;
          break;
        case 2:
          setCyclotronLightState(c1Start, c1End, 2);
          setCyclotronLightState(c2Start, c2End, 2);
          setCyclotronLightState(c3Start, c3End, 0);
          setCyclotronLightState(c4Start, c4End, 2);
          cycFading = 2;
          cyclotronRunningFadeOut = 255;
          cycOrder = 3;
          break;
        case 3:
          setCyclotronLightState(c1Start, c1End, 2);
          setCyclotronLightState(c2Start, c2End, 2);
          setCyclotronLightState(c3Start, c3End, 2);
          setCyclotronLightState(c4Start, c4End, 0);
          cycFading = 3;
          cyclotronRunningFadeOut = 255;
          cycOrder = 0;
          break;
      }

      doUpdate = true;
    }
  }
  // END CYCLOTRON

  // START POWERCELL
  if (currentMillis - prevPwrMillis > anispeed) {
    // save the last time you blinked the LED
    prevPwrMillis = currentMillis;

    for ( int i = powercellIndexOffset; i <= powerSeqTotal; i++) {
      if ( i <= powerSeqNum ) {
        powerStick.setPixelColor(i, powerStick.Color(0, 0, 150));
      } else {
        powerStick.setPixelColor(i, 0);
      }
    }

    if ( powerSeqNum <= powerSeqTotal) {
      powerSeqNum++;
    } else {
      powerSeqNum = powercellIndexOffset;
    }

    doUpdate = true;
  }
  // END POWERCELL

  // if we changed anything update
  if( doUpdate == true ){
    powerStick.show();
  }
}

// shutdown animation for the powercell/cyclotron
int cyclotronFadeOut = 255;
void powerSequenceShutdown(int currentMillis) {
  if (currentMillis - prevShtdMillis > pwr_shutdown_interval) {
    prevShtdMillis = currentMillis;

    // START CYCLOTRON
    for(int i=c1Start; i <= c4End; i++) {
      if( cyclotronFadeOut >= 0 ){
        powerStick.setPixelColor(i, 255 * cyclotronFadeOut/255, 0, 0);
        cyclotronFadeOut--;
      }else{
        powerStick.setPixelColor(i, 0);
      }
    }
    // END CYCLOTRON

    // START POWERCELL
    for ( int i = powerSeqTotal; i >= powercellIndexOffset; i--) {
      if ( i <= powerShutdownSeqNum ) {
        powerStick.setPixelColor(i, powerStick.Color(0, 0, 150));
      } else {
        powerStick.setPixelColor(i, 0);
      }
    }

    powerStick.show();

    if ( powerShutdownSeqNum >= powercellIndexOffset) {
      powerShutdownSeqNum--;
    } else {
      poweredDown = true;
      powerShutdownSeqNum = powercellLedCount - powercellIndexOffset;
      cyclotronFadeOut = 255;
    }
    // END POWERCELL
  }
}

/*************** Nose Jewel Firing Animations *********************/
unsigned long prevFireMillis = 0;
const int fire_interval = 50;     // interval at which to cycle lights (milliseconds).
int fireSeqNum = 0;
int fireSeqTotal = 5;

void clearFireStrobe() {
  for ( int i = 0; i < 7; i++) {
    noseJewel.setPixelColor(i, 0);
  }
  noseJewel.show();
  fireSeqNum = 0;
}

void fireStrobe(int currentMillis) {
  if (currentMillis - prevFireMillis > fire_interval) {
    prevFireMillis = currentMillis;

    switch ( fireSeqNum ) {
      case 0:
        noseJewel.setPixelColor(0, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(1, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(2, 0);
        noseJewel.setPixelColor(3, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(4, 0);
        noseJewel.setPixelColor(5, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(6, 0);
        break;
      case 1:
        noseJewel.setPixelColor(0, noseJewel.Color(0, 0, 255));
        noseJewel.setPixelColor(1, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(2, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(3, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(4, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(5, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(6, noseJewel.Color(255, 255, 255));
        break;
      case 2:
        noseJewel.setPixelColor(0, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(1, 0);
        noseJewel.setPixelColor(2, noseJewel.Color(0, 0, 255));
        noseJewel.setPixelColor(3, 0);
        noseJewel.setPixelColor(4, noseJewel.Color(0, 0, 255));
        noseJewel.setPixelColor(5, 0);
        noseJewel.setPixelColor(6, noseJewel.Color(255, 0, 0));
        break;
      case 3:
        noseJewel.setPixelColor(0, noseJewel.Color(0, 0, 255));
        noseJewel.setPixelColor(1, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(2, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(3, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(4, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(5, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(6, noseJewel.Color(255, 255, 255));
        break;
      case 4:
        noseJewel.setPixelColor(0, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(1, 0);
        noseJewel.setPixelColor(2, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(3, 0);
        noseJewel.setPixelColor(4, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(5, 0);
        noseJewel.setPixelColor(6, noseJewel.Color(255, 255, 255));
        break;
      case 5:
        noseJewel.setPixelColor(0, noseJewel.Color(255, 0, 255));
        noseJewel.setPixelColor(1, noseJewel.Color(0, 255, 0));
        noseJewel.setPixelColor(2, noseJewel.Color(255, 0, 0));
        noseJewel.setPixelColor(3, noseJewel.Color(0, 0, 255));
        noseJewel.setPixelColor(4, noseJewel.Color(255, 0, 255));
        noseJewel.setPixelColor(5, noseJewel.Color(255, 255, 255));
        noseJewel.setPixelColor(6, noseJewel.Color(0, 0, 255));
        break;
    }

    noseJewel.show();

    fireSeqNum++;
    if ( fireSeqNum > fireSeqTotal ) {
      fireSeqNum = 0;
    }
  }
}

/*************** Bar Graph Animations *********************/
// This is the idle sequence
unsigned long prevBarMillis_on = 0;   // bargraph on tracker
const int pwrcl_interval = 60;     // interval at which to cycle lights (milliseconds).
bool reverseSequenceOne = false;

void barGraphSequenceOne(int currentMillis) {
  // normal sync animation on the bar graph
  if (currentMillis - prevBarMillis_on > pwrcl_interval) {
    // save the last time you blinked the LED
    prevBarMillis_on = currentMillis;

    if ( reverseSequenceOne == false ) {
      switch_graph_led(seq_1_current, HIGH);
      seq_1_current++;
      if ( seq_1_current > num_led ) {
        reverseSequenceOne = true;
      }
    } else {
      switch_graph_led(seq_1_current, LOW);
      seq_1_current--;
      if ( seq_1_current < 0  ) {
        reverseSequenceOne = false;
      }
    }
  }
}

// This is the firing sequence
unsigned long prevBarMillis_fire = 0; // bargraph firing tracker
int fireSequenceNum = 1;

void barGraphSequenceTwo(int currentMillis) {
  if (currentMillis - prevBarMillis_fire > firing_interval) {
    // save the last time you blinked the LED
    prevBarMillis_fire = currentMillis;

    switch (fireSequenceNum) {
      case 1:
        switch_graph_led(2, LOW);
        switch_graph_led(14, LOW);
        switch_graph_led(1, HIGH);
        switch_graph_led(15, HIGH);
        fireSequenceNum++;
        break;
      case 2:
        switch_graph_led(1, LOW);
        switch_graph_led(15, LOW);
        switch_graph_led(2, HIGH);
        switch_graph_led(14, HIGH);
        fireSequenceNum++;
        break;
      case 3:
        switch_graph_led(2, LOW);
        switch_graph_led(14, LOW);
        switch_graph_led(3, HIGH);
        switch_graph_led(13, HIGH);
        fireSequenceNum++;
        break;
      case 4:
        switch_graph_led(3, LOW);
        switch_graph_led(13, LOW);
        switch_graph_led(4, HIGH);
        switch_graph_led(12, HIGH);
        fireSequenceNum++;
        break;
      case 5:
        switch_graph_led(4, LOW);
        switch_graph_led(12, LOW);
        switch_graph_led(5, HIGH);
        switch_graph_led(11, HIGH);
        fireSequenceNum++;
        break;
      case 6:
        switch_graph_led(5, LOW);
        switch_graph_led(11, LOW);
        switch_graph_led(6, HIGH);
        switch_graph_led(10, HIGH);
        fireSequenceNum++;
        break;
      case 7:
        switch_graph_led(6, LOW);
        switch_graph_led(10, LOW);
        switch_graph_led(7, HIGH);
        switch_graph_led(9, HIGH);
        fireSequenceNum++;
        break;
      case 8:
        switch_graph_led(7, LOW);
        switch_graph_led(9, LOW);
        switch_graph_led(6, HIGH);
        switch_graph_led(10, HIGH);
        fireSequenceNum++;
        break;
      case 9:
        switch_graph_led(6, LOW);
        switch_graph_led(10, LOW);
        switch_graph_led(5, HIGH);
        switch_graph_led(11, HIGH);
        fireSequenceNum++;
        break;
      case 10:
        switch_graph_led(5, LOW);
        switch_graph_led(11, LOW);
        switch_graph_led(4, HIGH);
        switch_graph_led(12, HIGH);
        fireSequenceNum++;
        break;
      case 11:
        switch_graph_led(4, LOW);
        switch_graph_led(12, LOW);
        switch_graph_led(3, HIGH);
        switch_graph_led(13, HIGH);
        fireSequenceNum++;
        break;
      case 12:
        switch_graph_led(3, LOW);
        switch_graph_led(13, LOW);
        switch_graph_led(2, HIGH);
        switch_graph_led(14, HIGH);
        fireSequenceNum = 1;
        break;
    }
  }
}

/************************* Shutdown and helper functions ****************************/
void shutdown_leds() {
  // reset the sequence
  seq_1_current = 1;
  fireSequenceNum = 1;

  // shut all led's off
  for (int i = 1; i <= 15; i++) {
    switch_graph_led(i, LOW);
  }
}

void switch_graph_led(int num, int state) {
  switch (num) {
    case 1:
      io.digitalWrite(SX1509_BAR_01, state);
      break;
    case 2:
      io.digitalWrite(SX1509_BAR_02, state);
      break;
    case 3:
      io.digitalWrite(SX1509_BAR_03, state);
      break;
    case 4:
      io.digitalWrite(SX1509_BAR_04, state);
      break;
    case 5:
      io.digitalWrite(SX1509_BAR_05, state);
      break;
    case 6:
      io.digitalWrite(SX1509_BAR_06, state);
      break;
    case 7:
      io.digitalWrite(SX1509_BAR_07, state);
      break;
    case 8:
      io.digitalWrite(SX1509_BAR_08, state);
      break;
    case 9:
      io.digitalWrite(SX1509_BAR_09, state);
      break;
    case 10:
      io.digitalWrite(SX1509_BAR_10, state);
      break;
    case 11:
      io.digitalWrite(SX1509_BAR_11, state);
      break;
    case 12:
      io.digitalWrite(SX1509_BAR_12, state);
      break;
    case 13:
      io.digitalWrite(SX1509_BAR_13, state);
      break;
    case 14:
      io.digitalWrite(SX1509_BAR_14, state);
      break;
    case 15:
      io.digitalWrite(SX1509_BAR_15, state);
      break;
  }
}

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


Initial code for the official Victoria ros node. A work in progress.

/*
 * Victoria Teensy ROS Node
 *
 * This code is the ROS node that executes on the Teensy processor
 * for the Victoria RoboMagellan team. It uses the rosserial
 * library to communicate with ROS. It uses Arduino and Teensy
 * libraries to interact with systems and circuits connected to the
 * Teensy processor. This code assumes that a Teensy 3.5 is used.
 */

// Teensy includes
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>  //
#include <i2c_t3.h>

// ROS includes
#include <ros.h>
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include <tf/transform_broadcaster.h>

// Teensy pin definitions
#define ENCODER_LEFT_PIN_1 29   // Teensy digital pin 29
#define ENCODER_LEFT_PIN_2 30   // Teensy digital pin 30
#define ENCODER_RIGHT_PIN_1 31  // Teensy digital pin 31
#define ENCODER_RIGHT_PIN_2 32  // Teensy digital pin 32
#define BUMPER_LEFT_PIN 14      // Teensy analog pin 14
#define BUMPER_RIGHT_PIN 15     // Teensy analog pin 15

// TRex motor controller
HardwareSerial trex = HardwareSerial();

// Motor encoders
Encoder encoder_l(ENCODER_LEFT_PIN_1, ENCODER_LEFT_PIN_2);
Encoder encoder_r(ENCODER_RIGHT_PIN_1, ENCODER_RIGHT_PIN_2);
unsigned long encoder_l_pos;
unsigned long encoder_r_pos;

// Bumper sensors
#define BUMPER_THRESHOLD 500  // Threshold that will indicate robot should stop
unsigned int bumper_l_base;
unsigned int bumper_r_base;

// ROS node handle
ros::NodeHandle ros_nh;

// ROS cmd_vel subscriber
void cmdVelCallback(const geometry_msgs::Twist& twist_msg);
ros::Subscriber<geometry_msgs::Twist> ros_cmd_vel_sub("cmd_vel", cmdVelCallback);

// ROS Odometry publisher
nav_msgs::Odometry ros_odom_msg;
ros::Publisher ros_odom_pub("odom", &ros_odom_msg);

// ROS Odometry broadcaster
geometry_msgs::TransformStamped ros_odom_transform;
tf::TransformBroadcaster ros_odom_broadcaster;

ros::Time current_time;
ros::Time last_time;
ros::Time last_cmd_vel_time;

char ros_odom_header_frame_id[] = "/odom";
char ros_odom_child_frame_id[] = "/base_link";

void setup() {
  current_time = ros_nh.now();
  last_time = current_time;
  last_cmd_vel_time = current_time;
  encoder_l_pos = 0.0;
  encoder_r_pos = 0.0;
  bumper_l_base = analogRead(BUMPER_LEFT_PIN);
  bumper_r_base = analogRead(BUMPER_RIGHT_PIN);

  // Setup basic I2C master mode pins 18/19, external pullups, 400kHz, 200ms default timeout
  Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
  Wire.setDefaultTimeout(200000); // 200ms

  // Start serial port to TRex
  trex.begin(19200);

  // Initialize ros node
  ros_nh.initNode();

  // Initialize broadcasters
  ros_odom_transform.header.frame_id = ros_odom_header_frame_id;
  ros_odom_transform.child_frame_id = ros_odom_child_frame_id;
  ros_odom_broadcaster.init(ros_nh);

  // Initialize ros publishers
  ros_odom_msg.header.frame_id = ros_odom_header_frame_id;
  ros_odom_msg.child_frame_id = ros_odom_child_frame_id;
  ros_nh.advertise(ros_odom_pub);

  // Initialize ros subscribers
  ros_nh.subscribe(ros_cmd_vel_sub);
}

void loop() {
  ros_nh.spinOnce();
  current_time = ros_nh.now();

  // If we have not received any cmd_vel messages for a while,
  // something is wrong, stop the robot.

  // Read bumper sensors
  unsigned int new_bumper_l = analogRead(BUMPER_LEFT_PIN);
  unsigned int new_bumper_r = analogRead(BUMPER_RIGHT_PIN);

  // Check bumper thresholds to stop robot

  // Read encoders
  unsigned long new_encoder_l_pos = encoder_l.read();
  unsigned long new_encoder_r_pos = encoder_r.read();

  // Read imu data

  // Broadcast odometry transform
  ros_odom_transform.header.stamp = current_time;

  // TODO: set all the transform data

  ros_odom_broadcaster.sendTransform(ros_odom_transform);

  // Publish Odometry
  ros_odom_msg.header.stamp = current_time;

  // TODO: Set all the odometry data

  ros_odom_pub.publish(&ros_odom_msg);

  last_time = current_time;
}

void cmdVelCallback(const geometry_msgs::Twist& twist_msg) {
  last_cmd_vel_time = ros_nh.now();

  // Do something interesting with the cmd_vel
  setMotors(100, 100);
}

/*
 * Sets the speed for the motors. Values are expected
 * to be between -255 and 255. Values outside this range
 * will be pinned.
 */
void setMotors(int motor_l_speed, int motor_r_speed) {
  byte command_byte_l = 0xC4;
  if (motor_l_speed < 0) {
    command_byte_l = command_byte_l | 0x01;
  } else {
    command_byte_l = command_byte_l | 0x02;
  }
  motor_l_speed = abs(motor_l_speed);
  if (motor_l_speed > 255) {
    motor_l_speed = 255;
  }

  byte command_byte_r = 0xCC;
  if (motor_r_speed < 0) {
    command_byte_r = command_byte_r | 0x01;
  } else {
    command_byte_r = command_byte_r | 0x02;
  }
  motor_r_speed = abs(motor_r_speed);
  if (motor_r_speed > 255) {
    motor_r_speed = 255;
  }

  trex.write(command_byte_l);
  trex.write((byte)motor_l_speed);
  trex.write(command_byte_r);
  trex.write((byte)motor_r_speed);
}

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