Entries in this blog

I had been thinking about how to achieve individual addressing using demultiplexers even before I gave Charlieplexing a shot. But during my preliminary research the stumbling block was that the largest demux I could find was only a 4 to 16. If I wanted to individually address 64 LEDs I would need four of these, thats 16 I/O pins required to drive them all (I only have 14 on the Arduino).

So that wouldn't work. I continued to mull about this because there was an itch in the back of my skull telling me it could still work. And then it hit me! As you may or may not know, demultiplexers have a given number of inputs to select which output pin to activate. But they also have an enable pin that can disable the entire demux (so no output pins are active).

My idea was to hook up all of the four demux inputs up in parallel with each other. So pin 1 for each demux would be hooked up in parallel together to one I/O pin on the Arduino, and same for pin 2, 3, and 4. So to drive all four demux's you only need 4 I/O pins on the Arduino. Now the problem with this of course is that if you select pin 8 for output, then pin 8 on every demux will go active.

My solution is to use a smaller 2 to 4 demux, and hook these outputs up to the enable pins on each 4 to 16 demux. So with only 2 I/O pins on the Arduino I can select which Demux is active, and only that one will have an output pin going active.

When all is said and done, I only need 4 pins to drive the 4x16 inputs, and 2 to drive the 2x4 inputs. Thats 6 I/O pins to individually address 64 LEDs :D

Now my previous exploration of Charlieplexing was far from a waste of time because it got me thinking about Persistence of Vision as a valid way of presenting a static image. Using this demux method for individual addressing of the LEDs, and Persistence of Vision to present a static image, I have a perfect method for engineering my display! Some bonuses of this method over Charlieplexing are:
The circuit complexity increases linearly as you add more LEDs
LEDs always get the same amount of current
The layout lends itself very well to being in a grid!
So with this rough sketch I set forth! It's a real shame that "The Shack" (Formerly known as Radio Shack, they re-branded them selves, seriously) doesn't carry the stuff they used too. They have just a single cabinet of fairly worthless components. It's a real let down. So finding ICs and other small electronics is a real pain these days. Ordering them from sites is an option, but it took some research to find sites that sell in small quantities. I did find a few good ones finally. Shipping time and cost kinda suck, but what can you do.

The first issue I ran into was that nearly every demux was active LOW. Meaning, all unactive output pins were putting out 5V (HIGH), and when you activated one, it would go to 0V (LOW). Thats fine if you have a logic circuit that is all active LOW. But in my case, that would mean that every LED would always be on, and when I addressed one of them, it would actually turn OFF... Not what I wanted :P

So the only one I found that was active HIGH had a 4bit transparent latch for the input. Not a big deal, kinda cool actually, but it means I need an extra I/O pin for the latch strobe. That puts me at 5 pins rather then 4 for the 4x16 demux's (since i will be hooking all the strobes up in parallel as well), which makes it 7 pins total, well within bounds. The inputs were active HIGH as well, but oddly the enable was active LOW. So if I'm pushing 5V (HIGH) into the enable pins, it DISABLES the demux, and if I drop that to 0V (LOW) it ENABLES the demux.

