0% found this document useful (0 votes)
7 views35 pages

ECE 415 Laboratories Group 1

This laboratory report from Batangas State University details a series of Arduino-based projects undertaken by a group of electronics engineering students. The projects aim to enhance understanding of microcontrollers through hands-on experiments, including building circuits for a light dimmer, memory game, and motion control systems. The report outlines the objectives, materials used, and procedures followed to implement these projects, emphasizing the practical applications of microcontrollers in various fields.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views35 pages

ECE 415 Laboratories Group 1

This laboratory report from Batangas State University details a series of Arduino-based projects undertaken by a group of electronics engineering students. The projects aim to enhance understanding of microcontrollers through hands-on experiments, including building circuits for a light dimmer, memory game, and motion control systems. The report outlines the objectives, materials used, and procedures followed to implement these projects, emphasizing the practical applications of microcontrollers in various fields.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Republic of the Philippines

BATANGAS STATE UNIVERSITY


The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

LABORATORY REPORT NO. 1


Arduino Projects

Prepared and Submitted by Group 01 from ECE 3302


In partial fulfillment of the Course ECE 415 - Microprocessor and
Microcontroller Systems and Design
Bachelor of Science in Electronics Engineering
Batangas State University – Alangilan

Macalintal, Keybeard
Nora, Rashid M.
Peralta, Paul
Samonte, Kyte Valerie

July 2025

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

I.​ INTRODUCTION
Microcontrollers are fundamental components in electronics and embedded systems.
These small integrated circuits combine a processor, memory, and input/output interfaces,
enabling them to perform programmed tasks repeatedly and efficiently [1]. Due to their
efficiency and versatility, microcontrollers have become essential components in a wide range of
applications including home automation, medical devices, automotive systems, and many more.

​ One of the most popular platforms for learning and developing microcontroller-based
systems is Arduino. Arduino is an open-source prototyping platform with simple hardware and
software components [2]. It comprises a programmable circuit board (also known as a
microcontroller) and ready-made software called Arduino IDE (Integrated Development
Environment), which is used to develop and upload computer code to the physical board [3]. It is
particularly effective for students and beginners due to its user-friendly interface and accessible
programming environment. Unlike traditional microcontroller environments that often require a
deep understanding of embedded C or assembly language, Arduino uses a simplified
programming environment based on C/C++, and its development board designs are user-friendly
[4].

The most commonly used board in the Arduino family is the Arduino Uno, which is built
around the ATmega328P microcontroller. It comes equipped with 14 digital input/output pins, 6
analog input pins, a USB connection for uploading code, and a power jack [5]. These features
make it ideal for learning how to interface with components such as LEDs, sensors, buzzers,
motors, and displays. Arduino also supports a wide range of libraries that simplify the process of
coding for different hardware modules [6]. For example, libraries for controlling servos, reading
joystick values, or playing tones through a buzzer are all readily available. The ability to upload
sketches (Arduino’s term for code) directly from a computer to the board using a USB cable
makes the process of building and testing electronic systems more immediate and engaging.

In this laboratory activity, students are introduced to essential microcontroller


applications through a series of interactive and practical experiments. One experiment focuses on
building a light dimmer circuit that visually displays the brightness of an LED through the use of
potentiometer. Another involves developing a memory game where players respond to
illuminated LEDs and sounds by pressing the correct buttons in sequence. In addition, students
also explore motion control by assembling a joystick-operated laser system using dual servos
which enables directional movement in two axes. Additional activities include programming an
LCD to display personalized messages with adjustable brightness through the use of a
potentiometer, simulating an electronic die that produces random outputs on a seven-segment
display through a shift register, and constructing an intrusion detection system using an
ultrasonic sensor. From this series of experiments, students develop a deeper understanding of
how microcontrollers operate in real-world applications.

II.​ OBJECTIVES
In this laboratory activity, the group will work on different projects using the Arduino
Uno as the main microcontroller to control and connect electronic parts. It helps the students to
better understand the basic principles of microcontroller and electronic systems. With this,
student aims to achieve the following objectives:

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

1.​ To develop and operate various kinds of Arduino-based projects that illustrate
important capabilities such as LED manipulation, sound-based operations, servo
motor operation, LCD output, counting mechanisms, and basic security applications.
2.​ To enhance understanding of microcontrollers by applying theoretical knowledge
through hands-on implementation using the Arduino Uno.
3.​ To improve technical skills in circuit assembly, coding, and troubleshooting
Arduino-based devices.

III.​ MATERIALS
This section provides the list of all the materials and components utilized in the
experiment. Each item is listed along with an explanation of its specific role and function within
the overall setup.

Description Picture Quantity Purpose

The Arduino UNO functions as


the “brain” of the embedded
Arduino system circuits. It uses sensor
1
UNO data along with the program in
order to control the output
devices.

The bread board was used to


Bread Board 1 construct the circuits temporarily
without using solder.

The connector wires, both male to


male, male to female, and female
Connector
1 set to female were used in order to
Wires
connect different components of
the circuits.

The LEDs were used as output


LEDs 4 devices to test the functionality of
the circuits.

The 50k ohm potentiometer was


Potentiometer 1 used as an input device for the
LED and LCD circuit.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

The 220 ohm resistors were used


Resistors 8 to limit the current for both the
LED display and LEDs.

The buttons were used as the


Buttons 4
input devices for the game circuit.

The speakers were used as an


output device for the game circuit
Speaker 1
ensuring additional output and
entertainment

The LCD display was used as the


LCD Display 1
output device for the LCD circuit

The 7 segment display was used


7 Segment
1 as the output device for the dice
LED display
circuit

The decoder was used to convert


the binary output of the Arduino
7 Segment
UNO to a number in the 7
LED Display 1
segment display. This was done to
Decoder
reduce the output pins used from
7 to only 4.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

The servo served as an output


Servo Motor 2 device for the security system and
joystick controlled laser

Ultrasonic The ultrasonic sensor was used as


1
Sensor the sensor for the security system

The joystick was used as the input


Joystick 1
of the joystick controlled laser

The pan and tilt housing module


