0% found this document useful (0 votes)
9 views

computer-architecture

The document is a lab manual for a Computer Architecture course at the Karachi Institute of Economics and Technology, compiled by Razia Qamar. It includes a detailed index of labs covering various topics such as ARDUINO, interfacing sensors, and controlling devices, with objectives and instructions for each lab. The manual aims to provide hands-on experience with computer architecture and development boards.

Uploaded by

Okorie Chinedu P
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)
9 views

computer-architecture

The document is a lab manual for a Computer Architecture course at the Karachi Institute of Economics and Technology, compiled by Razia Qamar. It includes a detailed index of labs covering various topics such as ARDUINO, interfacing sensors, and controlling devices, with objectives and instructions for each lab. The manual aims to provide hands-on experience with computer architecture and development boards.

Uploaded by

Okorie Chinedu P
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/ 68

lOMoARcPSD|12193041

CA v2 - Summary Computer Architecture

Advanced Computer Architecture (Karachi Institute of Economics and Technology)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Okorie Promise (okoriechinedup@gmail.com)
lOMoARcPSD|12193041

Karachi Institute of Economics & Technology


College of Computing & Information Sciences

Computer
Architecture
Lab Manual

Compiled by: Razia Qamar

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Karachi Institute of Economics & Technology


College of Computing & Information Sciences

Computer
Architecture
Lab Manual
Compiled by: Razia Qamar

CID: Semester: _
StudentID:

StudentName:

InstructorName:

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

KARACHI INSTITUTE OF ECONOMICS &


TECHNOLOGY
College of Computing & Information
Sciences
Computer Architecture Lab Manual

INDEX
Lab
Date Particulars Instructor Marks
Signature
Lab 1: Introduction to Computer Architecture /
Development Boards

Lab 2: Introduction to ARDUINO Board - LED, Button

Lab 3: Interfacing 16x2 LCD with ARDUINO UNO

Lab 4: Introduction to Analog Channel & Using


Temperature Sensor LM35
Lab 5: Introduction to Analog Channel & Using
Temperature Sensor LM35

Lab 6: Controlling LED with a Remote Control using IR


receiver
Lab 7: Make a real time clock using RTC DS3231 MODULE

Lab 8: Detecting Motion using PIR MOTION SENSOR

Lab 9: Keypad Interfacing with ARDUINO Uno

Lab 10: To interface DC-MOTORS with ARDUINO UNO

Lab 11: Interfacing ARDUINO with relay to control high


voltage devices

Lab 12: Interfacing ARDUINO with ESP8266

Lab 13: Introduction to Bluetooth Serial Communication

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Table of Contents
LAB: 01 ................................................................................................................................................... 1
Introduction to Computer Architecture / Development Boards........................................................... 1
OBJECTIVES: Introducing Introduction to Computer Architecture /Development Boards ............... 1
Computer Architecture ........................................................................................................................ 1
Microcontroller ................................................................................................................................... 1
Previous Microcontrollers Disadvantages ......................................................................................... 1
Development Boards ......................................................................................................................... 1
Beagle Board ..................................................................................................................................... 2
Raspberry PI ...................................................................................................................................... 2
Features ............................................................................................................................................. 2
ARDUINO .......................................................................................................................................... 3
The best way to describe an ARDUINO is with a few examples ...................................................... 3
Why ARDUINO?......................................................................................................................... 3
ARDUINO Uno ........................................................................................................................... 4
Specs ............................................................................................................................................. 4
ARDUINO IDE (Web+ Desktop) ................................................................................................ 4
Libraries ......................................................................................................................................... 4
Sensors .......................................................................................................................................... 5
Next Lab Materials ......................................................................................................................... 5
Purchase if you want (Not Necessary) .......................................................................................... 5
LAB: 02 ...................................................................................................................................................... 6
Introduction to ARDUINO Board -LED, Button ............................................................................... 6
OBJECTIVES: Introducing ARDUINO board with its syntax and setup ................................... 6
Sketch ......................................................................................................................................... 7
Some Basic Circuit Components ............................................................................................... 7
Resistors..................................................................................................................................... 7
Resistor Reading ........................................................................................................................ 7
Breadboard ................................................................................................................................. 8
LED ............................................................................................................................................. 8
Get an ARDUINO board and USB cable ................................................................................... 8
Download the ARDUINO environment....................................................................................... 8
Install the drivers ........................................................................................................................ 9
Select your board ...................................................................................................................... 9
Select your serial port................................................................................................................. 9
Uploading the program ............................................................................................................. 10

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Blink Example........................................................................................................................... 10
Hardware .................................................................................................................................. 10
CODE ....................................................................................................................................... 10
FADE Example ......................................................................................................................... 10
Hardware .................................................................................................................................. 10
CONCEPT ................................................................................................................................ 11
Circuit Diagram ......................................................................................................................... 12
CODE ....................................................................................................................................... 12
CONCEPT ................................................................................................................................ 12
HIGHIMPEDENCE................................................................................................................... 12
Pull Up / Pull Down Resistors .................................................................................................. 13
Button Example ........................................................................................................................ 13
Hardware .................................................................................................................................. 13
BUTTON Circuit Diagram ......................................................................................................... 13
CODE ....................................................................................................................................... 13
INPUT_PULL UP Example ...................................................................................................... 13
Hardware .................................................................................................................................. 13
Circuit Diagram ......................................................................................................................... 13
CODE ........................................................................................................................................... 13
LAB: 03 ................................................................................................................................................... 14
Interfacing 16x2 LCD with ARDUINOUNO...................................................................................... 15
OBJECTIVES: the main object is to interfacing 16x2 LCD with ARDUINO to display data ... 15
Hardware .................................................................................................................................. 15
Instruments ............................................................................................................................... 15
Basic Theory............................................................................................................................. 16
Experiment ............................................................................................................................... 16
Circuit ....................................................................................................................................... 16
Schematic ............................................................................................................................................... 17
Example Code Of HelloWorld .................................................................................................. 10
SCROLLLCDTEXT................................................................................................................... 18
Scroll Display Left () and scroll Display Right()methods .......................................................... 19
CIRCUITDIAGRAM .................................................................................................................. 19
CODE ....................................................................................................................................... 19
LAB: 04 ................................................................................................................................................. 20
Introduction to Analog Channel &Using Temperature SensorLM35 ............................................... 20
HARDWARE ............................................................................................................................................ 21
Instruments ............................................................................................................................................ 21
Code ......................................................................................................................................... 22
Downloaded by Okorie Promise (okoriechinedup@gmail.com)
lOMoARcPSD|12193041

LAB: 05 .................................................................................................................................................... 23
INTERFACING SONAR (RANGE) SENSORWITHARDUINO........................................................ 23
OBJECTIVES: How to measure the distance using ultrasonic sensor .................................... 23
HARDWARE............................................................................................................................. 23
Instruments ............................................................................................................................... 24
Wire connecting direct as following .......................................................................................... 24
Difference between 3 Pin And 4 Pin Ultrasonic Sensor .......................................................... 24
EXAMPLECODE(4-PIN) .......................................................................................................... 25
3-PINCONNECTION ................................................................................................................ 26
EXAMPLECODE(3-PIN) .......................................................................................................... 27
LAB: 06 ..................................................................................................................................................... 29
Controlling LED with a Remote Control using IRreceiver ............................................................... 29
OBJECTIVES:ControllingLED(Anydevice)withaRemoteControlusingIRreceiver ..................... 29
HARDWARE............................................................................................................................. 29
CIRCUITDIAGRAM .................................................................................................................. 30
CIRCUITDIAGRAM ............................................................................................................................ 31
ARDUINO Code ....................................................................................................................... 32
LAB: 07 ..................................................................................................................................................... 32
Make a REAL TIME CLOCK USING RTC DS3231MODULE......................................................... 33
OBJECTIVES:Makeareal-timeclockusingrtcds3231moduleandshowtimeon16*2LCD .................... 33
HARDWARE............................................................................................................................. 33
Software ................................................................................................................................... 33
Overview ................................................................................................................................... 33
Working Explanation ................................................................................................................ 34
CIRCUITDIAGRAM .................................................................................................................. 35
CONNECTIONS ....................................................................................................................... 35
LCD Connections ..................................................................................................................... 36
Setting the Time in the RTC ..................................................................................................... 37
Uploading the Time Sketch ...................................................................................................... 38
LAB: 08 ................................................................................................................................................ 39
Detecting Motion using PIRMOTIONSENSOR ............................................................................... 39
OBJECTIVES: Detecting Motion using PIR MOTION SENSOR and indicating motion by
lighting up Led……………………………………………………………………………………….39
HARDWARE............................................................................................................................. 39
Instruments ............................................................................................................................... 39
Working Explanation ................................................................................................................ 40
PINOUT .................................................................................................................................... 40
ARDUINO Code ....................................................................................................................... 40
Downloaded by Okorie Promise (okoriechinedup@gmail.com)
lOMoARcPSD|12193041

