0% found this document useful (0 votes)
3 views57 pages

Arduino

Arduino is an open-source electronics prototyping platform that combines hardware and software for creating interactive projects. It is not a microcontroller, programming language, or company, but rather a movement founded in 2005. The platform is designed to be user-friendly and is supported by a large community, making it accessible for artists, designers, and hobbyists.

Uploaded by

2401akpandeyxi4
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)
3 views57 pages

Arduino

Arduino is an open-source electronics prototyping platform that combines hardware and software for creating interactive projects. It is not a microcontroller, programming language, or company, but rather a movement founded in 2005. The platform is designed to be user-friendly and is supported by a large community, making it accessible for artists, designers, and hobbyists.

Uploaded by

2401akpandeyxi4
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

What is Arduino Not?

» Itis not a chip (IC)


» Itis not a board (PCB)
» It is not a company or a manufacturer
» Itis not a programming language
» It is not a computer architecture

(although it involves all of these things...)

Official Definition: 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.
So, What is Arduino?
» It’s a movement, not a microcontroller
» Founded by Massimo Banzi and David Cuartielles in 2005 based on
“Wiring Platform™, which dates to 2003
» Open-source hardware platform
» Open source development environment

» Easy-to learn language and T e o . g


libraries (based on Wiring ing A community
. A phzsncal
piece
envnronment &phllosophy
e
» Integrated development
environment (based on
Processing programming
environment)
» Available for Windows /
Mac/ Linux
Why Arduino?
For whatever reason, Arduino microcontrollers have
become the de facto standard
Strives for the balance between ease of use and
usefulness
1. Programming languages seen as major
obstacle
2. Arduino C is a greatly simplified version of
C++
It is an open-source project, software/hardware is
extremely accessible and very flexible to be
customized and extended
Arduino is backed up by a growing online
community, lots of source code is already available
Arduino!
and we can share and post our examples for others to
use, too!
> It is inexpensive and comes with free authoring
software ARDUINO
Original [Link] Manufactured Arduino Uno: 2,400.00 OPEN-SOURCE
COMMUNITY
Electrical & Code compatible Arduino Uno Clone: ¥ 500.00
Resistor
» A resistor is a passive two-terminal electrical component that
implements electrical resistance as a circuit element.
» In electronic circuits, resistors are used to reduce current flow,
adjust signal levels, to divide voltages, bias active elements, and
terminate transmission lines, among other uses.
4-Bang-Code
2%, 5%, 10% 560k 0 5%

Black
Brown

0.1%, 0.25%, 0.5%, 1% -


5-Bang-Code
Breadboard
» A breadboard is a solder-less device for
temporary prototype with electronics and test
circuit designs.
» Because the solder-less breadboard does not
require soldering, it is reusable.
» This makes it easy to use for creating
temporary prototypes and experimenting with
circuit design.
All holes in the selected row ase internally conmected
| Analog & Digital Signals
" Whatis analog ? Analog Signal
» Itis continuous range of voltage
values (not just 0 or 5V)
» Analog has many (infinite) values

Why convert to digital ?


» Because our microcontroller only
understands digital.
» Digital has two values: on and off
Arduino Uno & Its Parts
Voltage 16MH2z ATmegalsu2
regulator crystal microcontroller IC/USB controlier
7 to 12VDC input
2.1mm x 5.5mm USB-B port
Male center positive to computer

Reset button

ICSP for
USB interface

(12C) SCL ~ Serial clock


(12C) SOA ~ Serial data

- Pin-13 LED
-

. (SPI) SCK - Serial clock


o R-lm ita e
- (SP1) MISO ~ Master-in, slave-out
S— wkc:
.
3.3V Output > (SP1) MOSI - Master-out, slave-in
g (SP1) SS ~ Slave select
: SV Output
Ground - ;

g0 o Note: Pins denoted with “~~


Input ol
voltage 3 s are PWM supported
B5 . a
Analog pin 0 § g
1 - =
Anal
An-:: :: 2 v - Interrupt 1
5 = ?, Interrupt 2
Anaing pie. 3 . ~ ™o
(12C) SDA
- RXD
(12C) scL

ATmegal2s
RESET
microcontroller IC
1CSP for Scx
ATmega328 MISO
ATMega328P Microcontroller
ATmega328P pin mapping
OO Arduino function Arduino function OO
reset PC6 1 w PCS analog input 5

digital pin 0 EXB PO 2 n PCA analog input 4

digital pin | ¢EEB PD1 3 % PC3 analog input 3


CPU Speed: 20MHz
digital pin 2 PD2 s P2 analog input 2
RAM: 2KB
digital pin 3 @D PD3 & n Q1 analog input 1

digital pin 4 PDA ¢ n PCO analog input 0


Storage: 32KB
vCcc vce 2 GND GND Program Memory
GND GND » 1 AREF analog reference

crystal PB6E 9 1 AVCC AVCC 1/0: Up to 23 Generic


crystal PB7T ®» 1 digital pin 13 1/0O, 6 are Analog
digital pin S @ PD5 u w PB4 D digital pin 12
Capable, UART/ 12C /
SPI
digital pin 6 (D PD6 n v PB3 u @ digital pin 11
digital pin 7 D7 B % PB2 §§! : @ digital pin 10
digital pin 8 PBO s PBl g ; @ digital pin 9
]
ATMega328p Specifications
Microcontroller Atmel ATmega328
Operating Voltage (logic level) | Sv
Input Voltage (recommended) | 7v-12v
Input Voltage (limits) 6v-20v
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 8
DC Current per 1/O Pin 40mA
Flash Memory | 32 KB of which 2 KB used by bootloader
SRAM 2KB
EEPROM 1KB
Clock Speed 16MHz
Dimensions 0.73" x 1.70"
Length 45 mm
Width 18 mm
Weight 5¢g
Microcontroller (nC, MCU)
Computer on a single Integrated Chip
» Processor (CPU)
» Memory (RAM / ROM / Flash)
» 1/0 ports (USB, 12C, SPI, ADC)

Common microcontroller families:


~ Intel: 4004, 8008, etc.
» Atmel: AT and AVR
» Microchip: PIC
» ARM: (multiple manufacturers) p smm
s
tel
intel)
Used in:
Cell Phones, Toys, Household Appliances, Cars, Cameras, etc. m
Embedded System
Embedded System
» An embedded system is a combination of computer hardware and software,
either fixed in capability or programmable, designed for a specific function or
functions within a larger system.
» Industrial machines, agricultural and process industry devices, automobiles,
medical equipment, household appliances, vending machines and toys, as well
as mobile devices, are possible locations for an embedded system.
User ln'.duc.l