was used to attach the two servo
Pan and Tilt motors so that they could point
Housing 1 the laser within a limited angle
Module vertically or horizontally
according to the input provided
by the user through the joystick.

IV.​ PROCEDURES
The procedures implemented in this Arduino-based laboratory project included a
methodical approach to designing, constructing, and programming various electronic circuits on
the Arduino platform. Each project was accomplished by identifying the required components,
establishing the circuit on a breadboard, writing and uploading the needed code, and performing
functional tests to confirm proper operation. Troubleshooting and iterative changes were
implemented as needed to further develop each system. The following are the related processes
used for all projects in this laboratory activity.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

1.1.​ LED

The initial phase of this project starts by inserting the potentiometer into the
breadboard, ensuring that it is securely positioned for stable connections. The center pin
of the potentiometer is then connected to the Arduino’s analog input pin A0, which
allows the microcontroller to read varying voltage levels. One of the outer pins of the
potentiometer is connected to the +5V rail of the breadboard to provide a reference
voltage, while the other outer pin is connected to the GND rail to complete the circuit.

Table X. Potentiometer to Arduino Pin Configuration


POTENTIOMETER ARDUINO

Left pin +5V

Center pin A0

Right pin GND

​ Then, the next step is to insert the LED into the breadboard. The longer leg of the
LED, which is the positive (anode) terminal, is connected to digital pin 9 of the Arduino
through a 470-ohm resistor to limit current and protect the LED. The shorter leg, which is
the negative (cathode) terminal, is connected to the GND rail of the breadboard to
complete the circuit.

Table X. LED to Arduino Pin Configuration


LED ARDUINO

Positive leg Pin 9

Negative leg GND via 470-ohm resistor

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Figure X.X. Flowchart of the Sketch

​ After setting up, the sketch will be uploaded, which will serve as the instructions
that will control the behavior of the components that are connected in the Arduino.The
flowchart above shows the sequence of operations in the Arduino-based light dimmer
project. Then the potentiometer was gradually changed to see how it affected the LED
brightness. As expected, moving the potentiometer changed the voltage read at the analog
input, which controlled the LED intensity via PWM. The results were recorded and
examined to ensure that the system was functional and responsive, confirming that the
light dimmer circuit had been successfully implemented.

1.2.​ SOUND
​ To begin this project, all the required components were gathered which include an
Arduino Uno board, a breadboard, jumper wires, a piezo buzzer, four momentary tactile
four-pin pushbuttons, four LEDs, and four 220-ohm resistors. This project also utilizes
the “Tone” library for sound output, which must be installed beforehand.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Figure X.X. Materials Used in Memory Figure X.X. Installed Library Used in
Game Setup Memory Game Setup

Initially, the pushbuttons are placed on the breadboard so that they straddle the
center break, with pins A and B on one side and pins C and D on the other. Following
this, pin B of each pushbutton is wired to the ground rail of the breadboard, which is then
connected to one of the Arduino’s GND pins. Meanwhile, pin D of each pushbutton is
connected to digital pins 2 through 5 of the Arduino in sequential order.

Figure X.X. Placement of Pushbuttons on Figure X.X. Jumper Wire Connections


the Breadboard Between Pushbutton and Arduino Uno Pin

Next, the LEDs are inserted into the breadboard. Each LED’s shorter leg (the
negative leg) is connected to the same row as pin C of the corresponding pushbutton. The
longer positive leg is directed toward the right side of the board to allow space for a
resistor. Then, each 220-ohm resistor is placed between the positive leg of an LED and
Arduino digital pins 8 through 11. Specifically, the red LED is connected to pin 11,
yellow to pin 10, green to pin 9, and blue to pin 8. In the following step, the piezo buzzer
is wired into the circuit. The black (negative) wire of the buzzer is connected directly to
the Arduino’s GND, while the red (positive) wire is linked to digital pin 12.

Once all wiring is completed, the overall setup is checked against the provided
circuit diagram to ensure accuracy and correct placement of all components.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Figure X.X. Reference Circuit Diagram for Figure X.X. Final Setup for Memory Game
Memory Game Setup Setup

After confirming the setup, the provided code (See Appendix B) is uploaded to
the Arduino board.

Figure X.X. Code Uploaded to the Arduino Board

To better understand how the memory game operates once the code is uploaded, a
flowchart is provided below. This flowchart shows the sequence of operation that the
system follows during the game, from initialization to user input validation and sequence
progression.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


Figure X.X.

At the start of the game, the system plays a short melody through the piezo and
flashes an LED to signal that the game has begun. A randomly chosen LED lights up, and
the player is expected to press the corresponding pushbutton. If the correct button is
pressed, the system adds another step to the sequence and repeats the entire pattern,
making the game progressively more challenging. During each round, the code generates
a new random value that corresponds to one of the four LEDs, which is stored in an array.
The LEDs light up one by one in the stored sequence, each accompanied by a unique tone
played by the piezo buzzer. Button presses are detected using the “digitalRead()”
function and are then compared to the stored sequence in the “randomArray”. The
player must then press the pushbuttons in the correct order to match the sequence. If an
incorrect button is pressed at any point, the game immediately triggers a failure response
which flashes all LEDs and plays a distinctive tone, before resetting the sequence and
starting over.

1.3.​ SERVOS
This project requires a few essential components to build a joystick-controlled
laser system. The materials include an Arduino Uno board, a breadboard, jumper wires,
two Tower Pro SG90 9g servomotors, an analog two-axis joystick module, and a
pan-and-tilt servo housing. Additionally, the “Servo” library must be installed to enable
control over the servo motors.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

The wiring setup starts with powering the servos. Both red power wires are
connected to the +5V rail of the breadboard, while the brown wires are grounded. The
+5V and GND rails are connected to the corresponding pins on the Arduino to complete
the power circuit. The yellow signal wire of one servo is connected to pin 9, while the
second servo’s signal wire is connected to pin 10 on the Arduino.

The joystick module is connected next. It includes five pins labeled +5V, GND,
VRx, VRy, and SW. The +5V and GND pins are connected to the power and ground rails
of the breadboard. The VRx pin, which reads horizontal motion, is wired to analog pin
A0 on the Arduino, while the VRy pin, responsible for vertical motion, is connected to
analog pin A1. The SW pin, which functions as a pushbutton, is not used in this particular
project.