LAB: 09 ................................................................................................................................................. 41
Keypad Interfacing with ARDUINO Uno .......................................................................................... 41
OBJECTIVES: Keypad Interfacing with ARDUINO Uno and showing characters on LCD screen 41
HARDWARE............................................................................................................................. 41
Instruments ............................................................................................................................... 41
Working Explanation ................................................................................................................ 42
CONNECTIONS ....................................................................................................................... 42
CIRCUITDIAGRAM .................................................................................................................. 43
LAB: 10 ................................................................................................................................................. 44
TO INTERFACE DC-MOTORS WITHARDUINOUNO .................................................................... 44
OBJECTIVES: To demonstrate how to interface three types of motor i.e. DC, Stepper and
Servo motor…………………………………………………………………………………………..44
HARDWARE............................................................................................................................. 45
Instruments ............................................................................................................................... 45
BASICTHEORY........................................................................................................................ 46
DC Motor .................................................................................................................................. 46
Stepper Motor ........................................................................................................................... 46
Servo Motor .............................................................................................................................. 47
EXPLORATION ........................................................................................................................ 47
DC Motor .................................................................................................................................. 48
Commonly use for small application Dual Hbridge .................................................................. 48
Stepper Motor ........................................................................................................................... 49
WORKING PRINCIPLE OFSERVOMOTOR ........................................................................... 49
Sample Code: To control single DC motor using H-bridge L298d .......................................... 49
Sample Code: For Stepper motorwithULN2003/ULN2008 ...................................................... 49
Sample Code: For Servo Motor ............................................................................................... 49
LAB: 11 .................................................................................................................................................. 50
INTERFACING ARDUINO WITH RELAY TO CONTROL HIGHVOLTAGEDEVICES ................... 50
OBJECTIVES: Learn how to Control High Voltage Devices using the ARDUINO Board ...... 50
HARDWARE............................................................................................................................. 50
Software ................................................................................................................................... 50
Introduction ............................................................................................................................... 51
High Voltage Warning .............................................................................................................. 51
Relay Module............................................................................................................................ 51
What is NO NC and COM in relay? ......................................................................................... 52
Circuit Diagram ......................................................................................................................... 52
Code ......................................................................................................................................... 52

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

LAB: 12 .................................................................................................................................................... 53
INTERFACING ARDUINOWITHESP8266 .................................................................................. 53
OBJECTIVES: Programming ESP8266 ESP-01with ARDUINO ............................................ 53
HARDWARE............................................................................................................................. 53
Introduction ............................................................................................................................... 54
ARDUINO Setup ...................................................................................................................... 54
ESP8266Modes ....................................................................................................................... 55
InstallingESP8266Platform ...................................................................................................... 56
References ............................................................................................................................... 57
LAB: 13 .................................................................................................................................................... 58
Introduction to Bluetooth Serial Communication ............................................................................. 58

OBJECTIVES: The main objective of the lab is to understand how the communication system
works and discus serial and parallel communication 58
HARDWARE............................................................................................................................. 58
Instruments ............................................................................................................................... 58
BASICTHEORY........................................................................................................................ 58
USART ..................................................................................................................................... 59
UART ........................................................................................................................................ 59
Data Transmission ................................................................................................................... 59
Standard BAUD Rates ............................................................................................................. 59

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-1
Course Title: Computer Architecture Introduction to Computer Architecture

LAB: 01
Introduction to Computer Architecture / Development Boards

OBJECTIVES: Introducing Introduction to Computer Architecture / Development Boards

Computer Architecture
Computer architecture is a specification detailing how a set of software and hardware technology
standards interact to form a computer system or platform. In short, computer architecture refers to how a
computer system is designed and what technologies it is compatible with.

Microcontroller
A microcontroller (MCU) is a small computer on a single integrated circuit.
Microcontrollers are used in automatically controlled products and devices, such as automobile engine control
systems, implantable medical devices, remote controls, office machines, appliances, power tools, toys and
other embedded systems. By reducing the size and cost compared to a design that uses a separate
microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control
even more devices andprocesses.

Examples: Atmel AVR (8-bit), AVR32 (32-bit)

Previous Microcontrollers Disadvantages


• Expensive toimplement
• Expensive hardware as compares toARDUINO

Development Boards
Intel Edison

Intel Edison is a high-performance, dual-core CPU with a single


core micro-controller that can support complex data collection. It
has an integrated Wi-Fi, Bluetooth® 4.0 support, 1GB DDR and
4GB flash memory. Edison comes with two breakout boards – one
that’s compatible with ARDUINO and the other board designed to
be a smaller in size for easy prototyping.

College of Computing & Information


Sciences
Downloaded by Okorie Promise (okoriechinedup@gmail.com) 1
lOMoARcPSD|12193041

Lab-1
Course Title: Computer Architecture Introduction to Computer Architecture

The ARDUINO breakout board has 20 digital input/output pins, including four pins as PWM outputs,
Six analog inputs, one UART (Rx/Tx), and one I2C pin. Edison runs on a distribution of embedded Linux called
Yocto. Certified by Microsoft, AWS, and IBM for cloud connectivity.

Beagle Board

The Beagle Bone Black is one of the industry’s favorite development platforms.
With 512MB of RAM, 4GB of onboard flash, a Cortex A8 processor and tons of
hardware support, The Beagle Bone Black Industrial takes it a step further by
adding industrial temperature capabilities, meaning this board will run at
temperatures anywhere from -40 degrees Celsius all the way up to blistering +85
degreesCelsius

Raspberry PI

Raspberry Pi is the most popular platform used by many hobbyists and hackers. Even non-technical users
depend on it for configuring their digital media systems and surveillance cameras. The recently launched
Raspberry Pi 3 included built-in WiFi and Bluetooth. Based on a Broadcom BCM2837 SoC with a 1.2 GHz
64-bit quad-core ARM Cortex-A53 processor and 1GB RAM. The
Raspberry Pi 3 is equipped with 2.4 GHz WiFi 802.11n and
Bluetooth 4.1 in addition to the 10/100 Ethernet port. The HDMI port
makes it further easy to hook up A/V sources.

Raspberry Pi runs on a customized Debian Linux called Raspbian,


which provides an excellent user experience. For developers and
hackers, it offers a powerful environment to install a variety of
packages including Node.js, the LAMP stack, Java, Python and much
more. With four USB ports and 40 GPIO pins, you can connect many peripherals and accessories to the Pi.
There are third party breakout boards to connect various ARDUINO shields to the Pi. At a price of 3500rs.

Features
• Quad Core 1.2GHz Broadcom BCM2837 64bitCPU
• 1GBRAM
• BCM43438 WiFi and Bluetooth Low Energy (BLE) onboard
• 40-pin ExtendedGPIO
• 4x USB 2ports
• 4 Pole stereo output and composite videoport
• Full sizeHDMI
• CSI camera port for connecting a Raspberry Picamera
• DSI display port for connecting a Raspberry Pi touchscreendisplay
• Micro SD port for loading your operating system and storingdata
• Upgraded switched Micro USB power source up to2.5
College of Computing & Information 2
Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-1
Course Title: Computer Architecture Introduction to Computer Architecture

ARDUINO
ARDUINO is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and
software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or
environments.
It is based on the ATmega328P which has 14 digital input/output pins and six analog inputs. Though it
comes with just 32 KB of Flash memory, it can accommodate code that deals with complex logic and
operations.
https://www.ARDUINO.cc/
ARDUINO can sense the environment by receiving input from a variety of sensors and can affect its
surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is
programmed using the ARDUINO programming language (based on Wiring) and the ARDUINO
development environment (based on Processing). ARDUINO projects can be stand-alone or they can
communicate with software on running on acomputer.

For learning basics of electronics and IOT

The best way to describe an ARDUINO is with a few examples.


• Want to have a coffee pot tweet when the coffee is ready?ARDUINO.
• Want to have t-shirts glow?ARDUINO.
• Howaboutgettinganalertonyourphonewhenthere’sphysicalmailinyourmailbox?ARDUINO.
• Wanttomakeyourownheartratemonitorforcyclingthatlogstoamemorycard?ARDUINO.
• Want to make a robot that draws on the ground, or rides around in the snow?ARDUINO.

