arduino projectsoomaelecturer.com/wp-content/uploads/edd/introductio… ·  · 2018-01-04arduino...

81
ARDUINO PROJECTS INTRODUCTION Digital electronics: A field of science which deals with discrete quantities which are either 0 or 1. Analogue electronics: Deals with continuously varying quantities with respect to time. Features of Analogue Electronics: Varies continuously with time i.e. amplitude Mostly typical of nature e.g. speech, light energy Has been used for over 100 years It is wavy in nature Digital Lab: Introduction: Omae M. Oteri

Upload: vankhanh

Post on 23-Mar-2018

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO PROJECTSINTRODUCTION

• Digital electronics: A field of science which deals with discrete quantities which are either 0 or 1.

• Analogue electronics: Deals with continuously varying quantities with respect to time.

• Features of Analogue Electronics:

• Varies continuously with time i.e. amplitude

• Mostly typical of nature e.g. speech, light energy

• Has been used for over 100 years

• It is wavy in nature

Digital Lab: Introduction: Omae M. Oteri

Page 2: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Features of Digital Electronics• They are discrete i.e. they occur in 0’s and 1’s

• Typical of technology

• Has been used for around 50 years; when transistors came into existence

Page 3: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Advantages of Digital over Analogue• Easier to process information/signal i.e. ease of manipulation

• Use of very large scale integration integrated circuits

• Take up small space as they are very small in size

• They are programmable i.e. Programmable Logic Devices (PLD’s) like PROM

• Not costly compared to analogue

• Durable

• More accurate

• Portable

• More secure

• Not mechanical

• Not affected by noise

• Disadvantages of Digital Electronics:

• Require skills to operate

• Initial cost of design is high

• Can pose as a health hazard in some cases

Page 4: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Applications of Digital Electronics:• Communication and entertainment

• Medicine

• Industrial applications

• Instrumentation

• Defense

• Robotics

• Astronomy

• Biometrics

• Training

Page 5: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Components of a Digital systems• According to von Neumann model

Storage device

Output Memory Input

ALU

Control unit

CPU

Page 6: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with
Page 7: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Hardware • Input devices

• Mouse, keyboard, joystick, touch screen, stylus, Light pen, Microphone, Scanner, Trackball, Camera.

• Output devices• Printers, visual display system (monitors CRTs, LCD, LED), Speakers, Cameras,

Plotters.

• System unit devices

• CPU-Central processing unit (processor, ALU, CU),Motherboard, buses, Memory, Power supply unit together with the casing, interface cards, connecting wires (Cards or cables e.g. hard disk to main board, floppy to main board) Fan and heat sink, switches, Reset, LED

• Storage devices• Floppy disk, CD-Rom, DVD-ROM, Zip disk, Memory card, Flash disk,

Page 8: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Software • System and application software

• System Software• Operating Systems

• Windows, Linux Unix, Mac operating System, Novel, OS/2, Apple

• Mobile Operating System• Android, Symbian, Apple, Windows CE

• Operating system and utility programs

• Application software• Interface user and the operating system

• SPSS, Excel, Mat lab, Access

Digital Lab: Introduction: Omae M. Oteri

Page 9: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

DIGITAL SYSTEMS HARDWARE BASICS• A digital system is constructed from electrical and electronic materials.

• The materials are classified into:-• Good conductors• Insulators • Semiconductors

• Good conductors• Materials that allow current to pass through them.• Examples Aluminum and copper are commonly used.

• Insulators• They are materials which do not allow current to pass through.• Examples include Rubber, plastic, polythene and ceramics.

• Semi-Conductors• These are materials that partially allow current to pass through.• They have properties between good conductors and insulators.• Examples include all group four elements i.e. Carbon, Silicon, Germanium

Digital Lab: Computer HW Basics: Omae M. Oteri

Page 10: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

AS USED IN DIGITAL SYSTEMS• Good Conductors

• Wires• Cables Buses• Computer casing (grounding)

