I'm mucking about with a new challenge: I want to create a simple timer that starts counting when my car is turned on. This is the elapsed time feature my Acura has, but I'd like to build it as a stand alone device.
To prototype this, I busted out my micro:bit and wrote the following code:
OLED.init(64, 128);
function pad(x: number): string {
return x < 10 ? "0" + x : "" + x;
}
basic.forever(() => {
let remaining = input.runningTime() / 1000;
let hours = remaining / (60 * 60);
remaining = remaining % (hours * 60 * 60);
let minutes = remaining / 60;
remaining = remaining % (60 * minutes);
let seconds = remaining;
OLED.clear();
OLED.showString(pad(hours) + ":" + pad(minutes) + ":" + pad(seconds));
basic.pause(800);
});
I then brought the micro:bit out to my car and plugged it into a USB port. I turned on the vehicle and in a few moments, the counter started ticking away. Whoo!
In about 15 minutes, and using little more than CS 101 coding skills, I had my prototype. I suppose I could stop there, but for a more refined version of the device I'm thinking of using the following:
- The Huzzah Weather Display Tutorial describes hardware that matches up with the footprint I had in mind. The fact that the micro-controller includes WiFi support is extraneous, but does open the door to future functionality. I could imagine issuing commands to the timer remotely, which would be sweet.
- The Universal Dashcam Installation Kit answers the question of how to power my device. The kit turns an automotive fuse into a 5v power source. This is what the Huzzah calls for, so I think this should work nicely.
I even took a peek under my car's dashboard and sure enough, the fuse box is just itching to be plugged into:
All that's left to do is buy the parts and build this bad boy. It may not as audacious as say, making your car doors removable, but this would be a fun (and gentle) foray into the world of Car Hacking.
No comments:
Post a Comment