## Implementation of insertion sort algorithm for single linked lists.

The following program generates N random integers between 0 and 999, creates a linked list inserting a number in each node and then rearranges the nodes of the list so that the numbers appear sorted when we go through the list. For the sorting, it maintains two lists: one input list (not sorted) and one output list (sorted). In each iteration of the loop, it removes a node from the input list and enters it in the appropriate position in the output list. The code is simplified by using head nodes for each list, which contains links to the first node lists. Also, both lists (input and output) are printed.

## Implementation of closest point calculation.

This program demonstrates the use of an array and is representative of the usual situation in which we store data in one array to process them later. It counts the number of pairs of N randomly generated points of the unit square, which can be connected to a line segment of length less than ‘d’, using the point data type. Because the execution time of this program is O(n2), it can’t be used for large N.

## Implement simple reverse list iteratively.

The function ‘reverse’ in the following example reverses the links in a list, returning a pointer to the end node, which then shows the next of the last node, and so forth, while the link to the first node of the initial list is assigned the value 0 corresponding to null pointer (in C++). To accomplish this task, we must maintain links to three consecutive nodes in the list.

## Implementation of a circular list for solving the problem of Josephus.

For the representation of individuals arranged in a circle, we create a circular linked list with a combination of each person to the person on his left in the circle. The integer i represents the i-th person in the circle. After you create a circular list of one node for 1, we insert its unique node to nodes 2 to N. We end up with a cycle from 1 to N, with x indicating the node N. Then, starting from 1 we omit M-1 nodes, we define the pointer of the (M-1)-th node to omit the M-th, and continue that way until only one node remains in the list.

## Implementation of algorithm for finding primes with the sieve of Eratosthenes.

The aim of this program is to assign to a[i] the value 1 if i is a prime number and the value 0 if not. Initially, all elements of the array take the value 1 to indicate that there are no numbers which are known not to be prime. Then all elements of the array corresponding to indexes that are known not to be primes (multiples of known primes) take the value 0. If a[i] has the value 1 even after all multiples of smaller primes have taken the value 0, we know that i is a prime number.

## Implementation of algorithm for the simulation of the ‘twisting’ of a coin.

The program generally simulates a Bernoulli trials sequence, a familiar and abstract notion of probability theory. So, if you flip a coin N times, we expect “head” to occur N/2 times – but it could occur anything between 0 and N times. The program performs the experiment M times, reading the N and M from the command line. It uses an array ‘f’ to count the frequency with which the result “i heads” appears for 0 <= i <= N, and then displays a histogram of the results of experiments with an asterisk for every 10 appearances. Also, the operation behind the program – of indexing an array with a calculated value – is critical to the effectiveness of many computational procedures.

## Implementation of sequential and binary search (iterative version).

Sequential Search.

This algorithm checks whether the number ‘v’ is contained in a set of numbers already stored in the data a[0], a[1], …, a[r-1] of the array ‘a’ (where ‘r’ the number of elements in it), comparing it sequentially with all numbers, starting from the beginning. If the check reaches the end without finding the number, the value -1 is returned. Otherwise, we are returned the index of the position of the one-dimensional array containing the number.

## Arduino: A library for implementing a generic, dynamic queue (array version).

This project refers to an Arduino library implementing a generic, dynamic queue (array version).

The data structure is implemented as a class in C++.

For more information, you can get the project itself ‘QueueArray‘.

## Solving the problem of connectivity with the weighted quick-union algorithm with path compression by halving.

If we replace the loops ‘for’ of the simple version of weighted quick-union (you’ll find it in a previous article) with the following code, we reduce the length of each route passing to the half. The end result of this change is that after a long sequence of operations the trees end up almost level.

## Solving the problem of connectivity with the quick-find algorithm.

This program reads from the standard input a sequence of pairs of non-negative integers which are less than N (interpreting the pair [p q] as a “link of the object p to object q”) and displays the pairs that represent those objects which are not yet connected. The program complies with the array ‘id’ to include an entry for each object and applies that id[q] and id[p] are equal if and only if p and q are connected.

## Solving the problem of connectivity with the quick-union algorithm.