• Insulator• Casing, Keyboard, insulated wires• Protective purpose

• Semiconductors• Used to obtain semiconductor devices which include:-• Diode• Transistors• Integrated circuits (Chipsets and processors)

• The basic components obtained from these materials include;-• Fuse Resistors• Inductor• Transistor• Integrated circuit

Page 11: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Classification • Passive Components

• They do not require power to operate

• They do not increase strength of a signal.

• Examples are fuse, resistor, capacitor, diodes.

• Active components• They require power to operate.

• They increase strength of a signal.

• They include transistor and Integrated circuits.

• Switch • Puts power on or off-first in a device from mains

• Fuse• A wire that has properties which will make it blow up when the power supply

goes beyond the required level.

Page 12: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Resistor • Resistor

• This is a device that opposes the flow of current in a circuit.

• Resistor colour coding is the process of representing resistance of resistor using colour bands.

• Ohms Law

• The current passing through a conductor is proportional to the voltage applied across it provided all external factors are constant.

• Resistor circuits

• Resistors can be connected in series, parallel or combination

• Types of resistors

• Fixed value-wirewound, carbon, metal film

• Variable -Potentiometer, thermistor, light dependent

Number Colour Multiplier Tolerance

0

1

2

3

4

5

6

7

8

9

-

-

-

Black

Brown

Red

Orange

Yellow

Green

Blue

Violet

Grey

White

Gold

Silver

No. band

100

101

102

103

104

105

106

107

108

109

10-1

10-2

-

+ 1%

+ 2%

+ 5%

+ 10%

+ 20%

Red, Black, Orange, Brown

2 0 103 1%

%11020 3

Page 13: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Inductors, transformers and capacitors• Inductors

• A device that stores magnetic energy, it also opposes flow of AC current.

• Transformer • A device which can change the level of voltage from high to low or vice versa.

• Capacitor• It is a device that stores electric energy in a circuit.

• It opposes flow of AC current. A combination of an inductor and a capacitor will be used to filter out electrical noise.

• Types-ceramic, air, electrolytic-alluminium

Digital Lab: Computer HW Basics: Omae M. Oteri

Page 14: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Components • Diode

• A device that allows current to pass through in one direction. It can be used to change AC to DC (rectification).

• It can be used to changer AC to DC rectification.

• Can be constructed using the P and N type semiconductors materials.

• P-type (+)

• N-type (-)

• P-type is obtained by combining silicon and group 3 elements, Boron.

• N-type is obtained by combination of group 4and group 5 elements silicon and phosphorus.

• Types include rectifier, zener, photo, LED, varactor and tunnel

Digital Lab: Computer HW Basics: Omae M. Oteri

Page 15: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Transistor• Transistor-An active device that can amplify a signal (electrical)

• These are two types• Bipolar in transistor (BJT)• Field effect transistor (FET)

• Bipolar junction transistor (BJT)• It is current controlled and has these terminals• Emitter -gives out electrons• Collector –collects• Base –controls the electrons collected• Conducted using P and N –type materials

• Field Effect Transistor (FET)• Voltage controlled• Has 3 terminals• Drain –takes electrons• Source –give out electrons• Gate –control electrons taken in by drain

Page 16: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Power supply• Provides power to various components in a system

• Linear power supply

• Single stage amplifier

Page 17: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Power devices • Used to control power-include SCR, triac and diac

• Silicon controlled rectifier-It is a 4 layer P-N-P-N device which is basically a rectifier with a controller element.

• Triac-It’s a 5 layer bi-directional device which can be triggered into conduction by both +ve and -ve voltages at its anode and with both the +veand -ve triggering pulses at the gates.

• Diac-It has only 2 terminals and is like a triac without its gate.

Page 18: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Integrated circuits• A device that has several components fabricated together in one material (substrate)

• Mostly the transistors are the ones that are integrated

• Level of integration depends on the number of transistors put together

