In this project the Raspberrypi board is loaded with Ubuntu and is remotely accessed using VNC. The Raspberrypi board is also connected to the internet. There are 26 connectors which can be taken out from the connector port of the Raspberrypi board. All the connector pins are taken out using 13*2 pin female connectors and at the other end of their wire 26 pin Burg stick male connectors are attached. The Burg stick male connectors allow each pin out from the Raspberrypi board to be plugged into the holes of a breadboard. To access the pins that coming out of the Broadcom controller of the Raspberrypi board using C language, a C library is available called “bcm2835” which has been downloaded and installed.
The Shell is a program or an application which accepts the commands entered through the command line searches for the executable files having the same name at some particular directories and executes them. A Shell Script is a file which normally uses a file extension ‘.sh’. This file should only consist of commands which the Shell can execute. Also the shell will be having permission to execute the file.
The advantage of writing a shell script is that the user can write the commands required to perform a particular task in a single file and then execute them all at once, rather than enter each command one-by-one through the command line. The Shell scripts can be written for performing single tasking or multitasking. The following section explains how to create a Shell script which can do multi-tasking.
There are eight general purpose IO pins on the 13*2 pin connectors of the Raspberrypi board and to each one of them a LED is connected through 1K resistor. Separate code has been written to blink the LEDs individually and made them into executable files named blink2, blink3, blink4, blink5, blink6, blink7 and blink8. It is suggested to keep all the .c files and the executable files in a single folder for this particular project.
The user can run any of the LED blinking programs from the command line. For example to execute the file ‘blink1’, the user can use the following command:
The user can perform on them by entering the following commands one after the other. The user can perform multi-tasking with the eight LED codes by entering the following eight commands one after the other.
The easiest method is to create a Shell script. Open the vi-editor and type the following:
The first line is a comment only, which is a standard to follow and the following lines are the commands to execute the executable files as background process. Save it into a file name, say ‘blink.sh’. The Shell can execute this command only if it is given the permission to. Use the following ‘change mode’ command to make the file executable;
chmod u+x blink.sh
That creates the Shell script and the user can execute the Shell script just like executing any other executable file. To execute the Shell script in which the commands for multitasking are scripted into, use the following command;
*** Make sure that all the executable files blink1, blink2 etc. are there in the same folder with the Shell script.
***Note that in this project the latest version of library “bcm2835” is used with an old version of Raspberrypi board. It is not possible to access the pin number 13 of the old board with the latest library version and hence in the code “blink3.c” the pin number 24 is used to blink the 3rd LED. The circuit diagram is also drawn accordingly. Those who have the latest version of the board can use the pin 13 without any trouble.
To find the ‘Revision’ and other important details about the Raspberrypi board, use the following command;