{-El Industal Robots GPSRecevess Digtal Cameros


DVD Poyers

el Embedded Sysfems
Wreless Routen QW3 rioyer

' .

Set top Bowes Camq(,omoes Pholocopers Mcrcmovc


Ovv_m
Boot Loader
What's a boot loader?
Microcontrollers are usually programmed through
a programmer unless you have a piece of firmware in your
microcontroller that allows installing new firmware without
the need of an external programmer. This is called a boot
loader.
Ao fomenad
1\ okt
e 2k e A8
e 8 ok
v it et ek v iTindt
gy D18 e
Ahme (W1 Al ]W o
PR it endi B o) qah_techd
R gt Sk e 08 o AR A
Sty MDA Al
el W cock
oo ) ee Sowd ’ Yot '
e . il jommd B SePot L foa bt '
9 Maels Preyimeme DR Ingee '
- b e R besteste . -
o fectende oot Suamimere v Almep e

acture Deomia r Daeminos Uty


edne Vg w ATl Paskdl

et gl
edane Vg 161 0 Mege X
¢ iia®
Communication: 12C, SPI

1. 12C (Inter-Integrated Circuit) T


> Speed = 100 kHz, 400 kHz, and 3.4 3
MHz (not supported by Arduino) % C L
> Two bi-directional lines: SDA & ' |
SCL device | |device | device
» Multiple slaves can share same bus L] LR 8