• Chipset micro–processor and processors (SSI, MSI, LSI, VLSI, ULSI).

• There are 2.6 billion transistors latest for processor, more transistors for memory.

• These components are used to construct basic digital electronic devices called gates.

• Photolithography.

• Transfers patterns using light energy to a substrate

• Semiconductor material.Photolithography.

Transfers patterns using light energy to Sc material.

Light

Mask

Photoresist

Substrate

Digital Lab: Computer HW Basics: Omae M. Oteri

Page 19: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

LOGIC GATES• LOGIC-A way of reasoning to make a decision

• An electronic device that makes logic decisions.

• It’s the basic building blocks for all digital systems

• It is digital deals with 0s and 1s constructed from basic components i.e.• Transistors• Capacitors• Diodes• Transistors• Switches

• They are called the basic building blocks all digital systems.

• They are analyzed using Boolean algebra and truth tables. The gates include:-• NOT gate• OR• AND• XOR• XNOR• NAND• NOR

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 20: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Combinational Logic Circuits• They are characterized by:-

• No memory

• Input appears at output when switched on

• Have no feedback (no output connected to input)

• They include:-• Adder

• Subtractor

• Encoder

• Decoder

• Multiplexer

• De-multiplexer

• Comparator

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 21: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Programmable Logic Devices (PLD)• They are devices that can be programmed using either electricity or ultra

violet (UV) light.

• Constructed using an AND or OR arrays matrices. There are three types• Programmable ROM (PROM)

• Programmable Array logic (PAL)

• Programmable Logic Array (PLA)

• General Format

AND

Array

OR

Array

AND OR

O/P I/P Array AND OR

PROM Fixed Programmable

PAL programmable Fixed

PLA programmable Programmable

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 22: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

SEQUENTIAL LOGIC CIRCUITS• A logic circuit whose output depends on the present inputs and past

outputs

• Made of combinational logic circuits and memory elements

• Have feedback

• Can store a 1 or a 0

• Mostly they have two outputs complementing each other ie Q and Q’

• Organization

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 23: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Devices • Flipflops

• Registers

• Counters

• Types of Flip Flops• RS Flip Flop –reset set

• JK Flip Flop- jump kill

• D Flip Flop-data latch

• T Flip Flop-toggle

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 24: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

EXAMPLES OF DIGITAL SYSTEMS• There are a number of digital systems examples which include;

• Computers

• Microcontrollers

• Mobile phones

• Tablets

• Satellites

• Routers among many others

Page 25: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

MICROCONTROLLERS• Microcontroller is defined as a specialized computer-on-a-chip or a single-

chip computer.

• The word ‘micro’ suggests that the device is small, and the word ‘controller’ suggests that the device may be used to control one or more functions of objects, processes or events.

• It is also called an embedded controller as microcontrollers are often embedded in the device or system that they control.

• The microcontroller contains a simplified processor, some memory (RAM and ROM), I/O ports and peripheral devices such as counters/timers, analogue-to-digital converters, etc., all integrated on a single chip.

• It is this feature of the processor and peripheral components available on a single chip that distinguishes it from a microprocessor-based system.

• A microprocessor is nothing but a processing unit with some general-purpose registers.

IST 3040 : Inside the Microcontrollers: Omae M. Oteri

Page 26: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

MICROCONTROLLERS cont…• A microprocessor-based system also has RAM, ROM, I/O ports and

other peripheral devices to make it a complete functional unit, but all these components are external to the microprocessor chip.

• While a microprocessor-based system is a general-purpose system that may be programmed to do any of the large number of functions it is capable of doing, microcontrollers are dedicated to one task and run one specific program.

• This program is stored in ROM and generally does not change.

• Figures below further illustrates the basic difference between a microprocessor-based system and a microcontroller.

• As is evident from the two block schematics shown in the figure, while a microprocessor-based system needs additional chips to make it a functional unit, in a microcontroller the functions of all these additional chips are integrated on the same chip.

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 27: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Microprocessor and microcontroller

