Kiyana SalkeldIan BirnamZoe Beba
Published

Behavior Staining

A way to keep your clutter in its place.

Full instructions provided2,819
Behavior Staining

Things used in this project

Hardware components

3"x4"x.0625" Acrylic
×1
3"x4"x.125" Diffuse acrylic
×1
Force Sensor Resistor
×1
LED's
×12
Plywood box
×1
3"x4"x.0625" Foam
×1
Arduino UNO
Arduino UNO
×2
speaker
×1

Story

Read more

Code

CM_P1.ino

C/C++
CM_P1.ino
int ledPins[] = {7, 8, 4, 12, 2, 13}; // LED pins
int pulsePins[] = {3, 11, 5, 10, 6, 9}; //Pulse/Fading LED pins
int sensorPin = 0;  // select the input pin for the sensor
int val = 0; //store value coming from the sensor


void setup()
{
  //get on same serial communication with other arduino
  Serial.begin(115200);
  //turn all LEDs to OUTPUT mode
  int index;
  for(index = 0; index <= 5; index++)
  {
    pinMode(ledPins[index],OUTPUT);
    pinMode(pulsePins[index],OUTPUT);
  }

}

void loop() {
  //read in value from FSR
 val = analogRead(sensorPin);
 
// if pressure detected beyond 128 threshold, start staining
 if (val > 128) {
    //turn on middle row lights one at a time, 1.5 second delay between each.
    digitalWrite(ledPins[0], HIGH);
    delay(1500);
    digitalWrite(ledPins[1], HIGH);
    delay(1500);
    digitalWrite(ledPins[2], HIGH);
    delay(1500);
    digitalWrite(ledPins[3], HIGH);
    delay(1500);
    digitalWrite(ledPins[4], HIGH);
    delay(1500);
    digitalWrite(ledPins[5], HIGH);    
    
    delay(1000);
    //fade outer lights in
    for(int i =0; i < 256; i += 16) {
       analogWrite(pulsePins[0], i);
       delay(100);
       analogWrite(pulsePins[1], i);
       delay(100);
       analogWrite(pulsePins[2], i);
       delay(100);
       analogWrite(pulsePins[3], i);
       delay(100);
       analogWrite(pulsePins[4], i);
       delay(100);
       analogWrite(pulsePins[5], i);
       delay(50);
    }
    delay(50);
    //send signal to other arduino to start playing slimey sound
    Serial.println (1);
    delay(28000);
 } else {
   //turn off all lights if no pressure detected
    analogWrite(pulsePins[0], 0);
    analogWrite(pulsePins[1], 0);
    analogWrite(pulsePins[2], 0);
    analogWrite(pulsePins[3], 0);
    analogWrite(pulsePins[4], 0);
    analogWrite(pulsePins[5], 0);
    digitalWrite(ledPins[0], LOW);
    digitalWrite(ledPins[1], LOW);
    digitalWrite(ledPins[2], LOW);
    digitalWrite(ledPins[3], LOW);
    digitalWrite(ledPins[4], LOW);
    digitalWrite(ledPins[5], LOW);
    
 }
}

audio_recev.ino

C/C++
audio_recev.ino
//Code from Slides by Eric Paulos
#include <Wtv020sd16p.h>
int val;
int resetPin = 2;  // The pin number of the reset pin.
int clockPin = 3;  // The pin number of the clock pin.
int dataPin = 4;  // The pin number of the data pin.
int busyPin = 5;  // The pin number of the busy pin.

Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);

void setup()
{
  //get on same serial communication with other arduino
  Serial.begin(115200);
  Serial.println("Serial Monitor Connected");
  wtv020sd16p.reset();
}

void loop()
{
  //check to see if communication exists
  int incoming = Serial.available();
  
  if (incoming > 0)
  {
    //play slime sound for 30 seconds
    wtv020sd16p.asyncPlayVoice(0);
    delay(30000);
  }
}

Credits

Kiyana Salkeld

Kiyana Salkeld

4 projects • 3 followers
Senior double majoring in Computer Science and Cognitive Science
Ian Birnam

Ian Birnam

4 projects • 2 followers
Zoe Beba

Zoe Beba

4 projects • 2 followers

Comments