In this section, we will use Arduino to work on two projects.
Introduction to Arduino
Arduino is an open-source electronics platform used to build interactive projects. It consists of both hardware (the Arduino board) and software (the Arduino IDE) that allows users to write and upload code to the board. Arduino is widely used by students, engineers, and hobbyists because it is simple to learn and easy to use.
With Arduino, you can control many electronic components such as LEDs, sensors, motors, and displays. This makes it possible to create a wide variety of projects like smart systems, automation devices, and interactive games.
Arduino is also very popular in education because it helps beginners understand the basics of programming and electronics through practical experiments and real projects.
1️⃣first project:
Electronic Dice Using Arduino and 555 Timer
This project presents an Electronic Dice System built using an Arduino Uno and a NE555 Timer. The purpose of the project is to simulate the behavior of a traditional dice in an electronic and interactive way.
When the player presses the push button, the system starts the rolling process. During this stage, the LEDs blink rapidly to simulate the effect of a rolling dice. At the same time, a buzzer produces a sound to enhance the user experience.
After a short delay, the Arduino generates a random number between 1 and 6. The LEDs are arranged in the pattern of a real dice and illuminate according to the generated number. In addition, the result is displayed on an LCD Display to clearly show the final number.
The NE555 Timer is used to generate timing pulses that help create the blinking effect during the rolling stage, while the Arduino Uno controls the main logic of the system, including reading the push button, generating the random number, controlling the LEDs, activating the buzzer, and displaying the result on the LCD screen.
This project demonstrates the integration between programmable microcontrollers and basic electronic components, providing a simple but effective example of embedded system design.
Push Button (Used to start the dice roll)
Resistors 220Ω (Used to protect the LEDs)
Resistors 1kΩ and 10kΩ (Used in the 555 timer circuit)
Capacitor 10µF (Used for timing in the 555 circuit)
Breadboard (For building the circuit)
Jumper Wires (For electrical connections)
The Electronic Dice project is built using the following components:
Arduino Uno (Microcontroller board used to control the whole system)
NE555 Timer (Used to generate timing pulses for the rolling effect)
LCD Display 16x2 with I2C module (Used to display the dice number)
Buzzer (Used to produce sound during dice rolling and result display)
connections:
5V → goes to the positive power rail on the Breadboard
GND → goes to the ground rail (GND) on the Breadboard
Pin D2 → Push Button (one side)
Pin D3 → Buzzer (other side connected to GND)
SDA (A4) → SDA of LCD
SCL (A5) → SCL of LCD
One terminal → D2 on Arduino
Other terminal → GND
(A pull-up resistor can be added, or use INPUT_PULLUP in the code)
Positive (+) → D3 on Arduino
Negative (-) → GND
VCC → 5V
GND → GND
SDA → A4 (Arduino)
SCL → A5 (Arduino)
Pin 1 (GND) → GND
Pin 2 (Trigger) → connected to control circuit with resistors and capacitor (controls pulse speed)
Pin 3 (Output) → can be connected to a LED pin or any other circuit if signal control is needed (in our project, used for internal trigger only)
Pin 4 (Reset) → 5V
Pin 5 (Control) → 10nF capacitor to GND (optional)
Pin 6 (Threshold) & Pin 7 (Discharge) → connected with resistors and capacitor to set pulse frequency
Pin 8 (VCC) → 5V
Note: In the Arduino code, NE555 is used to assist the random blinking effect (LEDs can be added later if desired).
Positive power rail (+) → connected to 5V
Ground rail (-) → connected to GND
Connect all components on the Breadboard using Jumper Wires for easier connections
This shows the actual wiring of the circuit on the real hardware setup.
And this code file is the one we uploaded to the Arduino.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int button = 9;
int buzzer = 10;
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
void setup()
{
pinMode(button, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Electronic Dice");
delay(2000);
lcd.clear();
randomSeed(analogRead(A0));
}
void loop()
{
if(digitalRead(button) == LOW)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Rolling...");
for(int i=0;i<15;i++)
{
randomLED();
tone(buzzer,1000);
delay(100);
noTone(buzzer);
}
int number = random(1,7);
showDice(number);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Number = ");
lcd.print(number);
tone(buzzer,1500);
delay(300);
noTone(buzzer);
delay(3000);
}
}
void allOff()
{
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(led4,LOW);
digitalWrite(led5,LOW);
digitalWrite(led6,LOW);
digitalWrite(led7,LOW);
}
void randomLED()
{
allOff();
int r = random(2,9);
digitalWrite(r,HIGH);
}
void showDice(int n)
{
allOff();
if(n==1)
{
digitalWrite(led3,HIGH);
}
if(n==2)
{
digitalWrite(led1,HIGH);
digitalWrite(led7,HIGH);
}
if(n==3)
{
digitalWrite(led1,HIGH);
digitalWrite(led3,HIGH);
digitalWrite(led7,HIGH);
}
if(n==4)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led6,HIGH);
digitalWrite(led7,HIGH);
}
if(n==5)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
digitalWrite(led6,HIGH);
digitalWrite(led7,HIGH);
}
if(n==6)
{
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led4,HIGH);
digitalWrite(led5,HIGH);
digitalWrite(led6,HIGH);
digitalWrite(led7,HIGH);
}
}
Watch the video to see the final result of our project. 🎬