Figure X.X. Circuit Connections in Joystick-Controlled Laser System

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Before turning on the circuit, the connections between the breadboard rails and
the Arduino’s GND and +5V pins are carefully checked for accuracy. Once the wiring is
confirmed to be accurate, both servos are secured in the pan-and-tilt housing. The laser
pointer is then placed on top of the module. Following the setup, the provided code (See
Appendix A) is uploaded to the Arduino board to enable control of the system.

Figure X.X. Reference Circuit Diagram for Figure X.X. Final Setup for
Joystick-Controlled Laser System Joystick-Controlled Laser System

Once the joystick-controlled laser system is properly assembled and the code is
uploaded to the Arduino, the program begins running its main control loop. The
flowchart below breaks down the entire process into clear, sequential steps.

Figure X.X.

The program operates by first setting up the system components, specifically


attaching the two servo motors used for pan and tilt movements through the Servo library.
Once initialized, the code enters a continuous loop where it reads the analog values from
the joystick's X and Y axes to detect directional input.

To ensure compatibility with the servo motors, these analog readings, originally in
the 0 to 1023 range, are converted to pulse widths between 900 and 2100 microseconds.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

This conversion allows the joystick's position to be accurately translated into servo
angles. The “write()” function is then used to send these mapped values to the respective
servos which prompt them to move accordingly.

Following each set of commands, the program pauses briefly for 15 milliseconds
which gives the servos time to adjust before the next input is processed. This loop runs
continuously which enables real-time control of the servo positions based on joystick
movements.

1.4.​ LCDS
In this project, an Arduino Uno microcontroller is used to interface with a Liquid
Crystal Display (LCD), which serves as the main visual output for displaying data and
messages. The LiquidCrystal library is utilized to handle the communication between the
Arduino and the LCD, simplifying the complex processes involved in rendering
characters on the screen. To enhance usability, a potentiometer is also included in the
circuit, allowing users to adjust the display contrast in real time.

Fig X. LCD Screen Writer Circuit Fig X. LiquidCrystal Library for the
Configuration LCD Screen Writer

The initial phase of this project involved the assembly of the display interface,
beginning with the soldering of a 16x2 liquid crystal display (LCD) module onto a row of
16 male header pins. Once the soldering was completed, male-to-female jumper wires
were used to interface the LCD with the breadboard. Following this, the LCD was wired
to the Arduino UNO according to the standard pin configuration, as outlined in the
corresponding connection table.

Table X. LCD Screen Writer Pin Configuration


LCD SCREEN ARDUINO
1 VSS GND
2 VDD +5V
4 RS Pin 7
5 R/W GND
6 Enable Pin 8
11 D4 Pin 9
12 D5 Pin 10
13 D6 Pin 11
14 D7 Pin 12
15 A BcL+ +5V
16 K BcL- GND

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Table X presents the complete pin configuration used for connecting the LCD
module with the Arduino UNO. It outlines the specific connections established between
each pin of the LCD and the corresponding digital or analog pins of the microcontroller,
including the power supply, ground, data lines, and control lines.

After successfully setting up the basic connections, a 50k-ohm potentiometer was


added to the breadboard to allow manual adjustment of the LCD screen's contrast. The
middle (wiper) pin of the potentiometer was specifically connected to pin 3 (VO) of the
LCD, which is responsible for controlling the contrast level. The other two terminals of
the potentiometer were connected to VCC and GND, respectively. This configuration
enables the user to adjust the display contrast by simply rotating the knob of the
potentiometer.

Upon completion of all hardware interconnections, the code for the project was
uploaded to the Arduino UNO using the Arduino IDE. The LCD immediately displayed
the expected output, confirming that both the hardware setup and software execution
were working as intended.

Fig X. LCD Screen Writer Flowchart

Figure X illustrates the LCD Screenwriter flowchart. It begins with including the
LiquidCrystal.h library and initializing the LCD with defined pin assignments. Once set
up, the display prints the message "Arduino Sketch" and enters a repeating loop that
manipulates text scrolling with precise timing.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

1.5.​ NUMERIC COUNTERS


In this project, a digital die is created using a seven-segment LED display. When
the pushbutton is pressed, it sends a signal to the Arduino, prompting the display to
"shake" and show a randomly generated number between 1 and 6. The setup incorporates
a 74HC595 shift register, a compact integrated circuit (IC) and sequential logic counter
which enables the Arduino to control more output connections than its limited number of
pins would normally allow, by shifting and storing data efficiently.

Fig X. Electronic Die Circuit Configuration

The project began with the placement of the seven-segment display and the
74HC595 shift register onto the breadboard. Once both components were correctly
positioned, the necessary wiring connections were made, following the appropriate pin
configuration as shown in the table below.

Table X. Seven-Segment Display and 74HC595 Shift Register Pin Configuration


SEVEN SEGMENT LED SHIFT ARDUINO
DISPLAY REGISTER
Pin 1 (E)* Pin 4
Pin 2 (D)* Pin 3
Pin 3 GND
Pin 4 (C)* Pin 2
Pin 5 (DP)* Pin 7
Pin 6 (B)* Pin 1
Pin 7 (A)* Pin 15
Pin 9 (F)* Pin 5
Pin 10 (G)* Pin 6

Table X shows the pin configuration between the seven-segment LED display and
the 74HC595 shift register. Each segment of the display is connected to a corresponding
output pin on the shift register. Specifically, the shift register's output pins are wired to
the segment pins of the seven-segment display as outlined in the table. To prevent
excessive current from damaging the LED segments, 220-ohm resistors are placed in
series between the shift register outputs and the segment input pins.

Table X.Shift Register to Arduino Pin Configuration