2. SPI (Serial Peripheral Interface Bus)


» Speed = 1-100 MHz (clock/device
limited)
» Four-wire bus: SCLK, MOSI, MISO &
SS
» Multiple slaves can share same bus (but
each needs a dedicated SS, slave select)
PWM & Duty Cycle

controlling the amplitude of digital signals in


order to control devices and applications
requiring power or electricity.
» Duty cycle = Pulse Width / Wave Period
Pulse Width Modulation
0% Duty Cycle - analogWrite(0)

. & § 1 § &
Sv

Ov
25% Dury Cycle - analogWrite(64)

M i
Sv

Oov
50% Duty Cycle - analogWrite(127)
Sv

Oov

75% Duty Cycle - analogWrite(191)


Sv

Ov

100% Duty Cycle - analogWrite(255)

[
Sv

Ov
Different Arduino Boards

» Arduino Uno
» Arduino Leonardo
» Arduino LilyPad
» Arduino Mega
» Arduino Nano
» Arduino Mini
» Arduino Mini Pro
» Arduino BT
» Arduino Due
Different Arduino Shields

» TFT Touch Screen


Wy

» Data Logger ot

»,
-

» Motor/Servo Shield
e

» Ethernet Shield e s

» Audio Wave Shield


» Cellular/GSM Shield
» Wifi Shield
» Proto-shield, etc.
Getting Started with Arduino
Download Arduino compiler and development environment from:
[Link]

» Current version: 1.8.10


» Available for Windows, Mac OS X & Linux
» Downloadable as Installer & Zip File
» Before running Arduino, plug in your board using USB cable (external power
is not necessary)
» When USB device is not recognized, navigate to and select the appropriate
driver from the installation directory
» Run Arduino
Arduino IDE
(Integrated Development Environment)

Verify

o Sy
Upload
New
Open
Save

B R
Serial Monitor
Sketch Name
Code Area
Message Area
Text Console

-
Board & Serial Port

=
Setting Up of Arduino IDE
Step 1
Settings: Tools = Board - Arduino Uno » The computer
communicates
e sketchjun17a | Arduino 105, ATomeS (etemal 20 Mt dock) ;
T ATy itemal 1 Mz lock to the Arduino
ATtiny44 (internal 8 MHz clock)
mfi i St H
n?lcrocoqtrloller
e ATtiny34 (intemal 1 MHz clock) via a serial port
‘ ATtiny4 Gesmal 8 iz cock through a USB-
o SN o ot 20 M cock) .
o Serial adapter.
T L Adino w/ ATmega28
R —— Arduino Diecimila or Duemdanove w/ ATmega 168
Serl Pot [ B » Check to make
Programmer Y Auduino
Nano w/ ATmega1é3 sure that the
Bum Bootloader Arduino Mega 2560 or Mega ADK dl'ivers are
Arduine
Mega (ATmega1280)
Asduine Lecnardo Pmperly
Arduino Esplora installed.
Step 2
Settings: Tools = Settings: Tools - Serial Port > COM#(Arduino Uno)
=00———
Arduino Sketch Structure
@ sketch_nov29s
[ Arduino 106 =
File Edit Sketch Tools Help

P “ void setup()
Will be executed only when
the program begins (or reset
e button is pressed)

void loop()
Will be executed repeatedly
Arduino Program Development

» Based on C++ without 80% of %


the instructions.
» A handful of new commands. ARDUINO
» Programs are called 'sketches'.
» Sketches need two functions:
» void setup( )
» void loop( )
» setup( ) runs first and once. CE
» loop( ) runs over and over,
until power is lost or a new - o L -]
sketch is loaded. o l . ‘ . } |
Important Functions
~ pinMode(pin, mode)
Designates the specified pin for input or output
» digitalWrite(pin, value)
Sends a voltage level to the designated pin
~ digitalRead(pin)
Reads the current voltage level from the designated pin
~ analogWrite(pin, value)
Sends analog voltage of the range 0 to 1023 to the designated pin
» digitalRead(pin)
Reads the current analog voltage of the range 0 to 1023 from the designated
pin
» delay(delaytime)
pauses the execution of the program for the given amount of time
» Serial Commands
print(), printin(), write(), read(), begin(), end(), find()
Variables
» A variable is a way of naming and storing a value for later use by the
program, such as data from a sensor or an intermediate value used in a
calculation.
Declaration
» Before they are used, all variables have to be declared. Declaring a variable
means defining its type, and optionally, setting an initial value (initializing
the variable). Variables do not have to be initialized (assigned a value)
when they are declared, but it is often useful.

