Not-so final Final Submission? December 2, 2015

So the bluetooth-driven code works for the part of the skirt I have done, but the physical connections on the skirt are so finicky that I haven’t been able to test the accelerometer.  I need to find a less finicky way of connecting the lights, because conductive thread (even now that it’s insulated with tape) just doesn’t seem to want to work.

I jerry rigged the flora, bluetooth, and accelerometer onto the skirt with safety pins so it’s one unit that doesn’t need computer connection to work and they are pretty much where I plan to actually sew them on. when I have time.

In theory my code should work, and it does before you add the accelerometer.  I broke the code into three parts: The final code with the bluetooth and accelerometer, one code for bluetooth by itself, and one code for accelerometer by itself (to test without dependence on bluetooth).

The final code has the brightness driven by the accelerometer and the color driven by bluetooth.  Unfortunately if you move the skirt the lights freak out and generally don’t work, so this code is not testable currently.

Well shoot. November 23, 2015

My thread is more resistant than I anticipated, so only 5 lights lit up on the chain when I began testing it.  I have had to rethink the chaining, and I need to re-sew a lot of it. Honestly, I’m really worried at this point.  I am flying home Wednesday for Thanksgiving, and in the current state of panic that the US is experiencing due to terrorism, there’s no way I’m going to try to risk bringing a computerized wired skirt on an airplane. I get back late Sunday night, so I can try to work on the code at home but I can’t sew (which is the most time-intensive part).

At this point I am pretty much finished with my other class and I can do my research hours project at home over the break. The class I teach is wrapping up, I can focus about 75% of my time to this project.  I’m just worried that it may mess up again.

I am going to try to get at least one row of lights working with the accelerometer or the bluetooth color changer.  I can sew the rest of them on after the semester ends so I can still have my awesome light-up skirt the way I want it.  For this class, I just want it to prove the concept so I can keep working and not go insane.

Boogy Woogy, more like booger wooger November 16, 2015

I came down with an illness last Wednesday, got better on Thursday and Friday, and then got a cold on Saturday and Sunday. My nose became a fountain and I slept 80% of the weekend, which is when I planned to get cracking on my skirt. Excuses aside, I got a lot less done than I expected to this week.

I have 19 out of 79 lights sewn, but all 79 lights are pinned so that’s good.  My basic code lights the skirt up, but the accelerometer is not sewn or coded so it does not control anything yet.  I’m hoping to get to that ASAP.  My sewing has gotten faster as I’ve gone along and figured things out, and since I got an embroidery circle to stretch the fabric.

The conductive thread cannot touch any other thread in order to light up, so it’s hard to test without laying the skirt out entirely.  I’m not sure what this will do when I wear it, I may have to put a backing on the thread to avoid contact while swishing.

Pinned lightsFullSizeRender(2)

Lighting up the first few lightsFullSizeRender(1)

It’s electric…. boogy woogy woogy November 1, 2015

For my final I am going to make a skirt that lights up in different ways depending on how you move.
If you spin fast enough the lights will all light up. If you swish, they’ll twinkle. There will be a bluetooth connection that allows you to change the color manually. I want to add more functionality than that, but for now that’s my starting point.
I also want to have different modes, so you can have them change color as you spin or swish depending on the setting. I am going to set up a soft potentiometer from adafruit on a chain with the accelerometer so I can set modes that way.

I have an adafruit flora, which is a sewable arduino, and sewable smart neopixels also from adafruit that are chainable. I am soon to be receiving a bluetooth module for the flora that will allow me to connect to the flora from my computer via bluetooth and change the colors of the lights via a phone app. The accelerometer/magnometer I used for the fortune teller project is the same one I will sew to the edge of the skirt to detect motions.

I will have approximately 84 neopixels to work with, and the main consideration now is how to chain them together; what pattern will I sew them in, how many pins will I use on the arduino, etc.

Week 10:
Monday- skirt design, light layout, begin code
Wednesday- work on code, start pinning lights
Friday- more parts get in

