There are different varieties of Arduino boards available among which one can find a board which suits the particular application. In this project the Arduino pro-mini board is used since it comes in very small in size and any kind of connectors can be soldered on its periphery according to our requirements. It is very breadboard friendly and occupies very less space of a typical breadboard.
The image of the arduino pro-mini board and the arduino IDE are shown below;
Fig. 2: Typical Arduino Pro-Mini Board
Fig. 3: Arduino IDE Software Window
Since the arduino pro-mini board has no circuitary for interfacing it with the serial port or the USB port of the PC, an external USB to TTL converter board is required to connect it with the PC. This hardware helps in programming the arduino board and also helps in the serial communication with the USB port of the PC.
Fig. 4: External USB to TTL converter board for programming Arduino and serial communication
It is assumed that the reader has gone through the project how to get started with the arduino and tried out all the things discussed there.The method of random number generation using a microcontroller board like Arduino with the help of the pseudo-random number generating algorithm are already discussed in a previous project on how to generate random number using Arduino. This particular project makes use of two functions namely randomSeed() and random() and the details of the function are discussed below;
randomSeed() initializes the pseudo-random number generator, causing it to start at an arbitrary point in its random sequence. This function has a parameter which decides from which point in the sequence should the random number generation starts. To initialize the pseudo-random number generator with a new sequence each and every time, the value provided as the parameter should also be different.
This particular code reads a random value from the analog input pin A0 which is left unconnected so that each and every time the code runs it can generate different set of random numbers.
The function random() is used to generate pseudo-random number which falls in a specified range. The function is always called after calling the randomSeed() function. This function has two parameters of which the first one is the lowest required value and the second one is the largest required value.
To get a different set of random numbers the function randomSeed() is provided with a random value which can be read from the unconnected analog pin A0. The analog value is read with the help of the function analogRead() which is already used in the previous projects on how to use analog input and analog output of Arduino board, how to use Arduino to display sensor values, how to make dynamic sensor display using Arduino, how to save sensor values in the EEPROM of the Arduino.
The Arduino IDE provides a library called <LiquidCrystal.h> which can be used to interface an external LCD module with the Arduino board. The functions which can be used to access the LCD are already discussed in previous projects on how to interface an LCD , how to display sensor value on LCD, how to connect the LCD with the PC and how to make an LCD scrolling display.
In this project two different smileys are generated which are then displayed in a random manner across the LCD screen. The previous projects on how to generate smileys in an LCD and how to create animation in an LCD discuss about the method of generating smileys.The code also blinks an LED connected to the pin number 6 of the Arduino board using the functions pinMode(),digitalWrite() and delay() which are explained in the previous projects on how to get started with the Arduino board and how to use the digital input and output of the Arduino board.
The code simply generates a random number and displays the smileys in the first and second line of the 16*2 LCD with an offset given by the random number generated within the range 0 to 16.