Cchar 1 o
Cint 2 -32768 767 i

long 4 204TAB48 24647 byee int tong


; unsignedlong 4 0 m char unsigned int unsigned long
Conditions
If
Statement: If a certain condition is true, the While Loop executes a set of statements until the
set of statements enclosed in curly braces are expression inside the parentheses is false
executed. If the condition is false, then the set of while (some variable ?? value){
statements are skipped during the execution. /
iftsome variable ?? state){
/ Do While Loop executes a set of statements once
and repeatedly execute the set if a certain condition
If
Statement
Else makes an “either-or decision. is true.
The if statements checks a condition. If it is true, dof
it executes a set of statements; if the condition is [} while (some variable ?? value);
not true, it executes other set of statements under
else. Switch
Case Statement allows to execute one
if (some variable ?? state){ code block among many alternatives.
/ switch (expression)
else| !
/ case I:
// statements
For Loop: If you want to repeatedly execute a set break;
of statements for a specific number of times, then case 2:
you can use a for loop. // statements
JSor(initialization; condition; expression){ break;
/ default: // default statements
/
Basic IDE Code

(Baslc blinking LED \

int ledPin = 13;


Variable to store the pin number
void setup()
{
pinMeode(ledPin, OUTPUT);
void setup() {
set ledPin as output /Pln No.

H pinMode(9, OUTRPUT);
Input or Output
void loop() 2
{ void loop() {
digitalWrite(ledPin, HIGH); Port # from setup
LED ON
delay(1000): //Wait 1000ms (=1s)
digitalWrite(9, HIGH);
digitalWrite(ledPin, LOW); delay(1000);
JLED OFI digitalWrite(9, LOW);
delay(1000); //Wait 1000ms (=1s) delay(1000); Turn the LED on
N or off
. 7 } Wait for 1 second
or 1000 milliseconds
Sensor
What is a sensor?
» A device that receives a stimulus and responds with an
electrical signal.
» A special type of transducer, device that converts one type of
energy into another
Physical quantities

2y W
Protein Bacteria
Common Sensors
» Mechanical
» Accelerometers
» Gyroscopes
» Optical
» Photo Detectors
» Infrared
» Semiconductor
» Gas
» Temperature
» Magnetic

Sensor Characteristics
» Range
» Accuracy
» Transfer Function
» Sensitivity
» Error
Actuators
» Device that turns energy (typically electrical) to motion.
» An actuator is a component of a machine that is responsible
for moving and controlling a mechanism or system, for
example by opening a valve. In simple terms, it is a "mover".
» An actuator requires a control signal and a source of energy.

Features:
» Force
» Speed
» Torque
» Power
» Efficiency
A “Q'.C‘,’

.y Activities Ty
eyvre——.

Activity 1 : Blinking & Fading an LED


What is LED?
» An LED lamp or LED light bulb is an electric light for use in light fixtures that
produces light using one or more light-emitting diodes (LEDs).
» LED lamps have a lifespan many times longer than equivalent incandescent lamps,
and are significantly more efficient than most fluorescent lamps.
» The main semiconductor materials used to manufacture LEDs are: InGaN, AlGalnP,
AlGaAs, GaP
Other Mobile Appliances

;E
Indicators, small dsplays
IIIummuon
amusement, misc. other

- Longlegg| | Lo
re .B
.Automotive - -
Signs and Displays

| . Al
Circuit Connections

D=
L o 4700
g z LED

I\

Ground (GNDY -
Code & Explanation
/*LED Blink Experiment */

int led =9; // LED anode is connected to Arduino Pin 9

void setup(){
pinMode(led, OUTPUT): // Initialize the digital pin as an output
|

// The loop routine runs over and over again forever:


void loop(){
digitalWrite(led,HIGH); // turn the LED on by making voltage HIGH
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Activity 2 : Potentiometer
Potentiometer
» A potentiometer is a three-terminal resistor with a sliding or rotating
contact that forms an adjustable voltage divider.
» If only two terminals are used, one end and the wiper, it acts as a variable
resistor or rheostat.

1 VVV 3
T Applications:
2
» Controllers
» Audio Systems
» Measuring Devices
» Tuners & Calibrators
Circuit Connections
Code & Explanation
/* Program to control LED by varying the pulse width */

int potPin = 2; // select input pin A2 for the pot


int ledPin = 13; // select output pin 13 for the LED
int val = 0; // variable to store pot voltage

void setup() {
pinMode(ledPin, OUTPUT); // declare ledPin13 as an
OUTPUT
}
void loop() {
val = analogRead(potPin); // read pot voltage as integer
digital Write(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
i
Activity 3 : Push Button Switch
Switch
» A switch is an electrical component that can "make" or "break" an
electrical circuit, interrupting the current or diverting it from one conductor
to another.
» The mechanism of a switch removes or restores the conducting path in a
circuit when it is operated.
» It may be operated manually, for example, a light switch or a keyboard
button, may be operated by a moving object such as a door, or may be
operated by some sensing element for pressure, temperature or flow.

J— -
Tt psaatly € e teed

S
e ity € oanneoing

tnresnally € cnnested

5 = @
P

Trte
s mabiy € e il
‘- ®, L.
19°0° 1) q onnnecrione
- Ui} - il >

|
il| LU
U
R B
I I )
Cre e LA
I B A
e |R A

| 0
L ) l.l%l&'ll'..l.

too’og‘"notooo
L 1 1 e R R
LU I L A R I
LR L
AR AR R RN R R AN
Code & Explanation
// Program for Push Button with LED void loop()
{
// set pin numbers: buttonState =
const int buttonPin = 7; // Pushbutton pin digitalRead(buttonPin);
const int ledPin = 9; /' LED pin // read the state of the pushbutton value

// variables will change: //if it is, the buttonState is HIGH:


int buttonState = 0; if (buttonState == HIGH) |{
// variable reads pushbutton status /I check if the pushbutton is pressed
digitalWrite(ledPin, HIGH);
void setup() { // turn LED on
pinMode(ledPin, OUTPUT): }
// initialize the LED pin as an output else
{
pinMode(buttonPin, INPUT); digitalWrite(ledPin, LOW); //turn
// initialize the pushbutton pin as an input ~ LED off
}
i |
Activity 3.1 : Interrupt
Interrupt Introduction
» An interrupt, in microcontroller context, is a signal that temporarily stops what
the CPU is currently working at.
» A typical Arduino sketch consists of setup() and loop() functions. When a
sketch is executed, the top most lines are run first. So logically
the setup() function is run before the loop() function. Although it’s far more
common to have headers for libraries above setup() which are of course catered
first by the compiler. The /oop() function is an endless loop so there is no way
to exit it.
If we will now use interrupts, we add a third function named isr(). ISR is short
v

for Interrupt Service Routine. This is where the program jumps to whenever
there is an interrupt.

;Oid setup)i > When does the program jump to isr()?

}"°id loop(){ » Arduino Uno Digital Pins: 2 & 3 usable for interrupts

}Wid isr({ > attachInterrupt(digital PinTolnterrupt(interruptPin), isr, CHANGE);


Code & Explanation
//Program for Arduino Interrupt
//Make connections as per the code ! @
const byte ledPin = 13;
const byte interruptPin = 2;
volatile byte state = LOW;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(interruptPin, INPUT_PULLUPY);
attachInterrupt(digital PinToInterrupt{interruptPin), blink, CHANGE); #Interrupt
}
void loop() {
digitalWrite(ledPin, state);
}
void blink() { HISR
state = !state;


Activity 4 : Controlling an RGB LED

RGB LED
» RGB LED means Red, Blue and Green Light Emitting Diode.
» By configuring the intensity of each LED, other colours can be produced.

There are two kinds of RGB LEDs: common anode LED and common
cathode LED.

Common Cathode (-) Common Anode (+)

1-RED - > Applications:


pp :
2-GROUND N \
3 - GREEN G 0 G » Interior Lighting
4-BLUE 4 LAY ¢ > Sl@S
r Si i
& Dlsplays.
5 " » Designer Decorations

N N
Circuit Connections
Code & Explanation
/* Program to control RGB delay(1000); setColor(0, 255, 255);
LED ¥/ setColor(0, 255, 0); / // aqua
green delay(1000);
int redPin = 11;
H
int greenPin = 10; delay(1000);
int bluePin =9; setColor(0, 0, 255); // Void setColor(int red, int
blue green, int blue)
void setup() delay(1000); {
{ analogWrite(redPin, red);
pinMode(redPin, OUTPUT); // Next, we also get some analogWrite(greenPin,
pinMode(greenPin, secondary colours! green);
OUTPUT); analogWrite(bluePin,
pinMode(bluePin, OUTPUT); setColor(255, 255, 0); / blue);
| vellow )
delay(1000);
void loop() setColor(80, 0, 80); //
purple
i
setColor(255, 0. 0): //red delay(1000);
Activity 5 : Piezo Buzzer
Piezo Buzzer
I
- A buzzer or beeper is an audio signalling device, which may be mechanical,
electromechanical, or piezoelectric (piezo for short).
> Typical uses of buzzers and beepers include alarm devices, timers, and confirmation
of user input such as a mouse click or keystroke.
- Whenever an electric potential is applied across a piezoelectric material, a pressure
variation is generated. A piezo buzzer consists of piezo crystals in between two
conductors. When a potential difference is applied across these crystals, they push
one conductor and pull the other conductor by their internal property. The
continuous pull and push action generates a sharp sound wave.

Ac Voltage Applies

1 Vibrotion creotes sound woves


Circuit Connections
Code & Explanation
//A sketch to demonstrate the tone() 3) Duration - how long teh tone
Sunction plays */
//Specify digital pin on the Arduino that
the positive lead ofpiezo buzzer is tone(piezoPin, 1000, 500):
attached.
/Ntone(piezoPin, 1000, 500);
int piezoPin = 9; /delay(1000);
/
void setup() {
Melose setup

void loop() {
/*Tone needs 2 arguments, but can
take three
1) Pint#
2) Frequency - this is in hertz (cycles
per second) which determines the pitch
of the noise made
Activity 6 : LCD Display
LCD
» LCD (Liquid Crystal Display) is a type of flat panel display which uses liquid
crystals in its primary form of operation.
» LCDs have a large and varying set of use cases for consumers and businesses, as
they can be commonly found in smartphones, televisions, computer monitors and
instrument panels.

EEUPEISERNEERAR Gy
12C Bus
To Ardiuno or Raspberry port
» 12C stands for Inter Integrated Circuit
» A 12C bus is a bidirectional two-wired HD44780 compatible
serial bus which is used to transport the data 18 Pin connecter
between integrated circuits.

solder pad
LCD backlight address select
_——
Circuit Connections

- al LOoOurTnpuy —
NO -—

*axd>2
E B mMRar YVARYIN =

8 ~Seld txz 8 8,
Code & Explanation
//Program for LCD Display with 12C // Print a message to the LCD.
Bus [Link]();
[Link](2,0);
#include <Wire.h> [Link]("Hello Everyone");
#include <LiquidCrystal 12C.h> [Link](2,1);
[Link]("Welcome To DIC");
LiquidCrystal_12C led(0x27,20,4); /


set the LCD address to 0x27for a 16
chars and 2 line display

void loop()
void setup() {
{
[Link](); // initialize the
led
[Link]();
Activity 7 : Alphanumeric Keypad
Alphanumeric Keypad
» An alphanumeric keypad is a keyboard that contains both numbers and
letters on the same keys.
» Typically, they are found on telephones and cellular phones.
¥ T W .
Circult connectons
_UIIIICL
Code & Explanation
/* Program for Using Keypad with Arduino */ Keypad(makeKeymap(keymap), rPins, cPins, .
Rows, Cols):
#include <Keypad.h>
#include <Wire.h>
void setup()}
const byte Rows= 4;
[Link](9600); // serial monitor
//mumber of rows on the keypad i.e. 4
const byte Cols= 4; ]
//If key is pressed, this key is stored in
'keypressed' variable’
char keymap[Rows][Cols]=
//1f key is not equal to 'NO_KEY", then this
{ key is printed out
{III‘ '2!, I3I'IAI} 5

{'4,'s','6''B'},
{371’ '8., |9D,'Cl}‘ void loop() //main program
{l‘l' lol. C#'.lD', {
char keypressed = [Link]();
1 if (keypressed != NO_KEY)
//a char array is defined
byte rPins[Rows]= {9,8,7.6}; {
[Link](keypressed); // write this string on
//Rows 0 to 3
the top row
byte cPins[Cols]= {5,4.3,2};
/IColumns 0 to 3 H
/I command for library for keypad |
Keypad kpd=
Activity 8 : HC-05 Bluetooth Module
Bluetooth
7 Bluetooth is a wireless technology standard for exchanging data between
fixed and mobile devices over short distances using short-wavelength UHF
radio waves in the industrial, scientific and medical radio bands, from 2.400
to 2.485 GHz, and building personal area networks (PANs).
» It was originally conceived as a wireless alternative to RS-232 data cables.

HC-05 Bluetooth Module


» HC-05 module is an easy to use Bluetooth SPP
(Serial Port Protocol) module, designed for
transparent wireless serial connection setup.
» The HC-05 Bluetooth Module can be used in a
Master or Slave configuration, making it a great
solution for wireless communication.
AT Command Mode
» AT commands are instructions used to control a modem. AT is the
abbreviation of ATtention. Every command line starts with "AT" or "at".

Few commonly used AT commands are:

» AT : Check the connection


» AT+NAME : See default name
> AT+ADDR : see default address
» AT+VERSION : See version
» AT+UART : See baudrate
» AT+ROLE : See role of bt module (1=master/O=slave)
» AT+RESET : Reset and exit AT mode
» AT+ORGL : Restore factory settings
» AT+PSWD : see default password
AT Command Code
//Make the Connections as per the code !
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(5, 6); // RX | TX

void setup(){
[Link](9600);
[Link]("Enter AT commands:");
[Link](38400); // HC-05 default speed in AT command more
}

void loop(){
if ([Link]()) // read from HC-05 and send to Serial Monitor
[Link]([Link]()):
if ([Link]()) // Keep reading from Serial Monitor and send to HC-05
[Link]([Link]());
}
P L
4 (\T",\T':/l/,\.[l“‘\f'
1L 1L Uil L LAURRS
Bluetooth Terminal App
Download & Install Bluetooth -
Terminal App Sa—
[Link] Iui sve
details?id=[Link] s
Tre BRUTOR Bltoces
nal&hl=en IN R
Open the app and pair the HC-05 P
module to your mobile. The
password is: 1234 (default)
» Then select the Byte Stream mode ==
out of the three modes that appear.
Send “1” to ON the LED and “0” PSR i
to OFF the LED. ert._&-+()/
Thus the LED on the Arduino can - it @
be controlled by the App through ., 3 ®
Bluetooth.
Code & Explanation
/* Program to interface Bluetooth digitalWrite(ledpin,HIGH);
Module with Arduino */ [Link]("LED On!");
H
#include <SoftwareSerial.h>
else if (Data=='0"){
SoftwareSerial mySerial(3, 2); digitalWrite(ledpin,LOW);
int ledpin=13; [Link]("LED Off!");
int Data; |
}
void setup() {
[Link](9600);
pinMode(ledpin,OUTPUT);
H

void loop(){
if ([Link]()){
Data=[Link]();
if(Data=="1"){

You might also like