Week 11-
Monday- Start sewing, code light chain(s)
Wednesday- Keep sewing, finish light coding

Week 12-
Monday- Keep sewing, code accelerometer
Wednesday- Keep sewing, finish accelerometer coding

Week 13-
Monday- Finalize
Wednesday- Look pretty

It’s always 5 o’clock somewhere… October 13, 2015

Does anybody really know what time it is? Does anybody really care?
I call it the Chicago clock, and it will revolutionize confusion.

The Chicago clock is a fantastic new invention that will weed out the kids with their newfangled digital contraptions and distinguish high-class society.  It is a wall clock modeled after the traditional grandfather clock, complete with swinging pendulum.

Telling time with an analog clock is a skill that is taught in first grade; or it was during my escapades in elementary school. I remember this distinctly because I was so proud when I learned how to read a clock, and then I got a digital watch. It was all downhill from there.  To read an analog clock ever since I first learned that we have digital things that tell us the exact time in numbers and not positions on a wheel, I have had to count the minutes by 5.  I know that up is :00 and down is :30.  If I try really hard I even remember that pointing to the right is :15 and pointing to the left is :45.  Anything in-between those marks is a count-by-fives strategy until I get to where the minute hand is (or close enough to where it is that I have to count by ones until I reach it). In short, it takes me forever to read an analog clock and I am a disgrace.

The hands on the clock are always correct.  The numbers, however, are not.  Whenever the clock changes hours, the numbers shuffle around.  The current hour is always 5 o’clock as per the numbering, regardless of where the hour hand is.  The rest are randomly placed to confuse innocent bystanders. Muahahahahaha.

The Mystic Seer October 6, 2015

The fantasy: A fortune telling orb that changes color when my mystic hands are waving over it to commune with the spirits.  It will tell your future or answer any question you have about it.  When the supernatural forces in the room have your answer, the light will pulse white. In order for the spirits to portray your future onto a screen, you must place your palm on the mystical hand symbol on a podium.  This will prompt the supernatural beings to give your answer. (The fortune will be determined by a foot pedal trigger that the regular puny mortal will not be able to see because it is under the table and tablecloth, so it will seem as if the spirits are answering.)

The reality:  An LED under a small fishbowl changes color at the prompt of the spacebar, and will continue to change until a magnometer on my wrist detects that my hands have turned upwards. The fortune is input by a number on the keyboard: fortunes are 1-5, 6 is answering a question.  The fortune number corresponds to whether it is good or bad.  5 is wonderful, 1 is downright rude.  6 is a nondescript answer so it works and is right always.  The hand symbol has a light sensor under it.  When there is no light reaching the sensor (because your hand is over it) your fortune will appear in the serial monitor.  There are three options for each number, ant it will be a random selection amongst the ones assigned to the number I push.  The lights will turn off and await the command to being a new fortune.

For this assignment, I wanted to start exploring the Adafruit Flora arduino board that I will be using for my final project. I have LEDs, a light sensor, and a color sensor that connect specifically to the Flora and are designed to be sewn for wearable projects. one of the biggest hurdles was figuring out how to not sew with the conductive thread, but still have the wires stay uncrossed.  I ended up making tape strips of the thread wires to keep them together but separate.

Code-wise, the main issues I had were loading the flora libraries and syntax errors.  The pulsing white light also took a while longer than I expected because I was trying to math it out with a cosine wave and it would move in steps rather than smoothly fading.  I ended up scrapping the too-mathy approach and set the increment in a loop to negative when it reached full brightness or off.

One cool thing about the flora is that it is small so it doesn’t have many pins, but that is solved by the fact that you can chain the lights and the sensors to the flora.  The light sensor is connected to the flora arduino board, and the accelerometer/magnometer is connected to the light sensor.  The information is passed down the chain, and you can read the output of the light sensor and the accelerometer/magnometer separately because they have different serial addresses on the pins they all eventually connect to on the board.

My favorite part was writing the answers:

// 1 is just rude

“The fact that nobody understands you doesn’t mean you’re an artist.”

