I Am Sensor – Twitch (tilt switch) code and circuit

The code and circuit for the Arduino-powered giant tilt switch was adapted from this page – http://starter-kit.nettigo.eu/2010/tilt-sensor/

Starting circuit for giant tilt switch
Starting circuit for giant tilt switch
Circuit for giant tilt switch
Circuit for giant tilt switch
/// Defining a pin for the tilt sensor
#define SENSOR_PIN 2
// Defining a pin for the LED diode
#define LED_PIN 13
// Defining a pin for the piezo
#define PIEZO_PIN 3
// Defining sensitivity time [ms]
#define SENSOR_TIME 100
// Defining alarm duration time [ms] (5000 ms = 5 s)
#define ALARM_TIME 10000

// variable storing sensor's switching time
unsigned long sensor_time;
// variable storing alarm duration
unsigned long alarm_time;
// variable storing pitch change time
unsigned long signal_time = 0;
// variable storing the pitch value
// 0 - no sound
// 1 - first tone
// > 1 - second tone
byte sound_tone = 0;

// alarm siren function
void alarm_signal()
{
  if (sound_tone != 0) // checking if the siren should be turned on
  {
    if (millis() - signal_time > 750) // checking tone duration
    {
      signal_time = millis(); // storing the time when the tone was turned on
      sound_tone = ~sound_tone; // turning on the second tone
    }

    if (sound_tone == 1) // first tone
    {
      tone(PIEZO_PIN, 300);
    }
    else // second tone
    {
      tone(PIEZO_PIN, 200, 100);
      delay(1000);
      tone(PIEZO_PIN, 400, 100);
      delay(1000);
    }
  }
  else
  {
    noTone(PIEZO_PIN); // Sound off
  }
}

// Function invoked when the alarm is off
void alarm_on()
{
  alarm_time = millis(); // storing the time when the tone was turned on
  digitalWrite(LED_PIN, HIGH); // LED on
  sound_tone = 1; // Turning alarm siren on
}

// Function invoked when the alarm is off
void alarm_off()
{
  if (millis() - alarm_time > ALARM_TIME) // checking alarm duration
  {
    digitalWrite(LED_PIN, LOW); // LED off
    sound_tone = 0; // Turning alarm siren off
  }
}

// function checking sensor's state
void check_sensor()
{
  // checking sensor's state
  if (digitalRead(SENSOR_PIN) == HIGH)
  {
    // Action if off

    if (sensor_time == 0) // checking if the state was changed
    {
      sensor_time = millis(); // storing sensor's activation time
    }
    // Condition, if sensor's state lasts for a specified time
    else if (millis() - sensor_time > SENSOR_TIME)
    {
      alarm_on();
    }
  }
  else
  {
    // Action if off
    sensor_time = 0;
    alarm_off();
  }
}

void setup()
{
  // Setting the sensor's pin as input
  pinMode(SENSOR_PIN, INPUT);
  // Turning internal Pull Up resistor on
  digitalWrite(SENSOR_PIN, HIGH);
  pinMode(LED_PIN, OUTPUT);
}

void loop()
{
  check_sensor();
  alarm_signal();
}

Second prototype for over-sized Arduino-powered tilt switch

Second prototype for over-sized Arduino-powered tilt switch - clear acrylic tube
Second prototype for over-sized Arduino-powered tilt switch – clear acrylic tube
Second prototype for over-sized Arduino-powered tilt switch - clear acrylic tube
Second prototype for over-sized Arduino-powered tilt switch – clear acrylic tube
Second prototype for over-sized Arduino-powered tilt switch - clear acrylic tube
Second prototype for over-sized Arduino-powered tilt switch – clear acrylic tube
Second prototype for over-sized Arduino-powered tilt switch - clear acrylic tube
Second prototype for over-sized Arduino-powered tilt switch – clear acrylic tube

Sketches for over-sized Arduino-powered tilt switch

Some initial sketches for an over-sized tilt switch that will generate audio through the Arduino board when activated.

Sketch for over-sized Arduino-powered tilt switch
Sketch for over-sized Arduino-powered tilt switch
Sketch for over-sized Arduino-powered tilt switch
Sketch for over-sized Arduino-powered tilt switch
Sketch for over-sized Arduino-powered tilt switch
Sketch for over-sized Arduino-powered tilt switch

Sketch for over-sized Arduino-powered tilt switch

Sketch for over-sized Arduino-powered tilt switch
Sketch for over-sized Arduino-powered tilt switch
First draft schematic - over-sized tilt switch
First draft schematic – over-sized tilt switch

 

PG02, Cycle 2 – initial individual concept + notes

My initial notes + sketch for PG02, Cycle 2 – Behind the Scenes brief
Interface design
Thinking about the process that translates gesture to sound, sound to 3D sculptures, movement to light. How people will interact with the piece. What the touchpoints are? The elements that people can interact with. What do they look like? How do we signpost them? Make them usable. Is the interface clear or is there some mystery within it? 
What does the ‘box’ or object that contains the Arduino look like? Feel like? Sound like? What is the environment. 
Is the translation one way? Or does the user get feedback (haptics, smell, sound, light)?
Creating or designing a process that will translate one type of input into a different output. 
Research sensors and how they can be used. 
Use skills in audio production and composition. What are the inputs and outputs of any audio / sound content? Create a musical score that explains the process of how the sound / audio / composition is generated. 
PG02, Cycle 2 - Behind the Scenes - initial individual concept sketch
PG02, Cycle 2 – Behind the Scenes – initial individual concept sketch
PG02, Cycle 2 - Behind the Scenes - initial individual concept diagram
PG02, Cycle 2 – Behind the Scenes – initial individual concept diagram

Save