Thursday, 21 April 2016

Sweet Peas

My wife planted some sweet peas and put them in the conservatory to get started.

I was sorting through my Pi bits and bobs and found the camera module and a project was born.

I made a camera rig from an old bit of wood and a section of bicycle brake cable and used a PoundWorld specs to get the focal length shorter*:

And found the code for the time lapse online here:


and only made slight amendments:

After 11 days I copied the files across with scp and deleted all the files smaller than 150k (the dark night time pics) with this great command:

find . -name "*.jpg" -size -150k -delete

Then it was just a matter of using ffmpeg to make the images into a video. A quick search confirmed that it was possible to do this on filenames organised by dates:

ffmpeg -framerate 5 -pattern_type glob -i '*.jpg' -c:v libx264 -r 30 sweetpea01.mp4

5 images per second, 30fps video and it literally took a few seconds to create this:

All done headless and with the command line.

Saturday, 2 April 2016

Arduino - Acceleration Due to Gravity Testing Rig

I made the rig in the picture to measure acceleration due to gravity, just for fun.

The hardware is just a home made electromagnet powered through a ULN2003 (linking  2 channels to boost current). This was controlled using an Arduino Nano. I added an LED to indicate when the electromagnet was activated, and a button to activate it. The switch that detected the ball hitting the ground was also home made from a peg, some paperclips and tin foil:

The plan for the program was:

  • Push a button on the rig to activate the electromagnet for long enough to attach a bearing but not so long it burns out the hardware (4 seconds seemed about right)
  • Switch off the electromagnet automatically and simultaneously start a timer.
  • When the pressure switch is activated by the ball hitting the ground, stop the timer.
  • Work out the acceleration using a = 2s / t**2 
  • (s= distance fallen, t is the time)

I started the code in Ardublock because it avoids typing errors, but the calculations refused to give a valid result even when the timing was giving valid readings. After a frustrating hour of trying to fix it within Ardublock, 3 minutes with the actual code in the Arduino IDE had it working well. The erroneous values are when the ball missed the switch and I had to trigger it manually.

 The code: