0% found this document useful (0 votes)
18 views4 pages

Button Switches

This laboratory exercise introduces students to digital input and output using an Arduino board, push-button switches, and LEDs, emphasizing the importance of pull-down and pull-up resistors for stable input signals. Participants learn to read digital signals from buttons to control an LED, laying the groundwork for more complex interactive systems. Despite challenges in integrating additional functionalities, the exercise provides valuable insights into Arduino programming and circuit design.

Uploaded by

Lorenzo Bande
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)
18 views4 pages

Button Switches

This laboratory exercise introduces students to digital input and output using an Arduino board, push-button switches, and LEDs, emphasizing the importance of pull-down and pull-up resistors for stable input signals. Participants learn to read digital signals from buttons to control an LED, laying the groundwork for more complex interactive systems. Despite challenges in integrating additional functionalities, the exercise provides valuable insights into Arduino programming and circuit design.

Uploaded by

Lorenzo Bande
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/ 4

Laboratory Exercise #02 – Push Button Switches

and Digital Inputs


Mark Lorenzo B. Camarines
Bachelor of Science in Mechanical Engineering
Visayas State University
Baybay City, Philippines
[email protected]

Abstract—Using an Arduino board, some push-button This exercise also highlights the requirement of resistors in
switches, and an LED, this laboratory exercise teaches students digital circuits, specifically the utilization of pull-down or
the principles of digital input and output. Incorporating pull-down pull-up resistors to keep a defined condition for the input pins
or pull-up resistors to stabilize input signals, students will learn while the push button is not pressed[4].
how to read digital signals from push buttons and trigger an LED.
This exercise will teach you the foundations of creating circuits on Beyond its educational utility, this exercise establishes the
a breadboard, as well as how to create and upload code to an groundwork for more complicated applications needing user
Arduino, and how the two function together. While the activity is input and output control. For instance, the skills acquired here
extendable with extra components, it focusses on essential skills, may be used to create interactive systems such as control
neglecting advanced topics such as analog inputs, PWM, or panels, gaming interfaces, or IoT devices. By studying the
debouncing techniques. For those just starting out with Arduino, principles of digital input and output, participants will be
this is an excellent method to learn the fundamentals of circuit better prepared to address complex challenges in electronics
design and programming, which will pave the way for more and programming.
complicated projects that demand input and output control from
the user. In summary, this laboratory exercise gives as an
introduction to the essential notions of digital input and output
Keywords—Basic Arduino Project, Arduino Project for using Arduino. It gives a practical, hands-on approach to
Starters, Push Buttons, Digital Inputs, Digital Outputs, Digital learning how to interface push buttons and LEDs with a
Outputs and Inputs, Toggle Buttons, Arduino Project, Arduino microcontroller, highlighting the necessity of suitable circuit
Code, Basic Arduino Sketch, Arduino for Kids, Arduino design and programming. Through this project, participants
will obtain a broader understanding of how microcontrollers
I. INTRODUCTION interact with the physical world, establishing the framework
In the realm of electronics and embedded systems, for further inquiry in the field of embedded systems and
microcontrollers have become key tools for prototyping and interactive electronics.
building interactive systems. Among these, the Arduino
platform stands out as a versatile and accessible solution for II. OBJECTIVES
beginners and professionals alike. Arduino boards are often A. Objectives
used in educational settings to teach fundamental ideas of
programming, electronics, and hardware-software • Learn how buttons work.
interaction[1]. One of the most basic yet vital competencies in • Input and Output modes.
working with microcontrollers is understanding how to handle
digital inputs and outputs, which comprise the backbone of • Control one LED using two buttons.
uncountable applications, from simple LED control to
sophisticated user interfaces. B. Scope and Limitation
This laboratory is designed to teach students on the
This laboratory exercise, titled Push Button Switches and fundamentals of digital input by making use of push-button
Digital Inputs, focuses on examining the link between digital switches and an Arduino board to operate an LED. Through
input devices, such as push buttons, and digital output devices, the exercise, students will enhance their understanding of
such as LEDs, using an Arduino board. Push buttons are one interpreting digital signals from buttons and regulating an
of the simplest methods of user input, allowing individuals to LED. Projects like interactive systems, control panels, and
interact with a system by delivering binary signals (HIGH or Internet of Things (IoT) devices that demand more
LOW)[2]. When combined with an Arduino, these signals complicated user input may be built atop this exercise.
may be exploited to control outputs like LEDs, enabling the
development of interactive systems. However, working with While the exercise allows for scalability with additional
digital inputs involves an understanding of fundamental buttons, LEDs, and resistors, it stays constrained to core
concepts such as pull-up and pull-down resistors, which give digital input and output notions. Advanced features such as
stable and reliable signal readings by reducing floating analog inputs, PWM, or debouncing procedures for push
voltages[3]. buttons are not described. The Arduino's restricting number of
digital pins may still impede the expansion of the circuit, and
The principal goal of this activity is to educate participants bad wiring or breadboard connections can lead to
with the technique of reading digital inputs from push buttons communication issues. Additionally, the offered code is
and employing them to run an LED. By making a basic circuit simple and does not address error management, multitasking,
on a breadboard and generating a simple Arduino program, or sophisticated programming approaches.
participants will acquire hands-on experience in connecting
components, writing code, and diagnosing typical problems.