This actually worked to my advantage because every 2x4 demux i could find (whos output would feed into the 4x16 demux's enable pin) were active LOW logic, so every output pin would propagate HIGH until I activated one, which itself would then go LOW.

2 to 4 Demultiplexer : CD74HC139E

4bit Transparent Latch/4 to 16 Demultiplexer : MC14514BCP

As I was saying, the thing that sucks with Radio Shack and every other small eletronics outfit going the way of the Dinosaurs, is the shipping time. If i got a dead IC, or burned one out my self, I'd have to wait another two weeks for a replacement. So i ordered double of everything I needed. (Each IC was only like $0.75, so not a big deal). And to be extra careful, I'm ordering IC sockets, so I won't be soldering the ICs directly.

Now I ordered and received the demultiplexers already. And hooked one of the 2x4s up to my Arduino to test it all out. I haven't worked with ICs let alone demux's in years, so I wanted to test out my self as well as the hardware, to know for sure they all work:

This is being controlled by my computer via serial input, so i can flip the inputs manually, and see the output state instantly. I plan on modifying the program to run through each state automatically and verify the output for each input state. Sort of unit testing the ICs. Then I will do the same for my 4x16's.

Still quite a bit to do before I'm ready to begin the build, but it feels good to have a solid design finally.

So I got my brandy new Arduino Mega 2560 in the mail. It has 256KiB of program memory (8x the memory of a standard Arduino!)

As I mentioned in my last post, the standard Arduino only has 32KiB of program memory, and with all of the networking features I want compiled into the library I'm using, I was already at 33KiB. But now with a spacious 256KiB (What will I ever do with it all!) I can add in features until my heart's content! (DNS and DHCP oh my!) Other than the extra memory (and extra I/O pins) It is identical to the regular Arduinos. Or so I thought... (cue the misery.)

Getting a blinking LED sketch (Arduino speak for program) running on it from the Arduino IDE was easy enough. But replicating it inside my Code::Blocks setup was not so easy. It took further modification of my command line scripts for which there was little to no documentation to base it off of. After lots of groping around in the dark, trial and error, and some guess work, I got it there. Though the auto-reset was not working, so I have to time a physical reset of the board with the compile button in the IDE to get the programs to upload. *annoying*. This took a few hours... but it gets worse.

Then began the real pain. You see, the trouble starts with the fact that the wonderful WiFi board that I use (the WiShield, made by AsyncLabs) is no longer in production. In fact, in March of this year, AsyncLabs shuttered their little studio completely. Which is a real bummer because they are the ONLY mature, drop-in WiFi solution for Arduino

With AsyncLabs out of the picture, development on its library and support in its forums has all but ceased. With the Mega2560 being a relatively new board, its fair to say that support will never be added for it in the WiShield's code. Now you might ask, but Adam! You said the Mega was pretty much identical to other Arduinos! Why would support need to be added at all! And it's because it's NOT identical. There is a small difference that turned out to be vitally important.

You see the Arduino's are based on an AVR type chip manufactured by Atmel. Atmel makes a variety of these chips under the ATmega line.

These ATmega chips provide a nice little piece of hardware/software functionality called SPI or Serial Protocol Interface. I won't go into the details, but it's critical to the functioning of the WiShield.

This is where the problem lies. Arduino's based on the ATmega168 or the ATmega328, have their SPI pins on 11, 12, 13.

But Arduino's based on the ATmega1280 or the ATmega2560, have their SPI pins on 51, 52, 53. This was a deep rabbit hole the wasn't helped by my ignorance of underlying hardware. Most Ardunio hobbyists never need to get this deep into the micro-controller at the heart of the Arduino, so I initially wasn't trying to learn all about it, I was just trying to solve the problem. And I wasted a *lot* of hours going down this vein. After two days of researching the problem, banging my head against a wall, investigating other WiFi chips and even other micro-controllers entirely, the project was in real danger. But I finally had a break through. I pieced together a solution from many different forum posts and a deeper understanding of the hardware and the problem at large.

It ended up being both a hardware and a software fix. And I had to mutilate my beloved WiFi board a little

This was not a fun excursion. But I hope it clears the the path for some smoother sailing. Next I'm going to try to make the Arduino keep time using NTP (Network Time Protocol) for synchronization. And after that work on pulling events from a Google Calendar. So stay tuned, and I hope to keep these posts shorter

As most techies I know, I have a set of websites I check up on each morning, and throughout the day. I get to the office in the morning, and first things first, I "make the rounds." And thanks to my handy dandy RSS reader, I never miss a single thing. I'm hyper-informed about the narrow set of topics that the sites in my usual rotation cover.

One of those sites is The Verge. A splinter group formed from former Engadget editors, it's quickly becoming one of the best tech and tech culture news sites on the web.

Recently, one of the editors that I follow closely, Paul Miller, came up with an experiment he wanted to run: go internet free for an entire year. And I mean completely internet free. Not just browsing websites, but email, streaming video, music, everything. He even ditched his smart phone and got an old Nokia, and won't even text on it.

I actually kinda get it at a basic level. The internet is completely integrated into my life, it's always there. Any lull in a conversation, out comes the smartphone. Any down time at the office, up comes the browser. So limiting one's interactions with the internet to a more balanced amount sounds perfectly fine to me.

I began following his updates from the disconnected world with some interest. My first reaction was one of: Why so extreme? So many little tasks would become orders of magnitude more difficult for him.

But the more I read of his dispatches, I began identifying with a lot of what he was saying. He talks about the "phantom limb syndrome" of the tech world. Like when you Ctrl+X a piece of text, you almost feel its unpasted ghost in your fingers until you Ctrl+V it back into existence. Or phantom leg vibrations that make you check your phone.

Or worse still for me... the phantom RSS stories left unchecked in my feed. I get a high filtering through my RSS feeds, saving the interesting articles to Pocket (formerly Read-It-Later) for more dedicated consumption later. I've got it down to a science, I'm hyper efficient at it. Clearing out my RSS feeds in the morning is a cathartic experience. For a few minutes... and then I start to get the itch... What new stories have been posted... What am I missing. I better check now so they don't pile up and require even more time to sift through later!

It kinda sucks actually. Something I really enjoyed has become a compulsive need. I tell myself it's both enjoyment (I do genuinely enjoy tech news) and important to stay up on the industry for professional reasons. But it's almost a chore now. This must be how OCD people feel about checking the lock on their door twenty times before they leave. They know it's bad but can't help themselves.

Now I'm not saying the internet is bad. It's a piece of technology. And Technology isn't inherently good or evil, it's how we as human use it that give it import and meaning. I think in terms of inventions that have most profoundly impacted our species, it goes like this so far: Fire, Wheel, Internet. So don't misread my next statement.

In his most recent dispatch, he talks about the signal to noise ratio on the internet being askew. And it really struck a chord with me. It's something that's been burning in the back of my mind for a long time now, and this put a name to it. I instantly seized on it. This was my problem with my RSS feeds. Out of usually around 200 articles sitting in my feed in the morning, I usually only save out about five to read later. I glean tiny fragments of information from scanning the rest, but it's mostly worthless.

For the last year or so I've been trying to cut down on the worthless noise that I usually click on. I've seen enough people walking into signposts and cute kittens to last me a lifetime. It's absolutely a waste of time. So I've been making a conscious effort, before I save something out to read later, to ask myself, is this really worth spending time on? And it's helped. Some. But I'm still filtering through hundreds of articles a day. The internet has lowered the barriers on content creation so far that the noise is now the pervasive standard. And finding the signal in it requires this OCD level of effort, filtering through it all if you don't want to miss something.

My RSS addiction is just one of my "phantom limb" problems though, which cumatively add up to a very distracted life style. So I'm back to reading Paul's dispatches, and being kind of jealous actually.

For my part, I've got a backpacking trip coming up to the Grand Tetons in Wyoming, and from the moment my plane lands I intend to turn my phone off, throw it in the trunk of the rental car, and have my own week of extreme disconnectedness.

I had an unexpected break through on my C3 project! A couple nights ago, I had some spare time, and had been thinking about the pressure sensor for a long time. The problem with it is, there is a circle with a radius of just 4mm, and in order to get good readings, the force must be applied to the center, not the edges. This gives me only about 2mm's in radius to apply force in. Since this will be under my mattress where things can be jostled or move around, that's a pretty narrow margin of error.

With this in mind, I came up with an idea for a "puck" and threw it together in Google SketchUp:

I was blown away by how easy SketchUp was, I learned the program and made this model all in less than an hour. What you are looking at here, on the right is the base of the puck. The sensor will sit at the bottom of the trench and be held in place by it's constrained neck. And the left is the top, that will insert into the trench, and the notch will hold it perfectly in place, while the nubbin will be the only thing applying pressure, and it will be held perfectly on the 2mm pad.

The ease of all of this, really motivated me, and the next night I got my self over to my local hacker space, sprout & co. and printed this baby up using their fantastic Thing-o-matic:

So I brought it home, marveled at how this thing that had been in my brain just two nights before, was now sitting in my hand, and set to programming my Arduino. Came up with a voltage divider so I could get good values out of it, and calibrated it so I could convert the values to readings in pounds. Then I set it up to record a full night of sleep, and dump the contents to a text file on this little net book.

And it functioned perfectly!

You can even see when I got out of bed near the beginning there!

Despite these resounding successes, I hit the same wall I had been at for a while now. The standard Arduino, as well as the available WiFi shields, really weren't up to the scale of the project I had in mind. And the new Arduino Due and the official Arduino WiFi shield which might solve my problems, are seemingly never to be released.

After a day or two of mulling this issue over in my head, I began perusing SparkFun as I am want to do. And I came across the IOIO which I have seen before, but this time it sparked (see what I did there?) a sea change in how I was thinking about this project! So many of the things I wanted the project to do (Like WiFi, NTP, Google Cal sync, Text-to-Speech) are exceedingly difficult for little 8bit Arduino's to do. And other things I wanted the project to do (interfacing with a variety of hardware sensors) are difficult for Android phones to do.

But my change in thinking was to treat my Micro-controller merely as a "Sensors Package". Which a custom Alarm Clock app on my phone will communicate with in order to be smarter than it could be on it's own.

So that's what I'm doing! I'll hook my sensors into my IOIO (pronounced yo-yo) which will connect to my phone via Bluetooth. And my Alarm App which I will make, will utilize the sensor data to do everything I had hoped it work! And more!

Over the weekend, many weeks of research culminated in the first concrete progress on my new hardware project. First let me give a run down of the idea for this project.

The core idea originated from the fact that I'm a bit like Jekyll and Hyde. Except instead of a murderous monster living in my psyche, there is a sleep loving monster who shuts off my alarm clock instead of snoozing it. I know. It's ridiculous. I'm determined to be victorious, however, which brings us to my latest weapon in this battle:

[size="4"]C[sup][cube][/sup]

It's an alarm clock that solves the problem using a pressure sensor. The sensor will be between my mattress and box spring, so it will "know" if I'm still in bed, and simply not allow me to turn an alarm off until I get out of bed and stay out. Though I will still be able to snooze alarms as usual.

Now in order to interface with this pressure sensor, I will of course be using my trusty Arduino. And given that, a whole world of possibilities open up! So in addition to the Arduino, I've also pilfered the Wifi board from my robot. So here is the short list of features the C[sup]3[/sup] will center around:
Time always accurate using NTP (Network Time Protocol), never set it again after losing power!
OLED touch screen for simple input, vibrant graphics, no back-lighting for good night time viewing.
Alarms scheduled using Google Calendar. Never have a work alarm go off on the weekends, vacations, or days off.
Pressure sensor to ensure alarms are not turned off while still in bed.
Current weather conditions displayed on screen.
WAV or MP3 playback for more pleasant alarm types. I'm also investigating a speech synthesization chip (SpeakJet) to allow it to talk And obviously there are many more possibilities having an internet connected alarm clock that I will explore once the base features are implemented.

Night 1: The alarm went off as expected! I snoozed it (as I am want to do). But 30 seconds later it went off again! I had left in my hard coded debugging value of 30 seconds for the snooze time :/ Realizing this in my half awake state, I got out of bed in order to turn the alarm off... but nothing happened... with the alarm still blaring out at full volume, I inspected the app closer, and noticed the pressure value was not updating. I close and reopened the app in an effort to reconnect to the sensor, but to no avail. I ended up having to go under my bed and power cycle the IOIO.

Debugging first thing in the morning is not my idea of fun.

Night 2: In preparation for night 2, I decided to connect to the IOIO over USB to ensure the connection remain steady for the whole night. But 8am come and went with no alarm. I didn't have time to collect any data on what went wrong because I was in quite a rush when I finally did get up.

I had a nagging suspicion however that the volume may have been at least partly to blame. So I modified the app to hard set the volume to max every time it went off, and I improved some of the data smoothing related to the pressure sensor to avoid false positives for getting out of bed.

I also discovered that, with the current firmware on the IOIO, it won't provide power to the phone over USB, so that's not really an option at the moment.

Night 3: Connected over Bluetooth again for this night of testing (due to the charging issue over USB), and added in some more debug logging. This time the Alarm went off at full volume, exactly when it should, and snoozing worked beautifully. But the Bluetooth connection was lost again. I got up and plugged my phone into my computer and dumped the logs. They don't go back far enough to see the disconnect, but I got some data out of it anyway.

I've modified the app now so that when the connection is lost, it dumps the Log to disk right then and there, so Night 4 should produce some more definitive results as to whats going on.

LLOONNGG week of packing, moving, and unpacking. Still not done unpacking. Probably won't be fully unpacked by the time we move again Oh well.

ANYWAY! Onward and upward!

[sub][ I really like my little Paint.NET logo, so thought I'd throw it in again ;) ][/sub]

So since my last post I began working on NTP (Network Time Protocol) synchronization. As with EVERY part of the project so far, there were a lot of snags along the way, but I got it there. It's a truly crippling problem having the maker of my WiFi chip defunct. It leads to all sorts of problems with documentation and community support. But "Damn the torpedoes!" I say! FORWARD!

I had to implement the NTP protocol on my end. I simplified it quite a bit by not taking advantage of many features [40 bytes of hard coded zeros in the middle of my message ;) ], so it was actually pretty easy. Sending and receiving the UDP packets, however, was a bear because of the poor documentation for my WiFi chip. Took quite a bit of fiddling, but I got it working.

Then I found the great little Time library for Arduino that allows for easy manipulation of time and time keeping, and set that up to use my new NTP code for synchronization.

Putting it all together, here you can see the current boot sequence for the C3:

With this working, I set it up for a soak test. I wanted to see how much time the Arduino would lose after it synchronized only once, that way I could figure out how often I would have to re-sync with the NTP servers. After 24 hours I had lost just under a minute, and after 48 hours I had lost just about 2 minutes, which looks pretty good because it doesn't seem to be accelerating. It's a pretty minimal, and a pretty linear loss. I could probably sync with NTP as little as once a day, but to be safe I'll probably start by syncing every 12 hours.

So that's all good! But during the soak tests I did discover yet another problem with my WiFi software stack. It doesn't automatically reconnect when it's connection to the WiFi AP is dropped. It's a fairly minor problem in the software stack that I already found someone's patch for. My version of the stack is already pretty customized however.

So my next goal will be to setup auto-syncing at 12 hour intervals. Merge the WiFi auto-reconnect patch with my customized stack. And finally further customize the stack in preparation for working along side the display shield I will eventually be integrating. (I need to move some pins around in the code)

With all of that I should have a rock solid NTP clock, which of course is the necessary basis for everything going forward. After that I can focus on Google Calendar integration and other "fancy features" like audio output and a display

No I haven't hit any sort of production or even commercial level polish. But the title sure had some nice alliteration huh? ;)

As the title hints at though, the past month has been a great example of the vast gap between a prototype (as seen in my last YouTube video) and a production ready product.

At first I thought doing all of the alarm clock stuff (with Google Calendar integration) would be easier because I was now doing it on Android, with Java and all of Androids high level features. Boy was I wrong.

On Android apps are meant to be ephemeral. Meaning that if you want your app to be a permanent fixture on the system, you really have to fight the system. I've ironed out most of these bugs over the past month, but it's been a long process because I can only do one real world test a day.

I've got it down to the Alarm working very reliably (so far). But the user facing Activity seems to want to die in the middle of the night some times, still working this bug. On the hardware side of things, the Bluetooth connection has some durability issues. Not every night, but often enough, the IOIO disconnects and won't reconnect without a power cycle. Still working this issue.

And lastly, I've determined that the sensor it's self, can't accurately measure a whole Queen sized bed. So I've ordered the parts and will use two sensors, one for each side of the bed. This will give me the added benefit of being able to figure out how many people are actually in bed. Not sure what I will do with this info yet, but more info is always better.

Once I fix the last remaining software problem, and add in some spit and polish, I'm thinking about releasing the app stand alone (sensor parts disabled in options). It will help me with wider testing, and I think the apps Google Calendar integration is a really killer feature on it's own. I'll probably release a free version with a donate micro-transaction or something.

As I stated in my last post, I began some actual work on this project over the weekend.

What's some times not appreciable, is the amount of time it takes just to get started on something like this. Finding all my Arduino parts and pieces, installing the software, figuring out all the little quirks again (It's been more than 6 months since I finished the robot project).

