Laser Pointer Interface

A while ago I built a computer input device using a laser pointer and regular usb web camera.

It was a pretty simple setup, and I used a lot of existing tools as a jumping off point. Here’s a writeup of my work and details for how to replicate it and what I learned.

First, a video overview:

Materials

At a minimum:

  • A web camera
  • A laser pointer

Optionally:

  • A projector

Technically speaking, the laser is completely optional. In fact, during testing I just had a desktop computer with the camera pointed at a sheet of paper taped to a wall, and I drew with the laser pointer on that sheet of paper and used that as an input device. With the projector, you can turn the setup into a more direct input, as your point translates directly to a point on a screen. But that’s just a bonus. This can be done without the projector.

Physical Setup

Take the camera, point it at something. Shine the laser inside the area where the camera can see. That’s it in a nutshell. However, there are some additional considerations.

First, the more direct the camera, the more accurate it will be. If the camera is off to the side, it will see a skewed wall, and because one side is closer than the other, it’s impossible to focus perfectly, and one side of the wall will be more precise than the far side of the wall. Having the camera point as directly as possible at the surface is the best option.

Second, the distance to the surface matters. A camera that is too far from the surface may not be able to see a really small laser point. A camera that is too close will see a very large laser point and will not have great resolution. It’s a tradeoff, and you just have to experiment to find the best distance.

Third, if using a projector, the camera should be able to see slightly more than the projected area. A border of a few inches up to a foot is preferable, as this space can actually be used for input even if it’s not in the projected space.

Fourth, it’s important to control light levels. If there are sources of light in the view of the camera, such as a lamp or window, then it is very likely the algorithm will see those points as above the threshold, and will try to consider them part of the laser pointer (remember white light is made up of red, green, and blue, so it will still be above the red threshold). Also, if using a projector, the laser pointer has to be brighter than the brightest the projector can get, and the threshold has to be set so that the projector itself isn’t bright enough to go over the threshold. And the ambient light in the room can’t be so bright that the threshold has to be really high and thus the laser pointer isn’t recognized. Again, there are a lot of tradeoffs with the light levels in a room.

Software Packages

I wrote my software in Java. There are two libraries that I depended on heavily:

The JAI library is not entirely essential, as you could decide not to translate your coordinates, or you could perform your affine transform math to do it and eschew the large library that will go mostly unused. The neat thing about this transform, though, is that it allows for the camera to be anywhere, and as long as it can see the desired area, it will take care of transforming to the correct coordinates. This is very convenient.

The JMF library exists for Windows, Linux, and Mac. I was able to get it working in Windows, but wasn’t able to get it completely working in Linux (Ubuntu Jaunty as of this writing), and I don’t have a Mac to test on.

Basic Theory

The basic theory behind the project is the following; a laser pointer shines on a surface. The web camera is looking at that surface. Software running on a computer is analyzing each frame of that camera image and looking for the laser pointer. Once it finds that pointer, it converts the camera coordinates of that point into screen coordinates and fires an event to any piece of software that is listening. That listening software can then do something with that event. The simplest example is a mouse emulator, which merely moves the mouse to the correct coordinates based on the location of the laser.

Implementation Theory

To implement this, I have the JMF library looking at each frame. I used this frameaccess.java example code as a starting point. When looking at each frame, I only look at the 320×240 frame, and specifically only at the red value. Each pixel has a value for red, green, and blue, but since this is a red laser I’m looking at, I don’t really care about anything but red. I traverse the entire frame and create a list of any pixels above a certain threshold value. These are the brightest pixels in the frame and very likely a laser pointer. Then I average the locations of these points and come up with a single number. This is very important, and I’ll describe some of the effects that this has later. I take this point and perform the affine transform to convert it to screen coordinates. Then I have certain events that get fired depending on some specific things:

  • Laser On: the laser is now visible but wasn’t before.
  • Laser Off: the laser is no longer visible.
  • Laser Stable: the laser is on but hasn’t moved.
  • Laser Moved: the laser has changed location.
  • Laser Entered Space: the laser has entered the coordinate space (I’ll explain this later)
  • Laser Exited Space: the laser is still visible, but it no longer maps inside the coordinate space.

For most of these events, the raw camera coordinates and the transformed coordinates are passed to the listeners. The listeners then do whatever they want with this information.

Calibration

Calibration is really only necessary if you are using the coordinate transforms. Essentially, the calibration process consists of identifying four points and mapping camera coordinates to the other coordinates. I wrote a small application that shows a blank screen and prompts the user to put the laser point at each of the prompted circles, giving the system a mapping at known locations. This writes the data to a configuration file which is used by all other applications. As long as the camera and projector don’t move, calibration does not need to be done again.

Here is a video of the calibration process.

The Code

Here is the camera.zip (3.7mb). It includes the JAI library, the base laser application, the calibrator, and an example application that just acts as a mouse emulator.

Below are a couple snippets of the important stuff.

This first part is the code used to parse each frame and find the laser point, then fire the appropriate events.

/**
* Callback to access individual video frames. This is where almost all of the work is done.
*/
void accessFrame(Buffer frame) {
/***************************************************************************************/
/********************************Begin Laser Detection Code*****************************/
/***************************************************************************************/
// Go through all the points and set them to an impossible number
for (int i = 0;i<points.length;i++){
points[i].x = -1;
points[i].y = -1;
}
int inc = 0; //set our incrementer to 0
byte[] data = (byte[])frame.getData(); //grab the frame data
for (int i = 0;i<data.length;i+=3){//go through the whole buffer (jumping by three because we only want the red out of the RGB
//if(unsignedByteToInt(data[i+2])>THRESHOLD && unsignedByteToInt(data[i+1])<LOWERTHRESHOLD && unsignedByteToInt(data[i+0])<LOWERTHRESHOLD && inc<points.length){//if we are above the threshold and our incrementer is below the maximum number of points
if(unsignedByteToInt(data[i+2])>THRESHOLD && inc<points.length){//if we are above the threshold and our incrementer is below the maximum number of points
points[inc].x = (i%(3*CAMERASIZEX))/3; //set the x value to that coordinate
points[inc].y = i/(3*CAMERASIZEX); //set the y value to the right line
inc++;
}
}
//calculate the average of the points we found
ave.x = 0;
ave.y = 0;
for (int i=0;i<inc;i++){
if (points[i].x!=-1){
ave.x+=points[i].x;
}
if (points[i].y!=-1){
ave.y+=points[i].y;
}
//System.out.println(points[i].x + "," + points[i].y);
}
//System.out.println("-------------------");
if (inc>3){//if we found enough points that we probably have a laser pointer on the screen
ave.x/=inc;//finish calculating the average
ave.y/=inc;
PerspectiveTransform mytransform = PerspectiveTransform.getQuadToQuad(mapping[0].getX(), mapping[0].getY(),
mapping[1].getX(), mapping[1].getY(), mapping[2].getX(), mapping[2].getY(), mapping[3].getX(), mapping[3].getY(),
correct[0].getX(), correct[0].getY(), correct[1].getX(), correct[1].getY(), correct[2].getX(), correct[2].getY(), correct[3].getX(), correct[3].getY());
Point2D result = mytransform.transform(new Point(ave.x,ave.y),null);
in_space = !(result.getX()<0 || result.getY() < 0 || result.getX() > SCREENSIZEX || result.getY() > SCREENSIZEY);
if (!on){
fireLaserOn(new LaserEvent(result, new Point(ave.x, ave.y), last_point, last_raw_point,in_space));
on = true;
}
if (in_space && !last_in_space){
fireLaserEntered(new LaserEvent(result, new Point(ave.x, ave.y), last_point, last_raw_point,true));
}
//                System.out.println(result.getX() + "," + result.getY());
//                System.out.println(last_point.getX() + "," + last_point.getY());
//                System.out.println("----------------------");
if (result.getX()!=last_point.getX() || result.getY()!=last_point.getY()){
fireLaserMoved(new LaserEvent(result, new Point(ave.x, ave.y), last_point, last_raw_point,in_space));
}
else{
fireLaserStable(new LaserEvent(result, new Point(ave.x, ave.y), last_point, last_raw_point,in_space));
}
if (!in_space && last_in_space){
fireLaserExited(new LaserEvent(result, new Point(ave.x, ave.y), last_point, last_raw_point,false));
}
last_time = 0;
last_point = new Point2D.Double(result.getX(), result.getY());
}
else if (last_time==5){//if it's been five frames since we last saw the pointer, then it must have disappeared
if (in_space){
fireLaserExited(new LaserEvent(-1,-1, ave.x, ave.y, (int)last_point.getX(), (int)last_point.getY(), (int)last_raw_point.getX(), (int)last_raw_point.getY(),in_space));
}
fireLaserOff(new LaserEvent(-1,-1, ave.x, ave.y, (int)last_point.getX(), (int)last_point.getY(), (int)last_raw_point.getX(), (int)last_raw_point.getY(),in_space));
on = false;
in_space = false;
}
if (ave.x>0 || ave.y>0 && ave.x<CAMERASIZEX && ave.y<CAMERASIZEY)
fireLaserRaw(new LaserEvent(-1,-1, ave.x, ave.y, -1,-1, (int)last_raw_point.getX(), (int)last_raw_point.getY(),in_space));
last_time++;//increment the last_time. usually it gets set to 0 every frame if the laser is there
last_raw_point = new Point(ave.x,ave.y);//set the last_point no matter what
last_in_space = in_space;
/**************************************************************************************/
/********************************End Laser Detection Code*****************************/
/*************************************************************************************/
}
public int unsignedByteToInt(byte b) {
return (int) b & 0xFF;
}

This next part is pretty standard code for adding event listeners. You can see which laser events are getting passed. I intentionally made it similar to how mouse listeners are used.

Vector<LaserListener> laserListeners = new Vector<LaserListener>();
public void addLaserListener(LaserListener l){
laserListeners.add(l);
}
public void removeLaserListener(LaserListener l){
laserListeners.remove(l);
}
private void fireLaserOn(LaserEvent e){
Enumeration<LaserListener> en = laserListeners.elements();
while(en.hasMoreElements()){
LaserListener l = (LaserListener)en.nextElement();
l.laserOn(e);
}
}
private void fireLaserOff(LaserEvent e){
Enumeration<LaserListener> en = laserListeners.elements();
while(en.hasMoreElements()){
LaserListener l = (LaserListener)en.nextElement();
l.laserOff(e);
}
}
private void fireLaserMoved(LaserEvent e){
Enumeration<LaserListener> en = laserListeners.elements();
while(en.hasMoreElements()){
LaserListener l = (LaserListener)en.nextElement();
l.laserMoved(e);
}
}
private void fireLaserStable(LaserEvent e){
Enumeration<LaserListener> en = laserListeners.elements();
while(en.hasMoreElements()){
LaserListener l = (LaserListener)en.nextElement();
l.laserStable(e);
}
}
private void fireLaserEntered(LaserEvent e){
Enumeration<LaserListener> en = laserListeners.elements();
while(en.hasMoreElements()){
LaserListener l = (LaserListener)en.nextElement();
l.laserEntered(e);
}
}
private void fireLaserExited(LaserEvent e){
Enumeration<LaserListener> en = laserListeners.elements();
while(en.hasMoreElements()){
LaserListener l = (LaserListener)en.nextElement();
l.laserExited(e);
}
}
private void fireLaserRaw(LaserEvent e){
Enumeration<LaserListener> en = laserListeners.elements();
while(en.hasMoreElements()){
LaserListener l = (LaserListener)en.nextElement();
l.laserRaw(e);
}
}
  • This algorithm is extremely basic and not robust at all. By just averaging the points above the threshold, I don’t take into consideration if there are multiple lasers on the screen. I also don’t filter out errant pixels that are above the threshold by accident, and I don’t filter out light sources that aren’t moving. A more robust algorithm would do a better job and possibly identify multiple laser pointers.
  • I’m not the first person that has done this, though from what I can tell this is the first post that goes into so much detail and provides code. I have seen other people do this using other platforms, and I have seen other people try to sell this sort of thing. In fact, this post is sort of a response to some people who think they can get away with charging thousands of dollars for something that amounts to a few lines of code and less than $40 in hardware.
  • Something I’d like to see in the future is a projector with a built in camera that is capable of doing this sort of thing natively, perhaps even using the same lens system so that calibration would be moot.
  • You may have seen references to it in this post already, but one thing I mention is having the camera see outside the projected area and how that can be used for additional input. Because the laser pointer doesn’t have buttons, its input abilities are limited. One way to get around this is to take advantage of the space outside the projected area. For example, you could have the laser act as a mouse while inside the projector area, but if the laser moves up and down the side next to the projected area it could act as a scroll wheel. In a simple paint application, I had the space above and below the area change the brush color, and the sides changed the brush thickness or changed input modes. This turns out to be extremely useful as a way of adding interactivity to the system without requiring new hardware or covering up the projected area. As far as I can tell, I haven’t seen anyone else do this.
  • I have seen laser pointers with buttons that go forward and backward in a slideshow and have a dongle that plugs into the computer. These are much more expensive than generic laser pointers but could be reused to make the laser pointer much more useful.
  • Just like a new mouse takes practice, the laser pointer takes a lot of practice. Not just smooth and accurate movement, but turning it on and off where you want to. Typically releasing the power button on the laser pointer will cause the point to move a slight amount, so if you’re trying to release the laser over a small button, that has to be considered so that the laser pointer goes off while over the right spot.
  • This was a cool project. It took some time to get everything working, and I’m throwing it out there. Please don’t use this as a school project without adding to it. I’ve had people ask me to give them my source code so they could just use it and not do anything on their own. That’s weak and you won’t learn anything, and professors are just as good at searching the web.
  • If you do use this, please send me a note at laser@bobbaddeley.com. It’s always neat to see other people using my stuff.
  • If you plan to sell this, naturally I’d like a cut. Kharma behooves you to contact me to work something out, but one of the reasons I put this out there is I don’t think it has a lot of commercial promise. There are already people trying to, and there are also people like me putting out open source applications.
  • If you try to patent any of the concepts described in this post, I will put up a fight. I have youtube videos, code, and witnesses dating back a few years, and there is plenty of prior art from other people as well.