MEng 125n – Basic Electronics


2nd Semester SY 2024-2025
Instructor: Engr. Philip Caesar L. Ebit
This exercise is targeted for basic learning and does not C. Code
touch more advanced Arduino features like interrupts, pinMode() – selects a designated pin and either designates
communication protocols, or sensor integration. it as an output or an input.
III. METHODOLOGY INPUT – switches the digital pin’s mode into input.
OUTPUT – switches the digital pin’s mode into output.
1. Set a positive (+) and negative (-) terminals on the
breadboard by connecting the positive side to the digitalWrite() – allows the to send 0V-5V at the output
Arduino 5V pin and the negative side to the Arduino pin.
GND pin. See Figure 1 for guidance. HIGH – means turn on or apply voltage.
2. Connect the LED and 330 Ohm resistor on a series LOW – means turn off or don’t apply voltage.
with their positive side connecting to the Arduino
digital 13 pin (D13)[4]. int ledPin = 3;
3. Connect 2 push buttons on the breadboard. int buttonLeftPin = 9;
4. In series with a button, connect a 10k ohm from the int buttonRightPin = 8;
positive (+) terminal of the breadboard.
5. Before completing the circuit on the button side, void setup() {
make sure to connect the wires adjacent to the side of pinMode(ledPin, OUTPUT);
where the resistor is connected. pinMode(buttonLeftPin, INPUT);
6. Next connect a wire between the resistor and the pinMode(buttonRightPin, INPUT);
button to the digital 9 pin (D9) on the Arduino board.
7. Repeat 4 and 5, and same as 6 but instead connected }
to digital 8 pin (D8).
8. Sketch a code and upload unto the Arduino board. void loop() {
A. Materials if (digitalRead(buttonLeftPin) ==
LOW)
• 1 – Arduino UNO R3 digitalWrite(ledPin, HIGH);
• 1 – USB Cable (USB-A to USB-B)
if (digitalRead(buttonRightPin) ==
• 1 - Breadboard LOW)
• 1 – 330 Ohms Resistor digitalWrite(ledPin, LOW);

• 2 – 10k Ohms Resistor }


• 1 – LED
// The code should be similar to Figure 2 in the Arduino
• 2 – Push Button IDE software.
• Connecting Wires
• Computer with Arduino IDE software
B. Circuit Diagram

Figure 2

IV. RESULTS AND DISCUSSIONS


The laboratory exercise successfully exhibited the
Figure 1 utilization of push button switches as digital inputs to control
LEDs using an Arduino board. Initially, the circuit was created
utilizing two push buttons and one LED, with one of the
buttons turning the LED on and the other turning it off. The
circuit functioned as expected, with the LED responding

MEng 125n – Basic Electronics


