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!