My second mini project, a metaphor for human impact on an environment and how intervening in one area can can cause a chain reaction throughout an ecosystem. This project is composed of hand-crocheted flowers laced with conductive thread, a plush fabric landscape, and a lilypad arduino. When the first flower is touched, it 'dies', the light in it's center going out and causing a chain reaction throughout the other flowers.
Video of the project in action:
Code (Under Read More):
#define COMMON_PIN 5 // The 'send' pin for all flowers
#define NUM_OF_SAMPLES 30 // Higher number whens more delay but more consistent readings
#define CAP_THRESHOLD 100 // Capactive reading that triggers the light
#define NUM_OF_S 1 // Number of flower sensors
#include <CapacitiveSensor.h>
#include "pitches.h"
// Defines the pins that the flowers are connected to:
CapacitiveSensor cs_4_2 = CapacitiveSensor(5,7);
int mode = 0;
void setup() {
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);
pinMode(6, OUTPUT);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
pinMode(12, OUTPUT);
//flowers are on in the beginning
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
digitalWrite(10, HIGH);
digitalWrite(12, HIGH);
}
void loop() {
long total1 = cs_4_2.capacitiveSensor(30);
// If the capacitance reading is greater than the threshold, play a note:
if(cs_4_2.capacitiveSensor(30) > CAP_THRESHOLD) {
digitalWrite(6, LOW); // Turns off the corresponding light
mode = 1;
}
else if(mode == 1)
{
delay(100);
digitalWrite(6, LOW); //Keeps light off
delay(500);
digitalWrite(8, LOW);
delay(500);
digitalWrite(10, LOW);
delay(500);
digitalWrite(12, LOW);
}
else{
digitalWrite(6, HIGH); //Otherwise it's on.
}
}
No comments:
Post a Comment