The Big Black Bag has two functions: (1) when the zipper is unzipped, lights inside the bag light up; (2) when my cellphone rings, the bag vibrates. If I am not holding the bag, a LED on the bag will light up. If I am holding the bag, the LED will not light up since I cannot see it anyway.
Zipper
For the zipper portion of the interactive bag, I did not use any code for it. It is a physical switch that connects when the bag is unzipped. I sewed conductive thread at the ends so when the zipper reaches the ends, it is connecting the circuit and the LEDs in the bag light up.
Cellphone Ring
For the cellphone ring portion, I sewed the lilypad vibe board in the shoulder straps as well as a push button so my arduino knows when I am holding the bag or not. If I am holding the bag, the push button is pushed (input = LOW). If I am not holding the bag, the push button is released (input = HIGH). To know whether my celllphone is ringing or not, I wanted to use an RF sensor but there is none out there that is off-the-shelf. I tried buying this key chain for $0.89 which is suppose to detect cellphone rings and then light up but it did not work. So instead, I used a photosensor to detect incoming cellphone calls since all cellphones light up when it receives a call.
Testing Code:
Testing photosensor response to cellphone LCD:
shoulder strap embedded w/ vibe board & pushbutton:
A Working Bag…
has not been produced yet. I used conductive thread and solid wire to make the connections which is something I learned NOT to do. After putting the bag together nothing worked. It seems like the connections are not solid and the programming is a bit faulty. I decided to test the circuit and code again by going back to the breadboard. Individually the push button and vibe board circuit and the photosensor work but together they do not work. I don’t understand why. If someone can figure that one out please let me know. In the meantime I am going code it a different way.
Code for the breadboard circuit:
/* This sketch describes how the BIG BLACK BAG behaves when there is an incoming cellphone call.
When there is an incoming call the shoulder strap will vibrate and:
(a) if the bag is being carried, the LED on an accessory pin will NOT light up
(b) if the bag is NOT being carried, the LED on an accessory pin will light up
*/
int photoPin = 0; // sets photosensor to analog 5
int val = 0; // variable for storing the value coming from photosensor
int light = 0; // variable for reading photosensor
float sens = .85; // defines sensitivity of the photocells (0 - 1.0 "always on")
int vibe = 5; // sets vibe board to digital 1
int triLed = 7; // sets LEDs to digital 7
int buttonPin = 13; // sets input pin for pushbutton to digital 13
int buttonVal = 0; // variable for reading the button status
void setup() {
pinMode(photoPin, INPUT); // declare photosensor near zipper as input
light = analogRead(photoPin); // reads initial state of photosensor i.e. retrieves ambient light value
pinMode(vibe, OUTPUT); // declare vibe as an output
pinMode(triLed, OUTPUT); // declare the triPin as an output
pinMode(buttonPin, INPUT); // declare photosensor as input
}
void loop() {
val = analogRead(photoPin); // reads resistance from photosensor i.e light value
buttonVal = digitalRead(buttonPin); // read input value from button
if ((val > light*sens) && buttonVal == HIGH) { // If amount of light is larger than threshold & button is released (HIGH)
digitalWrite(vibe, HIGH); // turn vibe board on ...
digitalWrite(triLed, HIGH); // turn LED on.
}
if ((val > light*sens) && buttonVal == LOW) { // If amount of light is exceeds threshold & button is pressed (LOW)
digitalWrite(vibe, HIGH); // turn vibe board on ...
digitalWrite(triLed, LOW); // turn LED on.
}
else { // when there is no incoming call (inactive state)...
digitalWrite(triLed, LOW); // LEDs are off
digitalWrite(vibe, LOW); // vibe board is off
}
}