Page 28: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Applications• Microcontrollers are embedded inside a surprisingly large number of product

categories including automobiles, entertainment and consumer products, test and measurement equipment and desktop computers, to name some prominent ones.

• Any device or system that measures, stores, controls, calculates or displays information is sure to have an embedded microcontroller as a part of the device or system. In automobiles, one or more microcontrollers may be used for engine control, car cruise control, antilock brakes and so on.

• Test and measurement equipment such as signal generators, multimeters, frequency counters, oscilloscopes, etc., make use of microcontrollers to add features such as the ability to store measurements, to display messages and waveforms and to create and store user routines.

• In desktop computers, microcontrollers are used in peripheral devices such as keyboards, printers, modems, etc.

• Consumer and entertainment products such as TVs, video recorders, camcorders, microwave ovens, washing machines, telephones with caller ID facility, cellular phones, air conditioners, refrigerators and many more products make extensive use of microcontrollers to add new control and functional features.

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 29: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

INSIDE THE MICROCONTROLLER• Figure below shows the block schematic arrangement of various

components of a microcontroller.

• As outlined earlier, a microcontroller is an integrated chip with an on-chip CPU, memory, I/O ports and some peripheral devices to make a complete functional unit.

• A typical microcontroller as depicted in the figure below has the following components:

• a central processing unit (CPU),

• a random access memory (RAM),

• a read only memory (ROM),

• special-function registers and peripheral components including serial and/or parallel ports, timers and counters, analogue-to-digital (A/D) converters and digital-to-analogue (D/A) converters.

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 30: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Microcontroller

Page 31: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Central Processing Unit (CPU)• The central processing unit processes the program. It executes the

instructions stored in the program

• memory pointed to by the program counter in synchronization with the clock signal. The processor

• complexity could vary from simple eight-bit processors to sophisticated 32-bit or even 64-bit processors.

• Some common microcontrollers using eight-bit processors include 68HC11

• Examples of microcontrollers using 16-bit processors include the 8096 family (Intel), 68HC12 and 68HC16

• Examples of microcontrollers using 32- bit processors include 683XX, MPC 860 (PowerQUICC)

BBT 3102 : Chapter 3: Computer Hardware Basics: Omae M. Oteri

Page 32: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Random Access Memory (RAM)• RAM is used to hold intermediate results and other temporary data

during the execution of the program.

• Typically, microcontrollers have a few hundreds of bytes of RAM.

• As an example, microcontroller type numbers 8XC51/80C31, 8XC52/80C32 and 68HC12 respectively have 128, 256 and 1024 bytes of RAM.

IST 3040 : Inside the Microcontrollers: Omae M. Oteri

Page 33: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Read Only Memory (ROM)• ROM holds the program instructions and the constant data.

• Microcontrollers use one or more of the following memory types for this purpose: ROM (mask-programmed ROM), PROM (one-time programmable ROM, which is not field programmable), EPROM (field programmable and usually UV erasable), EEPROM (field programmable, electrically erasable, byte erasable) and flash (similar to EEPROM technology).

• Microcontroller type numbers 8XC51, 8XC51FA and 8XC52 have 4K, 8K and 16K of ROM.

• As another example, the 68HC12 16-bit microcontroller has 32K of flash EEPROM, 768 bytes of EEPROM and 2K of erase-protected boot block.

Page 34: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Special-Function Registers• Special-function registers control various functions of a microcontroller.

• There are two categories of these registers.

• The first type includes those registers that are wired into the CPU and do not necessarily form part of addressable memory.

• These registers are used to control program flow and arithmetic functions.

• Examples include status register, program counter, stack pointer, etc.

• These registers are, however, taken care of by compilers of high-level languages, and therefore programmers of high-level languages such as C, Pascal, etc., do not need to worry about them.

• The other category of registers is the one that is required by peripheral components.