Finally being setup again for Arduino development, I set to soldering together a little voltage regulator for my bread board. It would allow me to put in anywhere between 3V and 36V and get a nice clean 5V signal out. This way I could independently power my breadboard without extra wires from the Arduino.

Next I needed to test my pressure sensor, to figure out how it works and how best to use it. I started by building a little RC (resistor capacitor) circuit as described in the sensor's user manual. But quickly realized this wasn't necessary with the Arduino, Just using one resistor and an Analog pin I could read it directly. Problem was, I was getting these highly variable values. In fact, when graphed over time, they looked quite a bit like the charge and release cycle of a capacitor.

This puzzled me of course because all I had in the circuit was a resistor and the sensor. After more fiddling and frustration, I removed my nifty bread board power supply and hooked it up directly to my Arduino's 5V pin, and instantly I got stable values. Good for my level of frustration. Sad because I really liked my little bread board power supply. Not sure what I screwed up when soldering it together...

Anyway, I happily played around with my sensor, creating functions to produce readings in lbs rather than voltage and such. It was fun and cleared the way for what was, in my mind, one of the biggest question marks for the whole project.

So it's been a bit since my last update, and that's because things have stalled.

The bad news is I've hit a bit of a wall in terms of long term stability with my existing WiFi module. I've addressed issue after issue gradually improving stability of the WiFi stack and my own code. But in the end I just can't get it to stay alive long enough. Even a few days of stability isn't good enough for an Alarm Clock that I'd be relying on to get me to work on time. I could pursue the issues further into the WiFi stack, but it would take a fairly big time investment. Since the stack and hardware are no longer supported I'd be investing all of this time into what is essentially dead hardware. If I ever wanted to upgrade or make another one of these clocks, all of this time would be wasted since I couldn't buy another one of these WiFi modules.

