Archive

Archive for the ‘Programming’ Category
05 Oct

I hate keys

I don’t like having more in my pockets than I absolutely have to and I don’t like having to extract keys and sort through them each time I access my car.  I want my car to automatically unlock when I approach it.

This is a project I have been considering for a while but never started because my car had manual locks and I wasn’t going to install automatic locks on it when I didn’t intend to keep it for long.  It also only had two doors so unlocking everything wasn’t much of a hassle.  I now own a Jeep Cherokee which has four doors and unlocking all of them is a hassle.  In this case it is worth is for me to convert to automatic locks.  (Currently has manual locks.)

In order to have my car unlock as I want it to I will need:

  • Aftermarket automatic door locks installed
  • Arduino w/bluetooth aware of when paired phone is in range
  • Phone or other bluetooth host device
I already have an Arduino Pro Mini 5v, bluetooth serial adapter and phone with bluetooth.  I’ll just need to order that lock kit and slap it all together.  I’ll post updates on my progress.
24 Oct

Arduino Knight Rider KITT Lights

After I had the LEDs plugged into my breadboard for the watch project I’m working on I couldn’t help but make a quick sketch that flashes the lights like the light on KITT from Knight Rider.

[youtube]J-KUAknRGDI[/youtube]

The code is very simple.  First we just set up all of the pins we use as output pins:

void setup(){
//Set the pins we use as OUTPUT
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}

The next and last thing we do is turn on and off the lights in sequence with a small delay in between each like so:

void loop(){
//Flash from the lower numberd pins to the higher numbered ones...
digitalWrite(3, HIGH);
delay(80);
digitalWrite(2, LOW);
delay(80);
digitalWrite(4, HIGH);
delay(80);
digitalWrite(3, LOW);
delay(80);
digitalWrite(5, HIGH);
delay(80);
digitalWrite(4, LOW);
delay(80);
digitalWrite(6, HIGH);
delay(80);
digitalWrite(5, LOW);
delay(80);
digitalWrite(7, HIGH);
delay(80);
digitalWrite(6, LOW);
delay(80);
digitalWrite(8, HIGH);
delay(80);
digitalWrite(7, LOW);
delay(80);
//and back the other way again
digitalWrite(7, HIGH);
delay(80);
digitalWrite(8, LOW);
delay(80);
digitalWrite(6, HIGH);
delay(80);
digitalWrite(7, LOW);
delay(80);
digitalWrite(5, HIGH);
delay(80);
digitalWrite(6, LOW);
delay(80);
digitalWrite(4, HIGH);
delay(80);
digitalWrite(5, LOW);
delay(80);
digitalWrite(3, HIGH);
delay(80);
digitalWrite(4, LOW);
delay(80);
digitalWrite(2, HIGH);
delay(80);
digitalWrite(3, LOW);
delay(80);
}

This could also be done much more efficiently would be much easier to change the number of and position of the lights or the speed the array blinks at just using the loop and incrementing the value of the pins being set high or low.  A while loop could even be used in the set up to make the pins all output pins and the highest and lowest value pins as well as the speed could all be defined at the top of the sketch.  Maybe I’ll code that up sometime and post it but as this sketch stands now it is really just a glorified Arduino “Hello World.”

Here is the source in a .zip folder: Knight Rider KITT Lights Arduino Sketch.

Categories: Arduino, Hardware, Programming, Projects Tags: