0% found this document useful (0 votes)
54 views3 pages

Micro Lab Act 2

This activity demonstrates digital input and output operations using an Arduino microcontroller. Students will assemble a circuit with switches, LEDs, and resistors, then program the Arduino to read the switch states and control the LEDs accordingly. The program uses functions like pinMode(), digitalRead(), and digitalWrite() to set pin directions, read switch values, and output to the LEDs based on different switch combinations. Upon completion, students will be able to write code to interface with digital sensors and display output.

Uploaded by

RHINROME
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views3 pages

Micro Lab Act 2

This activity demonstrates digital input and output operations using an Arduino microcontroller. Students will assemble a circuit with switches, LEDs, and resistors, then program the Arduino to read the switch states and control the LEDs accordingly. The program uses functions like pinMode(), digitalRead(), and digitalWrite() to set pin directions, read switch values, and output to the LEDs based on different switch combinations. Upon completion, students will be able to write code to interface with digital sensors and display output.

Uploaded by

RHINROME
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Activity

Digital I/O Operations


Program:
Course Title: Microprocessor System

1. Objective:
This activity aims to demonstrate the different digital I/O operations in a microcontroller based
system. The activity will cover assembly of a switch-driven circuit, programming digital input functions,
using conditional statements, and outputting digital results.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:

-Write a code for a microprocessor based system that implements digital input devices.

-Design a circuit that accepts digital transducer data, process and then display digital output.
3. Discussion:
The digital inputs and outputs (digital I/O) on the Arduino are what allow you to connect the Arduino
sensors, actuators, and other ICs. Learning how to use them will allow you to use the Arduino to do some
really useful things, such as reading switch inputs, lighting indicators, and controlling relay outputs.
As for today’s activity, we used 4-input dip switch to control the output or LED. This will be done
through programming functions such as: pinMode(), digitalRead() and digitalWrite(). These functions
determine the pin and mode (input or output), reads a value from the digital I/O pin you want to read and
writes the digital value of a pin (I\O or High\Low).

4. Resources Needed:
1 Arduino
Arduino (Software)
1 USB cable
2 LED
2 100 ohm resistor
2 1000 ohm resistor
1 Set wires
1 Breadboard
1 4-input Dip Switch

5. Procedures:
Steps in running the experiment:
1. Connect the arduino to a computer through USB cable.
2. Make a connection as shown in Figure 1.
Figure 1

3. Make a command through Arduino Software to control the LED using 4-input dip switch.
4. Run the Program.

Code:
int x = 0;
int y = 0;
void setup()
{
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{
x = digitalRead(3);
y = digitalRead(4);
Serial.println(x);
Serial.println(y);
delay(100);

if( x == 0 and y == 0)
{
digitalWrite(13, LOW);
digitalWrite(12, LOW);
}
else if ( x== 0 and y == 1)
{
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
}
else if (x == 1 and y == 0)
{
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
}
else
{
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
}
}

6. Results

7. Observations:

8. Conclusions:

9. References:

10. Assessment (Rubric for Laboratory Performance):

You might also like