2nd Semester SY 2024-2025
Instructor: Engr. Philip Caesar L. Ebit
perfectly to the button inputs. To widen the exercise, more setup, with two push buttons and one LED, functioned as
push buttons and LEDs were incorporated into the circuit. predicted, exhibiting the potential to read digital inputs and
This allowed for more intricate interactions, such as control outputs satisfactorily. Expanding the circuit with
controlling many LEDs independently or combining additional buttons and LEDs further showed the scalability of
combinations of buttons to trigger particular LED patterns. the Arduino platform, but it also brought complexity in circuit
However, an attempt was made to merge the previous design and programming. The endeavor to combine the
laboratory activity, which required blinking an LED, into this previous flashing LED exercise revealed the constraints of
system. Unfortunately, this integration was unsuccessful. The blending different functionalities within a single program,
flashing LED code, when matched with the new push button particularly when dealing with time and input/output
control logic, resulted in unpredictable behavior. The button interactions. Despite the difficulty to accomplish flawless
to turn on the LED was needed to be held push to integration, the exercise revealed valuable insights on
flash consistently[5]. This failure showed the limitations of debugging, program structure, and the restrictions of
merging several functionalities inside a single Arduino blocking techniques like delay().
program, especially when dealing with time and input/output
interactions. Overall, the exercise emphasized essential ideas in
Arduino programming and circuit design, such as the
The initial success of the experiment proved the employment of pull-down resistors, pin management, and the
fundamental ideas of digital input and output using Arduino. requirement of modular coding strategies. It also underlined
The use of pull-down resistors offered consistent signal the requirement for thorough planning and testing while
readings from the push buttons, while the 330Ω resistor extending huge projects or integrating distinct capabilities.
shielded the LED from excessive current. Expanding the
These abilities are important for transitioning to more
circuit with more buttons and LEDs highlighted the scalability
difficult projects in embedded systems and interactive
of the Arduino platform, as well as the requirement of precise
pin management and circuit design. individual component electronics.
brought complexity to the circuit, necessitating careful design Structure the code into discrete functions or states for
to minimize conflicts in pin assignments and insure reliable specific purposes. This strategy promotes readability,
functioning. simplifies debugging, and makes the program more scalable.
The failure to include the blinking LED functionality into When integrating new functions, test each component
the broader circuit revealed various crucial aspects. First, the independently before combining them. This helps isolate
issue likely occurred from the employment of the delay() issues and ensures that each part of the program performs as
function in the blinking LED code. The delay() function expected. Plan the circuit layout carefully to avoid conflicts
pauses the entire program, preventing the Arduino from in pin assignments and ensure accurate current distribution.
reading button inputs during the wait time. This limitation Use a schematic design to examine connections and uncover
underscores the importance of using non-blocking any issues before construction. For more complicated
programming methods, such as millis(), to manage time applications, consider learning about interrupts, state
without disturbing other operations. Second, the integration machines, and communication protocols. These tactics may
effort revealed the requirement for modular programming boost the usability and efficiency of Arduino-based solutions.
methodologies[6]. By breaking the flashing logic and button Maintain clear documentation of the circuit design and code.
input logic into different functions or states, the program may Regularly analyze and rewrite the code to increase its
have been more manageable and easier to debug. structure and efficiency.
Despite the failure, the exercise gave crucial lessons in
troubleshooting and problem-solving. It underlined the ACKNOWLEDGMENT
necessity of understanding how distinct components of a To my dear mother, Angelita B. Camarines, who always
program interact and how hardware restraints, such as the fully supported me, I would like to express my deepest
number of accessible pins or current constraints, may impact gratitude to her despite the problems faced during my
the design. Moving forward, resolving these problems will academics without question and to my lovely pair, Jemiah B.
require altering the code to eliminate blocking routines and Sabares, for always motivating me, keeping me from falling
adopting a more rigorous approach to program design. off and succumbing to pressure. I also want to reach my thanks
to my dear friends and regular-mates for continuing the
In conclusion, the exercise successfully presented the key
support with each other. And to our Basic Electronics
notions of digital input and output employing push buttons
instructor, Engr. Philip Caesar Ebit for always guiding us and
and LEDs. While the integration of the flashing LED function
teaching us not only in theory but also with hands-on
was unsuccessful, it offered an opportunity to uncover areas
experience-based learning.
for development and enhance understanding of Arduino
programming and circuit design. These insights will be useful REFERENCES
for future endeavors, particularly those needing more
[1] “What is Arduino? | Arduino.” Accessed: Feb. 04, 2025. [Online].
sophisticated relationships between various inputs and results. Available: https://www.arduino.cc/en/Guide/Introduction
[2] “How to Wire and Program a Button | Arduino Documentation.”
Accessed: Feb. 04, 2025. [Online]. Available:
https://docs.arduino.cc/built-in-examples/digital/Button/
V. CONCLUSIONS AND RECOMMENDATIONS [3] “Software | Arduino.” Accessed: Feb. 04, 2025. [Online]. Available:
This laboratory exercise efficiently presented the https://www.arduino.cc/en/software
fundamental ideas of digital input and output utilizing an [4] “Digital Pins | Arduino Documentation.” Accessed: Feb. 04, 2025.
[Online]. Available:
Arduino board, push button switches, and LEDs. The initial https://docs.arduino.cc/learn/microcontrollers/digital-pins/

MEng 125n – Basic Electronics


2nd Semester SY 2024-2025
Instructor: Engr. Philip Caesar L. Ebit
[5] “Blink | Arduino Documentation.” Accessed: Feb. 04, 2025. [Online].
Available: https://docs.arduino.cc/built-in-examples/basics/Blink/
[6] “Blink Without Delay | Arduino Documentation.” Accessed: Feb. 04,
2025. [Online]. Available: https://docs.arduino.cc/built-in-
examples/digital/BlinkWithoutDelay/

MEng 125n – Basic Electronics


2nd Semester SY 2024-2025
Instructor: Engr. Philip Caesar L. Ebit

You might also like