If we replace the body of the while loop of the quick-find algorithm (you can find it in a previous article) with the following code we have a program that meets the same specifications as the quick-find algorithm but performs fewer calculations for the act of union, to the expense of more calculations for act of finding. The ‘for’ loop and the ‘if’ operation that follows in this code determine the necessary and sufficient conditions in the array ‘id’ that p and q be linked. The act of union is implemented by the assignment id[i] = j.

## Solving the problem of connectivity with the weighted quick-union algorithm.

This program is a modification of the simple quick-union algorithm (you’ll find it in a previous article). It uses an extra array ‘sz’ to store the number of nodes for each object with id[i] == i in the corresponding “tree”, so the act of union to be able to connect the smaller of the two specified “trees” with the largest, and thus avoid the formation of large paths in “trees”.

## Arduino: A library for implementing a generic, dynamic queue (linked list version).

This project refers to an Arduino library for implementing a generic, dynamic queue (linked list version).

The data structure is implemented as a class in C++.

For more information, you can get the project itself ‘QueueList‘.

## Arduino: A library for implementing a generic, dynamic stack (linked list version).

This project refers to an Arduino library implementing a generic, dynamic stack (linked list version).

The data structure is implemented as a class in C++.

For more information, you can get the project itself ‘StackList‘.

## Arduino: Run applications with a remote control and an infrared receiver (IR).

This project refers to a sketch (an Arduino program) in which you have the ability to run applications with the help of an infrared receiver (IR) and a remote control. Also included in this project is a Python script that implements a background service (Daemon) which communicates with the Arduino and initiates the execution of various applications. The program can manage several remote controls following the communication protocols NEC, Sony SIRC, Philips RC5 and Philips RC6. Also, you are given the opportunity to train the software to respond to specific keys from several remotes (the knowledge is recorded in the EEPROM of the Arduino).

## Arduino: Valuation calculator of infix mathematical expressions.

This project refers to an Arduino sketch that implements a calculator which valuates infix mathematical expressions using appropriate algorithms and data structures. The mathematical expressions are given through the USB port, while the valuation and presentation of results is done by Arduino. The results are displayed in an appropriate LCD display.

## Free source code documentation systems for applications.

In this article, I quote a personal documentation implementation of the source code of the application “GNU Find String” using the Doxygen system. The source code of the application is written in ANSI C. You’ll find the documentation here: Doxygen documentation of the source code of the application “GNU Find String”.

## Arduino: Device control with passive infrared motion sensor and relay.

This project refers to an Arduino sketch that implements a motion detector for driving and controlling other devices using a passive infrared sensor (PIR) and an electromechanical switch (relay). The program examines whether there is movement (the detection range of the detector is about 6 meters) in space (via the sensor PIR) to activate the device via the relay.

## Arduino: Remote control of lamp through double beat of the palm.

This project refers to an Arduino sketch which with the help of a relay (electromechanical switch), the system VRBot and the expansion card for sensors (Sensor Shield) can control (enable or disable) an external device (eg. a lamp, a car alarm, a home air conditioner, etc.) with a double beat of the palm.

## Arduino: Executing applications with voice command recognition.

This project refers to an Arduino sketch which with the help of a VRBot system can recognize voice commands, making it possible to run applications. For example, we could  cause the execution of the relevant browser with the voice command «Firefox». Also included in this project is a Python script that implements a background service (Daemon) which communicates with the Arduino and initiates the execution of various applications.

## Arduino: Adjustable mood lighting with voice recognition.

This project refers to an Arduino sketch which, with the help of an RGB LED and a VRBot system, can implement a mood lighting system controlled by voice commands. There are voice commands to activate / deactivate the red, green and blue. The color changes are performed with fade effects.

## Arduino: Security Access Control with Multi-Factor Authentication.

This project refers to an Arduino sketch which – with the help of a system VRBot, a basic keyboard, an RFID reader and a piezo speaker – can implement a Security Access Control with Multi-Factor Authentication.

The system comprises a security level associated with typing a password (something I know), a security level associated with the use of an RFID tag (something I have) and a security level associated with the recognition of a voice message password (something I am).

## Arduino: Vehicle Parking Helper with Ultrasonic Sensor and LCD display.