The good news however is there is a ray of hope! Truly excellent news out of Maker fair: Arduino (the company) announced several new Arduino's (the micro-controller) which is great and all, but most excellently, they announced an official Arduino WiFi shield! The library and hardware will be officially supported going forward! They are due to release some time in October, so my project is stalled until I can get my hands on one of these, but this is truly great news for all of my projects which usually have wireless connectivity at their heart

The next day at work it was all I could think about, and around lunch time, it hit me. They are in series! I'm dividing the voltage between the two servos! If I hook them up in parallel they'll EACH get 9V!

That night after a flurry of cutting, de-soldering, and re-soldering, it was ready. Popping a 9V on it made it leap forward! Excited, I set to work hooking the logic boards together, but when it came time to affix them to the chassis I encountered another problem. It wasn't really meant to host a board like this. The screw holes were probably intended for something else, but certainly not for my Arduino. Additionally, I have a bare circuit board I'm trying to attach to a metal chassis! I looked all around in my spare parts for some sort of fastener or holder or something to mount my logic boards with to prevent them from shorting out on the chassis, but couldn't find anything. Finally I settled on cutting an anti-static bag from an old video card and screwing the boards awkwardly through that bag and onto the chassis however I could make them fit.

I then set to testing out some stuff with the Arduino. Read up on the docs for the motor driver, wrote some test programs making it move and turn. Then did the same with the wireless chip, tested hosting a webserver on it and allowing you to control the motors by clicking links. It worked! It wasn't very responsive of course, reloading the page after a link click was pretty slow and all. But it worked! So I called one of my friends via Skype who lives in Texas, and using the webcam on my laptop gave him a view of the robot on the floor. Then I setup some port-forwarding so he could access the server hosted on the robot, and it was ready to go! I stepped back, couldn't see the laptop because of how it was positioned for the webcam. And all of a sudden this little robot starts moving on its own, via commands from my friend in TEXAS! (I live in Boston) I mean c'mon! We really take the internet for granted I know, but the series of events that are transpiring to make his actions in Texas manifest themselves in the real world in my apartment in Boston... I mean c'mon!!!

As Tesla once said: "I do not think there is any thrill that can go through the human heart like that felt by the inventor as he sees some creation of the brain unfolding to success... Such emotions make a man forget food, sleep, friends, love, everything."

Over the next several days I fast iterated. I ripped out the webserver and wrote a proper socket server for the robot, and socket client that ran on my home server. It was MUCH more responsive. Then I wrote a webpage that used AJAX to send "real-time" control commands to stub PHP script, which in turn sent them onto the socket client. And finally, after much research, I found a webcam that worked with Linux, had auto-focus, and great video quality (glass optics, no plastic crap), and a software package for streaming the video to the control webpage (no X11 or GUI of any kind, which restricted my options quite a bit).

This was a blast, you could log onto the site, see the robot from the webcam mounted in the corner of the room, and drive it around using WASD or GUI controls on the webpage. And I did some input wrapping so key down & key up worked the way you'd expect. It was fun. But it was lacking something big. I wanted to drive this robot in first person perspective.

I began researching wireless webcams, or really wireless cams of any kind, and there weren't a whole lot of options. I know you're reading this and saying "Oh c'mon, there's GOT to be some wireless webcams out there!" But really! There aren't! Try Googling for them! There's one or two that were prohibitively expensive and had other problems. Using a regular camera and streaming the video over the robot's WiFi connection was not an option. The Arduino has 2KiB of RAM, and clocks in at 15MHz. That's not a typo. One, Five MegaHertz. Ya, you're not doing video processing of ANY kind on that

The last option I had was home security cameras. But they were prohibitively expensive. The CHEAPEST were well over $100, most up around $300. To give you an idea, I was into this project for about $150 so far, so this camera would cost more than the rest of the project COMBINED. Not an option. But lo and behold, I found a home security camera meeting all my criteria for HALF OFF on a Black Friday sale! So for $60 I was in business.

I got it, chopped up its power cord so I could run it off the robot's internal power, and was off and.... crawling? Ya... and that's where this project kind of ends... After all of that, the wireless security camera was too heavy for the servos. It could BARELY crawl forward, and could only turn about 50% of the time. And this was one of the smaller ones I had seen while doing my research (size was one of my criteria when selecting a camera!). Anti-climactic, trust me I know.

But still, it was a great project, and I learned a LOT. I would post a demo or pictures of me controlling it, but the robot has since been dismantled. I'm scavenging parts for my next project which I hope to be much more successful!