SHIFT REGISTER ARDUINO
Pin 10 +5V
Pin 11 Pin 12

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Pin 12 Pin 8
Pin 13 GND
Pin 14 Pin 11
Pin 16 +5V
Pulse Pin 2
Following this, the 74HC595 shift register was interfaced with the Arduino UNO
microcontroller. This step involved establishing precise connections between specific
shift register pins and designated Arduino pins, including power supply lines (+5V and
GND), as well as the data input, clock, and latch control lines. These connections,
detailed in Table Y, are essential for enabling the Arduino to transmit serial data to the
shift register, which in turn controls the outputs connected to the seven-segment display.

A push button was added to the circuit to allow user input, with one terminal
connected to digital pin 2 of the Arduino and the other to ground. When pressed, the
Arduino detected the input and triggered a response. After verifying the connections, the
program was uploaded using the Arduino IDE. It used the built-in shiftOut() function to
send data to the shift register, which controlled the active segments of the display. Each
button press generated a random number between 1 and 6, displaying it on the
seven-segment display like a digital die.

Fig X. Electronic Die Flowchart

Figure X shows the flowchart of an electronic dice system using a seven-segment


display. The process begins with system initialization, followed by continuous monitoring
for a button press. Once the button is pressed, a shaking and rolling animation is triggered
to simulate the behavior of rolling a real die. The system then waits for the button to be
released. Upon release, a random number between 1 and 6 is generated, which represents
the dice roll result. This number is then displayed on the seven-segment display. After
displaying the result, the system returns to monitoring the button for the next interaction,
completing the loop.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

1.6.​ SECURITY
This project involves the use of an ultrasonic sensor in order to detect intruders.
The ultrasonic sensor works by using the amount of time that sound travels to measure
the distance of an object from the sensor. When the sound produced by a sensor hits an
object 15 cm in front of it, the sound bounces back and is detected by the sensor and it
sends a signal to the Arduino through the echo pin. After receiving the signal, the arduino
sends a signal to a servo motor and changes the lit LED from green to red.

Ultrasonic sensor ARDUINO


​ GND GND
VCC +5V
Trig Pin 12
Echo Pin 13
TableX

Table X shows that the GND pin of the ultrasonic sensor is connected to the
Arduino GND, the VCC is connected to +5V, the trig pin is connected to pin 12, while
echo is connected to pin 13. This shows that the ultrasonic sensor is operating at 5 volts.

Servo ARDUINO
Red +5V
Brown GND
Yellow Pin 9

TableX
Table X shows that the brown wire of the servo sensor is connected to the
Arduino GND, the red wire is connected to +5V, while the yellow wire is connected to
pin 9. This shows that the servo is operating at 5 volts.

LEDs ARDUINO
Negative legs GND
Positive leg (red) Pin 2 via
220-ohm resistor
Positive leg (green) Pin 3 via
220-ohm resistor

TableX

Table X shows that the negative legs of the LEDs are connected to the Arduino
GND, the red led positive leg is connected to pin 2, while the green led is connected to
pin 3. Resistors were used to regulate the current to prevent the LEDs from taking in
excessive power.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Fig X
Fig X shows the overall connection of the embedded system. The wires were
connected in the proper pin configuration.

Fig X
The flowchart shows how the security system works. If an object, presumably an
intruder, is detected, the servo moves and the red LED is lit while the green LED is
turned off; otherwise, the servo remains static while the green LED is lit while the red
LED is turned off.

V.​ DATA AND RESULTS


Lorem ipsum dolor sit amet, consectetur adipiscing elit. In accumsan nunc sapien, eget
condimentum purus volutpat eu. Mauris tortor magna, imperdiet a mollis eu, tempor sagittis dui.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

1.1.​ LED

Fig X. Light Dimmer Circuit Configuration

The figure shows the complete configuration of the Arduino-based light dimmer
circuit. It includes a potentiometer, an LED, and the necessary connections to the
Arduino Uno. The potentiometer is utilized as an analog input device, and the LED is the
output component whose brightness is adjustable. The circuit connects the potentiometer
to analog pin A0 and the LED to digital pin 9 via a 470-ohm resistor, allowing the
Arduino to read varying voltage levels and alter the LED intensity using Pulse Width
Modulation (PWM).

Fig X. Demonstration of the Light Intensity Control using Potentiometer

This configuration efficiently illustrates the concept of analog input and PWM
output in a microcontroller system. It demonstrates how user contact with a basic
hardware component (the potentiometer) may affect the behavior of another component
(the LED) in real time.As seen in the figure, when the potentiometer is set to a lower
resistance (low ohms), it sends a lower voltage to the Arduino, resulting in a lower PWM
signal. As a result, the LED receives shorter power pulses, making it appear less bright.
When the potentiometer is turned to its highest resistance setting, it generates a greater
analog voltage, which the Arduino converts to a wider PWM signal. This increases the
brightness of the LED, demonstrating the proportional link between analog input and
LED output intensity.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

1.2.​ SOUND
The Memory Game system operates by flashing a sequence of LEDs
accompanied by corresponding tones from a piezo buzzer. Each LED is assigned a
distinct tone and is paired with a specific pushbutton for player input. At the beginning of
the game, all LEDs flash in a preset order, as shown in Figure X.X. This initial display
serves as a visual indicator that the system is powered on and ready to start.

Fig X.X.

Following the initialization sequence, the game begins with the Arduino selecting
a random LED to light up. This marks the first step in the pattern that the player must
observe and replicate. To ensure that the pattern changes every time the game is played,
the Arduino uses “randomSeed(analogRead(0))”, which introduces randomness by
reading electrical noise from an unused analog pin. To test if the game is working, two
test scenarios were conducted, one where the player successfully follows the sequence
and another where the player fails.

LED Sequence
Game Sequence Player Input
Step

​ Table X.X. Game and Player LED Sequence Showing Winning Scenario

The table presents the results from the winning scenario, in which the player
successfully followed the LED sequence generated by the game. Each step of the game
sequence, where the system lights up LEDs in a specific order (green and green) is
matched by the player’s input, with no errors in timing or order. The player pressed the

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

correct buttons that corresponded to each LED, and the inputs were recorded accurately
by the Arduino. Since there were no mismatches or errors, the round is considered a
successful attempt, demonstrating that the memory game operated as intended during this
trial.