This project refers to an Arduino sketch which uses an ultrasonic sensor for calculating the time return of the ultrasonic signal emitted by the sensor and the object reflecting the signal back. Then, with the help of appropriate physicomathematical formulas, it performs calculation of the distance between the sensor and the object causing the reflection signal. The distance is displayed in an appropriate LCD display both in inches and in centimeters. This system could be used in security doors, on cars as a helper to park or anywhere else where distance at close proximity is important.

## Arduino: Vehicle Parking Helper with Ultrasonic Sensor.

This project refers to an Arduino sketch which uses an ultrasonic sensor for calculating the time return of the ultrasonic signal emitted by the sensor and the object reflecting the signal back. Then, with the help of appropriate physicomathematical formulas, it performs calculation of the distance between the sensor and the object causing the reflection signal. Also, the system includes a piezo speaker used to produce a tune when an object is detected too close nearby. This system could be used in security doors, on cars as a helper to park or anywhere else where distance at close proximity is important.

## Arduino: Monitor sensors with an LCD display and a Keypad.

This project refers to an Arduino sketch which uses an LCD display (as output device) with in-built elementary Keypad (as input device) to display information from sensors. In this project, there are temperature, light and motion sensors. If we want to check the value of one of the sensors, we can do it via the keypad onto the LCD screen. We can choose the sensor of interest using the keys UP and DOWN.

## Arduino: True Random Number Generator.

This project refers to an Arduino sketch that implements a true random number generator with the help of an audio sensor. The sensor measures the sound volume in the nearby environment. The Arduino acts as a network device with an appropriate WEB interface in it from which we can access the random numbers. This technology is not new as it exists in other network devices. For example, routers or network printers have a WEB interface.

The WEB interface is installed in the Arduino itself and is supported with the help of a simple but quite progressive web server (which is also located within the Arduino). The Arduino is connected to the Internet with a special Ethernet card (Ethernet Shield). The Ethernet card is assigned with a static IP (because the Arduino in this case does not work as a client but as a server since the web server is executed there at port 80).

To enable the sound sensor to collect really random values as regards the volume of sound in the environment, it helps to place it in a noisy room or near a radio.

## Arduino: Device Control (open or close) via a relay and voice recognition.

This project refers to an Arduino sketch which with the help of a relay (electromechanical switch) and the VRBot system can drive an external device (eg. a household lamp, a car alarm, a home air conditioner etc.) with voice commands. The system VRBot is properly trained with voice messages and then performs voice recognition.

More specifically, the Arduino detects acoustic sounds and tries to recognize them through the system VRBot. Finally, if acceptable voice messages are identified, the Arduino manages them for the use of the device driven with the help of the relay.

## Arduino: Remote Morse Code Web Encoder.

This project refers to an Arduino sketch that implements an online Morse Code web encoder. The Morse Code is until now a global communication system. However, it is now rarely used (it has been previously extensively used in the Navy and the Army in general). In this project, the Arduino works as a server, which remote clients can be connected to with the help of TCP sockets and send occasional messages on a regular alphanumeric form.

For example: “SOS! USA NAVY (12/02/1920, 23:00)”

## Input function as a possible scenario for reproducing non-deterministic errors with defensive programming.

The presence of errors in software development (and not only) is inevitable. However, over time the programs improve and tend to perfection through various techniques and methods we have developed.

The deterministic problems are easy to spot because they always lead to the same error. There are tools that run through the source code of an application to find possible deterministic errors (these tools are especially useful in applications written with scripting languages such as Python, Bash Scripting, etc).

## Implementation of a C function to convert a typical process into a background service (Daemon) – Version 1.

Below I quote a function in C to convert a standard Linux kernel process into background service (Daemon Service). If you wish to develop a server to provide services, it may be helpful. Although there are several manuals on the Internet on how to create background services, most of them don’t show a complete example, while others are barely functioning. The following function converts a standard process into a service taking everything you need into account. Also, this function is the result of a combination of several textbooks and numerous studies about this issue. Finally, it has been tested on personal applications servers and it is performing well.

## Implementation of functions in C for software signal management in POSIX operating systems – Version 1.

Below I quote a simple implementation in C that you can use in your applications for the management of software signals in POSIX operating systems (such as the GNU/Linux). Of course, this implementation comes from a personal project of the past, especially where I grappled with system programming. You can modify this implementation to work best with your needs.