I probably should have posted about this when I was actually doing it. But C'est la vie.

Anyway I had been messing around with some Arduino stuff a while back, and got pretty far but never finished a project. Other things came up so I shelved it all. Then we got a kitten and I thought it would be fun to be able to play with the kitten while I was out of the house.

So I came up with the idea for a remote control robot with a kitten toy attached to it that you could control from a web page. Already having an Arduino, the natural choice was to extend what I had.

I looked into the different parts I would need and settled on this build:
Arduino
SyncLabs WiFi Shield (802.11b)
1amp dual motor driver shield
4 wheeled chassis kit

Now being, at least what I consider to be, a fairly adept programmer, I was not worried about the software side of things.

However I was also not worried about the hardware side of things... This was stupid.

Since the control side of the hardware was merely 3 boards that fit neatly together, I started by focusing on the chassis construction. Now I went into this wanting it to be a fun learning project, not just a robot in a kit. And boy did I get more than I bargained for.

The Chassis kit consisted of a 3 zip-lock bags. 1 contained several tiny metal pieces that clearly were meant to be the chassis frame. 1 contained assorted screws and other hardware necessary for assembly, and the last contained 4 small-ish servos.

I've done some electronics stuff, and we had covered circuits in my college physics classes, but any useful knowledge from those past experiences fell out of my head when I was presented with this unorganized, unstructured bag of parts. There was no manual, no instructions, no numbered pieces. Just a bag of constituent components that could, in the right and knowledgeable hands, be assembled into a robot chassis. Though truth be told they could also be assembled into a doomsday machine for all I knew. Each seemed equally possible from where I stood.

But this is what I had wanted! I wanted to embark on untrodden ground! I wanted to INVENT! Not to follow in the path of countless others! (Of course this isn't really Inventing, it's more so playing with Legos, assembling pre-made pieces into a semi-unique configuration, but give me a break )

So I dug in. Not knowing where in particular to start I began sizing up the metal parts that would make up the frame. Fitting them together didn't take long to figure out. I ended up assembling them, promptly realizing that the order I did it in presented me with problems, and reassembling it again, several times in fact, until I found the optimal method. Attaching the servos again made me disassemble and reassemble the frame (with the frame fully assembled the space was too small for me to work in to attach the servos).

So Finally, after longer then I'd like to admit, I had the chassis assembled and servo's installed inside it.

(I'd like to apologize to my past physics professors for this next part. You really did teach me these things! I just forgot for a few hours...)

I played around with my circuit boards a little, and mulled the problem before me. My motor drivers could drive 2 motor independently, but I had 4 servos. It's not a complex problem and the solution may seem obvious, but exactly how to go about it, and the fear derived from being "untethered", made it a contentious decision. After some rough sketches of my wiring harness, I did some Googling and found some one else's rough sketch that looked exactly like mine! That was enough confirmation for me that I was right. No thoughts back to my physics class about circuits, I forged ahead...

The design I had come up with was intended to keep things as simple as possible. Each motor driver had a + and - terminal on the shield, thus I only wanted 4 wires total coming out of the chassis bound for the control board. I would hook up the 2 motors on a given side in series. This kept wire clutter to a minimum, and kept everything as simple as can be.

I could regale you with tales of soldering through the plastic that held the leads, and cutting the wires too short after one end was already soldered, or how I realized the leads on the servo's were thin cheap and breakable, or how I forgot which lead was + and which was - on the servo because one was the revere of the other. But I won't, suffice it to say it's only the 3rd time I've soldered something. And I learned a lot.

At this point I had been at this for HOURS. It was a monster session. I was burnt out. My girlfriend who had been by my side for most of it, was passed out on the couch at this point, stirring only when I would get a face full of solder smoke and make a pained nasal sound.

I was DONE but couldn't go to sleep without seeing it move. Actually hooking up the logic boards was not an option so I just taped a 9V battery to the chassis and connected the leads to it. The results were less then spectacular. While holding it in the air, the wheels barely moved, and when sitting on the ground it couldn't overcome friction it seemed.

Blurry-eyed, frustrated, and tired. I called it quits for the night and passed out.

Still waiting on Arduino to release their official WiFi shield for my C3 project. So my mind began to wounder. And I started an Android app to help post articles to www.talentopoly.com. But got stalled due to waiting on 3rd party API support. So my mind began to wounder.

About two weeks ago I was browsing www.sparkfun.com checking out some of their Sensors and day dreaming about fun things to do with them, and came across this, the $4 MQ-3 Alcohol Gas Sensor. I immediately straightened up in my seat and all my synapses that had been on vacation began firing again.

You see, all my hardware projects so far get to a point of some sort of moderate success, and then get promptly torn down to produce another project. Mainly because their components are expensive and I don't want to re-buy them all. But also because those projects weren't something I could easily show someone. With the project now swirling around in my head, it was something I could put together, and keep together. And it would have obviously and meaningful applications to anyone I showed it to.

The project of course, is a Breathalyzer.

And after two nights of putzing around with it, I got it hooked up to a simple circuit, along with a 10 segment LED bar, and have it working.

[media]
[/media]

This past weekend I put it to the test but came up short. Even after 3 beers it was still not able to detect anything. By the end of the night after 10 beers, the highest reading I got was 5 (out of 1023). The effective range of the device it turns out, is MUCH smaller than the absolute range I was reading it in. So the next day I adjusted the AREF (Analog Reference) value to greatly shrink the range I was reading. This boosted the sensitivity 4.5x. It can now readily detect just a single beer on your breath.

In addition to this I added in continuous sampling of the base line readings, and factor them out in order to get more constant and reliable values. My ultimate goal here is to make this as accurate as is possible with the MQ-3 sensor (there are certainly some very real limitations to this sensor), and to make it hand held. With a side goal of making it awesome ;)

This week I ordered a 16x2 character LCD display to display the calculated BAC, and more 10 segment LED bars to increase the resolution of the bar graph. Once that is all tested and working, I want to package this up in an enclosure and make it handheld.

Testing the accuracy of my device has been quite an interesting ride, and it has lead me to one conclusion: Breathalyzers are far from an ideal way of testing Blood Alcohol Content (BAC).

This must be why in real serious cases, Police Departments use blood or urine tests as they are directly measuring the concentration of alcohol in your blood.

Breathalyzers however, are a one-off test. Quite simply, they are measuring the amount of alcohol gas in your mouth. Thats an important distinction. There is the obvious factor that could throw off the test, that you could have liquid alcohol in your mouth. Some of this will be in gas form, and thus what you will be measuring is the concentration of that liquid. Which has absolutely ZERO to do with your BAC.

It's obvious, but let me really drive this point home: you can take a mouth full of Vodka, spit it out, even rinse your mouth, and still blow a deadly level on a Breathalyzer, mean while your BAC is still zero.