• The contents of these registers could, for instance, set a timer or enable serial communication and so on.

Page 35: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Peripheral Components• Peripheral components such as analogue-to-digital converters, I/O

ports, timers and counters, etc., are available on the majority of microcontrollers.

• These components perform functions as suggested by their respective names.

• In addition to these, microcontrollers intended for some specific or relatively more complex functions come with many more on-chip peripherals.

• Some of the common ones include the pulse width modulator, serial communication interface (SCI), serial peripheral interface (SPI), interintegrated circuit (I2C) two-wire communication interface, RS 232 (UART) port, infrared port (IrDA), USB port, controller area network (CAN) and local interconnect network (LIN).

Page 36: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Analogue-to-Digital Converters• Analogue-to-digital and digital-to-analogue converters provide an

interface with analogue devices.

• For example, the analogue-to-digital converter provides an interface between the microcontroller and the sensors that produce analogue electrical equivalents of the actual physical parameters to be controlled.

• The digital-to-analogue converter, on the other hand, provides an interface between the microcontroller and the actuators that provide the control function.

• The digital-to-analogue converter function in microcontrollers is provided by a combination of pulse width modulator (PWM) followed by a filter.

Page 37: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

I/O Ports• I/O ports provide an interface between the microcontroller and the

peripheral I/O devices such as the keyboard, display, etc.

• The 80C51 family of microcontrollers has four eight-bit I/O ports.

• Microcontroller 68HC11 offers 38 general-purpose I/O pins including 16 bidirectional I/O pins, 11 input-only pins and 11 output-only pins.

Page 38: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Counters/Timers• Counters/timers usually perform the following three functions.

• They are used to keep time and/or measure the time interval between events, count the number of events and generate baud rates for the serial ports.

Page 39: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Types of Microcontrollers• Arduino

• Raspberry Pi

Page 40: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO MICROCONTROLLERINTERFACING PERIPHERAL DEVICES WITH ARDUINO

• This section briefly describes the interfacing of some common external peripheral devices with the microcontroller.

• The peripheral devices discussed in this section include LEDs, Button switches, buzzers, microphones, LDRs and many others.

IST 3040 : Interfacing Peripheral Devices to Microcontrollers: Omae M. Oteri

Page 41: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

INTERFACING LEDS• The commonly used configuration to connect an LED to a microcontroller is

shown in Fig. below. • The LED glows when the microcontroller pin is driven LOW and is OFF when

the pin is set HIGH. • The LEDs are connected in this fashion as the current-sinking capability of

microcontrollers is of the order of a few tens of milliamperes and the current-sourcing capability is of the order of microamperes.

• The resistor is used to limit the current through the LED.• The value of the resistance is chosen according to the equation• where VLED is the voltage across the LED and I is the current.• Typical values of VLED and I are 1.5 V and 20 mA respectively.

• If the current-sourcing capability of the microcontroller is sufficient to drive the LED directly, then the LED is connected to the directly without a resistor

• The LED in this case glows when the microcontroller pin is set HIGH.

Page 42: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Circuit diagrams

Page 43: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

How to connect• With a wire, connect ground from the Arduino (labeled GND) to the

bottom row of the farthest right column of the bread board.

• With a wire, connect power from where it says 5V (the V stands for voltage and this is where the electric power comes from.) on the Arduino to the bottom row of the next to right column.

• Connect the resistor with one end 5V and the other to the longer pin of the LED.

• Connect the LED cathode (shorter leg) to ground.

• The LED should light up.

Page 44: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Program structure

• setup() which is called once when the program starts is the preparation.

• Used to set pinMode or initialize serial communication.

• loop() which is called repetitively over and over again as long as the Arduino has power is the execution state.

• Used for Reading inputs and triggering outputs

Page 45: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

LED Program • // the setup function runs once when you press reset or power the board

• void setup() {

• // initialize digital pin 13 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

• }

Page 46: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