Why ARDUINO?
• Cheaper
• Less PowerConsumption
• Small Hardware
• Easy ChipIntegration

ARDUINO Nano

ARDUINO Meg

College of Computing & Information 3


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-1
Course Title: Computer Architecture Introduction to Computer Architecture

ARDUINORoboto UNO

ARDUINO Uno

Specs

• Runs at16mhz
• 32 KB ProgrammingMemory
• 2KB ~ 2048Bytes
• 1KBEPROM
• Built in Bootloader

ARDUINO IDE (Web + Desktop)

The IDE works on a Mac, Win, and Linux, and it’s completely open source. The IDE is how you program
the ARDUINO — it’s based on Processing (a graphics programming language and development system
popular with artists and designers)
It’s based on a strong and well-supported backend, the open source GCC tool chain, and wrapped in Java

Libraries
There are tons of object-wrapped libraries to do complex things, like writing to SD cards, LCD screens,
parsing GPS.Like UART (Universal asynchronous receiver/transmitter) set up code.
Serial begin (9600)

College of Computing & Information 4


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-1
Course Title: Computer Architecture Introduction to Computer Architecture

Sensors
The ARDUINO really took off because it has analog-to-digital input, in other words, you can take in sensor
data like light, temperature, sound, or whatever using the low-cost sensors already on the market and get
that into the ARDUINO easily. It also has ready-to-go SPI and I2C for digital sensors. This covers 99% of
sensors on themarket.
Unlike Beagle Board (great product) with an ARDUINO strapped to it just to get sensor datain.

Next Lab Materials


• ARDUINOUNO
• LEDs
• 330, 10k, 470k ohm Resistors / Resistorsheet.
• Breadboard
• Jumper wires (M-M, M-F,F-F)
• Buttons
• 16x2 LCD
• 10k Potentio

College of Computing & Information 5


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

LAB:02
Introduction to ARDUINOBoard, LED,Button

OBJECTIVES: Introducing ARDUINO board with its syntax and setup

Sketch

A sketch is the name that ARDUINO uses for a program. It's the unit of code that is uploaded to and run on an
ARDUINO board.

• Comments
• Variables
• Functions
• Pin Mode(), digital Write(), anddelay()
• setup() and loop()

Some Basic Circuit Components

• LEDs
• Transistor
• Resistors
• Solder less Breadboard
• Switches
• Throwswitch
• Push button

Resistors

A resistor is a passive two-terminal electrical component that


implements electrical resistance as a circuit element. ResistorCodes

Resistor Reading

From right to left the second color is multiplier. Digits from


the first colors must be multiplied with the number of this
color and the last color: This is tolerance. Tolerance is the
precision of the resistor and itis given asapercentage.
Resistorreading

College of Computing & Information 6


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

Common ARDUINO Used Resistors

Breadboard

A breadboard is a construction base for prototyping of electronics. Most


electronic components in electronic circuits can be interconnected by
inserting their leads or terminals into the holes and then making
connections through wires where appropriate. The breadboard has strips
of metal underneath the board and connects the holes on the top of
theboard.

LED

Get an ARDUINO board and USB cable


In this tutorial, we assume you're using an ARDUINO
Uno, You also need a standard USB cable (A plug to B
plug): the kind you would connect to a USB printer.

Download the ARDUINO environment

Get the latest version from the download page.

https://www.ARDUINO.cc/en/Main/Software

College of Computing & Information 7


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

When the download finishes, unzip the downloaded file. Make sure to preserve the folder structure. Double-
click the folder to open it. There should be a few files and sub-folders inside.

Install the drivers

Installing drivers for the Uno Windows 7,8,10, Vista, or XP:

• Plug in your board and wait for Windows to begin its driver installation process. After a few
moments, the process will fail, despite its bestefforts
• Click on the Start Menu, and open up the ControlPanel.
• While in the Control Panel, navigate to System and Security. Next, click on System. Once the System
window is up, open the DeviceManager.
• Look under Ports (COM & LPT). You should see an open port named “ARDUINO UNO
(COM**)".IfthereisnoCOM&LPTsection,lookunder"OtherDevices"for"UnknownDevice".
• Right click on the "ARDUINO UNO (COM**)" port and choose the "Update Driver Software”
option.
• Next, choose the "Browse my computer for Driver software"option.
• Finally, navigate to and select the driver file named "ARDUINO.inf", located in the "Driver’s" folder
of the ARDUINO Software download (not the "FTDI USB Drivers" sub-directory). If you are using
anoldversionoftheIDE(1.0.3orolder),choosetheUnodriverfilenamed"ARDUINOUNO.inf"
• Windows will finish the driver installation fromthere.

Select your board

You will need to select the entry in the


Tools > Board menu that corresponds to
your ARDUINO.

Selecting an ARDUINO Uno

Select your serial port

Select the serial device of the ARDUINO


board from the Tools | Serial Port menu.
This is likely to be COM3 or higher
(COM1 and COM2 are usually reserved for hardware serial ports). To find out, you can disconnect your
ARDUINO board and re-open the menu; the entry that disappears should be the ARDUINO board.
Reconnect the board and select that serial port.

College of Computing & Information 8


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

Uploading the program

Now, simply click the "Upload" button in the environment. Wait a few seconds - you should see the RX
and TX led on the board flashing. If the upload is successful, the message "Done uploading." will appear
in the status bar

Blink Example

This example shows the simplest thing you can do with an ARDUINO or GENUINO to see physical
output: it blinks the on-board LED. Turns on an LED on for one second, then off for one second,
repeatedly

Hardware

• ARDUINO or GENUINOBoard
• optional
• LED
• 220-ohmresistor

Circuit Diagram