In addition, each time the player correctly repeats the sequence, the system adds
another random LED to the pattern which makes the game more difficult. This process
repeats and becomes more challenging with every correct round, continuing until the
player eventually enters an incorrect input.

After completing the previous round successfully, the system proceeds to the next
by adding another random LED to the existing sequence which makes the game more
challenging. However, in the next scenario, the player will intentionally fail to correctly
replicate the extended pattern.

LED Sequence
Game Sequence Player Input
Step

4 -

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Table X.X. Game and Player LED Sequence Showing Losing Scenario

In this table, the results illustrate a losing scenario in the memory game. The game
begins with a sequence of LEDs lighting up in the order which is green, green, blue, and
green. During the first two steps, the player correctly replicates the pattern by pressing
the corresponding buttons for the green LEDs. However, in the third step, the system
lights up the blue LED, but the player mistakenly presses the green LED instead.

This incorrect response marks a failure to recall the sequence accurately which
leads to being unable to continue to the fourth step. The reason behind this is when an
incorrect button is pressed, a distinct tone plays to indicate the error, and the fail()
function is executed, which resets both arrays and restarts the game. This keeps the game
in a loop and allows the player to try again.

Based on the two test scenarios conducted by the group, it can be concluded that
the memory game worked as intended. The system was able to recognize correct and
incorrect responses, provided immediate feedback, and properly reset after an error which
allowed the game to run smoothly.

1.3.​ SERVOS
The results of the Joystick-Controlled Laser System experiment are presented
through a series of images that clearly demonstrate how the system responds to different
joystick movements. These images provide evidence of the system’s ability to convert
analog input from the joystick into accurate servo motor adjustments, which in turn
control the laser’s direction. By manipulating the joystick in different directions, up,
down, left, and right, the user is able to control the angles of two servo motors mounted
on a pan-and-tilt platform, effectively guiding the laser’s position.

Figure X.X. Joystick Toggled in Upward Figure X.X. Joystick Toggled in Downward
Direction Direction

​ In Figure X.X, the joystick is pushed upward, causing the tilt servo to move the
laser platform in the same direction. This action corresponds to a decrease in the Y-axis
analog value, which the system accurately maps to a specific pulse width using the
“map()” function. The servo’s upward movement confirms that the input was processed
correctly and translated into precise motion within the intended tilt range. On the other
hand, in Figure X.X , the joystick is toggled downward, causing the tilt servo to rotate the
laser platform downward. This shows that the system correctly detected an increase in the
Y-axis analog value and responded with an appropriate adjustment in servo angle.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

Figure X.X. Joystick Toggled in Leftward Figure X.X. Joystick Toggled in Rightward
Direction Direction

In terms of horizontal motion, in Figure X.X, the joystick is pushed to the left
which prompts the pan servo to rotate the laser in the same direction. This confirms that
the system correctly interprets a decrease in the X-axis analog value and maps it to a
corresponding angle for leftward movement. Similarly, in Figure X.X the joystick is
pushed to the right, and the laser adjusts accordingly by rotating in the rightward
direction. This shows that an increase in the X-axis analog reading is correctly translated
into rightward servo motion. The consistent and symmetrical behavior between left and
right movements further demonstrates that the pan servo operates reliably and responds
as expected to directional input.

1.4.​ LCDS

​ ​ [A] [B] [C]


Fig.X [A] LCD Output at Maximum Potentiometer Setting
[B] LCD Output at Nominal Potentiometer Setting
[C] LCD Output at Minimum Potentiometer Setting

This project effectively demonstrates the functionality of an Arduino when


interfaced with an LCD screen. In this setup, the Arduino Uno serves as the central
control unit, transmitting digital data and control signals to the LCD to display characters.
These signals define both the content and positioning of the text shown on the screen.
The LCD, functioning as the visual output component, interprets the incoming signals
and converts them into visible text characters. To ensure optimal readability of the
display, a 50k-ohm potentiometer is incorporated into the circuit. This variable resistor
provides analog voltage control for adjusting the contrast of the LCD. By rotating the
potentiometer, the user modifies the voltage applied to the contrast pin, which in turn
affects the biasing of the liquid crystals. This adjustment enables the user to enhance
character visibility, ensuring the displayed text remains clear and readable. It shows how
analog signals can be converted to digital signals.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

This interaction between the potentiometer and the LCD also illustrates a
fundamental concept in embedded systems of how analog inputs can influence digital
outputs. The analog voltage from the potentiometer is continuously interpreted by the
hardware, resulting in real-time changes to the digital display. From the observed figures,
it is evident that the LCD screen’s appearance clearly changes each time the
potentiometer is adjusted. This real-time response highlights how the analog and digital
parts of the circuit work well together and reinforces the Arduino’s capability to interface
effectively with external hardware for interactive applications.

1.5.​ NUMERIC COUNTERS


[A] [B]
Fig.X [A] Roll of 6 Displayed on the Electronic Die Circuit
[B] Roll of 1 Displayed on the Electronic Die Circuit

This Arduino-based project simulates the function of a digital dice using a


7-segment display, a 74HC595 shift register, and a pushbutton. At the core, the Arduino
Uno sends serial data to the 74HC595, which then controls the segments of the 7-segment
display. Key connections include dataPin (Pin 11), clockPin (Pin 12), and latchPin (Pin
8), which facilitate the communication between the Arduino and the shift register.

The 74HC595 shift register is used to expand the number of digital outputs,
enabling the Arduino to control multiple display segments using fewer pins. It receives
bits of data from the Arduino, which represent the segments to be turned on. After all
data bits are sent, the latch pin updates the output so the correct number appears on the
display. When the pushbutton is pressed, the Arduino detects the input and initiates an
animation sequence. This includes cycling through digits to simulate the shaking and
rolling of a physical die. Once the animation is complete, the Arduino generates a random
number between 1 and 6 and displays the corresponding digit on the 7-segment display.
As shown in the figure, pressing the button initially displays the number six. A
subsequent press changes the output to a different number, which is three, demonstrating
that the system functions correctly by generating random values with each button press.