“There is so much more knowledge to be learned than you have the capacity to possess.”

“We cannot identify your problem, but it is probably hard to pronounce.”


// 2 is negative, but not too mean

“We don’t see that success is immediately in your future.”

“Live every day like you are dying, because you slowly are.”

“Bless your heart.”


// 3 is neutral

“The spirits will do their best to influence your journey”

“Some soul-searching will help aid your decisions”

“Do your best to live life to the fullest”


// 4 is positive and nice

“Sometime in the future there will be happiness.”

“Walk towards the sunshine and the shadows will fall behind you”

“Hard work and perseverance will lead you towards your goal”


// 5 is super positive

“We believe in you. You can do it!”

“You are loved.”

“You have a wonderful soul.”


// 6 is noncommittal answers


“Maybe some day.”

“It might come to pass.”

Final Setup:Magnometer




The light hookup
Light setup



Accelerometer/Magnometer setupTaping the conductive thread

Flora setup clearer view of the board
Whole setup

Light sensor setup
Light sensor


And the Code:

* Fortune Teller project 2 for 662 Physical Computing
* Fortunes will be generated by a serial input
* Mystic light will go until a hand signal affects a sensor
* Fortunate one will place their hand on a pulsing white light to show their fortune
#include <Wire.h>
#include <Adafruit_FloraPixel.h> //led neopixels
#include <Adafruit_Sensor.h> //flora sensors
#include <Adafruit_TSL2561_U.h> //light sensor
#include <Adafruit_LSM303.h> //accel/mag sensor

//declare accel/mag sensor
Adafruit_LSM303 accelSensor;

//declare light sensor
Adafruit_TSL2561_Unified lightSensor = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);

//set the serial input codes/ascii chars for final color output
//fortunes 1-5, where higher is better
int fortune1 = ‘1’;
int fortune2 = ‘2’;
int fortune3 = ‘3’;
int fortune4 = ‘4’;
int fortune5 = ‘5’;
//fortune 6 is a noncommital answer
int fortune6 = ‘6’;

//set start command to spacebar
int start = 32;
//set end command to z
int ending = ‘z’;
//set reset command to q key
int escape = 113;

//read in the fortune as fortuneOutcome
int fortuneOutcome;

//set a variable to tell the program
//if the light is rotating or pulsing or not
int processing = 0;
int pulsing = 0;

//set a variable to hold the state of the program
//0 is off, 1 is color cycling, 2 is powering up to white,
//3 is powering from white to the final color
int state = 4;

//store the pressure of the hand trigger
int pressure = 0;

// set the variable for the light in the crystal
// there is one light, so initialize it as 1 pixel
Adafruit_FloraPixel light = Adafruit_FloraPixel(1);

//set an int to hold the current color number 0-255
int count;

//set an int to hold the count, brightness and fade increment value for pulse
int pulseCount = 0;
int brightness = 0;
int fadeIncrement = 5;

//store incoming byte values
int incomingByte;