CODE:
void setup() {
//initialize digital pin LED_BUILTIN as an output.
Pin Mode (LED_BUILTIN,OUTPUT);
}
// the loop function runs over and over again forever void
loop() {
Digital Write (LED_BUILTIN, H I G H ); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for asecond
Digital Write(LED_BUILTIN,LOW); // turn the LED off by making the voltage
LOW delay(1000); // wait for a second}

College of Computing & Information 9


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

FADE Example

This example demonstrates the use of the analog Write () function in fading an LED off and on. Analog
Write uses pulse width modulation (PWM), turning a digital pin on and off very quickly with different
ratio between on and off, to create a fading effect.
The analog Write() function uses PWM, so if you want to change the pin you're using, be sure to use
another PWM capable pin. On most ARDUINO, the PWM pins are identified with a "~" sign, like ~3,
~5, ~6, ~9, ~10 and ~11.

Hardware

• ARDUINO or GENUINOboard
• LED
• 220 ohmresistor
• hook-upwires
• breadboard

CONCEPT:

PWM (Pulse with Modulation)

Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.Digital
control is used to create a squarewave, asignal switched between on and off. The duration of "on time" is
called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you
repeat this on-off pattern fast enough a call to analog Write() is on a scale of 0 - 255, such that analog
Write (255) requests a 100% duty cycle (always on), and analog Write(127) is a 50% duty cycle (on half
the time)

College of Computing & Information 10


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

Circuit Diagram

CODE

void setup() {

pinMode(12,OUTPUT);

void loop() {

digitalWrite(12, HIGH);
delay(500);
digitalWrite(12,LOW);
delay(500);
}

College of Computing & Information 11


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

CONCEPT:

HIGH IMPEDENCE

In digital circuits, a high impedance (tri-stated or floating) output is not being driven to any defined logic
level by the output circuit. The signal is neither driven to a logical high nor low level; this third condition
leads to the description "tri-stated".
Pins configured as pin Mode(pin, INPUT) with nothing connected to them, or with wires connected to
them that are not connected to other circuits, will report seemingly random changes in pin state, picking
up electrical noise from the environment, or capacitive coupling the state of a nearby pin.

Button Example

Pushbuttons or switches connect two points in a circuit when you press them. This example turns on the built-
in LED on pin 13 when you press the button.

Hardware

• ARDUINOUNO
• Momentary button orSwitch
• 10K ohmresistor
• hook-upwires

Button Circuit Diagram

College of Computing & Information 12


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-2
Course Title: Computer Architecture Introduction to ARDUINO Board

CODE

void setup() {
Serial. Begin(9600);
pinMode(10,INPUT);
pinMode(12,INPUT);

}
void loop() {
int a=digitalRead(10);
int b=digitalRead(12);

if(a==1){
Serial.println("Welcome");
}
delay(1000);
if(b==1){
Serial.println("Serial button 12");
}

College of Computing & Information 13


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-3
Course Title: Computer Architecture Interfacing 16x2 LCD with ARDUINO UNO

LAB: 03
Interfacing 16x2 LCD with ARDUINO UNO

OBJECTIVES: The main object is to interfacing 16x2 LCD with ARDUINO to display data.

Hardware

1. ARDUINOUno
2. LCD Screen
3. 10k ohmpotentiometer
4. hook-upwires
Instruments

• ARDUINO IDE, LCD 16x2 or20x4

Basic Theory:

LCD/LED display one of the way to interact computer and provide human to machine interface. To work
with microcontroller, most of the time we need to know what is actually running in the background and
we need many reading to be display on LCD like temperature sensor, distance sensor etc. So, whatever
you need to display one should know how LCD works how pixels map on display and how all pixel
joins to formimage.

Experiment:

The Liquid Crystal library allows you to control LCD displays that are compatible with the Hitachi
HD44780 driver. There are many of them out there, and you can usually tell them by the 16pin interface.
This example sketch prints "Hello World!" to the LCD and shows the time in seconds since the
ARDUINO wasreset.

College of Computing & Information 15


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-3
Course Title: Computer Architecture Interfacing 16x2 LCD with ARDUINO UNO

Output of the sketch on a 16X2 LCD

The LCDs have a parallel interface, meaning that


the microcontroller has to manipulate several
interface pins at once to control the display. The
interface consists of the following pins:
A register selects (RS) pin that controls where in
the LCD's memory you're writing data to. You can select either the data register, which holds what goes on
the screen, or an instruction register, which is where the LCD's controller looks for instructions on what to
do next.
A Read/Write (R/W) pin that selects reading mode or writing mode

An Enable pin that enables writing to the registers

8 data pins (D0 -D7). The states of these pins (high or low) are the bits that you’re writing to aregister when
you write, or the values you're reading when youread.

There's also a display contrast pin (Vo),power supply pins (+5V and Gnd) and LED Backlight (Bklt+
and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on and off the
LED backlight,respectively.
The process of controlling the display involves putting the data that form the image of what you want to
display into the data registers, then putting instructions in the instruction register. The Liquid Crystal Library
simplifies this for you so you don't need to know the low-levelinstructions.
The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven
I/O pins from the ARDUINO, while the 8-bit mode requires 11 pins. For displaying text on the screen, you
can do most everything in 4-bit mode, so example shows how to control a 2x16 LCD in 4-bit mode.

Circuit
Before wiring the LCD screen to your ARDUINO or GENUINO board we suggest to solder a pin header strip
to the 14 (or 16) pin count connector of the LCD screen, as you can see in the image above.
To wire your LCD screen to your board, connect the following pins:

• LCD RS pin to digital pin12


• LCD Enable pin to digital pin11
• LCDD4pintodigitalpin5
• LCDD5pintodigitalpin4
• LCDD6pintodigitalpin3
• LCD D7 pin to digital pin2

College of Computing & Information 16


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-3
Course Title: Computer Architecture Interfacing 16x2 LCD with ARDUINO UNO

Schematic

LCD Display Circuit Diagram

College of Computing & Information 16


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-3
Course Title: Computer Architecture Interfacing 16x2 LCD with ARDUINO UNO

Example Code:

/*
Liquid Crystal Library - Hello World
Demonstrates the use a 16x2 LCD display. This
sketch prints "Hello World!" to the LCD and
shows the time.

The circuit:
* LCD RS pin to digital pin12
* LCD Enable pin to digital pin11
* LCD D4 pin to digital pin5
* LCD D5 pin to digital pin4
* LCD D6 pin to digital pin3
* LCD D7 pin to digital pin2
* LCD R/W pin toground
* LCD VSS pin to ground * LCD VCC pin to 5V * 10Kresistor:
* ends to +5V andground
* wiper to LCD VO pin (pin3)
*/

// include the library code:


#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin


// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Welcome in CA Class!");
}

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor (0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);

College of Computing & Information 17


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-3
Course Title: Computer Architecture Interfacing 16x2 LCD with ARDUINO UNO

SCROLL LCD TEXT:

Scroll Display Left () and scroll Display Right() methods

The Liquid Crystal Library allows you to control LCD displays that are compatible with the Hitachi
HD44780driver.Therearemanyofthemoutthere,andyoucanusuallytellthembythe16-pininterface.
This example sketch shows how to use the scroll Display Left () and scroll Display Right () methods to
reverse the direction the text is flowing. It prints "Hello World!” scrolls it off screen to the left, then off
screen to the right, then back to home.

CIRCUIT DIAGRAM

College of Computing & Information 18


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-3
Course Title: Computer Architecture Interfacing 16x2 LCD with ARDUINO UNO

CODE:

// include the library code:


#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin


// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Welcome in CA Class!");
}

void loop() {

for(int pos=0;pos<11;pos++){
lcd.scrollDisplayLeft();
delay(500);
}
lcd.clear();
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}

College of Computing & Information 19


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-4
Course Title: Computer Architecture Temperature Sensor LM35

LAB: 04
Introduction to Analog Channel & Using Temperature Sensor LM35
OBJECTIVES:Themainobjectiveofthelabistounderstanddifferencebetweenanalog
and digital system and how digital system see analog signal.

HARDWARE

1. ARDUINO
2. LM35 Temperature sensor(TMP36)
3. hook-upwires
4. breadboard

Instruments

• ARDUINO IDE, Tinker cad,lcd

BASIC THEORY:

Analog signal is a continuous signal mean that it exist infinite number of values. For example from 0 to 1
there is infinite numbers either 0.1 or 0.00000001. So it is impossible for digital system to handle infinite
number. This is the limitation of digital system. So what digital system does is it set threshold level of
values from which it can read which is called step size. The accuracy or resolution of digital system is
given bybits.

Following is the formula for the conversion of Analog


Value in Digital and viceversa.

In ARDUINO Microcontroller, you can use ADC in 8-bit or


10bit.But in this Lab, we will be using the 10-bit mode
because it is the only mode available. Vref is equal to the
VDD provided to the ARDUINO Microcontroller.

Resolution defines the number of possible analog-to-digital converter output states. As previously
discussed, the result is a digital or whole number, so for an 8-bit converter the possible states will be zero,
one, two, three and so on, with 255 as the maximum state. A 10-bit converter will have 1023 as the
maximum state, and a 12-bit converter will have 4095 as the maximum state. If the input range remains
constant, a higher resolution converter will have less quantization error because the range is divided into
smallersteps.

College of Computing & Information 20


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-4
Course Title: Computer Architecture Temperature Sensor LM35

The LM35 is a common TO-92 temperature sensor. It is often used with the equation temp

= (5.0 * analog Read (temp Pin) * 100.0) / 1024;

However, this does not yield high resolution. This can easily be avoided, however. The LM35 only
produces voltages from 0 to +1V. The ADC uses 5V as the highest possible value. This is wasting 8 0 % of
the possible range. If you change aRef to 1.1V, you will get almost the highest resolution possible.

The original equation came from taking the reading, finding what percentage of the range (1024) it is,
multiplying that by the range itself(aRef, or 5000 mV), and dividing by ten (10 mV per degree Celsius,
according to the datasheet:http://www.ti.com/lit/ds/symlink/lm35.pdf

However, if you use 1.1V as aRef, the equation changes entirely. If you divide1.1V over 1024, each step
up in the analog reading is equal to approximately 0.001074V = 1.0742 mV. If 10mV is equal to 1 degree
Celsius, 10 / 1.0742 = ~9.31. So, for every change of 9.31 in the analog reading, there is one degree of
temperaturechange.

To change aRef to 1.1V, you use the command "analog Reference (INTERNAL);"

Circuit Diagram

College of Computing & Information 21


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-4
Course Title: Computer Architecture Temperature Sensor LM35

Code:

FloattempC;//VariableforholdingCelsiustemp(floatingfordecimalpointsprecision)
Int reading;
int temp Pin = 0;

void setup()
{
Analog Reference (INTERNAL);
Serial begin (9600);
}

void loop()
{
reading = analogRead(tempPin);
// conversion math of LM35 sample to readable temperature and stores result to samples array.
tempC = reading / 9.31; Serial.println(tempC);
delay(1000);
}

College of Computing & Information 22


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-5
Course Title: Computer Architecture Interfacing Sonar (RANGE) sensor with ARDUINO

LAB: 05
INTERFACING SONAR (RANGE) SENSOR WITH ARDUINO

OBJECTIVES: How to measure the distance using ultrasonic sensor

HARDWARE

1. 1 xARDUINO
2. HC-SR04 (ultrasonic sensor)
3. LCD or SerialMonitor

Instruments

• ARDUINO IDE, TinkerCAD

Ultrasonic modules include ultrasonic transmitters, receiver and control circuit. The basic principle ofwork:

• Using IO trigger for at least 10us high levelsignal,


• The Module automatically sends eight 40 kHz and detect whether there is a pulse signalback.
• IF the signal comes back, time of high output IO duration is the time from sending ultrasonic to
returning.

Test distance = (high level time× velocity of sound (340M/S) / 2,

Wire connecting direct as following:


• 5V Supply
• Trigger PulseInput
• Echo Pulse Output
• 0V Ground

College of Computing & Information 23


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-5
Course Title: Computer Architecture Interfacing Sonar (RANGE) sensor with ARDUINO

Difference between 3 Pin And 4 PinUltrasonicSensor

There are two versions of this device. In the three pins version, you trigger the measurement and receive the echo
pulse on the same pin. In the four-pinversion,trigger and echo are on separate pins.

EXAMPLE CODE (4-PIN):


/*
HC-SR04 Ping distance sensor]
VCC to ARDUINO 5v GND to ARDUINO GND
Echo to ARDUINO pin 13 Trig to ARDUINO pin 12
Red POS to ARDUINO pin 11
Green POS to ARDUINO pin 10
560-ohm resistor to both LED NEG and GRD power rail
*/
#define trigPin 13
#define echoPin 12
#define led 11
#define led2 10
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}

College of Computing & Information 24


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-5
Course Title: Computer Architecture Interfacing Sonar (RANGE) sensor with ARDUINO

void loop() { long duration, distance;


digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 4) { // This is where the LED On/Off happens
digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off
digitalWrite(led2,LOW);
}
else {
digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
}
if (distance >= 200 || distance <= 0){
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" cm");
}
delay(500);

College of Computing & Information 25


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-5
Course Title: Computer Architecture Interfacing Sonar (RANGE) sensor with ARDUINO

3- PINCONNECTION:

This sketch reads a PING))) ultrasonic rangefinder and returns the distance to the closest object in range. To
do this, it sends a pulse to the sensor to initiate a reading, then listens for a pulse to return. The length of the
returning pulse is proportional to the distance of the object from thesensor.

