Loren – Soft Switch

I made a circuit that would light up with an animation when the circuit was completed. With this switch, I made an orange casing that would act as a lantern and emit light when the ‘handle’ is pulled. There is a flickering animation that would lead to runing on the main LED. Here is the code and schematic provided:arduinoschematic_lilypad_bb
// set pin numbers:
const int buttonPin = 12;     // the number of the pushbutton pin
const int ledPin1 = 10;       // below pins setup for LED pins
const int ledPin2 = 9;

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int flickerTime = 100;       // variable for delay of flicker animation
// can under-go change for manipulation
int counterFlicker = 0;

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);

// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// if the flicker counter is zero (first turn on state) flicker animation starts
if (counterFlicker == 0){
digitalWrite(ledPin2, HIGH);
delay(flickerTime);
// turn the pin off:
digitalWrite(ledPin2, LOW);
delay(flickerTime/2);

digitalWrite(ledPin2, HIGH);
delay(flickerTime);
// turn the pin off:
digitalWrite(ledPin2, LOW);
delay(flickerTime/2);

digitalWrite(ledPin2, HIGH);
delay(flickerTime);
// turn the pin off:
digitalWrite(ledPin2, LOW);
delay(flickerTime/2);

// adding to flicker counter, stops flicker animation
counterFlicker++;
}

// after flicker animation, turn on LED
digitalWrite(ledPin1, HIGH); //turn on led #1
} else {
// turn LED off:
digitalWrite(ledPin1, LOW); //turn off led #1
// reset flicker count so it shows for next connection
counterFlicker = 0;
}
}

From the process of this assignment, I tested the resistance and conductance of an orange. The only possibility of sending power through it, was using standalone orange juice. Through this reasoning, I was only able to include an orange housing with conductive copper strips and thread. Here are some follow-up pictures.

20170120_163351.jpg20170120_163331.jpg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s