Skip to content

Archive for February, 2014

10
Feb

PiDoor – Security Door Lock v2

Some readers may recall my old security door lock, which I made about a year ago. It was controlled with just a single AVR, which proved very inflexible. Though in theory it was capable, it was very limited unless I spent a lot of time and effort interfacing with an internet connectivity module. While that may have been an interesting challenge, the inflexibility and impracticality of the old system was simply too much for me, and I didn’t have time to maintain it. It was generally too time consuming to dismantle the module and reprogram it as required, and so when it broke (the strings simply snapped!) I decided it wasn’t worth the hassle, and went back to a good old-fashioned regular lock.

But, where’s the fun in that? Fast-forward a year to 2014, and I finally convinced myself to buy a Raspberry Pi to mess around with. I already have quite a bit of experience with Linux, so I wasn’t planning to use it to learn Linux. In fact, I didn’t know what I’d use it for until the night before it arrived when it hit me: I could use it to make a much better door lock! And so when it arrived, along with a servo I happened to order with it, I got to work. Here’s the end result:

At the start of the video, you see the Raspberry Pi on the left, the servo/circuit housing in the middle, and the lock itself on the right. In the second half, you can see the keypad connected via a ribbon cable to the circuit housing.

Features:

  • Keypad code locking/unlocking
  • Web interface to control and view status from any internet connected device

  • Easy to update (thanks to the Raspberry Pi itself being a Linux device)
  • Mains powered with a single 5v power source
  • GPIO ribbon cable/socket for easy removal of the Raspberry Pi

Read on to find out how it works.

Read moreRead more

0+
9
Feb

K-Nearest Neighbours

I spent a few hours over the past few days working on an interactive K-NN (K-Nearest Neighbours) classification map.

Try it out here: http://projects.bitnode.co.uk/KNN/

If you’re unfamiliar with it, K-NN is a part of machine learning. Specifically, it can be used for classification (I.E does this belong to x or does it belong to y). The points you see on the map are training data. They essentially define the boundaries for classification, so that if we were to bring an unclassified point into the data set, we could decide which class it belongs to based upon the training data. The map is showing the classification of each individual pixel in the feature space.

So the algorithm for K-NN is really simple. You just look at K training points nearest to the particular input point (in this case, the location of a pixel) and average out the class. So for example if K=3, at pixel (10,10) we simply find the distance from the pixel to all the points of the training set, then look at the nearest 3 points, and average out their class. In this case, class is a colour (red or blue) and so we can just sum up the RGB components of the point individually and divide them by 3, giving us our averaged colour and therefore class which we can assign to the pixel in question.

Here are some interesting outputs:

 

Also an interesting bug I encountered while making this:

 

Try it for yourself here: http://projects.bitnode.co.uk/KNN/

0+
Fork me on GitHub