Vous êtes sur la page 1sur 23

CPE006 - Using Arduino

Technological Institute of the Philippines Manila


Computer Engineering Department
Analog Signal, Serial Monitor,
LCD and Sensor
Review of the last topic
• Arduino Hardware
• Ports and Pins
• Major Parts, i.e: USB Port, AREF…
• Arduino IDE
• Edit Sketch
• Menu and Tool Bar
• Digital I/O Devices
• Buzzer and Keypad Control
• Simple Electronic Organ
• Music Player
Review of the last topic cont…
Arduino Libraries:
Arduino Port Declaration
pinMode(pinNo,INPUT/OUTPUT);
Ex: pinMode(13,OUTPUT);

Entire Port Addressing:


Ex: DDRD = B10101010; Individual Pin Output:
Individual Input:
Where 1: Output digitalWrite(pinNo,HIGH/LOW);
0: Input if(digitalRead(pinNo)==HIGH/LOW);
Ex: digitalWrite(13,HIGH); Ex: digitalRead(13)==HIGH);

Entire Port Addressing:


PORTNAME = B00000000;
Ex: PORTB = B10101010;
Review: Conditional & Looping Statements
Digital Signal
Digital signal are the electrical signal
that is converted into a discretized value
from the continuous signal. They have a
finite set of possible values. The number
of values in the set can be between two
and real non infinity numbers. They
either 1 or 0, ON or OFF and +5v or 0v.
Timing graphs of these signals look like
square waves.
Analog Signal
• An analog signal is a kind of signal that is continuously variable,
as opposed to having a limited number of steps along its range
(called digital). Meaning for every value in time there is
corresponding value of signal.
S = 100

t=0.8
t=0.4

S = -100
Analog Signal are everywhere
• Temperature readings
• Pressure
• Humidity
• Wind Speed
• Noise/Speech/Sounds
• etc
Arduino Analog Input
• Arduino has a building Analog port
• Analog port (PORTC) has 5 pins (A0-A5) which can also be
used as digital input if needed.
AnalogRead()
• Reads the value from the specified analog pin and convert to 10-bit
digital value.
• Analog input obtained from this port are automatically mapped into 10bits
value, 0-1023. That means that it yields to 5 volts / 1024 units or, .0049 volts
(4.9 mV) per unit.
Arduino Serial Monitor
• Like the HyperTerminal in Windows XP,
Arduino Serial Monitor allows you to
manipulate the Arduino board under the
windows environment.
• During the sketch uploading, the Arduino
Uno is connected to your computer using
Universal Asynchronous
Receiver/Transmitter (UART) and UART to
USB Bridge chip.
• Serial Monitor connects to your Arduino
over the same serial port (com).
In this Activity:
• Potentiometer
• Joystick
• Liquid Crystal Display
• Temperature Sensor
• Humidity Sensor
Potentiometer
2 General Types of Potentiometer
1. Rotary Type
2. Slide Type

Configurations
Coding the Potentiometer
Joystick A joystick is a hand switch actuated by a lever free
to move in more than one axis of motion. One or
more several switch contact mechanisms are
actuated depending on which way the lever is
pushed, and sometimes by how far it is pushed

MTS-100 Joystick Configuration


Coding the JoyStick
Coding the Joy Stick
Liquid Crystal Display (LCD)
• Liquid Crystal Display (LCD) contains
rows that can display several characters.
Each character is displayed using 5×8 or
5×10 dot matrix. It Is easy to use
module that can be interface for most
of the microcontrollers available in the
market including the Arduino.
• A 16x2 LCD means it can display 16
characters per line and there are 2 such
lines. In this LCD each character is
displayed in 5x7 pixel matrix.
LCD Pins
• A register select (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 a register when you write, or the
values you're reading when you read.
• There's also a display constrast 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.
I2C Module for LCD
This is an 16x2 LCD display screen with with I2C
interface. This I2C 16x2 Arduino LCD Screen is
using an I2C communication interface. It means it
only needs 4 pins for the LCD display: VCC, GND,
SDA, SCL. It will saves at least 4 digital / analog
pins on Arduino
Coding the 2
IC LCD
Coding the 2
IC LCD
End of Slides

Vous aimerez peut-être aussi