## Function implementation to generate true random numbers from the Linux kernel.

Before I mention the function that I have developed for the production of random numbers from the monolithic Linux kernel, I would first like to say something about the issue of random numbers.

The issue of producing truly random numbers is important and had even since the beginning puzzled computer scientists. In mathematics, it is very difficult to define the random and, generally, randomness is very difficult to prove with no assumptions. In the past, many scientists tried to develop mathematical models and algorithms to develop random number generators.

One of the greatest scientists of Computer Science, John von Neumann (the basic idea of the architecture of all computer systems today was his own design) jokingly said: ‘Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.’.

## Portable and Abstract version for storing settings in QT applications.

The QT provides an adorable way to store the settings of a program with a GUI (and not only) by means of the QSettings library. Below, we quote a personal version of the project ‘parkman‘ (Parking Manager).

## C++ function library for the comparison of floating point numbers.

Below I quote a simple but useful library (implemented in C++) which contains functions for comparing double precision floating point numbers.

## Arduino: Checking 3D shapes rotation with Python, OpenGL and Arduino.

This project refers to an Arduino sketch which allows the rotation of three dimensional shapes using appropriate sensors. Essentially, the Arduino collects values from the sensors and corresponds them to the [0, 360] range (rotation angle). Every time we get a pair of values (X, Y) for the rotation of the shape, the pair is sent over the USB serial port to the PC.

The PC runs a Python script which produces three-dimensional shapes with OpenGL. Also, the script obtains the pairs via the USB serial port and renews the current shape of the screen. For performance reasons, the three-dimensional shape is renewed only when there are changes in the pair (X, Y).

Finally, you should know that to run the Python script properly the Arduino should already be running and input sensors should have been calibrated regarding their edges. The calibration is performed automatically in the first 15 seconds (use two potentiometers as an example for both input sensors).

## Arduino: POV with ASCII bitmaps and algorithm “Walking 1’s”.

This project refers to an Arduino sketch which implements a POV (Persistence Of Vision) case for the representation of text messages which can contain the visible characters of the character set ASCII.

## Arduino: Light Indicator with multi-LED bar graph, light sensor and 8-bit shift register 74HC595.

This project refers to an Arduino sketch that implements a light indicator with the help of an external sensor (photoresistor) for the recognition of light (the sensor acts as input device for the Arduino), and a bar graph of many LEDs used as a rating indicator (the indicator functions as an output device for the Arduino).

In this project we use an 8-bit shift register (namely the 74HC595). This way we can drive 8 different LEDs in the output committing only three PINS of the Arduino.

## The Ben 10 Cube.

The Ben 10 cube presented enough interest. Although it is like the classic Rubik’s cube, it had some peculiarities.

Specifically, in order to solve it you need to concentrate your attention on the central square of each side so you can always orient it accordingly in the right direction to finalize plans without irregularities.

## The project ‘hcf’ (Histogram of Characters Frequencies).

Within the framework of the course “Programming II – Laboratory” (Department of Informatics and Communications, T.E.I. of Central Macedonia) we were asked to implement as homework a program that reads characters from the standard input and then export to standard output a frequency histogram of the characters that appear.

## Arduino: DC motor control with temperature sensor and dynamic calibration.

This project refers to an Arduino sketch which with the help of an external temperature sensor (input device) can control the rotation speed of a DC motor (output device). Also, during the execution of the program, there is dynamic calibration as regards the input values of the temperature sensor.

## Arduino: DC motor control with a light sensor.

This project refers to an Arduino sketch which with the help of an external light sensor (e.g: photoresistor) can control the rotation speed of a DC motor.

## Arduino: Control multi-LED bar graph with a potentiometer and calibration process.

This project refers to an Arduino sketch which with the help of an external potentiometer (input device) can control a bar graph of many LEDs. Finally, when the sketch starts running, it calibrates the potentiometer (and so there should be a spin at both ends manually).

## The project ‘mam’ (Müller’s Arithmetic Method).

Within the framework of the course “Numerical Methods in Programming Environments – Theory” (Department of Informatics and Communications, T.E.I. of Central Macedonia) we were asked to develop an optional program that implements Müller’s numerical method for finding the root of equations of the form f(x) = 0.

