Hands Up, Don’t Shoot

Since my project is available on Instructables, I’ll use this opportunity to go through some of the development of my project. I had to wire this thing up at least on three separate occasions, with increasing amounts of desperation. I first tried to do the whole thing on an Uno, but ran out of RAM. I tried to do the whole thing on a Micro, then realized that the timer infrastructure on the chip [which is different from the Uno’s chip] is different in precisely the way that I needed it to be the same for the code to work. I tried to use tilt switches – three at a time to make a ghetto accelerometer, which did work, even if it wasn’t the most reliable switch. Then I tried to use two boards together to make it work. I tried serial communication and then realized I could just digiwrite to one pin, and digiread it on the other side.

This became a theme in my work, where I bemoaned my lack of creativity and desire for simplicity. I could’ve just hooked up a transistor to a preexisting audio recorder [they sell on amazon for twenty dollars and lower], and hooked that up to an accelerometer, but alas, I thought of that too late. Anyway, here are the early prototypes of the circuit!

The first iteration of my soldering [it’s a mess]:

_DSC0765_1000

New and Improved Circuit with tighter wiring and a wrist case:

_DSC0855_1000 _DSC0856_1000 _DSC0844_1000 _DSC0841_1000 _DSC0840_1000

I ultimately resoldered the circuit one more time to get it even smaller… I tried to stuff it in a pocket and then sew the pocket onto a pair of gloves, but realized that I was doing more work than I needed to. I ultimately bought some gloves that I used to complete the project. See the Instructable for more info!

_DSC0906_1000

ARDX DC Motor

int transistorPin = 9;

void setup()
{
pinMode(transistorPin, OUTPUT);
Serial.begin(9600);
}

void loop()
{
for(int i =0; i<255;i++)
{
analogWrite(transistorPin, i);
Serial.println(i);
}
for(int j = 255; j>0; j–)
{
analogWrite(transistorPin, j);
Serial.println(j);
}
}

Final Project Ideas

wpid-img_20141112_213657.jpg

My first idea is to revisit my anti-vanity mirror. I would like to use an Ultrasonic sensor to detect people in front of the mirror. Matthew said during class that I ought to be able to get the wood of the frame thin enough to have the audio pings not detect the wood – I think that this would really enhance the “magic” of the experience of using the mirror. I would also try to split the 12V power supply into both the supply to the glass [using a 12V 40V convertor] and to the adafruit trinket board [a smaller board that I hope to supply using a 12V 5V convertor]. The only issue that might arise is that the amperage from the wall socket might be too high for the board.

wpid-img_20141112_213711.jpg

This next idea has more of a social bent to it. Police abuse has been pretty rampant lately in American society. This idea is meant to counteract the abuse of power by the boys in blue – namely by automatically recording any conversations with the police. The FM scanner would scan for the police frequency [since all policemen wear radios on their chest] and start an audio recording if a frequency that matches the police frequency is within range for more than 5 seconds [indicating interaction with a cop]. This is more of a speculative design, I’d have to check with Becky to see if it’s feasible. I think that the instructable aspect of this design is especially compelling.

wpid-img_20141112_213726.jpg

This last design is more one that is concerned with the form of the final object. I want to make this lamp look BEAUTIFUL. It’ll be powered by a tilt switch – when the lamp is horizontal and low over the surface that it is resting on, it’ll turn on. I envision using it when I’m drawing at my desk and I don’t want to disturb others with the light.

The Anti-Vanity Mirror [of Doom]

I grew up in a home with a lot of mirrors. Even if you’re not a vain person, if there is a mirror in front of you, it’s difficult to resist the temptation to at least glance in the mirror to check your reflection. It’s a tendency that I grew up with that I really dislike because it makes me feel superficial; on some level, I think that it actually does make me more vain, little by little. I wanted to discourage this vanity-inducing habit by creating a mirror that is only reflective for a short time before “turning off” [in its actual implementation, this time is 5 seconds].

I had read about smart film in a book by Dan Brown, and began to look for places online that would source it. It turned out to be incredibly expensive [$200 per sq. ft.], but I was able to get a small piece of 6″ x 6″ smart film that I made this mirror with. I initially thought it would be a good idea to build a frame out of 2×4 wood because I had planned on plunge routing a hole out of the wood to store my board and components in. This resulted in a pretty abysmal looking design:

_DSC0611_1000

I bought thinner planks of wood and settled on mounting the components of my circuit on the back of the mirror. If I bring this product to market, I’ll be using a much smaller microcontroller, so it’ll be easier to keep the controller out of sight. For the remainder of the bulky material [namely the 12-40v convertor [more on that later]], I could always laser cut a case out of acrylic to house it in.