The circuit:
- +V connection of the PING))) attached to +5V
- GND connection of the PING))) attached toground
- SIG connection of the PING))) attached to digital pin7

EXAMPLE CODE (3-PIN):

// this constant won't change. It's the pin number of the sensor's output:
const int pingPin = 7; void
setup() {
// initialize serial communication:
Serial.begin(9600);
}

void loop() {

College of Computing & Information 26


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-5
Course Title: Computer Architecture Interfacing Sonar (RANGE) sensor with ARDUINO

// establish variables for duration of the ping, and the distance result
// in inches and centimeters: long duration, inches, cm;

// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.


// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2); digitalWrite(pingPin,
HIGH); delayMicroseconds(5);
digitalWrite(pingPin,LOW);

// The same pin is used to read the signal from the PING))): a HIGH pulse
// whose duration is the time (in microseconds) from the sending of the ping
// to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);

// convert the time into adistance inches


= microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);

Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();

delay(100);
}

long microsecondsToInches(long microseconds) {


// According to Parallax's datasheet for the PING))), there are 73.746
// microseconds per inch (i.e. sound travels at 1130 feet per second). //
This gives the distance travelled by the ping, outbound and return, //
so we divide by 2 to get the distance of theobstacle.
// See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
return microseconds / 74 /2;
}

long microsecondsToCentimeters(long microseconds) {


// The speed of sound is 340 m/s or 29 microseconds per centimeter. //
The ping travels out and back, so to find the distance of the object we //
take half of the distance travelled.
return microseconds / 29 / 2;
}

College of Computing & Information 27


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-6
Course Title: Computer Architecture Controlling LED with a remote control using IR
receiver

LAB: 06
Controlling LED with a Remote Control using IR receiver

OBJECTIVES: Controlling LED (Any device) with a Remote Control using IR receiver.

HARDWARE

1. ARDUINOUNO
2. TSOP1738
3. IR TV/DVDRemote
4. LED

Instruments

• ARDUINO IDE, TinkerCAD

Working Explanation

When we press any button of IR Remote then remote sends a code in form of train of encoded pulses using
38Khz modulating frequency. These pulses are received by TSOP1738 sensor and read by ARDUINO and
then ARDUINO decodes received train of pulse into a hex value and compares that decoded value with the
predefined hex value of the pressed button. If any match occurs then ARDUINO perform relative
operation, in our case turning on and off al ed.
For detecting IR remote signal, we use TSOP1738 IR Receiver. This TSOP1738 sensor can sense
38Khz Frequency signal.

Decoding IR Remote Control Signals using ARDUINO

If you don’t know the Decoded output for your IR remote, it can be easily found, just follow these steps

1. Download the IR remote library fromherehttps://github.com/z3t0/ARDUINO-IRremote.

2. Unzip it, and place it in your ARDUINO ‘Libraries’ folder. Then rename the extracted folder to
IRremote.

3. Run the below program from your ARDUINO and open the Serial Monitor window in ARDUINO
IDE. Now press any IR Remote button and see the corresponding decoded hex output in Serial
Monitor window.

College of Computing & Information 29


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-6
Course Title: Computer Architecture Controlling LED with a remote control using IR
receiver

* IRremote:IRrecvDemo-demonstratesreceiving IRcodeswith IRrecv


* An IRdetector/demodulatormustbe connected to the inputRECV_PIN.
*/

#include
<IRremote.h>intRECV_P

IN=11;

IRrecvirrecv(RECV_PIN);

decode_resultsresults;

void setup()

{
Serial.begin(9600);

irrecv.enableIRIn();//Startthe receiver

}void loop(){ if
(irrecv.decode(&results)){

Serial.println(results.value,HEX);

irrecv.resume();//Receive the nextvalue


}

delay(100);

The above program is taken from IRremote libraries ‘examples’ folder, you can check out more
examples to learn more about using the IR remote. So that’s how we decoded the IR remote output.

College of Computing & Information 30


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-6
Course Title: Computer Architecture Controlling LED with a remote control using IR
receiver

CIRCUIT DIAGRAM

Controlling Led with an ARDUINO, An IR Sensor, And A Remote

Whenever a button is pressed on the remote, it sends an Infrared signal in encoded form. This
signal is then received by the IR receiver and then given to the ARDUINO.
We will save the code for the buttons we want to control the LEDs in the ARDUINO code.
Whenever a button on the remote is pressed, a code will be received by the ARDUINO. The
ARDUINO will compare this code with the codes already saved and if any of them match, the
ARDUINO will turn on the LED connected to that button.

CIRCUIT DIAGRAM
First, connect the four LEDs to the ARDUINO. Connect the positives of the four LEDs to the pins 7, 6,
5,

First, connect the LED to the ARDUINO. Connect the positive of the LED to the pins 13. Connect
the negative of the LED to GND on the ARDUINO through the 220-ohm resistors. The longer
wireson the LEDs are positive and the shorter wires arenegative.

College of Computing & Information 32


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-6
Course Title: Computer Architecture Controlling LED with a remote control using IR
receiver
Then connect the IR sensor to the ARDUINO. The connections for the IR sensor with the
ARDUINO are asfollows

• Connect the negative wire on the IR sensor to GND on theARDUINO.


• Connect the middle of the IR sensor, which is the VCC to 5V on theARDUINO.
• Connect the signal pin on the IR sensor to pin 2 on theARDUINO.

Code:

#include <IRremote.h>
int RECV_PIN = 2; //IR SENSOR
int led1=13; // LEDPIN
int itsONled[] = {0,0}; // STATUS ARRAY

//HEXA CODE FOR BUTTON RED


#define code1 255
IRrecv
irrecv(RECV_PIN);
decode_resultsresults;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led1,
OUTPUT);
}
void loop() { if
(irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value){ casecode1:
if(itsONled[1] == 1) { // if first led is on then
digitalWrite(led1, LOW); // turn it off when button ispressed
itsONled[1]=0; // and set its state asoff
}else{ // else if first led isoff
digitalWrite(led1, HIGH); // turn it on when the button is pressed
itsONled[1]=1; // and set its state ason
}
break;
}
Serial.println(value); // you can comment this line
irrecv.resume(); // Receive the next value
}