While this was apparent to me, I wasn't sure at first how much I would have to control for it. For instance, if I take a drink of beer immediately before testing, I knew that would skew the results, but how long between drinking and testing was long enough? One minute, five minutes, thirty minutes? In my first set of tests, this proved to be an overwhelmingly important factor that all but invalidated my results. However they were useful in that they taught me how to test in the future.

My second round of testing, I controlled for this by having everyone wait at least a minute between drinking and testing, and having everyone thoroughly rinse out their mouth with water immediately before testing. This clamped our values to much more linear and sensible readings as we went on. But we still had outliers throughout the night. And I discovered that:
Burps produce readings similar to drinking right before testing.
When you're drunk, you burp a lot without even thinking about it.
This was much more difficult to control for as the night went on... (also of note, data taking became increasing difficult toward the end of the night ;) )

The other thing I found, which may or may not seem intutive, is that Breathalyzers essentially need a male/female setting. Example: when my girlfriend was blowing an 18 (don't worry what that means, I'm just using it as a point of refrence), we calculated her BAC to be ~0.123%. (Also imperically verified her as: pretty drunk). Mean while, I blew a 19, and calculated my BAC to be ~0.034%. Even after controling for all of the skewing factors, her readings simply needed to be interpreted differently than mine or the other male subjects.

After discovering all of this I did some searching and found Breathalyzers are actually contested based on these exact grounds. They are bias against females, and there can be strongly mitigating factors during the test.

Oh well, I can still get rough approximations, and it's still been loads of fun

I've been super busy lately so I haven't had a whole lot of time for this project, but I did manage to get some work done last nite and merge in a patch I found floating around the internet.

It was supposed to make my WiFi chip reconnect to the AP more reliably, and so far it appears to be working! My original soak tests lost connection to the AP after about an hour and failed to ever reconnect. Last night after merging and testing this new patch, I set up another soak test which has been going 10 hours strong so far!

I set up some port forwarding, so you can check out the test page running on the Arduino right now (this link won't be live for very long): http://www.grendelsdomain.com:1234 (Note: Some people report this link as not working, but it's still working for me... go figure.)

Also note that it is currently NOT resynchronizing with NTP servers, so you will notice a widening divergence between the time reported and actual time (EDT).

Next up, (hopefully this weekend) I need to get it resyncing with NTP servers every 12 hours. And start pulling data from my Google Calendar. So hopefully by the end of the weekend this network connected clock will become a network connected alarm clock ;)

The next real step forward was to begin working on the networking and time keeping. But those steps were the beginning of what is to become a real software project. Still small to medium sized compared to PC projects. But it will have a level of complexity that Ardunio projects don't usually achieve. What this means is the Arduino IDE would be wholly unsuited for developing it. I ran into this a bit with the Robot project. Towards the end of development as some complexity emerged with the socket communications, it got fairly difficult to manage in the Ardunio IDE.

My solution was to fall back to my trusty C++ IDE Code::Blocks.