Broken Car Lock

It’s no secret that I love my car. It’s been extremely dependable, has treated me very well, has a good personality and an adventurous attitude, and doesn’t ask for much (it’s a 2000 Chrysler Neon, and yes, I mean Chrysler). I’ve had it for almost 10 years and put over 100,000 miles on it myself in addition to the 20,000 that were on it when I got it used. If I were to get another car, I’d look for something exactly like the one I have.

But once in a great while it will have small issues. Once a wiring harness broke loose and cause the rear lights to go out. Other than that, it’s worked very well and could probably go for another hundred thousand miles without problem.

About a week ago I put my key in the door to unlock it and found that it turned freely. I had to unlock the passenger side and then unlock the driver side from the inside. For a few days I drove around without locking the door. Monday I finally got an opportunity to examine the problem. I was able to disassemble the door relatively easily. It was fairly straightforward except for the part where the window handle was connected, but I managed to find the service manual online and pop the handle off. Then I could get in to the lock mechanism and see where the problem was. It didn’t take long to discover the problem. The rod that connects the lock mechanism to the key had slipped off. The piece that held it on was missing. Figuring it was probably at the bottom of the door frame, I felt around and identified it. Yep, there was the problem.

That piece should be symmetrical. The piece that had broken was about 2 millimeters wide and because of that the thing slipped off the lock and was no longer holding the rod in place. It didn’t take much jostling for the rod to fall out.

I didn’t have any parts exactly like that, and I was up to the challenge of fixing it with parts that I had around the house. I made a crude washer out of a piece of scrap tin from a can. Then I made a springy curl of stiff wire that would take the place of the part that broke. I installed onto the lock mechanism and played with it a little to make sure it was stuck pretty well. I tried to take it off to adjust it a little, but couldn’t even get it off without some serious effort, so I just left it on there. I tested it thoroughly before putting the door back together. With the door completely reassembled, I tested it out some more, and it worked exactly like it had originally worked.

I’m kind of glad that my car is mostly mechanical and doesn’t have a lot of electronic parts. Electronic locks or windows would have made this a much more difficult operation. I’m also happy that I was able to build the parts that I needed from scratch and basic tools. Plus, I always enjoy doing things with my hands and seeing the results and saving money in the process.

Partially Failed Cheesecake

Saturday I had a party for work, so I thought I’d throw together a cheesecake. I used the recipe I’ve used a few times in the past. Better Homes and Garden, by the way. Rather than melt some semi-sweet chocolate, I went instead with a bottle of Hershey chocolate sauce. I was getting to the bottom of the bottle, and I noticed that as I squeezed it would spatter out in neat randomness. So on top of the swirled cheesecake filling I sprayed the sauce, not realizing that it would ultimately be the cause of a huge problem.

The cake cooked fine, and after I took it out of the oven it still looked good, but the spots where there was sauce looked a little weak and were starting to crack. When the top of a cheesecake begins to crack, the cracks turn to crevasses as it cools down, and that’s exactly what happened. There were three pretty big cracks as it cooled. I looked around for something to fix it and found a block of milk chocolate that Erin had given me. I thought I’d shave chocolate onto the top to see if it would cover up the cracks. But the chocolate shavings weren’t as silky smooth as I thought, and they broke up into smaller pieces than I expected. It was time to go to the party, so I made the decision not to bring the cheesecake. That turned out to be ok, though, because there was already a lot of food there.

Aesthetically, the cheesecake was mediocre. It tasted great, though. Here’s a picture, but remember, it only looks average; it’s too bad I can’t make the web lick-able.

Camera Troubles

Erin handed me a camera a week ago that had gone through some tough times. It had been dropped while on, and the lens assembly was broken and askew. The camera couldn’t recover from it on its own, and so I was brought in to see if I could fix it. Having been able to revive Erin’s camera, which had the misfortune of a drop into sand, and having removed dust from my own camera many times, I took on the job. Since it was already broken, the owner of the camera didn’t have any expectations of getting it back anyway, so it was a riskless job. The first image is of the camera, though the lens problem is not visible.