From the software perspective, the lookup_7seg array stores hexadecimal codes
for displaying digits 1 to 6 on the common-cathode 7-segment display. Two arrays,
shake_dice and roll_dice, define simple animation patterns to mimic shaking and rolling
effects. The setup() function initializes the I/O pins and seeds the random number
generator, ensuring varied dice outcomes. Moreover, in the loop() function, the program
waits for the button press. Once detected, it plays a shaking animation, then displays the
final random number. Functions like DiceNumber() and AnimateDice() manage the

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

display logic, making it easier to control how the numbers and animations are shown on
the 7-segment display through the shift register.

Overall, this project illustrates how embedded systems integrate hardware control
and programmed logic to respond to real-world inputs. It highlights efficient pin usage,
timing-based animations, and structured code organization, making it a strong example of
practical embedded system design.

1.6.​ SECURITY



The results of the embedded system experiment were as expected but a few
changes were needed to be made in the program. The servo write function was modified
to be at 10 degrees instead of 0 and 170 instead of 180. This was done because setting the
servo to its maximum and minimum angles causes it to vibrate and make unwanted
noises. After the modification, the device worked as expected. The activated LED is
green if there is no object 15cm or closer in front of the ultrasonic sensor(Figure X) and
the activated LED is red and the servo rotates to the expected angles if there is an object
otherwise(Figure X).

VI.​ CONCLUSION
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In accumsan nunc sapien, eget
condimentum purus volutpat eu. Mauris tortor magna, imperdiet a mollis eu, tempor sagittis dui.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Phasellus
suscipit felis id lorem congue lacinia. Nullam at maximus mi. Quisque ultrices lobortis risus, nec
facilisis lorem suscipit ac. Maecenas congue tristique lobortis. Quisque tincidunt a ante et
pulvinar. Morbi rhoncus pharetra mauris, non aliquam lacus dignissim at. - SN, FN MI. Member
1
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In accumsan nunc sapien, eget
condimentum purus volutpat eu. Mauris tortor magna, imperdiet a mollis eu, tempor sagittis dui.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Phasellus
suscipit felis id lorem congue lacinia. Nullam at maximus mi. Quisque ultrices lobortis risus, nec
facilisis lorem suscipit ac. Maecenas congue tristique lobortis. Quisque tincidunt a ante et
pulvinar. Morbi rhoncus pharetra mauris, non aliquam lacus dignissim at. - SN, FN MI. Member
2
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In accumsan nunc sapien, eget
condimentum purus volutpat eu. Mauris tortor magna, imperdiet a mollis eu, tempor sagittis dui.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Phasellus
suscipit felis id lorem congue lacinia. Nullam at maximus mi. Quisque ultrices lobortis risus, nec
facilisis lorem suscipit ac. Maecenas congue tristique lobortis. Quisque tincidunt a ante et

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

pulvinar. Morbi rhoncus pharetra mauris, non aliquam lacus dignissim at. - SN, FN MI. Member
3

Samonte, Kyte Valerie C.

REFERENCES
[1] Lutkevich, Ben. “What Is a Microcontroller and How Does It Work?” TechTarget, Nov. 2019,
www.techtarget.com/iotagenda/definition/microcontroller.
[2] Arduino. “What Is Arduino?” Www.arduino.cc, 5 Feb. 2018,
www.arduino.cc/en/Guide/Introduction/.
[3] “Arduino - Overview - Tutorialspoint.” Www.tutorialspoint.com,
www.tutorialspoint.com/arduino/arduino_overview.htm.
[4] Ben. “What Is an Arduino?” Sparkfun.com, 2019,
learn.sparkfun.com/tutorials/what-is-an-arduino/all.
[5] Arduino. “UNO R3 | Arduino Documentation.” Docs.arduino.cc, 2025,
docs.arduino.cc/hardware/uno-rev3/.
[6] Arduino. “Arduino Integrated Development Environment (IDE) v1 | Arduino Documentation
| Arduino Documentation.” Arduino.cc, 2022,
docs.arduino.cc/software/ide-v1/tutorials/arduino-ide-v1-basics/.

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

APPENDIX
I.​ Project 1: LED’s - Light Dimmer
​ int potPin = A0; // Analog input pin connected to the potentiometer
int potValue = 0; // Value that will be read from the potentiometer
int led = 9; // Pin 9 (connected to the LED) is capable of PWM

// Runs once at beginning of the program


void setup() {
pinMode(led, OUTPUT); // Set pin 9 to output
}

// Loops continuously
void loop() {
potValue = analogRead(potPin); // Read potentiometer value
// from A0 pin
analogWrite(led, potValue / 4); // Send potentiometer value to LED
// to control brightness with PWM
delay(10); // Wait for 10 ms

II.​ Project 2: SOUND - Memory Game


#include <Tone.h>

Tone speakerpin;
int starttune[] = { NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4, NOTE_C4, NOTE_F4,
NOTE_C4, NOTE_F4, NOTE_G4, NOTE_F4, NOTE_E4, NOTE_F4, NOTE_G4 };
int duration2[] = { 100, 200, 100, 200, 100, 400, 100, 100, 100, 100, 200, 100,
500 };
int note[] = { NOTE_C4, NOTE_C4, NOTE_G4, NOTE_C5, NOTE_G4, NOTE_C5 };
int duration[] = { 100, 100, 100, 300, 100, 300 };
boolean button[] = { 2, 3, 4, 5 }; // Pins connected to pushbutton inputs
boolean ledpin[] = { 8, 9, 10, 11 }; // Pins connected to LEDs
int turn = 0; // Turn counter
int buttonstate = 0; // Check pushbutton state
int randomArray[100]; // Array that can store up to 100 inputs
int inputArray[100];

void setup() {
Serial.begin(9600);
speakerpin.begin(12); // Pin connected to piezo buzzer
for (int x = 0; x < 4; x++) {
pinMode(ledpin[x], OUTPUT); // Set LED pins as output

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


}
for (int x = 0; x < 4; x++) {
pinMode(button[x], INPUT); // Set pushbutton pins as inputs
digitalWrite(button[x], HIGH); // Enable internal pullup;pushbuttons start
in high position; logic reversed
}
// Generate "more randomness" with randomArray for the output
// function so pattern is different each time
randomSeed(analogRead(0));
for (int thisNote = 0; thisNote < 13; thisNote++) {
speakerpin.play(starttune[thisNote]); //
Play the next note
if (thisNote == 0 || thisNote == 2 || thisNote == 4 || thisNote == 6) { //
Hold the note
digitalWrite(ledpin[0], HIGH);
}
if (thisNote == 1 || thisNote == 3 || thisNote == 5 || thisNote == 7 ||
thisNote == 9 || thisNote == 11) {
digitalWrite(ledpin[1], HIGH);
}
if (thisNote == 8 || thisNote == 12) {
digitalWrite(ledpin[2], HIGH);
}
if (thisNote == 10) {
digitalWrite(ledpin[3], HIGH);
}
delay(duration2[thisNote]);
speakerpin.stop(); // Stop for the next note
digitalWrite(ledpin[0], LOW);
digitalWrite(ledpin[1], LOW);
digitalWrite(ledpin[2], LOW);
digitalWrite(ledpin[3], LOW);
delay(25);
}
delay(1000);
}

void loop() {
// Generate the array to be matched by the player
for (int y = 0; y <= 99; y++) {
digitalWrite(ledpin[0], HIGH);
digitalWrite(ledpin[1], HIGH);
digitalWrite(ledpin[2], HIGH);
digitalWrite(ledpin[3], HIGH);
// Play the next note
for (int thisNote = 0; thisNote < 6; thisNote++) {
speakerpin.play(note[thisNote]); // Hold the note
delay(duration[thisNote]); // Stop for the next note
speakerpin.stop();
delay(25);
}
digitalWrite(ledpin[0], LOW);

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


digitalWrite(ledpin[1], LOW);
digitalWrite(ledpin[2], LOW);
digitalWrite(ledpin[3], LOW);
delay(1000);
// Limited by the turn variable
for (int y = turn; y <= turn; y++) {
Serial.println("");
Serial.print("Turn: ");
Serial.print(y);
Serial.println("");
randomArray[y] = random(1, 5); // Assign a random number (1-4)
// Light LEDs in random order
for (int x = 0; x <= turn; x++) {
Serial.print(randomArray[x]);
for (int y = 0; y < 4; y++) {
if (randomArray[x] == 1 && ledpin[y] == 8) {
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_G3, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}
if (randomArray[x] == 2 && ledpin[y] == 9) {
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_A3, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}
if (randomArray[x] == 3 && ledpin[y] == 10) {
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_B3, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}
if (randomArray[x] == 4 && ledpin[y] == 11) {
digitalWrite(ledpin[y], HIGH);
speakerpin.play(NOTE_C4, 100);
delay(400);
digitalWrite(ledpin[y], LOW);
delay(100);
}
}
}
}
input();
}
}

// Check whether input matches the pattern


void input() {

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


for (int x = 0; x <= turn;) {
for (int y = 0; y < 4; y++) {
buttonstate = digitalRead(button[y]); // Check for button push
if (buttonstate == LOW && button[y] == 2) {
digitalWrite(ledpin[0], HIGH);
speakerpin.play(NOTE_G3, 100);
delay(200);
digitalWrite(ledpin[0], LOW);
inputArray[x] = 1;
delay(250);
Serial.print(" ");
Serial.print(1);
// Check if value of user input matches the generated array
if (inputArray[x] != randomArray[x]) {
fail(); // If not, fail function is called
}
x++;
}
if (buttonstate == LOW && button[y] == 3) {
digitalWrite(ledpin[1], HIGH);
speakerpin.play(NOTE_A3, 100);
delay(200);
digitalWrite(ledpin[1], LOW);
inputArray[x] = 2;
delay(250);
Serial.print(" ");
Serial.print(2);
if (inputArray[x] != randomArray[x]) {
fail();
}
x++;
}
if (buttonstate == LOW && button[y] == 4) {
digitalWrite(ledpin[2], HIGH);
speakerpin.play(NOTE_B3, 100);
delay(200);
digitalWrite(ledpin[2], LOW);
inputArray[x] = 3;
delay(250);
Serial.print(" ");
Serial.print(3);
if (inputArray[x] != randomArray[x]) {
fail();
}
x++;
}
if (buttonstate == LOW && button[y] == 5) {
digitalWrite(ledpin[3], HIGH);
speakerpin.play(NOTE_C4, 100);
delay(200);
digitalWrite(ledpin[3], LOW);
inputArray[x] = 4;

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


delay(250);
Serial.print(" ");
Serial.print(4);
if (inputArray[x] != randomArray[x]) {
fail();
}
x++;
}
}
}
delay(500);
turn++; // Increment turn count
}

// Function used if player fails to match the sequence


void fail() {
for (int y = 0; y <= 2; y++) { // Flash lights to indicate failure
digitalWrite(ledpin[0], HIGH);
digitalWrite(ledpin[1], HIGH);
digitalWrite(ledpin[2], HIGH);
digitalWrite(ledpin[3], HIGH);
speakerpin.play(NOTE_G3, 300);
delay(200);
digitalWrite(ledpin[0], LOW);
digitalWrite(ledpin[1], LOW);
digitalWrite(ledpin[2], LOW);
digitalWrite(ledpin[3], LOW);
speakerpin.play(NOTE_C3, 300);
delay(200);
}
delay(500);
turn = -1; // Reset turn value to start the game again
}

III.​ Project 3: SERVO - Joystick - Controlled Laser


#include <Servo.h>

Servo tilt, pan; // Create servo object


int joyX = A0; // Analog pin connected to x-axis servo
int joyY = A1; // Analog pin connected to y-axis servo
int x, y; // Variables to read values

void setup() {
tilt.attach(9); // Attach tilt servo on pin 9 to the servo object
pan.attach(10); // Attach pan servo on pin 10 to the servo object
}

void loop() {
x = joyX; // Read value of x-axis
(between 0 and 1023)
y = joyY; // Read value of y-axis
(between 0 and 1023)

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


x = map(analogRead(joyX), 0, 1023, 900, 2100); // Scale it to use with servo
between 900 to 2100 microseconds
y = map(analogRead(joyY), 0, 1023, 900, 2100);
tilt.write(x); // Set servo position according to scaled value
pan.write(y);
delay(15); // Wait for servos to get to new position

IV.​ Project 4: LCD - LCD Screen Writer


#include <LiquidCrystal.h>

// Initialize the library with the numbers of the interface pins


LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
lcd.begin(16, 2); // Set up the LCD's number of columns and rows
lcd.print("Arduino Sketch"); // Print a message to the LCD
delay(1000);
}

void loop() {
// Scroll 13 positions (string length) to the left to move it offscreen left
for (int positionCounter = 0; positionCounter < 13;
positionCounter++) {
// Scroll one position left
lcd.scrollDisplayLeft();
// Wait a bit
delay(150);
}
// Scroll 29 positions (string length + display length) to the right to move
it offscreen right
for (int positionCounter = 0; positionCounter < 29;
positionCounter++) {
// Scroll one position right
lcd.scrollDisplayRight();
// Wait a bit
delay(150);
}
// Scroll 16 positions (display length + string length) to the left to move
it back to center
for (int positionCounter = 0; positionCounter < 16;
positionCounter++) {
// Scroll one position left
lcd.scrollDisplayLeft();
// Wait a bit
delay(150);
}
// Delay at the end of the full loop
delay(1000);
}

V.​ Project 5: NUMERIC COUNTER - Electronic Die


const int latchPin = 8; // Pins connected to shift register

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


const int clockPin = 12;
const int dataPin = 11;
const int buttonPin = 2; // Pin connected to switch wire
// 1 to 6 and DP (decimal point) on 7-segment display
unsigned char lookup_7seg[] = { 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x80 };
// Shaking die pattern on 7-segment display
unsigned char shake_dice[] = { 0x63, 0x5C };
// Rolling die on 7-segment display
unsigned char roll_dice[] = { 0x1C, 0x58, 0x54, 0x4C };
// Vary duration of time before die number is received
int rand_seed;
int rand_num = 0; // Generate random number
unsigned char shake_toggle = 0; // For shaking dice animation
int index = 0; // For rolling dice animation
int shake_speed; // Accelerates dice shake speed

void setup() {
pinMode(latchPin, OUTPUT); // Output pins for controlling the shift register
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(buttonPin, INPUT); // Read switch wire state
digitalWrite(latchPin, LOW); // Display DP on 7-segment display at startup
shiftOut(dataPin, clockPin, MSBFIRST, lookup_7seg[6]);
digitalWrite(latchPin, HIGH);
randomSeed(analogRead(0)); // Generate random seed
}

void loop() {
if (digitalRead(buttonPin)) {
shake_speed = 150; // Reset die shaking speed
delay(30);
// Generate number for random speed and show shaking animation
while (digitalRead(buttonPin)) {
rand_seed++; // Generate random number
// Animate shaking die
if (shake_toggle) {
AnimateDice(0, shake_dice);
shake_toggle = 0;
} else {
AnimateDice(1, shake_dice);
shake_toggle = 1;
}
delay(80 + shake_speed); // Accelerate animation speed
if (shake_speed > 0) {
shake_speed -= 10;
}
}
// Animate rolling die
for (int rolls = 0; rolls < (rand_seed % 10 + 14); rolls++) {
AnimateDice(index, roll_dice);
delay((1 + rolls) * 20);
index++;

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering


if (index > 3) {
index = 0;
}
}
rand_num = random(0, 6); // Generate number thrown on die
DiceNumber(rand_num);
}
}

// Display the die number on 7-segment display


void DiceNumber(unsigned char num) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, lookup_7seg[num]);
digitalWrite(latchPin, HIGH);
}