College of Computing & Information 32


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-7
Course Title: Computer Architecture Make a real time clock using RTC DS3231
Module

LAB: 07
Make a REAL TIME CLOCK USING RTC DS3231 MODULE

OBJECTIVES: Make a real-time clock using RTC DS3231 module and show time on 16*2 LCD

HARDWARE

1. ARDUINO UnoRev3
2. 16x2 LCDDisplay
3. DS3231 Real Time ClockModule
4. USB Cable (Type A to TypeB)
5. Jumper Cable

Software
 ARDUINOIDE

 Proteus 8
Overview
Why we actually need a separate RTC for our ARDUINO Project when the ARDUINO itself has
built-in timekeeper. Well the point is that the RTC module runs on a battery and can keep track of
the time even if we reprogram the micro controller or disconnect the main power.

Working Explanation

The DS3231 is a low-cost, highly accurate Real Time Clock, which can maintain hours,
minutes and seconds, as well as, day, month and year information. Also, it has automatic
compensation for leap years and for months with fewer than 31days.
The module can work on either 3.3 or 5V, which makes it suitable for many development
platforms or microcontrollers. The battery input is 3V and a typical CR2032 3V battery can
power the module and maintain the information for more than a year.
The module uses the I2C Communication Protocol that makes the connection to the ARDUINO
Boardveryeasy.

College of Computing & Information 33


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-7
Course Title: Computer Architecture Make a real time clock using RTC DS3231
Module

CIRCUIT DIAGRAM

College of Computing & Information 35


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-7
Course Title: Computer Architecture Make a real time clock using RTC DS3231
Module

Code:
// Real time clock and calendar with set buttons using DS3231 and Arduino

// include LCD library code


#include <LiquidCrystal.h>
// include Wire library code (needed for I2C protocol devices)
#include <Wire.h>

// LCD module connections (RS, E, D4, D5, D6, D7)


LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
pinMode(8, INPUT_PULLUP); // button1 is connected to pin 8
pinMode(9, INPUT_PULLUP); // button2 is connected to pin 9
// set up the LCD's number of columns and rows
lcd.begin(16, 2);
Wire.begin(); // Join i2c bus
}

char Time[] = "TIME: : : ";


char Calendar[] = "DATE: / /20 ";
byte i, second, minute, hour, date, month, year;

void DS3231_display(){
// Convert BCD to decimal
second = (second >> 4) * 10 + (second & 0x0F);
minute = (minute >> 4) * 10 + (minute & 0x0F);
hour = (hour >> 4) * 10 + (hour & 0x0F);
date = (date >> 4) * 10 + (date & 0x0F);
month = (month >> 4) * 10 + (month & 0x0F);
year = (year >> 4) * 10 + (year & 0x0F);
// End conversion
Time[12] = second % 10 + 48;
Time[11] = second / 10 + 48;
Time[9] = minute % 10 + 48;
Time[8] = minute / 10 + 48;
Time[6] = hour % 10 + 48;
Time[5] = hour / 10 + 48;
Calendar[14] = year % 10 + 48;
Calendar[13] = year / 10 + 48;
Calendar[9] = month % 10 + 48;
Calendar[8] = month / 10 + 48;
Calendar[6] = date % 10 + 48;
Calendar[5] = date / 10 + 48;
lcd.setCursor(0, 0);
lcd.print(Time); // Display time
lcd.setCursor(0, 1);
lcd.print(Calendar); // Display calendar
}
void blink_parameter(){
byte j = 0;
College of Computing & Information 38
Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-7
Course Title: Computer Architecture Make a real time clock using RTC DS3231
Module
while(j < 10 && digitalRead(8) && digitalRead(9)){
j++;
delay(25);
}
}
byte edit(byte x, byte y, byte parameter){
char text[3];
while(!digitalRead(8)); // Wait until button (pin #8) released
while(true){
while(!digitalRead(9)){ // If button (pin #9) is pressed
parameter++;
if(i == 0 && parameter > 23) // If hours > 23 ==> hours = 0
parameter = 0;
if(i == 1 && parameter > 59) // If minutes > 59 ==> minutes = 0
parameter = 0;
if(i == 2 && parameter > 31) // If date > 31 ==> date = 1
parameter = 1;
if(i == 3 && parameter > 12) // If month > 12 ==> month = 1
parameter = 1;
if(i == 4 && parameter > 99) // If year > 99 ==> year = 0
parameter = 0;
sprintf(text,"%02u", parameter);
lcd.setCursor(x, y);
lcd.print(text);
delay(200); // Wait 200ms
}
lcd.setCursor(x, y);
lcd.print(" "); // Display two spaces
blink_parameter();
sprintf(text,"%02u", parameter);
lcd.setCursor(x, y);
lcd.print(text);
blink_parameter();
if(!digitalRead(8)){ // If button (pin #8) is pressed
i++; // Increament 'i' for the next parameter
return parameter; // Return parameter value and exit
}
}
}

void loop() {
if(!digitalRead(8)){ // If button (pin #8) is pressed
i = 0;
hour = edit(5, 0, hour);
minute = edit(8, 0, minute);
date = edit(5, 1, date);
month = edit(8, 1, month);
year = edit(13, 1, year);
// Convert decimal to BCD
minute = ((minute / 10) << 4) + (minute % 10);
hour = ((hour / 10) << 4) + (hour % 10);
date = ((date / 10) << 4) + (date % 10);
College of Computing & Information 38
Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-7
Course Title: Computer Architecture Make a real time clock using RTC DS3231
Module
month = ((month / 10) << 4) + (month % 10);
year = ((year / 10) << 4) + (year % 10);
// End conversion
// Write data to DS3231 RTC
Wire.beginTransmission(0x68); // Start I2C protocol with DS3231 address
Wire.write(0); // Send register address
Wire.write(0); // Reset sesonds and start oscillator
Wire.write(minute); // Write minute
Wire.write(hour); // Write hour
Wire.write(1); // Write day (not used)
Wire.write(date); // Write date
Wire.write(month); // Write month
Wire.write(year); // Write year
Wire.endTransmission(); // Stop transmission and release the I2C bus
delay(200); // Wait 200ms
}
Wire.beginTransmission(0x68); // Start I2C protocol with DS3231 address
Wire.write(0); // Send register address
Wire.endTransmission(false); // I2C restart
Wire.requestFrom(0x68, 7); // Request 7 bytes from DS3231 and release I2C bus at end of reading
second = Wire.read(); // Read seconds from register 0
minute = Wire.read(); // Read minuts from register 1
hour = Wire.read(); // Read hour from register 2
Wire.read(); // Read day from register 3 (not used)
date = Wire.read(); // Read date from register 4
month = Wire.read(); // Read month from register 5
year = Wire.read(); // Read year from register 6
DS3231_display(); // Display time & calendar
delay(50); // Wait 50ms
}

College of Computing & Information 38


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-8
Course Title: Computer Architecture Detecting motion using PIR Motion sensor

LAB: 08
Detecting Motion using PIR MOTION SENSOR
OBJECTIVES: Detecting Motion using PIR MOTION SENSOR and indicating motion by lighting up Led.

HARDWARE

1. ARDUINOUNO
2. PIR Motion Sensor
3. LED
4. Jumper Cables

Instruments

• ARDUINO IDE, TinkerCAD

Working Explanation

Passive Infrared Sensor (PIR) is very useful


module, used to build many kinds of Security.
Alarm Systems and Motion Detectors. It is
called passive because it receives infrared,
not emits. Basically, PIR sensor detects any
change in heat, and whenever it detects any
change, its output PIN becomes HIGH. They
are also referred as Pyroelectric or IR
motionsensors.
Here we should note that every object emits some amount of infrared when heated. Human also
emits infrared because of body heat. PIR sensors can detect small amount of variation in infrared.
Whenever an object passes through the sensor range, it produces infrared because of the friction
between air and object, and get caught byPIR.

PINOUT:

Wiring the PIR motion sensor to an ARDUINO is straightforward, the sensor has only 3 pins.
GND – connect to ground
OUT – connect to an ARDUINO digital
pin 5V – connect to 5V

College of Computing & Information 39


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-8
Course Title: Computer Architecture Detecting motion using PIR Motion sensor

CIRCUIT DIAGRAM