_DSC0618_1000

_DSC0614_1000

_DSC0664_1000

I had to cut channels in the wood to receive alligator clips; the smart film requires a really strong connection with its power supply, otherwise it has a tendency to flicker or not turn on at all.

_DSC0620_1000

I had originally experimented and tried to find perforated or clear material that I could hide the sensor behind within the frame, but I couldn’t find anything. I ultimately chiseled a hole out of the wood to fit the sensor, but accidentally chipped the exterior of the wood.

_DSC0648_1000

I used some veneer, courtesy of Boris, to patch up the cracks:

_DSC0647_1000

_DSC0653_1000

_DSC0649_1000

I also spray-painted the wired connection of my IR sensor black so that it wouldn’t be uber-visible through the hole that I made.

_DSC0619_1000

Here are two shots of the mirror in its on and off stages:

_DSC0662_1000

_DSC0661_1000

So now that the story of the physical build of this mirror is complete, I’ll regale you with the tale of the TWO Arduino boards and 1 IR sensor that I destroyed while making this mirror. I struggled with Boris, late one Wednesday night, trying to use a transistor to turn the circuit that controls the mirror on and off. You see, the smart film requires 40V to become transparent, which is more voltage than the Arduino could safely handle. The original idea was to use a transistor to control the flow of electricity between the 12V power source and the 40V convertor, but the transistor just wasn’t working. We then tried to use a relay, but the relay wasn’t working either. We finally tried a combination of the two… and that still didn’t work [what gives?!].

We pulled out the multimeter and realized that my Arduino board was fried, probably due to a short circuit earlier in the day, and wasn’t delivering voltage to the pins. With a new board, I was able to successfully flip the relay to power the film. The only issue [which would manifest itself in disaster the next day] was that the relay was controlling power to the 40V side of the convertor, instead of the 12V side. So the next day, as I was tweaking my code, which was largely functional, the power surged [or at least I think it did], my computer turned off, and my board fried. Also, my IR sensor was completely fried. Sad beans.

I rewired the circuit, removed the transistor and only relied on the relay, which now modulated my smart film circuit on the 12V side. Interestingly, because the convertor stores current, the smart film’s once discrete transition from clear to opaque and back again became gradual; I had to alter my code for this. The only issue that remained was a debouncing problem – when I stood at the edge of the mirror’s range, the mirror flickered on and off almost continuously. The way that my code was set up originally, I was checking for a state change defined by a baseline reading in the IR sensor, and then activated the smart film based on this reading and state change.

I tried debouncing, initially by setting a timer based on when the mirror knew someone was standing in front of the mirror, but this didn’t work because the debounce timer reset continuously when I wanted it to be activated just once [i.e. I wanted the timer to run when someone was standing in front of the mirror]. Because the bouncing occurred at the edge of the sensor’s range, I realized that I could start the timer on the off position, so that it ran when someone stood in front of the mirror. The problem now was that because the code was looking for a state change, it would only ever activate the mirror right after someone stood in front of it, when it would fail the debounce time requirement. I changed the methodology for controlling the relay, so that it specifically looked for a state continuity – the code had to loop twice with the switch activated for the mirror to activate. To allow the mirror to turn off [remember, the debounce timer was running off of the off state], I added a second loop that looked for the off state specifically, and turned the mirror off.

And so… it works!

Innovative Switch

I only have one idea cause I ran it by Becky after class last time. I want to make an “Anti-Vanity Mirror” that is covered with opacity-changing glass. This is glass that has charge-sensitive particles suspended in it. When a current is passed through it, all of the particles align, and the glass becomes transparent. The idea is to overlay this material on a mirror, and use an IR distance sensor to sense when someone comes within 3 ft of the mirror. When that happens, current will flow through the glass, making the mirror visible, for 10 seconds, after which the current will stop and the mirror will become opaque again.

Step 1. Prototype
Step 2. ???
Step 3. Profit

Arduino circuit 7

Here’s my code for the second circuit:

int OnSwitch = 2;
int OffSwitch = 3;
int LEDPin = 4;
boolean onoff = false;

void setup()
{
pinMode(OnSwitch, INPUT);
pinMode(OffSwitch, INPUT);
pinMode(LEDPin, OUTPUT);
}

void loop()
{
if(digitalRead(OnSwitch)==LOW)
{
onoff = true;
digitalWrite(LEDPin, HIGH);
}
else if(digitalRead(OffSwitch)==LOW)
{
onoff = false;
digitalWrite(LEDPin, LOW);
}

if(onoff == true)
{
digitalWrite(LEDPin, HIGH);
}
if(onoff == false)
{
digitalWrite(LEDPin, LOW);
}
}