LED1 ONCE LED2 ONCE Program • // the setup function runs once when you press reset or power the board

• void setup() {

• // initialize digital pin 13 as an output.

• // initialize digital pin 12 as an output.

• pinMode(13, OUTPUT);

• pinMode(12, 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

• digitalWrite(12, HIGH); // turn the LED1 on (HIGH is the voltage level)

• delay(1000); // wait for a second

• digitalWrite(12, LOW); // turn the LED1 off by making the voltage LOW

• delay(1000); // wait for a second

• }

Page 47: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

LED1 TWICE LED2 ONCE Program • // the setup function runs once when you press reset or power the board

• void setup() {

• // initialize digital pin 13 as an output.

• // initialize digital pin 12 as an output.

• pinMode(13, OUTPUT);

• pinMode(12, 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

• 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

• digitalWrite(12, HIGH); // turn the LED1 on (HIGH is the voltage level)

• delay(1000); // wait for a second

• digitalWrite(12, LOW); // turn the LED1 off by making the voltage LOW

• delay(1000); // wait for a second

• }

Page 48: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

LED1 and LED2 at same time Program • // the setup function runs once when you press reset or power the board

• void setup() {

• // initialize digital pin 13 as an output.

• // initialize digital pin 12 as an output.

• pinMode(13, OUTPUT);

• pinMode(12, OUTPUT);

• }

• // the loop function runs over and over again forever

• void loop() {

• digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

• digitalWrite(12, HIGH); // turn the LED1 on (HIGH is the voltage level)

• delay(1000); // wait for a second

• digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

• digitalWrite(12, HIGH); // turn the LED1 on (HIGH is the voltage level)

• delay(1000); // wait for a second

• }

Page 49: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the button switch• DIAGRAM

IST 3040 : Interfacing the button switch: Omae M. Oteri

Page 50: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect one pin of the pushbutton to ground and the other to 2 on

the Arduino board.

• Connect the LED according to the steps under LED interfacing

• Load the program below and test

Page 51: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO SKETCH• Using button switch

• // the setup function runs once when you press reset or power the board

• void setup() {

• // initialize digital pin 13 as an output.

• pinMode(13, OUTPUT);

• pinMode(2, INPUT);

• }

• // the loop function runs over and over again forever

• void loop() {

• if (digitalRead(2)==HIGH)

• {

• digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)

• }else {digitalWrite(13, LOW);}

• }

Page 52: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the LDR• DIAGRAM

IST 3040 Interfacing the LDR: Omae M. Oteri

Page 53: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect one pin of the 10kΩ (brown, black, orange) resistor to 5V.

• Connect one pin of LDR to the other of the resistor.

• Connect the other LDR pin to the ground.

• Connect a wire from the point where the LDR and the resistor pins are connected together to the analogue input A0 on the Arduino board.

• The LDR we are using acts like a potentiometer that has lower resistance the more light it sees.

• This is not a high precision instrument that measures exactly how much light there is.

• But it can be used to know whether a light is on in a room.

• You could also put it inside a drawer and know when it is opened.

Page 54: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO CODE• // the setup routine runs once when you press reset:

• void setup() {

• // initialize serial communication at 9600 bits per second:

• pinMode(A0,INPUT);

• pinMode(13,OUTPUT);

• Serial.begin(9600);

• }

• // the loop routine runs over and over again forever:

• void loop() {

• // read the input on analog pin 0:

• int sensorValue = analogRead(A0);

• // print out the value you read:

• Serial.println(sensorValue);

• delay(400); // delay in between reads for stability

• if (sensorValue > 50) { //bright

• digitalWrite(13, HIGH);}

• else {digitalWrite(13, LOW);} //dim

• }

Page 55: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Looping and arrays• Using For

• int a[]={10, 11, 12, 13}

• void setup() {

• // put your setup code here, to run once:

• for (int i=0; i<4; i++){

• pinMode(a[i], OUTPUT);

• }

• }

• void loop() {

• // put your main code here, to run repeatedly:

• for (int i=0; i<4; i++){

• digitalWrite(a[i], HIGH);

• delay(500);

• digitalWrite(a[i], LOW);

• delay(500);

• }

• }

Page 56: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Using While• int a[]={10, 11, 12, 13}

• void setup() {

• // put your setup code here, to run once:

• int i=0;

• while (i<4){

• pinMode(a[i], OUTPUT);

• i++;

• }

• }

• void loop() {

• // put your main code here, to run repeatedly:

• int i=0;

• while (i<4){

• digitalWrite(a[i], HIGH);

• delay(500);

• digitalWrite(a[i], LOW);

• delay(500);

• i++;

• }

• }

Page 57: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Using do While• int a[]={10, 11, 12, 13}

• void setup() {

• // put your setup code here, to run once:

• int i=0;

• do

• {

• pinMode(a[i], OUTPUT);

• i++;

• }

• while (i<4);

• }

• void loop() {

• // put your main code here, to run repeatedly:

• int i=0;

• do

• {

• digitalWrite(a[i], HIGH);

• delay(500);

• digitalWrite(a[i], LOW);

• delay(500);

• i++;

• }

• while (i<4);

• }

Page 58: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the POTENTIOMETER• DIAGRAM

IST Interfacing the POTENTIOMETER: Omae M. Oteri

Page 59: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect one end pin of the potentiometer to 5V and the other end to

the ground on Arduino board.

• Connect a wire from the middle pin to the A0 pin (Analog in 0) on the Arduino.

Page 60: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO CODE• void setup() {• // put your setup code here, to run once:• pinMode(A0,INPUT);• pinMode(13,OUTPUT);• Serial.begin(9600);• }•

• void loop() {• // put your main code here, to run repeatedly:• int sensorvalue=analogRead(A0);• Serial.println(sensorvalue);• delay(500);• analogWrite(13,sensorvalue);• }

Page 61: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the TEMPERATURE SENSOR• DIAGRAM

IST 3040 Interfacing the TEMPERATURE SENSOR: Omae M. Oteri

Page 62: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Temperature sensor (LM35) has 3 terminals.

• With the flat side facing up connect the right terminal to 5V and the left to the ground of the Arduino board.

• Connect the middle terminal to the analogue input A0.

Page 63: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO CODE• // the setup routine runs once when you press reset:

• void setup() {

• // initialize serial communication at 9600 bits per second:

• pinMode(A0,INPUT);

• pinMode(13,OUTPUT);

• Serial.begin(9600);

• }

• // the loop routine runs over and over again forever:

• void loop() {

• // read the input on analog pin 0:

• int sensorValue = analogRead(A0);

• // print out the value you read:

• Serial.println(sensorValue);

• delay(400); // delay in between reads for stability

• if (sensorValue > 50) { //cold

• digitalWrite(13, HIGH);}

• else {digitalWrite(13, LOW);}

• }

Page 64: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the ULTRSONIC SENSOR• DIAGRAM

Page 65: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Pinout of HC-SR04 Ultrasonic module

• Name Description

• Vcc +5V

• Trig Trigger (input) digital pin 12

• Echo Echo (output) digital pin 11

• GND GND

Page 66: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO CODE• #define echo 11 // Echo Pin

• #define trig 12 // Trigger Pin

• long travel_time, distance; // Duration used to calculate distance

• void setup() {

• Serial.begin (9600);

• pinMode(trig, OUTPUT);

• pinMode(echo, INPUT);

• }

• void loop() {

• digitalWrite(trig, LOW);

• delayMicroseconds(2);

Page 67: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Arduino code cont…• //Sending a high pulse to trigger the Ultrasound Module• digitalWrite(trig, HIGH);• delayMicroseconds(10); • digitalWrite(trig, LOW);• travel_time = pulseIn(echo, HIGH);• //Calculating the distance• distance = (travel_time*0.034)/2;• // Sending the distance to computer • Serial.println(distance);• //Delay for next reading.• delay(30);• }

Page 68: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the BUZZER• DIAGRAM

IST 3040 Interfacing the BUZZER: Omae M. Oteri

Page 69: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect the longer pin of the buzzer to pin 13 of the Arduino board

• Connect the shorter pin to the ground

Page 70: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO CODE• void setup() {

• // put your setup code here, to run once:

• pinMode(13,OUTPUT);

• }

• void loop() {

• // put your main code here, to run repeatedly:

• digitalWrite(13, HIGH); // turn the buzzer on (HIGH is the voltage level)

• delay(1000); // wait for a second

• digitalWrite(13, LOW); // turn the buzzer off by making the voltage LOW

• delay(1000); // wait for a second

• }

Page 71: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

WITH TONE• void setup() {

• // put your setup code here, to run once:

• pinMode(13,OUTPUT);

• }

• void loop() {

• // put your main code here, to run repeatedly:

• tone(13, 5000); // turn the buzzer on (HIGH is the voltage level)

• delay(1000); // wait for a second

• noTone(13); // turn the buzzer off by making the voltage LOW

• delay(1000); // wait for a second

• }

Page 72: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the SERVO MOTOR• DIAGRAM

IST 3040 Interfacing the SERVO MOTOR: Omae M. Oteri

Page 73: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect the red wire of the motor to 5V of the Arduino board

• Connect the black wire to the ground

• Connect the yellow wire to PWM input 9

• Also connect the potentiometer according to the steps under potentiometer interfacing

Page 74: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO CODE• #include <Servo.h> • Servo servo1; • const int kPinPot = A0; • const int kPinServo1 = 9; • void setup() 9 { • servo1.attach(kPinServo1); • } • void loop() • { • int val = analogRead(kPinPot); • val = map(val, 0, 1023, 0, 180); • servo1.write(val); • delay(15); • }

Page 75: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

Interfacing the MICROPHONE• DIAGRAM

IST 3040 Interfacing the BUZZER: Omae M. Oteri

Page 76: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect one pin of the 10kΩ (brown, black, orange) resistor to 5V.

• Connect one pin of the microphone to the other of the resistor.

• Connect the other microphone pin to the ground.

• Connect a wire from the point where the microphone and the resistor pins are connected together to the analogue input A0 on the Arduino board.

Page 77: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

ARDUINO CODE• // the setup routine runs once when you press reset:

• void setup() {

• // initialize serial communication at 9600 bits per second:

• pinMode(A0,INPUT);

• pinMode(13,OUTPUT);

• Serial.begin(9600);

• }

• // the loop routine runs over and over again forever:

• void loop() {

• // read the input on analog pin 0:

• int sensorValue = analogRead(A0);

• // print out the value you read:

• Serial.println(sensorValue);

• delay(400); // delay in between reads for stability

• if (sensorValue > 50) { //bright

• digitalWrite(13, HIGH);}

• else {digitalWrite(13, LOW);} //dim

• }

Page 78: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

BUZZER TO MICROPHONE• DIAGRAM

IST 3040 Interfacing the BUZZER: Omae M. Oteri

Page 79: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect the buzzer according to the steps under buzzer interfacing

• Connect the microphone according to the connections under microphone interfacing

• Load the relevant programs to the Arduino boards and test

Page 80: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

LED TO LDR• DIAGRAM

IST 3040 Interfacing the LDR: Omae M. Oteri

Page 81: ARDUINO PROJECTSoomaelecturer.com/wp-content/uploads/edd/Introductio… ·  · 2018-01-04ARDUINO PROJECTS INTRODUCTION •Digital electronics: A field of science which deals with

CONNECTING STEPS• Connect the LDR according to the steps under LDR interfacing

• Connect the LED according to the connections under LED interfacing

• Load the relevant programs to the Arduino boards and test