// Display one frame of the shaking or rolling dice


void AnimateDice(int seg, unsigned char *table) {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, table[seg]);
digitalWrite(latchPin, HIGH);

VI.​ Project 6: SECURITY - Intruder Sensor

#include <NewPing.h> // Call NewPing library


#include <Servo.h>
// Call Servo library
#define trigPin 12
#define echoPin 13
// Trig pin connected to Arduino 12
// Echo pin connected to Arduino 13
#define MAX_DISTANCE 500
NewPing sonar(trigPin, echoPin, MAX_DISTANCE); // Library setting
int greenLed = 3, redLed = 2; // Set green LED to pin 3, red to pin 2
int pos = 20;
Servo myservo;
void setup() {
Serial.begin (115200);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(greenLed, OUTPUT);
pinMode(redLed, OUTPUT);
myservo.attach(9); // Servo attached to pin 9
}
void loop() {
int duration, distance, pos = 0, i;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH); // Trig pin sends a ping
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

Leading Innovations, Transforming Lives, Building the Nation



Republic of the Philippines
BATANGAS STATE UNIVERSITY
The National Engineering University
Alangilan Campus
Golden Country Homes, Alangilan Batangas City, Batangas, Philippines 4200
Tel Nos.: (+63 43) 425-0139 local 2121 / 2221
E-mail Address: coe.alangilan@g.batstate-u.edu.ph | Website Address: http://www.batstate-u.edu.ph

College of Engineering - Department of Electronics Engineering

duration = pulseIn(echoPin, HIGH); // Echo receives the ping


distance = (duration / 2) / 29.1;
Serial.print(distance);
Serial.println(" cm");
// If sensor detects object within 15 cm
if (distance <= 15) {
digitalWrite(greenLed, LOW); // Turn off green LED
digitalWrite(redLed, HIGH); // Turn on red LED
myservo.write(180);
delay(450);
digitalWrite(redLed, LOW);
myservo.write(90);
delay(450);
digitalWrite(redLed, HIGH);
myservo.write(0);
delay(450);
digitalWrite(redLed, LOW);
myservo.write(90);
}
// Otherwise
else {
digitalWrite(redLed, LOW);
// Move servo arm 180 degrees
// Light the red LED
// Turn off red LED
digitalWrite(greenLed, HIGH); // Turn on green LED
myservo.write(90);
}
delay(450);
}

Leading Innovations, Transforming Lives, Building the Nation


You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy