Skip navigation

I’ve been making a fair few forms with the Laravel form-builder using model-binding. A few times I’ve had to make the user select a value for a one-to-many relation.

What’s the problem with model-binding and select-boxes?

In this example we’ll go with the status for a key (‘on loan’,’ at home’, or ‘broken’). The natural choice is a select-box, where the current state should already be chosen if we are editing the key.
The immediate solution is to just use  the ‘state’-property for the model-binding

 {{Form::select('keystatus', $keyStatus, null)}}

However, if you send a collection of models to a select box, you will end up with a weird box:

A botched select-box with json-representation of models - this won't work with model-binding.

A very unusable select-box

As you can see, this is the JSON-representation of the models – this won’t work.

The solution

This first obstacle is solved through a simple foreach-loop:

$statuses = Keystatus::all();
foreach($statuses AS $status){
$statusList[$status->id] = $status->status;

This is taken from my composer-file. As you can see, I get a nice array with the id for key and whatever text I want as the value.

Next step is to put it in the select-box and make the Laravel model-binding work it’s magic.

The tricky thing is, that the status on my key is an object, and doesn’t match whatever is in my array. Instead I put the status_id as the name of my select-box. This way the value in my status_id-column will match one of the keys in the array:

{{Form::select('status_id', $key, null)}}

Don’t forget to set the third parameter (default chosen value) to null. This allows the model-binding to work its magic. The last thing to do, is to adapt my controller to either save the id directly in the status_id-property, or load the status using Status::find($input[“status_id”]); and then associate that to the key:

//Either do this
$key->keystatus_id = $input["keystatus_id"];

//Or do this:
$state = KeysStatus::find($input["keystatus_id"]);

Personally I prefer the first method, as it save me a few calls to the database.

So, the idea of the arduino intervalometer is to trigger a camera at a set interval – therefore the first thing to figure out, is how to actually triggering the camera.

Most DSLRs have a pretty straight-forward way of triggering the camera, using the remote port. Opening the port, you find three pins, one ground, one for auto-focus and one for taking the picture.

Connect ground to #2, the camera focuses, and connect ground to #3, it takes a picture.

Disable auto

When shooting with an intervalomer, you will want to disable autofocus, and set the camera for manual focus. You can see below why using autofocus when shooting a timelapse is a bad idea

Apart from disabling autofocus, you should also disable other automatic controls such as whitebalance and lightmetering.

So all we need to do, is connect gnd and #3 pin – though you might want to experiment, some cameras won’t take the picture without #2 being connected to gnd, even if autofocus is disabled!

What I did, was I used the connector from a remote I had lying around.



So, for a while, I’ve been wanting to getting into time-lapse photography. I have looked at intervalometers, but felt they were pricy. At first, I tried doing it manually, taking a picture every 30 seconds, but that wasn’t ideal. The solution was obvious – after all I’m a tinkerer and a geek, so what better solution than making an Arduino intervalometer myself?

I started out by dividing this project into two parts: Hardware and Software; I’d need some kind of way to get the Arduino to trigger the camera, and I needed a way to set up the interval, number of pictures etc, on the arduino. Like the project, my write-up of my making the Arduino intervalometer has been divied into two parts.

I started out getting the hardware part of my arduino intervalometer going – after all, if I couldn’t get the Arduino to trigger the camera-shutter, there wasn’t much point to coding the arduino.

Don’t wait to read about my arduino camera-trigger!

I have divided the project into 4 parts, part 1 is how to trigger the camera, it is fairly simple, but must be done correctly, to make sure you don’t fry your camera.

Part 2 is setting up the display for the intervalometer, to make sure, you can see what you’re doing when setting up the shoot.

Part 3 is wiring the buttons for the control

Part 4, the final part, is programming the arduino, making a menu the  most efficient way possible.

The parts will be put online as they are written.

Ok, just a quick tip for a better way to get to your programs in windows without using the mouse.

We will create a windows shortcut for your programs accessible from the ‘run’ window.

First of all, create a folder somewhere with a name you can remember. The name and the location doesn’t matter. I usually go for “C:\shorts”.

  1. Now go to start (or your desktop) and right-click “My computer”.
  2. From the menu choose “Properties”.
  3. Now, on the left, find and click “Advanced settings”.
  4. In the window which appears, click the button “Environment variables”.
  5. In the bottom field, scroll down to the variable “path”. Hightlight it and click “edit”.
  6. Now go to the end of the line and enter the path for the folder you created. Make sure to seperate it from the previous entry with a “;”.

Click ok, ok, and ok. Now go to your folder and put shortcuts for whatever program you want in there.
Rename the shortcuts to something easy to remember; “ff” for firefox, “sp” for spotify, and so on.

Now press [win]+[r] and type whatever name you gave your shortcut, press [enter] and it opens the program.

Once you get used to this way of doing things, you can’t imagine yourself going back to the old way of doing things.

Using an Arduino and 3 pins to control 5 LED’s

So, I’ve been sitting on two shift-registers I got for my Arduino for a few weeks, without getting around to actually doing anything with them. I finally decided enough was enough, and I cooked up a binary counter which counted to 31. All I used was a shift-register, 3 I/O-pins, and a handfull of 1kΩ resistors. Using the provided example in the Arduino-IDE I gobbled together my own Arduino sketch which first cycles through the LED’s and then counts to 31 over and over. Currently I only have the video, but I’ll add the source code and a diagram later on, when I get home to the computer with the sketch on it.

The shift-register I got for my Arduino

The shift-registers

What is a shift-register?

The advantage to using a shift register compared to not using a shift-register is, that you can “extend” your 10 I/O pins on the Arduino to a practically unlimited number. You will be using only 3 pins on the Arduino (apart from 5V and GND). The three pins are used for a latch-pins, a timer pin and a data-pin. The shift-register takes a serial signal, and sends it to the 8 out-pins on the shift-register, which then outputs them, once the latch-pin goes to ‘HIGH’. If you need to control more than 8 outputs, you connect another shift-register to the overflow pin on the shift-register, and the remaining bits are sent to the extra shift-register and so on.

For example, if I send binary 153 (10011001) to the shift-register, the pins 8, 5,4, and 1, will be set to ‘HIGH’ once the shift-register gets the all-ok signal (the latch-pin going to ‘HIGH’). In my example I only used 5 LED’s, so the highest number I could show, was 11111 (16+8+4+2+1 = 31).

What does my arduino project do?

My counter/gadget starts out by cycling the LEDs a la KITT (of Knight Rider fame). Once that is done, the counter starts counting in binary. Once the highest available number is reached, it resets the counter and starts over.

Basically the sketch is just a bunch of for-loops. At the top of the sketch I define the number of LEDs connected to the shift-register. Throughout the sketch, I refer to that number when setting the range of the loops. The Arduino sends the appropriate number, formatted as binary, to the shift-register. When the number has been received, the latch-pin is set to HIGH and the shift-register sets the pins as instructed.

Where to go from here?

The possibilities of using a shift-register with an Arduino is almost limitless. Just the fact that it frees up I/O pins makes it a great tool for your projects. The next step for me, would be to either a) get it to work with an LCD, or b) get my hands on a shift-out register. That way I can do the same thing, just for inputs. Currently I have an idea of making a intervalometer with a menu-system, which’ll require at least 4 input-pins.

Yes my boys.

The new is in the air.

I realized I didn’t have the time to develop my own webpage/CMS from the bottom up. Between all the other projects I’m working at, I had to prioritize. Rolling my own system would end up in me reinventing the wheel over and over. Instead I chose to take the opportunity to try out wordpress.

Many advantages

First of all, wordpress is a widely used system and comes packed with tons of features. The features which isn’t build in, will most probably be available in the form of a plugin. Furthermore, I’m not a designer, so using one of the many themes out there is a given. Furthermore, I save a ton of time by not implementing stuff already done by others. Lastly there is tonnes of guides on the internet on how to perform SEO on a wordpress-installation, one of the most notorious being yoast who has also made a great plugin.

Stay tuned

This is just the first installation with an other-than-default theme, and I’ve only scratched the surface of plugins and what is possible. I have tons of ideas, both for posts and for features, so stay tuned or follow me on twitter.

Fork me on GitHub