Build Break Alarm

Note: I meant to post this a long time ago. It is definitely an out of order project post.

A while back I changed teams at Amazon. While in an early meeting my new dev manager mentioned using lava lamps to indicate when builds break. I told my team that I could be interested in making something that would be similar and would accomplish the same result.

Build Break Alarm Schematic

Build Break Alarm Schematic

I deleted some code from this sketch that would display info on a television as I never got the timing down for managing both serial data and TV out. There didn’t seem to be enough CPU cycles available for both at the same time. As a result I would miss some of the serial data as it came in. If I turned off the TV out I got all of the expected serial data. Long story long this code may not compile as I haven’t tried since I removed the TV out bits. You’re smart, you’ll figure it out.

/*
FLASHER - PINOUT
Flasher            12
Green Indicator    5
Red Indicator      3
*/

#define FLASHER_PIN 12 // the pin that the flasher mosfet gate is attached to
#define ALERT_GRN_PIN  5
#define ALERT_RED_PIN 3

#define NUMBER_OF_FIELDS = 2
#define BUFFER_MAX 255
#define MODE_LOADING_BUFFER 0
#define MODE_BUFFER_READY 1

boolean isOnAlert = false;

String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

int fieldIndex = 0; // The field we are currently reading into.
int bufferIndex = 0;
char buffer[BUFFER_MAX];
char mode = MODE_LOADING_BUFFER;

void readData();
void alert();
void clear_alert();
void selfTest();

void setup() {

    // reserve 200 bytes for the inputString:
  inputString.reserve(200);

  // initialize serial communication:
  Serial.begin(9600);

  // initialize the LED pin as an output:
  pinMode(FLASHER_PIN, OUTPUT);
  pinMode(ALERT_GRN_PIN, OUTPUT);
  pinMode(ALERT_RED_PIN, OUTPUT);

  selfTest();

  clear_alert();

}

void loop() {

  if (stringComplete) {
    Serial.println(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
  }

}

/*
  SerialEvent occurs whenever a new data comes in the
 hardware serial RX.  This routine is run between each
 time loop() runs, so using delay inside loop can delay
 response.  Multiple bytes of data may be available.
 */
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
     if(inputString.length() <= 0){
       if(inChar == '!'){
          alert();
          Serial.println("ALERT!");
          continue;
        } else if(inChar == '?'){
          clear_alert();
          Serial.println("All Clear");
          continue;
        }
     }
    Serial.println(inputString.length());
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }

}

void alert(){
   digitalWrite(FLASHER_PIN, HIGH);
   isOnAlert = true;
   digitalWrite(ALERT_GRN_PIN, HIGH);
   digitalWrite(ALERT_RED_PIN, LOW);
}

void clear_alert(){
  digitalWrite(FLASHER_PIN, LOW);
  isOnAlert = false;
  digitalWrite(ALERT_GRN_PIN, LOW);
  digitalWrite(ALERT_RED_PIN, HIGH);
}

void readData() {
  while(Serial.available()) {
    char ch = Serial.read();
    if(bufferIndex <= 0) {
        if(ch == '!'){
          alert();
          Serial.println("ALERT!");
        } else {
          clear_alert();
        Serial.println("All Clear");
        }
        bufferIndex++;
    } else if(ch == '\0' || ch == '\n' || ch == '\r' || bufferIndex >= BUFFER_MAX -1){
      buffer[++bufferIndex] = '\0';
      bufferIndex = 0;
      mode = MODE_BUFFER_READY;
    } else {
      mode = MODE_LOADING_BUFFER;
      buffer[bufferIndex] = ch;
      bufferIndex++;
    }
    delay(10);
  }
}

void selfTest() {
   digitalWrite(FLASHER_PIN, HIGH);
   delay(1500);
   digitalWrite(FLASHER_PIN, LOW);

  boolean flip = false;
  for(int i = 0; i < 20; i++) {
    digitalWrite(ALERT_GRN_PIN, flip ? HIGH : LOW);
    digitalWrite(ALERT_RED_PIN, flip ? LOW : HIGH);
    flip = !flip;
    delay(75);
  }

   for(int i=0; i < 5; i++){
     digitalWrite(ALERT_GRN_PIN, LOW);
     digitalWrite(ALERT_RED_PIN, LOW);
     delay(250);
     digitalWrite(ALERT_GRN_PIN, HIGH);
     digitalWrite(ALERT_RED_PIN, HIGH);
     delay(250);
   }

}
Electronics, Technology , , , , , , ,

Christmas Lights Hacked

GE Color Effects G35 Christmas LightsAfter working on my last hardware project, the Ara’Kus (a heavy metal opera) flickering/wireless lantern, I have moved on to hacking some Christmas lights.BJ Becker

I found that many people liked GE’s Color Effects G-35 lights. I happen upon this set of lights at Costco while shopping with my family. The price tag was ~$65 w/o tax. This seemed cheap for a string of 50 addressable rgb LEDs, but expensive for a set of Christmas lights. I didn’t buy them that day. Instead I sneaked over to Costco after work one day and picked them up under the radar.

I tried out the preset and found them less than desirable. Of course I needed to fix that. My plan was to be able to control the light via an Android app or web site or some such. I had the grand idea of allowing uses to write there own controller script (ECMAScript). I still think this is a good idea, but Read more »

Electronics, Life, Technology , , , , , ,

My 1st Oscilloscope

DS1052E

DS1052E 50 MHz Digital Oscilloscope

Yesterday I got my 1st oscilloscope from Rigol. It is the DS1052E 50 MHz DSO (digital storage oscilloscope). I payed about $315 w/shipping direct from Rigol. I immediately turned it on, hooked the leads up to the test square wave signal, started pushing buttons and turning knobs. I also checked out the remote control software used to control the unit from a PC. That will come in handy when making blog postings such as this.

My hope is to use this piece of equipment to be more active in my learning of electronics and to more easily debug/troubleshoot my projects.

This should be fun!

Electronics , ,

EEE: Embarking into Electrical Engineering

For the past year or so I’ve been teaching myself electronics. There have been a series of events that have moved me down this path. I had a software interview at a company that works in the embedded electronics space. My friend Demi Raven, who is a wonderful artist and person, bye the way, works there and thought I’d be a good fit. Turns out my interview skills were a bit rusty. I didn’t get the job. After the rejection I was inspired and fascinated with writing software that interacts directly with the real physical world. I went out and bought and read “Write Great Code” volumes 1 & 2. I also read  Make: Electronics (Learning by Discovery), Getting Started in Electronics & Forrest Mims Engineer’s Notebook. I am currently reading The Art of Electronics. It is fairly math oriented but I’m working my way through. The books and many internet resources have been great aids in developing as set of mental tools for me. Read more »

Electronics, Technology

New Job -> Amazon

amazon.comI just started my new position on the Product Imaging team at Amazon last week. So far I am enjoying myself here. It is good to work for a software company again. It has been about 3 years. I am excited to work on some of the more tangible scale challenge Amazon is facing when dealing with the all of the hands that have to touch a product image before it shows up on Amazon’s website.

Life ,

Hello world!

JeremyVeleber.com has moved. I have been having trouble with e107 and have decided to change to WordPress.

Content will be added soon. Thank you for your patience.

Life