// fortunes from the mystic void
// 1 is just rude
char* outcome1[] = {“The fact that nobody understands you doesn’t mean you’re an artist.”, “There is so much more knowledge to be learned than you have the capacity to possess.”, “We cannot identify your problem, but it is probably hard to pronounce.”};
// 2 is negative, but not too mean
char* outcome2[] = {“We don’t see that success is immediately in your future.”, “Live every day like you are dying, because you slowly are.”, “Bless your heart.”};
// 3 is neutral
char* outcome3[] = {“The spirits will do their best to influence your journey”, “Some soul-searching will help aid your decisions”, “Do your best to live life to the fullest”};
// 4 is positive and nice
char* outcome4[] = {“Sometime in the future there will be happiness.”, “Walk towards the sunshine and the shadows will fall behind you.”, “Hard work and perseverance will lead you towards your goal.”};
// 5 is super positive
char* outcome5[] = {“We believe in you. You can do it!”, “You are loved.”, “You have a wonderful soul.”};
// 6 is noncommittal answers
char* outcome6[] = {“Perhaps.”, “Maybe some day.”, “It might come to pass.”};
void setup() {
// initialize serial

//set up the light sensor

//initialize the florapixel

//update the light, to start it is off;


void loop() {
if (Serial.available()){
// read the oldest byte in the serial buffer
incomingByte =;

if (incomingByte == start) {
processing = 1;
state = 0;
else if (incomingByte == ending){
processing = 0;
state = 1;
else if (incomingByte == escape){
state = 4;
else {
fortuneOutcome = incomingByte;

//restart the count at 256
if(count == 256){
count = 0;

//cycle through colors one by one
light.setPixelColor(0, Wheel(count % 255)); //set the light color; //show the light color
count++; //increment count to go through every color eventually

light.setPixelColor(0, brightness, brightness, brightness);;

brightness += fadeIncrement; //ramp the brighntess up or down

//if the brigness is at max or min, go the other direction
if (brightness == 0 || brightness == 255){
fadeIncrement = -fadeIncrement;



case 0: //keep going with colors;
//change the state if my hands are turned palm up
if (accelSensor.magData.z > 0){
state = 1;

case 1: //fade from current color to off
pulsing = 1;
state = 2;

case 2: //pulse white
if (fortuneOutcome)
state = 3;

case 3: //display fortune
sensors_event_t event;
if (event.light)
Serial.print(event.light); Serial.println(” lux”);
state = 4;

case 4: //turn off
processing = 0;
pulsing = 0;
light.setPixelColor(0, 0, 0, 0);

light.setPixelColor(0, 0, 0, 0);


////////////////////////////////////helper functions
//configure the light sensor
void configureLightSensor()
/* You can also manually set the gain or enable auto-gain support */
// lightSensor.setGain(TSL2561_GAIN_1X); /* No gain … use in bright light to avoid sensor saturation */
// lightSensor.setGain(TSL2561_GAIN_16X); /* 16x gain … use in low light to boost sensitivity */
lightSensor.enableAutoRange(true); /* Auto-gain … switches automatically between 1x and 16x */

/* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
lightSensor.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); /* fast but low resolution */
// lightSensor.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); /* medium resolution and speed */
// lightSensor.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); /* 16-bit data but slowest conversions */

// Create a 24 bit color value from R,G,B
RGBPixel Color(byte r, byte g, byte b)
RGBPixel p; = r; = g; = b;

return p;

//Input a value 0 to 255 to get a color value.
//The colours are a transition r-g-b- back to r
RGBPixel Wheel(byte WheelPos)
if (WheelPos < 85) {
return Color(WheelPos * 3, 255 – WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return Color(255 – WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return Color(0, WheelPos * 3, 255 – WheelPos * 3);
//fade to dark from current color (Wheel edit)
RGBPixel fade(byte WheelPos){
int fullColor = 255;
int r, g, b;
if (WheelPos < 85) {
for ((r = WheelPos * 3) && (g = 255 – WheelPos * 3) && (b=0); fullColor > 0; r–, g–, b–, fullColor–){
//don’t let the colors get below 0
if (r < 0){ r = 0; }
if (g < 0){ g = 0; }
if (b < 0){ b = 0; }
//count–; //decrement the count so the loop will eventually end
light.setPixelColor(0, r, g, b);;
} else if (WheelPos < 170) {
WheelPos -= 85;
for ((r = 255 – WheelPos * 3) && (g = 0) && (b = WheelPos * 3); fullColor > 0; r–, g–, b–, fullColor–){
//don’t let the colors get below 0
if (r < 0){ r = 0; }
if (g < 0){ g = 0; }
if (b < 0){ b = 0; }
//count–; //decrement the count so the loop will eventually end
light.setPixelColor(0, r, g, b);;
} else {
WheelPos -= 170;
for ((r = 0) && (g = WheelPos * 3) && (b = 255 – WheelPos * 3); fullColor > 0; r–, g–, b–, fullColor–){
//don’t let the colors get below 0
if (r < 0){ r = 0; }
if (g < 0){ g = 0; }
if (b < 0){ b = 0; }
//count–; //decrement the count so the loop will eventually end
light.setPixelColor(0, r, g, b);;
state = 2;

void fortune(int fortuneNum){
int num = random(0,2); // generate a number between 0 and 2 to grab the mystic response

case ‘1’:
case ‘2’:
case ‘3’:
case ‘4’:
case ‘5’:
case ‘6’:


THE FLOOR IS LAVA! September 20, 2015

For our first assignment, I was at a conference in San Fransisco so I’m a little behind on turning it in.

My concept is a hallway in a building with tiled floors- it could be a small shopping mall, an office building main hallway, or even a wing in a school. There would be signs on either end and along the hallway walls saying things like “Caution, Lava Floor” and “Stay on the colored tiles!”  When a floor pad (pressure sensor) is stepped on at either end of the hallway, it triggers the translucent tiles (that were white-looking to start with) to light up with red and orange lights flowing down the hall, with the exception of the tiles that were colored at the start (grays, greens, and browns so you’ll know they’re safe, earthy ground spots).  The objective is to reach the end of the hall without stepping on the lava tiles and dying (in the game, they won’t actually kill you).  There is no actual end of the game because you still need to get where you’re going even if you burn in a lava-induced fiery death, so it just continues to glow as you go down the hallway.

To prevent any “mature adult” businessey humbugs from not playing along and just walking down the hall, a loud, low, rumbling buzzer will sound if you step in the lava.  It will turn off when pressure is released from the translucent-tile lava area, so if you stay on the safe ground islands and hop or long-step from one to the next you’ll be safe from the lava again and you’ll stop annoying the people who work in the areas around the hallway with the buzzing.

To account for the doors and such that open onto lava in the middle of the hallway, I set it so if you step in the lava while the hallway is inactive, it will activate the lights (and the buzzer, until you get onto safe ground).  To account for electric bills in the instillation space, I set it to turn off after a set amount of time

These are some overall view of my arduino and board:
FullSizeRender 2 FullSizeRender 3These buttons act as the sensors for the start and end of the hallway.  I would have used pressure sensors, but I didn’t have any more and buttons are basically binary pressure sensors so I figured it’s pretty much the same thing to trip the setup into working.

FullSizeRender 2

These lights are the lava, flowing from left to right in this setup.  The piezo represents the buzzer that scares people off the lava or signifies them burning to death.
FullSizeRender 3

The pressure sensor would be under the network of translucent tiles that light up and become lava.  It activates the buzzer sound and resets the lights so the lava continues to glow.

FullSizeRender 4

Below is my Arduino, with almost all of the pwm pins taken up.  I probably didn’t need to wire in the blue of the RGB LEDs if I needed more space, but I didn’t need the space and I had hooked them up so I just left them.



The hardest thing I had trouble with was figuring out how to make it turn off after a set amount of time. I tried a for-loop with a count in a separate function, but that stopped the program from progressing altogether until the count was done.  Eventually I set a counter variable as higher than the amount of time after which I wanted it to turn off, and set that back to zero every time a trigger was activated while incrementing it in the while loop that controls everything within the main loop of the program.

I also wanted to have the lava “flow” down the hallway, so I randomly set the first color as some red/orange shade and sequentially made the rest of the lights the last color of the light before it.  You can keep adding any amount of lights to this sequence if you have enough lights and Arduino pins, which I think is pretty cool.

I can’t get the center LED to read in the red value when the buzzer is going off, which is confusing because it’s getting its color value from the LED to the left of it in the picture, and it’s wired exactly like the other two.  It’s not a wiring issue because the red reads well when the buzzer is off. It’s not a hardware issue because if you switch two of the LEDs the middle one still doesn’t work properly and the others do. I don’t think it’s a code issue because it should just be grabbing the value of the first LED, and the third one grabs the value that the second should be pretty well. I have no clue what’s going on.  But the rest of it works great!

UPDATE: Pin 9 on my Arduino is stupid and just stops sending power to the center LED which is why it’s being dumb.  I switched it to PWM pin 2 on the board and in the code and now it works great.  I did not update my code below so it matched the pictures and the video, but that’s what the problem was.



* The Floor is Lava hallway installation
* VIZA 662, Fall 2015 by Leslie Martin

int sensLava = A2; //set the input pin for the pressure sensor lava in hallway

//set the input pins for the buttons start and end of hallway
int START = A0;
int END = A1;

int COUNT = 1000; //int to count up until lights should stop, at higher number so it starts as off
int ENDCOUNT = 100; //when to reset the process

int valLava = 0; //variable to store input values from sensor

int aLEDr = 12; //set the output pins for the first RGB LED
int aLEDg = 11;
int aLEDb = 10;
int bLEDr = 9; //set the output pins for the second RGB LED
int bLEDg = 8;
int bLEDb = 7;
int cLEDr = 6; //set the output pins for the third RGB LED
int cLEDg = 5;
int cLEDb = 4;
int PIEZO = 3; //set the output for the buzzer

// initialize the colors for the first runthrough as 0 (off)
int aRED = 0;
int aGRN = 0;
int aBLU = 0;
int bRED = 0;
int bGRN = 0;
int bBLU = 0;
int cRED = 0;
int cGRN = 0;
int cBLU = 0;

void setup() {
//initialize button pins as input
pinMode(START, INPUT);
pinMode(END, INPUT);
// initialize light pins as output
pinMode(aLEDr, OUTPUT);
pinMode(aLEDg, OUTPUT);
pinMode(aLEDb, OUTPUT);
pinMode(bLEDr, OUTPUT);
pinMode(bLEDg, OUTPUT);
pinMode(bLEDb, OUTPUT);
pinMode(cLEDr, OUTPUT);
pinMode(cLEDg, OUTPUT);
pinMode(cLEDb, OUTPUT);
// initialize serial

void loop() {

//read the sensor triggers
valLava = analogRead(sensLava);
START = analogRead(START);
END = analogRead(END);


if (START == HIGH || END == HIGH || valLava > 600){
COUNT = 0; //If any trigger is pressed, restart the count
START = LOW; //reset start and end values so they turn off


//read the lava sensor and print the value
valLava = analogRead(sensLava);

//trigger to turn lava lights on
if (START == HIGH || END == HIGH || valLava > 600){
COUNT = 0; //If any trigger is pressed, restart the count
START = LOW; //reset start and end values so they turn off

//if the sensor is not pressed, shut up
if(valLava <= 600){
//analogWrite(PIEZO, 0);
// COUNT += 1;
//if the sensor is pressed, make noise
if(valLava > 600){
analogWrite(PIEZO, 255);
tone(PIEZO, 0);
// COUNT += 1;
//COUNT += 1;

//turn the LEDs off
analogWrite(aLEDr, 0);
analogWrite(aLEDg, 0);
analogWrite(aLEDb, 0);
analogWrite(bLEDr, 0);
analogWrite(bLEDg, 0);
analogWrite(bLEDb, 0);
analogWrite(cLEDr, 0);
analogWrite(cLEDg, 0);
analogWrite(cLEDb, 0);

void lavaLights(){

//update the lava colors
//set c to the last values of b
cRED = bRED;
cGRN = bGRN;
cBLU = 0;

//set b to the last values of a
bRED = aRED;
bGRN = aGRN;
bBLU = 0;

//set a as random orangy-red color
aRED = random(30, 150);
aGRN = random(0, 3);
aBLU = 0;

//write the new colors to the LEDs
analogWrite(aLEDr, aRED);
analogWrite(aLEDg, aGRN);
analogWrite(aLEDb, aBLU);

analogWrite(bLEDr, bRED);
analogWrite(bLEDg, bGRN);
analogWrite(bLEDb, bBLU);

analogWrite(cLEDr, cRED);
analogWrite(cLEDg, cGRN);
analogWrite(cLEDb, cBLU);

New Blog! September 2, 2015

This is my blog for VIZA 662: Physical Computing at Texas A&M! Yay!