Skip to content

Instantly share code, notes, and snippets.

@arduinoboard
Created April 20, 2013 02:11
Show Gist options
  • Save arduinoboard/5424413 to your computer and use it in GitHub Desktop.
Save arduinoboard/5424413 to your computer and use it in GitHub Desktop.
The file that is currently on an LilyPad Arduino w/ ATmega328 with a serial number of AE01CSA1
/*
RUAH
BODY AS A CENTER
Year 2012/2013
BA/Graduation project
Product Design
Body as an object and dress as a second skin.
RUAH is an interactive corset controlled by Arduino.
This geometric corset helps people to learn the importance and
the benefits of a deep diaphragmatic breath.
The circuit is composed by a sensor sewn on an elastic belt and
an actuator placed inside the corset.
The stretch sensor catches the move of diaphragmatic breath
and sends a feedback from lilypad to muscle wire, a flexinol
spring, inflating and deforming the centre of the structure.
Through this interaction between user and bustier, user becomes
conscious about his body and his breath, increasing his sensory
abilities and his physical endurance.
The slow controlled breath, which balances body and mind, is
acquired only after a long workout.
As the wearer feels it like a real second skin, RUAH transmits and
receives emotional feedback, contrasting a continuous sense of
stillness and movement, opposite feelings that surround us and
join up to ecstasy.
*/
// Configuration
const int sensorAnalogIN = 0; // Analog Pin connected to Stretch Sensor
const int transistorOUT= 9; // Digital output PWM Pin (3,5,6,9,10,11) connected to actuator Transistor (connected to Nithinol Spring)
const int vibrationOUT = 12; // Output powered to signal the end of calibration.
int calibrationTime = 30; // time (in seconds) neeeded for initial calibration
int loopTime = 100; // time (in milliseconds) for each loop
// Variable declarations
int stretchValue = 0; // value returned from the potentiometer
int normalizedStretchValue = 0;
int maxStretchValue = 0;
int minStretchValue = 1024;
int actuatorValue = 0;
void setup() {
// set the transistor pin as output:
pinMode(sensorAnalogIN, INPUT);
pinMode(transistorOUT, OUTPUT);
//init Serial Console
Serial.begin(9600);
// init end-of-calibration Output
pinMode(vibrationOUT, OUTPUT);
//DEBUG:
digitalWrite(vibrationOUT, LOW);
Serial.print("======================= CALIBRATION START ====================\n");
// calibrate in the first seconds after boot
while (millis() < calibrationTime*1000) {
stretchValue = analogRead(sensorAnalogIN);
// record the maximum sensor value
if (stretchValue > maxStretchValue) {
maxStretchValue = stretchValue;
}
// record the minimum sensor value
if (stretchValue < minStretchValue) {
minStretchValue = stretchValue;
}
// DEBUG
Serial.print("minStretchValue= ");
Serial.print(minStretchValue);
Serial.print("\t stretchValue= ");
Serial.print(stretchValue);
Serial.print("\t maxStretchValue= ");
Serial.print(maxStretchValue);
Serial.print("\n");
}
maxStretchValue = maxStretchValue + 5;
minStretchValue = minStretchValue - 5;
// signal the end of the Calibration period
Serial.print("======================= END OF CALIBRATION ====================\n");
digitalWrite(vibrationOUT, HIGH);
delay(4000);
digitalWrite(vibrationOUT, LOW);
}
void loop() {
// Get the value of the stretch sensor (0-1024)
stretchValue = analogRead(sensorAnalogIN);
// Normalize the measured stretch value by the calibration bounds (from calibrated range to 0-255)
normalizedStretchValue = map( stretchValue, minStretchValue, maxStretchValue, 0, 255);
// cut out extremely high or negative out-of-calibration measured values
normalizedStretchValue = constrain(normalizedStretchValue, 0, 255);
//control output transistor (0-255)
analogWrite(transistorOUT, normalizedStretchValue);
// DEBUG
Serial.print("stretchValue = ");
Serial.print(stretchValue);
Serial.print("\t normalizedStretchValue (OUTPUT) = ");
Serial.print(normalizedStretchValue);
Serial.print("\n");
// wait fora a loop time
delay(loopTime);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment