IE-321L Instrumentation & Control (LAB)
IE-321L Instrumentation & Control (LAB)
1
Contents
Open Ended Lab ................................................................................................................................................ 3
Objectives: ......................................................................................................................................................... 3
Introduction: ....................................................................................................................................................... 3
Arduino: ......................................................................................................................................................... 3
Key Components:....................................................................................................................................... 3
Common Uses: ........................................................................................................................................... 3
Working Tools: ................................................................................................................................................... 4
Proteus 8 Professional: ................................................................................................................................... 4
Key Features of Proteus 8 Professional: ........................................................................................................ 4
Benefits of using Proteus 8 Professional: .................................................................................................. 4
Applications of Proteus 8 Professional: ..................................................................................................... 4
Apparatus In Application: .............................................................................................................................. 5
Arduino IDE: ................................................................................................................................................. 5
Working Procedure: ........................................................................................................................................... 6
Data & Observation: .......................................................................................................................................... 9
Arduino IDE Code: ...................................................................................................................................... 10
Results & Discussion: ...................................................................................................................................... 11
Conclusion: ...................................................................................................................................................... 11
2
Open Ended Lab
"Implementing LED On/Off Control in Binary (0 & 1)
Pattern Using Button Input with Arduino Uno R3."
Objectives:
The main objectives of this lab are:
To study the control of an LED's On/Off state using an Arduino microcontroller and button input.
To implement a binary (0 & 1) pattern for LED control.
To understand the interaction between digital input (button) and digital output (LED).
Introduction:
This experiment demonstrates the use of an Arduino microcontroller to control an LED using a button input,
following a binary (0 & 1) pattern. Binary patterns are fundamental in digital systems, representing the
simplest form of signal states—on (1) and off (0). In this experiment, a button serves as the digital input to
toggle the LED state, showcasing the basic functionality of a microcontroller's input-output (I/O) system. This
experiment serves as a foundation for understanding more complex digital systems involving user interaction
and real-time control.
Arduino:
Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's designed for
anyone interested in creating interactive objects or environments.
Key Components:
Hardware: Arduino boards are physical circuit boards containing a microcontroller, which is a
small computer on a chip. These boards have various inputs and outputs, allowing them to interact
with the world around them.
Software: The Arduino IDE (Integrated Development Environment) is a software program used
to write and upload code to the Arduino board. It uses a simplified version of C/C++ for
programming.
Common Uses:
Robotics: Building robots that can move, sense their environment, and interact with people.
Home automation: Controlling lights, appliances, and other devices in your home.
Internet of Things (IoT): Connecting everyday objects to the internet, allowing them to be
controlled remotely or monitored.
Art and design: Creating interactive art installations and other creative projects.
Education: Teaching electronics and programming concepts in schools and universities.
3
Working Tools:
Proteus 8 Professional:
Proteus 8 Professional is a powerful electronic design automation (EDA) software suite from Labcenter
Electronics. It's a comprehensive toolset used by engineers, educators, and hobbyists for designing, simulating,
and prototyping electronic circuits.
4
Industrial Design: Developing and manufacturing electronic products for a wide range of
industries.
Hobbyists: Designing and building electronic projects, such as robots, sensors, and other gadgets.
Apparatus In Application:
a. Arduino Uno R3 (virtual component in Proteus)
b. 36 LEDs (virtual component in Proteus)
c. 2 Buttons
d. DC in (5V) and ground
e. Connecting wires (virtual components)
Arduino IDE:
The Arduino Integrated Development Environment - or Arduino Software (IDE) - contains a text editor for
writing code, a message area, a text console, a toolbar with buttons for common functions and a series of
menus. It connects to the Arduino hardware to upload programs and communicate with them.
Arduino Ide has the following main components:
Sketchbook
Serial monitor
Libraries
Compilers
Uploading/Programming
Board Supports
Tools
5
Figure 2,Arduino IDE.
Working Procedure:
Software Setup:
o Open Proteus 8 Professional and create a new project.
o From the component library, select and place the following components on the workspace:
Arduino Uno
LEDs
Buttons
Ground (GND) and VCC (if required for the simulation setup).
6
Circuit Design in Proteus:
o Connect Three LEDs in parallel so that each have common Ground & VCC.
o Connect the anode of the LEDs to one end to a digital output pin (Pin 2) and the cathode to the
ground (GND) pin on the Arduino.
o Do the same for rest of LEDS (36 LEDs, 6 Connection (Pin 2 – 7)).
o Connect one terminal of the push button to the 5V pin on the Arduino and the other terminal to a
digital input pin (Pin 10). Do the same for second button but select Pin 11.
o Verify all connections and ensure the circuit design is error-free.
Code Implementation:
o Open Arduino Ide and Start New Sketch.
o Write a code by including the basic Arduino Library, then declaring the pins for output and input.
o Then in setup write code for testing and initiating the program.
o And in the loop write the code as follows,
Declare Input Pin 10 to be button 1 and Pin 11 to be button 2.
then write,
If button 1 is pressed so, power output to LED Pin output 2 and 3
If button 2 is pressed so, power output to LED Pin output 2 – 7
Else all output is 0.
Delay 250 milliseconds.
o Save and compile the code to Proteus using the Arduino IDE.
7
Figure 5,Code In Arduino IDE
8
Simulation:
o Run the simulation in Proteus.
o Press the Buttons and observe changes in the LEDs in real-time.
9
Figure 9, Button 2 is pressed.
10
digitalWrite(ledPins[1], LOW); // Turn off LED on pin 4}
// If button 2 (digital pin 2) is pressed
if (button2State == HIGH) { for (int i = 0; i < numLEDs; i++) {digitalWrite(ledPins[i], HIGH);
} } else {for (int i = 0; i < numLEDs; i++) {digitalWrite(ledPins[i], LOW); // Turn all LEDs off
} } delay(250); // Short delay for stability}
Button 1 Control:
o When button 1 (connected to digital pin 10) is pressed (HIGH), it will turn on the first two LEDs
(connected to pins 2 and 3).
o When button 1 is released (LOW), these two LEDs will turn off.
Button 2 Control:
o When button 2 (connected to digital pin 11) is pressed (HIGH), all six LEDs will turn on.
o When button 2 is released (LOW), all six LEDs will turn off.
Detailed View:
Initialization:
o The code begins by defining the number of LEDs and their respective pins.
o It also defines the pins for the two buttons.
o In the setup() function, the LED pins are initialized as outputs, and a brief test sequence is
performed to verify their functionality.
o The button pins are initialized as inputs.
Button Handling:
o In the loop() function, the code continuously reads the states of both buttons.
o If button 1 is pressed, it turns on the first two LEDs.
o If button 2 is pressed, it turns on all six LEDs.
o When either button is released, the corresponding LEDs are turned off.
Delay:
o A short delay (250 milliseconds) is introduced at the end of the loop() function to provide some
stability and prevent rapid switching of the LED states.
Conclusion:
So, it is concluded that, This Arduino code demonstrates basic button-controlled LED illumination,
showcasing fundamental digital I/O principles. Two buttons independently control two lighting scenarios: the
first button activates two LEDs, while the second illuminates all six. This experiment provided valuable hands-
on experience with the Arduino platform, including pin initialization, digital input/output operations, and basic
coding. The acquired skills are applicable to various projects, such as home automation, robotics, and
interactive installations, laying a strong foundation for further exploration in the field of electronics and
embedded systems.
11