## Arduino: DC motor control with potentiometer and calibration.

This project refers to an Arduino sketch which with the help of an external potentiometer (input device) can control the rotation speed of a DC motor (output device). Finally, when the sketch starts running, it calibrates the potentiometer.

## Rubik’s Magic: Personal Record.

A nice problem that intrigued me is the “Rubik’s Magic”. I could solve the problem fast enough. In the beginning, I thought it to be quite difficult. But I finally was able to join the three rings with little effort.

I will always post my best solutions on this post. I try to set up personal records.

Surely, I can not compete with the champions but I think I will one day reach their standards with continued practice.

Personal record: 5 seconds.

## Rubik’s Cubes: Personal Records.

Since I got my hands on Rubik’s cube, namely the classical one (3x3x3) I got hooked on solving it. I tried several times to solve it but more often I smashed it on the wall or give up.

But recently I learned that Rubik’s cube is solved with algorithms. So when I learned the algorithms and the solution methodology, I started with good intentions. So after a while, I could solve it by applying the algorithms. I have also solved the cubes with 2x2x2, 4x4x4, 5x5x5 and 6x6x6 dimensions. Knowing how to solve these cubes, you can solve any major dimension ones. In larger cubes, there are likely more parity errors. This does not prevent you from solving them.

## Arduino: Fire alarm controlled by temperature sensor.

This project refers to an Arduino sketch that implements a simple fire alarm using a temperature sensor, a piezo speaker and one LED as indicator for deaf-mute cases. The alarm checks every second if there is enough room temperature (via the temperature sensor). If there is enough temperature to consider it a fire burning in that place, then the alarm produces a musical tune with the piezo speaker and lights the LED indicator. Otherwise, both the speaker and the LED indicator remain in state OFF.

## Arduino: Servo motor control with potentiometer and calibration.

This project refers to an Arduino sketch which with the help of an external potentiometer (input device) can move the position of a servo motor (output device) clockwise or counterclockwise. The system also features two LEDs which – each time the value of the potentiometer changes – change their brightness in such a way that it is obvious in which side of the servo motor are.

For example, when the potentiometer is in the extreme left position then the left LED is lit 100% while the right one 0% (or vice versa). Finally, when the sketch starts running, it calibrates first the potentiometer.

## Infosystem 2009 – T.E.I. of Central Macedonia.

It was a very interesting experience for me to participate in the mission of the Department of Informatics and Communications of the T.E.I. of Central Macedonia in Thessaloniki, where the Department took part in the Infosystem 2009 exhibition.

## Arduino: Servo motor control with a light sensor.

This project refers to an Arduino sketch which with the help of an external light sensor, as e.g. a photoresistor, one can move the position of a servo motor clockwise or counterclockwise.

Within the framework of the course “Visual Programming – Theory” (Department of Informatics and Communications, T.E.I. of Central Macedonia) we developed a clinic management application as a semester project.

The database of the application was implemented in Microsoft SQL Server and the graphical user interface in Borland C++ Builder.

More specifically, this application enables the end user to manage different patients, visits, appointments, diagnoses, treatments, prescriptions, tests, links.

## Rubik’s 360 Sphere.

Rubik’s 360 Sphere is quite interesting. Once you understand how it works, the solution is then quite easy. Specifically, you need to concentrate your attention on the two axes as well as the two pendulums that are found inside the spheres.

## Arduino: Direct control of a servo motor.

This project refers to an Arduino sketch which moves continuously a servo motor but without the help of the pre-developed “Servo” library but by direct communication, sending the appropriate PWM output to the motor. That way you have clearly complete control of the servo motor, saving enough memory and achieving better response times with less delay.

## The project ‘dec2bin’ (decimal to binary converter).

The project ‘dec2bin’ (decimal to binary converter) is the implementation of an idea I had for some time. I have to admit that sometime in the past when studying possible ways of programming embedded systems with the programming language C and C++, I felt the need to be able to produce, through a program, supposed memory addresses in the form of binary numbers.

## Fosscomm 2010 (Thessaloniki).

A beautiful and dynamic experience that I hope will be repeated again.
Congratulations to the organizers and participants of this conference.
Their contributions to Free Software was invaluable.