Taking the camera apart was not difficult. There were lots of tiny screws, but for the most part the pieces separated fairly easily. Of course, as I did it I learned little bits about the assembly that made taking it apart easier. The second picture shows the partially disassembled camera. The lens assembly came out without any screws.

The lens assembly out, I was able to partially disassemble it as well. There were two main lenses. The first was the big one in the picture below. The second was the small one in the picture below that. Both were capable of moving.

In fact, it was the plastic on the smaller lens that had broken, and was sticking out, preventing the lens assembly from closing back up. This little piece of plastic, which is the part closest to the camera, turned out to be extremely important. I tried at first to just remove it and reassemble the camera, but it turned out that it wouldn’t focus without it. The piece was essential for guiding the lens forward and back and without it a small spring was pulling it in a direction it shouldn’t have gone. I was able to super glue it back together, but then had to take a small file to remove small jutting slivers that were adding too much friction to the assembly. The hardest part was putting the whole lens assembly together and back apart over and over, which took many minutes each time, and put wear and tear on some components that were only ever meant to be assembled once. In fact, a great deal of time was spent maintaining and guiding parts back together, and resetting springs that had to be unset.

I thought that I had been successful and had fixed the camera, but there was a problem. When I took a photo, the iris would stay closed, and it wasn’t until I would dismantle the whole thing that I could reopen the iris. Clearly this would not work in the field. I had to dismantle the assembly further to discover another unfortunate break.

The iris is controlled by two extremely small electromagnets, which apply torque to two magnets, which have small arms at the end of them. Those arms push and pull the thin pieces of plastic over the lens to adjust the light levels. Unfortunately, one of the arms was broken on the small magnet.

This was the deal breaker. Without the arm, the iris wouldn’t function properly, and the images would be overexposed (or possibly underexposed). The magnet wouldn’t take to super glue, and even the process of gluing was made more difficult by the fact that all my tools were metallic and would move the magnets as soon as they got near. For a sense of scale, the pic below is of an object that’s 4mm long at its longest

It took a lot of time to work on the camera and figure out how it all fit together. There were a lot of little pieces that had to be assembled just so, and it’s such a shame that the camera is perfectly good except for a few misplaced atoms, and because I won’t be able to find a replacement will now likely be discarded in its entirety.

My Empty Cupboards Project

For about a month leading up to my move, I stopped shopping for food. I was trying to clean out the cupboards and start over fresh. It was surprisingly easy. For a long time I was fine with meat from the fridge or freezer, for a few weeks I had fresh vegetables, and I had plenty of snackish food for between meals.

During the week or so that I moved my stuff, I had a hard time finding the motivation or the time or even the utensils to take care of too many meals, so I had fast food a couple days and pizza or sushi from Safeway a couple days.

Now I’m in the new apartment, and the project continues. I haven’t filled the cupboards yet. With the exception of a single cupboard that has baking stuff like sugar, flour, baking soda, etc., ALL of the food is in the fridge or on the counter. Having it on the counter has given me incentive to eat it, as it’s in my face and in my way. But it’s been about three weeks since I’ve moved and I’m still working away at the pile. In fact, I think I could continue this experiment for about another two weeks and still be ok.

A while ago I ran out of milk and eggs, and that had a huge impact on what I could do. Without those basic ingredients, a lot of the food became impossible. I couldn’t make bread or bake or do any kinds of desserts. A few days ago I broke down and got just milk and eggs, and that’s helped me along quite a bit.

Some of the things I’ve been making have been… interesting. There was an omelet made with mizithra cheese and diced prunes (it was actually pretty good), homemade tortillas with beans and salsa, beer bread with tuna salad, and other dishes. One of my favorite discoveries was that raw Ramen is an excellent substitute for rice cakes. Just open the bag, split the Ramen in half flat-ways (it’s easy to do), and spread jelly or peanut butter on it.

I’ve been craving a lot of meat, though, lately. I’d love to tear into a hamburger or a steak. And some of the food that I have left is more of a side dish, not a main course. I think I may break down and get some meat or vegetables so I can have the side dishes in a decent meal.

Another of my discoveries in this endeavor has been the strangeness of expiration dates. Perhaps it’s because of the dry and mold-free climate of this area, but I’ve been eating food that’s expired sometimes years ago. You’re not really supposed to keep your stored goods in moldy/damp areas, ie. basements and such, but I had corn tortillas that expired in February of 2008, and they were still perfectly fine. They were a little dried out at the bottom of the bag, but I sliced them up and baked them to make chips. I haven’t really come across much that I felt uncomfortable about eating, and some of it was canned food over a year past it’s date. I think either we shouldn’t be so prudish about expiration dates on food, or we should be using a lot less preservatives.