ARDUINO Code
int led=13; // the pin that the LED is attached to
int sensor= 3; // the pin that the sensor is attached to
int state=LOW; // by default, no motiondetected
int val=0; // variable to store the sensor status(value)

void setup() {
pinMode(led,OUTPUT); // initalize LED as an
output pinMode(sensor, INPUT); // initialize sensor
as an input Serial.begin(9600); // initializeserial
}
void loop(){ val = digitalRead(sensor); //
read sensor value if (val ==HIGH){ //
check if the sensorisHIGH
digitalWrite(led, HIGH); // turn
LED ON delay(100); // delay 100
milliseconds if (state == LOW){
Serial.println("Motiondetected!"); state =
HIGH; // update variable state toHIGH
}
}
else {
digitalWrite(led, LOW); // turn LED
OFF delay(200); //delay 200
milliseconds if (state ==HIGH){
Serial.println ("Motion stopped!");
state = LOW;
// update variable state to LOW
}
}}

College of Computing & Information 40


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-9
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

LAB: 09
Keypad Interfacing with ARDUINO Uno
OBJECTIVES: Keypad Interfacing with ARDUINO Uno and showing characters on LCD screen.

HARDWARE

1. ARDUINOUNO
2. Keypad4*4
3. LCD

Instruments

• ARDUINO IDE, TinkerCAD

In this experiment, we are going to interface a 4x4 (16-key) keypad with ARDUINO UNO. We
all know keypad is one of the most important input devices used. Keypad is the easiest and the
cheapest way to give commands or instructions to an electronic system. Whenever a key is
pressed in keypad module, the ARDUINO Uno detects it and shoes the corresponding key on
16x2 LCD.

Working Explanation

In 16x2 LCD there are 16 pins over all if there is a back light, if there is no back light there will
be 14 pins. One can power or leave the back-light pins. Now in the 14 pins there are 8 data pins
(7-14 or D0-D7), 2 power supply pins (1&2 or VSS&VDD or GND&+5v), 3rd pin for contrast
control (VEE-controls how thick the characters should be shown) and 3 control pins
(RS&RW&E).
In the ARDUINO Uno keypad interfacing circuit, you can observe that I have only took two
control pins. This give the flexibility of better understanding; the contrast bit and READ/WRITE
are not often used so they can be shorted to ground. This puts LCD in highest contrast and read
mode. We just need to control ENABLE and RS pins to send characters and data accordingly.

CONNECTIONS

LCD:
PIN1 or VSS to ground
PIN2 or VDD or VCC to +5v power
PIN3 or VEE to ground (gives maximum contrast best for a
beginner) PIN4 or RS (Register Selection) to PIN8 of ARDUINO
UNO
PIN5 or RW (Read/Write) to ground (puts LCD in read mode eases the communication for user)

College of Computing & Information 41


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-9
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

PIN6 or E (Enable) to PIN9 of


ARDUINO UNO PIN11 or D4 to
PIN10 of ARDUINO UNO PIN12 or
D5 to PIN11 of ARDUINO UNO
PIN13 or D6 to PIN12 of ARDUINO
UNO PIN14 or D7 to PIN13 of
ARDUINO UNO

KEYPAD:
We are going to connect the keypad module between pins 0-7 of ARDUINO Uno, as shown in
the circuit diagram. All the eight pins of keypad module are connected accordingly.
Now for setting up a connection between Keypad Module and UNO, we need to get the
keypad library from the ARDUINO website.

CIRCUIT DIAGRAM:

College of Computing & Information 43


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-9
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

CODE:

#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface
pins LiquidCrystal lcd(8, 9, 10, 11,
12,13);//RS,EN,D4,D5,D6,D7
#include <Keypad.h>//header
const byte ROWS = 4; // Four rows const byte COLS = 4;
// Three columns
// Define the Keymap char
keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'#','0','*','D'} };
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these ARDUINO
pins. byte rowPins[ROWS] = { 7,6,5,4};
// Connect keypad COL0, COL1 and COL2 to these ARDUINO
pins. byte colPins[COLS] = { 3,2,1,0};
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
for(int k=8;k<14;k++)
{
pinMode(k,OUTPUT);//pins 8-14 are enabled as output
}
lcd.begin(16, 2);//initializing LCD
}
void loop()
{
char key = kpd.getKey(); //storing pressed key value in a
char if (key !=NO_KEY)
{
lcd.print (key); //showing pressed character on LCD
}
}

College of Computing & Information 43


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-10
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

LAB: 10
TO INTERFACE DC-MOTORS WITH ARDUINO UNO

OBJECTIVES: To demonstrate how to interface three types of motor i.e. . DC, Stepper and Servo
motors.

HARDWARE

Arduino
L293D Motor Driver IC
DC Motor
Stepper Motor
Servo Motor

Instruments

ARDUINO IDE, Proteus 8

BASIC THEORY:

The main objective of this program is to make the student understand how to interface and control DC,
Stepper and Servomotor.

DC Motor:
A direct current (DC) motor is a simple electric motor that uses electricity and a magnetic field to
produce torque, which turns themotor.

At its most simple, a DC motor requires two magnets of opposite


polarity and an electric coil, which acts as an electromagnet. The
repellent and attractive electromagnetic forces of the magnets provide
the torque that causes the DC motor to turn.

Stepper Motor:
A stepper motor is a special type of electric motor that moves in
increments, or steps, rather than turning smoothly as a conventional motor
does. The size of the increment is measuredin degrees and can vary
depending on theapplication.

College of Computing & Information 44


Sciences
61

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-10
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

Inside the device, sets of coils produce magnetic fields that interact with the fields of permanent magnets.
The coils are switched on and off in a specific sequence to cause the motor shaft to turn through the
desired angle. The motor can operate in either direction (clockwise or counterclockwise).
WORKING OF L293D:

The L293D is a 16 pin IC which is known for their efficiency in controlling DC motors. There are two types of supply
voltage for this IC Vs, Vss. Vs is meant for its own internal operation, and it will not use this input for driving motors.
This Vs input voltage should not exceed 7 V or it will damage the IC.Vss is meant for supplying power to the motor
we are about to drive, for example if we are going to drive a 12V motor you should give 12V input to this 16th pin
Vss.
Enable pins are meant to make the respective motor drivers ready to operate; supplying high signal will activate the
corresponding drivers. Enable1 for motor 1 and Enable 2 is for motor 2. Input pins 2, 7, 10, 15 are used to operate the
motor in your desired direction. Output pins 3 & 6 should be connected to motor 1, Pins 11 & 14 should be connected
to motor 2. Here is a logic table for the inputs of L293D and the motor state corresponding to that input.

College of Computing & Information 45


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-10
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

DC Motor Circuit Diagram:

College of Computing & Information 46


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-10
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

Code:

int val =150;

void setup() {
// put your setup code here, to run once:

void loop() {
// put your main code here, to run repeatedly:
analogWrite(9,val);
analogWrite(10,0);
delay(10);
}

College of Computing & Information 46


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-10
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

Servo Motor:
Simple DC motor which is controlled for specific angular rotation with
help of additional servomechanism (a typical closed loop feedback control
system). If the motor as controlled device, associated with
servomechanism is DC motor, then it is commonly known DC Servo
Motor. If AC operates the controlled motor, it is called AC Servo Motor

The main reason behind using a servo is that it provides angular precision, i.e. it will only rotate as much
we want and then stop and wait for next signal to take further action. This is unlike a normal electrical
motor, which starts rotating as, and when power is applied to it and the rotation continues until we switch
off the power. We cannot control the rotational progress of electrical motor; but we can only control the
speed of rotation and can turn it ON and OFF.

Servo Motor Circuit Diagram:

Code:
#include <Servo.h>

Servo myservo; // create servo object to control a servo

int potpin = A0; // analog pin used to connect the potentiometer


int val; // variable to read the value from the analog pin

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

College of Computing & Information 47


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-10
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it for use with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
}

Stepper Motor:

This type of motor rotates in steps rather than continuous rotation. The minimum step of the stepper motor
is called step angle. A stepper motor is a Varies types of Stepper motors are available in different sizes and
step angles. In our lab, we would be interfacing a uni-polar 1.8’/step stepper motor.

Following is the full-step or 4-step sequence diagram of stepper motor

College of Computing & Information 48


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-10
Course Title: Computer Architecture Keypad Interfacing with ARDUINOUNO

Stepper Motor Circuit Diagram:

Code:

#include <Stepper.h>
const int spr=4;
Stepper steper (spr,8,9,10,11);

void setup() {
steper.setSpeed (10);
Serial.begin (9600);
}

void loop() {
steper.step (60);
delay (200);
//CS01
steper.step (-40);
delay (200);
}

College of Computing & Information 49


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-11
Course Title: Computer Architecture ARDUINO with Relay to control High Voltage Device

LAB: 11
INTERFACING ARDUINO WITH RELAY TO CONTROL HIGH
VOLTAGE DEVICES

OBJECTIVES: Learn how to Control High Voltage Devices using the ARDUINO Board.

HARDWARE

1. ARDUINO
2. 5V RelayModule
3. JumpWires
4. Cable, Plug,Socket

Software
• ARDUINOIDE.
• Proteus 8

Introduction

We can control High Voltage electronic devices using relays. A Relay is actually a switch, which is
electrically operated by an electromagnet. The electromagnet is activated with a low voltage, for example, 5
volts from a microcontroller and it pulls a contact to make or break a high voltage circuit.

High Voltage Warning

Before we continue with this tutorial, I will warn you here that we will use High Voltage which if
incorrectly or improperly used could result in serious injuries or death. So be very caution of what you are
doing because I take no responsibility for any of your actions.

Relay Module

The high voltage output connector has 3 pins, the middle on is the common pin and as we can see fromthe
markings one of the two other pins is for normally open connection and the other one for normally closed
connection. On the other side of the, there are 3 pins, a Ground and a VCC pin for powering the module and 1
input pin In1 which receives the signal from ARDUINO in form of digital output0/1.

67
College of Computing & Information 50
Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-11
Course Title: Computer Architecture ARDUINO with Relay to control High Voltage Device

What is NO NC and COM in relay?

C = Common Connection
NC = Normally Closed Connection
NO = Normally Open Connection
COM - Common Connection

It is the center terminal; it is hot as power to the load is connected at this terminal.
It acts like a switch, since it is open - there will be no contact between COM and NO, when we trigger the relay
module, it connects to COM by the electromagnet inside the relay and supply to the load is provided, which
powers up the light. Thus, the circuit is closed until we trigger the state to low in relay.
NC Normally Closed. It is always in contact with COM, even when relay is not powered.
When we trigger the relay, it opens the circuit, so the connection is lost. It behaves just opposite to NO.

Circuit Diagram

College of Computing & Information 51


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-11
Course Title: Computer Architecture ARDUINO with Relay to control High Voltage Device

Code:
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever


void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13,LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

College of Computing & Information 52


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-12
Course Title: Computer Architecture Interfacing ARDUINO with ESP8266

LAB: 12
INTERFACING ARDUINO WITH ESP8266
OBJECTIVES: Programming ESP8266 ESP-01 with

ARDUINO. HARDWARE

1. ARDUINO
2. ESP 8266 – 01
3. Jumper wires / Breadboard

Software. ARDUINO IDE.

Introduction

The ESP8266 ESP-01 is a Wi-Fi module that allows microcontrollers access to a Wi-Fi network. ESP8266
module is of low cost and comes pre-programmed with an AT command set firmware .This module is a
self-contained SOC (System On a Chip) that doesn’t necessarily need a microcontroller to manipulate inputs
and outputs as you would normally do with an ARDUINO for example, because the ESP-01 acts as a small
computer. Depending on the version of the ESP8266, it is possible to have up to 9 GPIOs (General Purpose
Input Output). Thus, we can give a microcontroller internet access like the Wi-Fi shield does to the
ARDUINO, or we can simply program the ESP8266 to not only have access to a Wi-Fi network, but to act as
a microcontroller as well. This makes the ESP8266 very versatile.

ARDUINO Setup

First download ARDUINO IDE ensure that you have the latest
software version (some older versions won’t work), visit the
following URL: https://www.ARDUINO.cc/en/Main/Software.

Upload Bare minimum sketch from examples to ARDUINO this


is to make sure that there are no other programs running on ARDUINO and using serial communication
channel.

AT firmware is compatible with the ARDUINO IDE, so we are going to use this firmware for this
tutorial. Connect ESP8266 as per the above circuit.

• VCC shall be connected to the 3.3V power supply.


• GPIO0 and GPIO2 are general-purpose digital ports.
• GPIO0 also controls the module mode (programming or normal operation).

College of Computing & Information 53


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-12
Course Title: Computer Architecture Interfacing ARDUINO with ESP8266

In our case (normal operation), it shall be connected to 3.3V (high).


GPIO2 is not used in this example.

• Rx: Goes to ARDUINO pin0 (But needs a


voltage adjusting).
• CH_PD: Chip enable. Keep it on high (3.3V) for
normal operation.
• RST: Reset. Keep it on high (3.3V) for normal
operation. Put it on 0V to reset the chip.
• GND is ground.
• TX: Goes to ARDUINOpin1.

ESP8266 Modes:
Open the serial monitor change the baud rate to 115200 and choose NL and CR (new line and carriage return).
Type AT on the serial monitor you will see an OK response. If you see garbage value on the screen, try to
resetting the module, or checking your baud rate. Make sure the NL and CR option is set. ESP8266 module has
three operational modes.

1. Access Point(AP)
In AP the Wi-Fi module acts as a Wi-Fi network, or access point (hence the name), allowing other devices to
connect to it. It establishes a two-way communication between the ESP8266 and the device that is connected to it
via Wi-Fi.
2. Station(STA)
In STA mode, the ESP-01 can connect to an AP (access point) such as the Wi-Fi network from your house. This
allows any device connected to that network to communicate with the module.
3. Both
In this mode ESP-01, act as both an AP as well as in
STA mode.
You can refer the following site for more ESP8266
AT command set click here.

Installing ESP8266 Platform

First ARDUINO environment has to be setup to


make it compactable with the ESP module. It is
required to have ARDUINO version 1.6.4 or higher
in order to be able to install the ESP’s platform
packages.
1. Open the preferences window from the ARDUINO IDE. Go to File >Preferences

College of Computing & Information 54


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-12
Course Title: Computer Architecture Interfacing ARDUINO with ESP8266

2. Enterhttp://ARDUINO.esp8266.com/stable/package_esp8266com_index.jsoninto Additional Board


Manager URLs field and click the “OK”button

College of Computing & Information 55


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-12
Course Title: Computer Architecture Interfacing ARDUINO with ESP8266

3. Open board’s manager. Go to Tools > Board > Boards Manager…

4. Scroll down, select the ESP8266 board menu and install “ESP8266platform”

College of Computing & Information 56


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-12
Course Title: Computer Architecture Interfacing ARDUINO with ESP8266

5. Choose your ESP8266 board from Tools > Board > Generic ESP8266Module.

References:

• http://www.instructables.com/id/Getting-Started-With-the-ESP8266-ESP-01

• https://create.ARDUINO.cc/projecthub/ROBINTHOMAS/programming-esp8266-esp-01-with-
ARDUINO011389

College of Computing & Information 57


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-13
Course Title: Computer Architecture Introduction to Bluetooth serial communication

LAB:13
Introduction to Bluetooth Serial Communication

OBJECTIVES: The main objective of the lab is to understand how the communication system works and
discus serial and parallel communication

HARDWARE

2x ARDUINO
Optional HC-05 (Bluetooth Module) and android phone

Instruments

ARDUINO IDE, HC-05, Android Phone

BASIC THEORY:

Communication is a way to understand and share ideas. In digital world, communication is necessary to
define machine what we actually want it to do. There is two way to communicate with devices parallel and
serial. In parallel data is transfer by mean of parallel connection between machine to machine, which in
term increase hardware size cost, and connection. In Serial communication data has send one by one on a
single channel, which reduces cost, connection and hardware.

College of Computing & Information 58


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

Lab-13
Course Title: Computer Architecture Introduction to Bluetooth serial communication

We prefer serial because It use less connecting then parallel so we do not have bunch of wire.USB
(Universal Serial Bus) is also a Serial data transfer device. So here in microcontroller, we have 5 or more
communication protocol USART, SPI, CAN, I2C, and Parallel. As a beginner, we learn simple
communication protocol USART.

USAT
• Two Signals are required for the bi-directional communication (TX,RX)
• Asynchronous Communication (No clock signal required)
• Both devices must have same BAUD rate

UART

Data Transmission

Standard BAUD Rat

College of Computing & Information 59


Sciences

Downloaded by Okorie Promise (okoriechinedup@gmail.com)


lOMoARcPSD|12193041

88

Downloaded by Okorie Promise (okoriechinedup@gmail.com)

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