I love this IDE, so light weight, cross-platform, and infinitely configurable. C::B has some high level support for AVR projects (that's the architecture of the micro-controller that the Arduino uses), but it's really a thin veneer. All of the guts, GCC-AVR and others, must be setup on your own.

This... Took... Awhile...

I was following spotty tutorials written for much older versions of every piece of software in the chain. I had to extract AVR-libc and the Arduino Core lib from the Arduino IDE, get headers, do all sorts of fun stuff that Arduino clearly never intended for you to do. But in the end, I got it all compiling, burning, and running from within C::B. I even got C::B auto-resetting the hardware prior to burning! (Something none of the tutorials managed to do!)

I'll tell you, when I got my own code without any of the Arduino auto-magical trickery running on that chip:

int main() { init();

while(1) { // Insert celebration here } }

That was a gooooood day.

So with everything ready to go, all set for serious software development, I began looking into the networking. Dusted off my old networking WiFi shield (Arduino speak for daughter board) and began loading up all the libraries. I got a basic web server test running, and then went on to compile in more feature in the library. And all of a sudden, cla-thunk! My program wouldn't upload. Scrolled through the build log and found "Memory out of range". Crap... opened up the /bin directory of my project and saw the .elf file's size at 33KiB. The Arduino only has 32KiB of program memory...

After playing with stripping & size optimization options, and weighing if I really needed those library features that had pushed me over the limit. I concluded that I needed a new micro-controller with more memory. Luckily Arduino's come in several flavors! After a quick look-see, I decided on the new Arduino Mega 2560. It's based off of the newest Arduino, the Uno, has 8 times the program memory, and MANY more I/O pins. But other than that, it's identical to my current one. Which means it can be a slot in replacement, and I don't have to change any of my plans

Welp, JUST over a month, and I've got it pretty much completed. I have it all together, working, packaged up in it's enclosure, and mobile. (I'll do a proper video of it soon and post it)

(Reading from a Vodka bottle, not a person ;))

It's currently using an external 9V battery for power. Though I'd like to devise an internal battery solution, it's difficult. There is much less room in the enclosure than I expected once all the components and wiring were in.

(Lots of wires to route and cram in there.)

The BAC calculation is pretty simple currently. I took the data I compiled from my many tests over this past month, and calculated a magic value that I simply multiply the voltage reading against. There's certainly room for improvements. For instance, according to my data, it's not a perfectly linear relationship between the voltage readings and actual BACs, so the magic value should modestly scale up as the voltage increases, but I haven't found a good fit yet.

All things considered, my magic value method is producing surprisingly accurate readings, and if you just focus on the Summary I output (Sober, Buzzed, Drunk. Very Drunk, ect...) it's more than sufficient for what I was trying to accomplish with this project.

Also I got to have some fun with my Dremel in order to customize parts of my enclosure:

In other quite serendipitous news! On this very day, Arduino has FINALLY announced the imminent release of their official Wireless module and 1.0 library which brings wondrous high level networking support This is what I've been waiting for to get back to work on my C3 Alarm Clock. Unfortunately it took so long that I'm just about to begin development on a fairly sizable game project. So C3 will be on the back burner. Hopefully I'll find time here and there to push it forward, but it certainly won't be a quick project.

I'll post more on C3 and the new game project as things progress. Anyway for today, it's just nice to have a working, finished project

We're in the early planning and prototyping stages for our next project. So I worked up a little prototype of the core tech we will need. The core mechanic is based around one important assumption: That it's fun to kick over someone's sand castle

To this end we need good free-form terrain destruction! So here is my first effort:

[media]
[/media]

This is about 4 hours of work.

The is tech is inspired by two main games. One should be somewhat obvious. The Worms series.

But the other was a lesser known game that I played YEARS ago called Pocket Tanks (or P. Tanks)

It was an artillery game with a few twists, the most interesting of which (in my opinion anyway) was the terrain destruction!

So after playing quite a few rounds of it, and then a few more rounds (for research I swear!) I went ahead and implemented it in C++ using SFML

Next I'm looking to implement this on Android in libGDX. Some discussions with the libGDX team leads me to believe I'll have to implement the actual pixel pushing using the Android NDK in order to get the unfettered access to the pixel buffer that I need. I've never worked with the NDK so this should be a fun learning experience to get my hands dirty with it!

I've been making good progress since receiving my IOIO. Got it up and running over USB, tested it all out, and then had to wait for my PICKit3 to upgrade it's firmware. Once it arrived, it took some time for me to grok it (I've never used a PIC programmer or anything like it before) but finally got the Firmware upgraded and got the IOIO talking to my phone over Bluetooth.

The next step was to recreate my sensor circuit and get back to where I was with the Arduino, and now I have it all soldered together in a more permanent fashion.

For now anyway, that pretty much wraps up the hardware side of things. I'll create an enclosure later, and maybe add a few more sensors (temperature, humidity, etc).

The other side of the coin, my Android app, has been coming along in between hardware work. I have it communicating with the sensor, and have a nice setup process to calibrate the sensor for any bed (measuring the dead load of the mattress). And I'm about 60% of the way toward using Google Calendar to set Alarms. Though Android's Calendar provider is rather... rudimentary. So I'm having to write a bit of a wrapper library in order to utilize it.

Anyway, that's it for now, I should have a working prototype very shortly!

It is small in all respects. We intentionally picked a very simple game so we could focus on refining our process of working together, and the tech and idioms specific to Android, and how the release & advertising process works.

However, while small, we still wanted it to be a quality and polished effort.

And I'm happy to report that I think we succeeded gloriously in all areas

It's a fast paced "whack-a-mole"-esque game set under the surface of the ocean. There's a circuitous mess of oil pipes which... low and behold... begin springing leaks! You must rush around and fix the leaks as fast as possible. As the oil content of the water rises, the poor fishes who are swimming around die and float to the surface Poor fish.

And no matter what you do, you always lose. (It's sorta like the helicopter game, you always lose, but you're trying to beat your previous high score for how long you stayed alive).

There are a few extras thrown into the mix, like a supply plane that drops power ups randomly. And a rescue boat you must find when you run out of bandages for fixing pipes. But like I said, it's a small game in all respects.

There are a few interesting things (at least I think so) technically that bear mentioning. The game is written entirely in Java, based on a great library called libGDX. GDX abstracts away the platform specific stuff (Think SDL, or SFML) and provides back ends for PC & Android. The great thing is that you can develop right on your computer, run and debug right on your computer (much nicer than debugging over the USB link) which makes iterations MMUUCCHH quicker.

As GDX develops it's starting to provide a robust set of base classes for game development. Which is even nicer than it sounds because the GDX author is a performance Nazi! (You know... the good kinda Nazi) Always benchmarking and improving. So if you go that route you really will get the best performance possible out of Java. And the heaviest lifting is done in native Android back ends.

For this project, the team was just me (programmer) and my friend Mike (artist/anything creative). We have already started pre-production (doing a much more robust planning stage this time around) and have brought in a long time friend of ours who works in the AAA industry to do art and game design. We're learning a ton from his experience and adapting some of the process he has seen that work well. (Still keeping the process pretty light weight as this is just a 3 man side project.)

With both of these artists though we officially have WAY more asset bandwidth than technical bandwidth. And our next project is a fair bit more ambitious which worries me. So I'm mulling over the idea of a 2nd programmer. For side projects I've found it exceedingly difficult to find competent programmers who have both the desire, and time to devote. Which is to say I've never found a programmer with those 3 elements Also if there is going to be money involved (which we sure hope there will be lol) then it gets more difficult bringing in someone you don't know. There can be some sticky legal issues down the road.

Well anyway, I'm really rambling now, so go give our game a try if you have an Android phone!

I've had my Droid for about a year and a half now (got it the day it came out) and all though it has treated me well, it's getting quite old in "phone years".

I'm not due for an upgrade until July, so it's not a pressing issue at the moment, but while musing on what I might get when it's time, I have come to the conclusion that there really isn't any Verizon Android phones in the near future that look compelling.

Probably the most interesting phone currently is the Motorola Atrix 4G, but of course that's AT&T.

HTC's up coming phones are decidedly last-gen, lacking the hardware sensors that 2.3 brings to the table, and shipping with 2.2.

The Sony PlayStation phone (Xperia Play) is fairly interesting to me for it's performance and how up to date it is with 2.3's hardware features, I feel like it will be kept up to date as new versions of Android roll out, but that's admittedly based on nothing.

And then there is the news that Netflix simply won't ship apps to phones with out hardware DRM support. Meaning ALL current phones will never get Netflix streaming. And more than likely all the phones currently in the pipe line will similarly never get Netflix. This is actually kinda a big deal to me, I'm a Netflix addict!

On the same vein, the Motorola Xoom, while very sexy from a lot of stand points, will NEVER get Netflix! And at least for me, it's primary use case would BE streaming movies!

Now Qualcomm has recently announced a new rev of the Snapdraggon line that included hardware DRM, and Netflix has given it it's blessing, so thats great news, but they are only now shipping samples to manufacturers, which means we most likely won't see handsets with it till NEXT YEAR! Suck!

And none of the other SOC manufacturers have even announced a similar solution yet. NVidia already release their road map through early next year, none of which included hardware DRM, and that's just the SOC release schedule, not end user devices including them. TI to my knowledge has not released a road map showing so far out, but we can assume they have at least the rest of this year planned out. All this means is we probably won't see wide spread Netflix support till the end of 2012! SUCK!

As a small side note, I'd been down on Qualcomm for their less then stellar GPU they saddled their Snapdragon SOCs with, but the new rev of their GPU is a whole different ball game, it's goes head to head with the Tegra 2 and holds it's own, so I'm very interested in the next generation of phones based on this SOC.

But I digress...

The last thing that weighs in on my decisions is both UI customization (I don't want any!), and time-to-update when new versions of the OS come out. Google's own handsets get updated very quickly, but they never come to Verizon. Both HTC and to a lesser degree Motorola manage to update their handsets, but pretty much every other manufacture has a MISERABLE track record.

As I stated last time, I had decided to try out Charlieplexing as a way of individually addressing 64 LEDs with only 14 I/O pins (9 is all I need for this actually). So I ordered some resistors and some very specific LEDs. Before I get into the build, let me give a high level overview of what Charlieplexing is and how it works, so that you can understand the conclusions I came to later.

Charlieplexing was invented in 1995 by Charlie Allen as a way of driving many LEDs with few I/O pins and nothing but resistors to implement it. It relies on two facts about LEDs:
That they are diodes, thus electricity will only flow through them in one direction
That they have a specific "operating voltage", below which they will not light up even if current is flowing through them
( Instructables has a really great in-depth explanation here. )

Simply put, you hook LEDs up in combinations such that electricity will either not flow through certain LEDs due to the fact they are diodes in the wrong direction, or that electricity will flow through ones you don't want to light up, but not enough current to actually light them:

When all is said and done, only one LED will light up at a time. Thus, individual addressing:

Now the more astute reader may have noticed I just glossed over something. Yes I can turn individual LEDs on by themselves, but as is dictated by the circuit, I can not turn on all the LEDs at once, in fact not even a third of them, and in practice, you can actually only turn one LED on at a time using this method, which sounds pretty limiting. But there is a way around it: Persistence of Vision.

I'm sure you've seen it used some where before but not known it. The idea is if you can turn a light on and off fast enough, the human eye won't be able to perceive that it was ever actually off, and thus it will look like it is always on. So to make this useful, you "schedule" all the lights that you want to be on, and then the software scans through and turns each one on and off in succession, when it gets to the end, it starts over. You have to be able to scan through the lights enough times per second to fake out the human eye:

So with all that, I set forth to implement a prototype on my breadboard, and have a video of it ">here (it look a long time to make, not because it's long, but because I suck with the video editing software, so give it a watch :D ). " target="_blank">

Now this whole research and prototype cycle allowed me to draw some important conclusions. And they aren't favorable for Charlieplexing :P

There are some small issues that make this method problematic for my application.
The circuit layout does not lend itself to have the LEDs in a grid. It could be designed around, but would be a real pain. This isn't a big one, but it's certainly a consideration.
As the circuit expands with more pins, and you want to have more LEDs on at once, I found the LEDs got dimmer. This could be for one of two reasons (or both). It could be the fact that the circuit itself is larger and has more resistance built into it over all (and the current is being split many different ways), and the more LEDs are scheduled to be on, the longer each LED will be off for during a given "scan". Now you can counteract this, by using lower ohm resistors to increase the overall current in the circuit, but then you run into the issue of the "compliment drive" LEDs lighting up dimly when they shouldn't.
And that last issue is a problem I ran into even in my small circuit.

So where does this leave me!

Well it leaves me out in the cold as far as Charlieplexing is concerned.

But I got to thinking... my original idea of using demultiplexers could still work, so that's where I am at, I have a few ideas I'm going to explore on paper, and I'll post when I have something concrete.

Still waiting on Arduino to release their WiFi shield... So the drinking continues! Er... I mean the MQ3 project continues!

So I've put some time into looking for parts and methods for more making this handheld. Ordered some bits, and I'll update more on that once those parts come in. But the more immediate and all important challenge, is continuing to iterate on the over all implementation of the circuits and software that turn this into a Breathalyzer.

Accuracy is important if this project is going to be successful. There are limitations to the MQ3 sensor, but I want to get the most out of it. So after increasing the accuracy 4.5x last week, we tested again. (All these tests occur when my friends come over to watch The Walking Dead on Friday's). The first test we saw values ranging between 0 to 6. (Remember these values are just voltage readings from an Analog to Digital [A2D] converter provided on the Arduino). Now that wasn't good, over 10 beers, the values only increased 6 points. That's not nearly enough resolution in the signal to be useful. My second attempt after the 4.5x bump in resolution, produced values between 11 and 23. (Note the oddity there of nothing below 11. In my next post I'll go into my testing procedures, and why there are oddities in these readings, as well as almost certainly in commercial breathalyzers used by authorities.)

[warning: technical details ahead!] The general idea here is that the MQ3 is essentially a variable resistor. When no alcohol is applied, it is entirely resistive, letting no electricity through. As you apply more and more alcohol gas to the sensor, it's resistance drops, letting larger and larger amounts of electricity through. That current is piped into one of the Arduino's A2D pins, where it converts it to a digital number that I can then use in my code.

The A2D takes a signal between 0V and xV and converts it to a number between 0 and 1023. Where xV is the Analog Reference Value: a voltage that the Arduino uses as the top end. By default 5V is used. There for if you put 5V into the A2D you get a reading of 1023. If you put in 2.5V, you get 512, and so on.

The problem with "resolution" as I've called it here, is that even with what our bodies consider to be very large amounts of alcohol (like deadly levels) they are still relatively low levels to the sensor. Example: after 10 beers, my BAC is ~0.104%, aka: pretty darn tipsy. But the resistor is still only letting through 0.029V out of 5V.

The solution? Shrink the range that the A2D is using for conversion. My first attempt at this used a built in function of the Arduino, to change the top end Analog Reference Voltage from 5V t0 1.1V. This is what gave me the roughly 4.5x improvement in resolution. But it still wasn't quite enough. So I began looking further into how to reduce the top end so the range has a closer fit to the values we are actually producing.

I found a feature of the Arduino that allows you to supply a voltage to a special pin (AREF), and what ever that voltage is, will be used as the Analog Reference Voltage by the A2Ds. So the next step was to find the correct voltage and reliably produce it!

I turned to voltage dividers.

Very simple circuits, you just do some math based on the input voltage and the target voltage to determine what resistors to use in it. And it will always output the desired voltage. I calculated from my previous tests that the desired top end, for maximum resolution, would be ~0.24V. Maybe a little more to pad for outliers. In practice however this ran into real world problems. And I ended up hooking in my 10kOhm potentiometer to find the lowest voltage I could use.

So far it looks like 0.5V is the lowest I can reliably use. Which is still pretty good. That will give me about half of the A2D value as usable range. Between 0 and 512. Which is a bit more than a 2x improvement on top of my first attempt.

With that determined, I can begin working out the actual BAC calculations based on my readings which should finally be of sufficient resolution.

So a small diversion from my Arduino efforts today, and a focus on warm winter apparel.

I bought a Motorola Droid when it came out last year and haven't looked back to my LG 77C (the C is for crap) or what ever it's stupid model was.

But now that winter is firmly upon us, grinding us down 'till the last breath of hope and life escapes from our frigid, sun starved bodies, as nothing more then a fart in the arctic wind... I got to thinking:

"Boy my hands are cold, wish I could answer phone calls with out having to take my gloves off."

So I began testing a few materials around my house, trying to find something non-abrasive that would create some capacitance on the screen (since they are capacitive touch screens). Nothing worked, not well anyway, so I tried tinfoil which worked of course, but covered it with some thin plastic, as to protect the screen, and it worked!

So without further ado, I give you the DIY Capacitive Touch Glove, or as I like to call it, "The one glove to rule them all":