Yet another realization was that food just seems to accumulate in the cupboards, and sometimes just never gets consumed. There’s no good reason for it, just entropy. I have a can of jellied cranberries that is a few Thanksgivings old, and I just haven’t done anything with it. I could easily have it as a side dish with pork chops, but instead other foods have a much higher turnover in my kitchen. I need to be better about keeping the cupboards tight. The good news, though, is that the average family could probably survive a lot longer than they think if they had to.

The experiment will continue until all the food is gone. Then we’ll go shopping and stock the cupboards more wisely. As I scrape the bottom of the barrel in the coming days, I’ll probably buy one or two things to supplement the meals, but this has been an interesting and difficult challenge.

TV Remote Alarm

We had an interesting problem at work. There’s a display in the main lobby of my building that shows the calendar of all the conference rooms and a map showing where they are in the building. It’s pretty handy for visitors and looks really slick. The problem, though, is night. There’s no point in having the display running 24/7. But the TV has a flaw where it won’t go into sleep mode when the HDMI cable is plugged in, even if the computer itself is asleep and there isn’t a signal.

The solution so far has been for a select few to turn it on in the morning when they arrive and off when they leave. Naturally, this isn’t a sustainable or reliable solution, as it doesn’t take a lot for the system to break down.

So Ian brought me in on the problem to see what I could do with it. I thought about some existing options. An outlet timer would work for turning it off in the evening, but not for turning it on in the morning (it would give the TV power, but not turn it on). I even found an alarm clock that was capable of being programmed to turn on and off a TV, which was really close to what we wanted, but it was discontinued, and reading into the manual it looked like it wasn’t going to work anyway.

I realized I would have to build something. I started off thinking of building off of the Arduino microcontroller board, which I’ve used for other projects and really enjoy using. I spent a day working on hooking up an infrared LED and trying to get it to output a standard on/off signal that the TV would recognize. I also tried to hook up an LCD screen and buttons for configuring the timer, but I quickly got frustrated as each part took way longer than I wanted, and wasn’t getting anywhere.

It made a lot more sense to work with existing electronics and cobble something together. It turned out I already had an alarm clock that I had stopped using in favor of my cell phone, and the alarm clock had two configurable alarms on it. And Ian had purchased for me a cheap universal remote. So I just had to get the alarm clock to trigger the remote control.

This was easier said than done. First I took apart the remote control. I followed the traces back from the on/off button and soldered a couple wires to them, then fed them out the back of the remote through a hole where the battery cover was. Next, I opened the alarm clock and went about trying to identify triggers I could use to determine the alarm state. I was hoping for something simple, like one node being +5V when the radio alarm was on and a different node being +5V when the buzzer alarm was on. Sadly, there was no such luck.

I’ll spare most of the details, but I never found a clean signal I could use. I ended up taking the radio alarm, cutting out the speaker, turning the volume all the way up, and using the speaker wire to drive two relays, which triggered the remote, then also fed to the alarm reset button. That way the radio would turn on, the signal would trip the remote, and it would reset the alarm. That one worked pretty slick.

It was even harder for the buzzer alarm. Not only could I not find a signal, but it didn’t go to the speaker, either. It went to a separate piezoelectric speaker, and the voltage to it wasn’t enough to trip the relays. So I had to build an amplifier circuit that bumped the signal up to something that would trip the relay. But then there was another problem. It was tripping the alarm reset button faster than it was tripping the remote, so it’d reset the alarm before the remote control had a chance, and the TV wouldn’t ever get switched. I fixed this by putting in an RC delay circuit on the alarm reset relay.

I put it all back together and tested it out. It’s in my apartment, so I had to try it out on the VCR (I had to take it out of its box), but it worked. The alarm clock dutifully turned off and on the VCR at the right times.

I’m bringing it in to work tomorrow to see if it’ll work on the intended television. It’ll probably sit on a counter across the lobby and point at the TV, and definitely have a sign that says what it is so people don’t get suspicious.

Here’s a picture of the completed project. I won’t show the insides because I’m a little embarrassed of the circuit. I could have done a much cleaner and more correct design, but it works now, so I’m happy. I hope people at work appreciate it, too.

Hard Drive Surgery

A friend of mine recently had a minor emergency when a portable hard drive was knocked off a table and ceased to function. I was called in to help. Indeed, it did not work. When plugged in (and I tried on multiple computers and operating systems), it wouldn’t be able to recognize the device.

Since there was nothing I could do externally, I opened up the case, careful to make sure that anything I did could be undone. The case wasn’t even screwed together; it was two pieces of plastic that snapped together. After unsnapping all the way around, the hard drive was exposed. Again, no screws. It was held fast with some rubber strips on the corners. There was a piece of aluminum foil covering the electronics, so I carefully peeled that back. Glancing at the board, I didn’t see anything wrong immediately. The board was attached to the hard drive, and was easy to pull off. It turned out, the hard drive was a standard SATA connection, so I turned off my computer, plugged it in, and turned the computer on. It had no problem recognizing the hard drive and mounting it. I created a folder on my computer and immediately copied all the files over without any problems. Next I compared the file sizes to make sure I had gotten all the files and they added up to the right size. After that, I turned off the computer and removed the hard drive.

Looking again at the board, I noticed a small part near the USB connection that was askew. Looking more closely, it was indeed broken off the board and hanging by only one of the four solder points. The board was so small, though, and the connections tiny. I tried heating up the soldering iron and getting in there, but there was no way I’d be able to resolder it on. Just too small. I told my friend the data was fine and that the board was not and that if she got another portable hard drive I could copy the files over to it.

She brought me a new portable hard drive, so I plugged it in, copied the files, checked the size to make sure it was all copied, and unplugged it. Then I brought her the new hard drive, the old one, and showed her the parts and what had happened. Since the hard drive was still good, it didn’t make sense to discard it. It’s a 120GB laptop hard drive. She’s going to confirm that everything is there, and then I’ll delete the copy of the data I have on my hard drive.

The whole operation was surprisingly easy, and it certainly helped that the portable hard drive was so simply designed and used standard connections. I’m glad we were able to recover everything, though a little disappointed I couldn’t resolder the part back on.

French Toast Sandwich

Continuing an effort to finish off a loaf of french bread before it went stale, I decided to try to make a good breakfast. I can’t remember exactly how I ended up with the idea, but the combination worked extremely well.

I took some brown sugar and honey link sausage and sliced it in half lengthwise. Then I made my french bread egg mixture with egg, cinnamon, nutmeg, and a splash of milk.

While the bread was toasting on the frying pan, I scrambled some eggs in another pan, then cooked the sausages in the pan with the toast. I grated some cheese onto the bread, then put the sausage and eggs on, and put the other slice on top.

It was pretty much the best breakfast sandwich I’ve ever had. It was delicious.

Erin’s Food Challenge

I recently received a pair of ingredients from Erin and was given the challenge to create an original dish with one or both ingredients, name it, and document it. The ingredients were wasabi cheddar cheese, and chili-cocoa powder. I tasted the powder and it was familiar but not extremely appealing. I tried using it as a rub on a pork medallion to see how it would work with other flavors. Again, familiar, but not extremely appealing. Almost done with the pork, I finally realized what it tasted like; mole sauce. Since mole is essentially chili and chocolate, this made a lot of sense. But I still don’t know what to do with it, so I’ll wait on that one.

The other ingredient made a lot of sense to me to use. I was at Safeway yesterday looking for something to eat, and I saw French bread. That triggered an idea for me; open faced grilled sandwiches. So I thought about what would go well on the sandwich with the wasabi cheddar. Obviously I’d need a green filler. I had spinach at home, but I thought sprouts would work better, so I picked up clover sprouts. I got a tomato, too, since that’s a staple for a sandwich. Then I thought about sushi and what goes into various rolls. I picked up an avocado based on that. For a meat, I had some salami at home, but I was a little worried the salami flavor would overpower or conflict with the cheddar. I also had some wasabi mustard at home that I thought about using in case the cheese wasn’t strong enough on its own. I saw a pear, too, and realized it would go perfect on the sandwich. You often have pear, cheese, and bread together. I checked out and headed home.

First, I sliced up all my ingredients:

Next, I started the bread. I sliced the loaf and heated some butter in the pan:

I toasted one side, then applied more butter and flipped the slices. While the bottoms toasted I put the slices of cheese on top to melt. I had to cover the pan to keep the heat in so that the cheese would melt before the toast burned.

Once I was satisfied with the bread, I added the other ingredients. Since this was an experiment, I decided to do 4 different sandwiches with the various ingredients:

On one sandwich is salami, sprouts, tomato, and avocado, with wasabi mustard as well. This one was really good. I think I would have used less wasabi and a milder meat, like turkey or ham, but it was still a really good sandwich.

The next one was mustard, sprouts, and pear. The pear turned out to be a really good choice, and it was also a tasty sandwich.

Next came the sprouts, tomato, avocado, and pear. This was my favorite. None of the flavors beat out the others, and it was all very good.

By the fourth, I was getting full. Plus, the fourth one had gotten a little too toasty on the bottom. I decided to pick everything off the top and eat just that. It was sprouts, tomato, and avocado, which are all very good, but the sandwich itself wasn’t noteworthy in any respect.

With my four sandwiches made and evaluated, the final part of the challenge was to pick a name. Since my favorite was the third, and it had green avocado, green sprouts, green pear, and greenish cheese, I wanted to give it a name, and incorporate green in the name. Some of the motivation behind the ingredients was from sushi, too, so I could incorporate the name soy perhaps. I think I’ll call it a “Soyless Green sandwich with tomato.” Don’t worry, it’s not made of people. But now I do wonder if I could put some kind of soy sauce in it. That could be pretty good.

Going green(er)

I’ve always thought that I am pretty good about doing things in a decently Earth-friendly way. I keep my AC and heat at barely tolerable levels, I recycle, I turn off the lights when I’m not in the room, I turn off the water when I’m brushing my teeth, and I carpool when it makes sense. But I recently read the book //Hot, Flat, and Crowded// by Thomas Friedman, and while it’s a very good book, it scared me pretty good. So I’ve resolved to do even more to reduce my energy usage, carbon footprint, and resource usage. I’ve been doing some experiments around the apartment, and I’ve tried a few things out, and I think I’ve come up with some more reasonable things I can do to save. Plus, I’m saving money this way, which is a bonus.

* Unplugged lights. People have said before that my place is pretty dark. Now it’s even more true. My bedroom is lit with a single 23 watt compact fluorescent bulb, and I’ve unscrewed half the lights in my dining room and bathroom. It’s enough to see clearly, and it’s not as dark as having candles. Plus, even though I was already turning off the lights when I left the room, having only half of them on when I’m in the room means a reduction of energy by 50%!
* Unplugged peripherals. A huge drain on the power grid is devices that are in standby. So I unplug my microwave except when I’m using it, and I use my cell phone as my alarm clock and no longer use a standalone alarm clock.
* Turned down the heat even more. For a couple days I turned it off entirely. However, when my fingers got too cold to let me type, and I started to get sick, I decided that going without heat entirely wasn’t an acceptable option. I did turn it down a couple degrees, though, to 62. Cold enough that I can’t lounge around in shorts and a t-shirt, but not so bad that I can’t type.
* Turning my desktop computer off or putting it in standby. For years I’ve run my desktop computer 24/7 because it acts as a server. I’m now trying to move those services off my computer and onto hosted servers or finding alternatives. Now I can have my computer off or in standby most of the time.

These simple things should reduce my electricity consumption even more. I’ve saved my utility bills every month, and created a graph that shows my power usage each month:

There are some obvious things to note about this graph. It looks like most months I hover just under 400 KWH. Looking at the trendline, there’s an obvious spike in the winter months, with a tiny spike one month in summer when it’s unbearable without some AC. My hope this year is to reduce everything by 25%. I think it’s entirely doable, and using less light, less heat, and having my computer off more will go a long way towards that.

I’ve also been dabbling in energy generation. I built a stand for my bike so I can ride it indoors. Then I took a motor and attached it to the outer rim of the bike so that the spinning wheel would turn the motor and it would generate a current. I put a voltage regulator on it so that it would keep the voltage at +5 so that I wouldn’t blow out my cell phone, then hooked the wires up to a USB port so that it could charge my phone.

Surprisingly, this actually worked. Well, it was easy enough to generate electricity, and getting up to 5 volts was no problem at all, but my phone didn’t appear to be charging. So I sped up. And up. And up. I was cranking it as hard as I could in top gear before the charging light came on. I was also smelling ozone from the motor, so I decided to end the experiment. It was clearly not a sustainable solution, even though it did work for a few seconds.

So I thought the next approach would be to gear down so that I would have more resistance on the bike and it would spin the motor faster. The only set of gears I could find in my apartment were from an old CD player. I tried those and while I was still testing to see what kind of a current I could get I managed to put so much energy into the gears that they quickly melted and then broke. So that wasn’t going to work. Now I’m looking into buying used car alternators, which is probably the way I should have been going from the beginning. Still, it’s good to know that in a pinch I have the knowledge to generate electricity to power a small device.

Finally, I’m working on reducing my consumption in other areas. I’ll be even more vigilant about recycling everything, I’ll reuse things as I can, and I’m going to monitor how much trash I take out. I think that before I was taking out a single plastic grocery bag a week (I don’t buy garbage bags), which is pretty good, and I want to keep track of that to see how that continues. I’m also going to figure out a timer for my showers, and I’ll flush less frequently. That’s actually pretty hard because I’m so accustomed to lifting the seat, putting it down, and flushing that I often don’t realize until I’m washing my hands that I flushed when I shouldn’t have.

It is my hope that watching my consumption and taking small steps to reduce it will have a better effect on the environment and my pocketbook, without reducing my quality of life.