Applications

A collection of miscellaneous guides, tutorials and info


Time lapse photography



First of all you need to activate your camera if you haven't done so already. You can do that through:

sudo raspi-config

Test your camera with

raspistill -vf -hf –o test.jpg

This command will take a picture with your camera and you can check the picture at your home directory through file manager. Once you know that your camera is working properly you should create a directory to store your pictures.

mkdir timelapse

Now we need to create a very simple bash script for our pictures and we are going to name it capture.sh

sudo nano capture.sh

In the editor just type

#!/bin/bash
DATE=$(date +"%Y-%m-%d_%H%M")
raspistill -o /home/pi/timelapse/$DATE.jpg

This is going to allow us to save our pictures named with the time stamp in the timelapse folder. We will have to give permission to our capture.sh to be executed, we will do that with:

sudo chmod a+x /home/pi/capture.sh

For the next step we are going to use cron (a scheduling tool), to set the exact time when we want to take our pictures. Type:

crontab

We are not going to go into too much detail about cron, just change the last line to

*/5 * * * * sudo home/pi/timelapse/capture.sh

What this does is that it takes a picture every 5 minutes. To take a picture every 30 minutes change the value to 30 like this

*/30 * * * * sudo home/pi/timelapse/capture.sh

You can change the asterisks to your liking.

# * * * * *  command to execute
# ┬ ┬ ┬ ┬ ┬
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ └───── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
# │ │ │ └────────── month (1 - 12)
# │ │ └─────────────── day of month (1 - 31)
# │ └──────────────────── hour (0 - 23)
# └───────────────────────── min (0 - 59)

Source: Wikipedia

Once you have all the pictures you need you should change the crontab to what it was otherwise your camera will keep on taking pictures forever (unless that's what you want).

All we have to do now is copy our pictures to a computer and use a video editing software to import the images and make the time lapse according to the software we are using.


Line Following


Line following is a great feature that will give you robot functionality, while it seems like a difficult, there are quite clever algorithms at play.

The TiddlyBot utilises an IR sensor on the bottom of the chassis to allow it the ability to follow lines. Line following robots can use several sensors to detect where the line in front of them is, with TiddlyBot there is only one sensor so we need implement a clever way of using just one sensor to move along the line.

Robots with two sensors would be able to keep the line in between the sensors, so the line is in the middle, the robot will only turn when it detects a line under one of it's sensors, rectifying its path to keep the line in the middle of the two sensors. The TiddlyBot needs to follow a line with just one sensor, so how do we do this?


Robots with two sensors would be able to keep the line in between the sensors, so the line is in the middle, the robot will only turn when it detects a line under one of it's sensors, rectifying its path to keep the line in the middle of the two sensors. The TiddlyBot needs to follow a line with just one sensor, so how do we do this?

The sensor on the TiddlyBot will either be on or off, or ‘line’ or ‘no line’. We can set TiddlyBot to move forward and left at the same time, but change direction to forward and right when Tiddles detects the line, when Tiddles no longer detects the line Tiddles will move forward and left again, continuing on with this cycle along the line. By knowing whether we have found a line or not we will know to change direction, this allows us to keep going forward, but at the same time keeping on the line, or more so the edge of the line. The Pseudo code for this simple line following algorithm is below to give you a better insight to how this works.


While true:
if line_detected:
turn_left_and_forward
else:
turn_right_and_forward


Robotic Dancing

Coming soon!



Alarm Clock

Coming soon!



Baby Monitor

Coming soon!



Spy Cam

Coming soon!


If you are needing help before the articles are completed please see the useful links for some great resources on the web for learning more about various topics.