You are on page 1of 7

Labor

ator
yRepor
tCov
erSheet

SRM Instit
uteofSci
enceandTechnology
Facult
yofEngineeri
ngandTechnology
Depar
tmentofElectr
oni
csandCommuni cat
ionEngineer
ing
18ECO108JEMBEDDEDSYSTEM DESI
GNUSI
NGARDUI
NO
Si
xthSemest
er,
2020-
21(
EvenSemest
er)

Name :Par
thJai
n
Regi
sterNo. :RA1811003010826
Day/Sessi
on :
Day5P23,
24
Venue :ONLI
NE
Ti
tl
eofExper
iment :GPI
OLED
Dat
eofConduct
ion :01/
02/
2021
Dat
eofSubmi
ssi
on :08/
02/
2021

Parti
cular
s Max.Mar
ks Mar
ksObt
ained
Pre-l
abquesti
ons 10
In-
labexperi
ment 20
Post-l
abquesti
ons 10
Total 40

REPORTVERI
FICATI
ON

Dat
e :

St
affName :

Si
gnat
ure :

1
Exper
iment2:GPI
OLED

Ai
m:
Tocont
rol
thebr
ight
nessoft
heLEDwhi
chi
sconnect
edi
nanyoft
hePWM pi
n.

Component
sRequi
rement
:

Har
dwar
ecomponent
s : i
)Deskt
op/Lapt
op(
Host
)
(
ii
)Ar
dui
noUnoDev
elopmentBoar
d(Tar
get
)
(
ii
i)Ty
peBUSBCabl
e
Sof
twar
eTool
s : Ar
duinoIDE,
Ti
nkercadonl
ineVi
rt
ual
Lab(
Forsi
mul
ati
on)

Theor
y:

Ledblinki
ngisthemostbegi
nner&easystept
ost arty
ourexper
imentwi
thArdui
no.Let
’sget
star
ted.Fi
rst
ly,
ident
if
yanode(
+ve)&cathode(
-ve)legofLED.Fol
lowi
ngdiagr
am gi
vesaclear
i
deaofLED.

ALEDi
sconnect
edt
otheGPI
Opi
n9t
hroughabal
l
astr
esi
stert
oli
mitt
hecur
rent

2
t
hrought
heLED.

CodeSt
ruct
ure

v
oidset
up(){
/
/putyourset
upcodeher
e,t
orunonce:

v
oidl
oop(){
/
/puty
ourmai
ncodeher
e,t
orunr
epeat
edl
y:

Bar
emi
nimum code

 set
up:I
tiscal
l
edonl
ywhent
heAr
dui
noi
spower
edonorr
eset
.Iti
susedt
oini
ti
ali
ze
v
ari
abl
esandpi
nmodes
 l
oop:Thel
oopf
unct
ionsr
unscont
inuousl
yti
l
lthedev
icei
spower
edof
f.Themai
n
l
ogi
coft
hecodegoesher
e.Si
mil
art
owhi
l
e(1)f
ormi
cro-
cont
rol
l
erpr
ogr
ammi
ng.

Pi
nMode

 ApinonArduinocanbesetasinputoroutputbyusi
ngpi
nModef
unct
ion.
 pi
nMode(9,OUTPUT) ;
//set
spin9asout putpin
 pi
nMode(9,INPUT);/
/setspi
nasi nputpi
n

Pr
elabQuestions:
1.Howmanyanal ogpinsarether
einArduinoUnoDevel
opmentBoard?
2.Whi chofgener
alpurposeworki
ngregisterar
eusedas16-bi
tindi
rectaddr
essr
egi
ster
poi
nter
s?

LabPr
ocedur
e:

1. Connectt
heAr
dui
noUnoDev
elopmentBoar
dtot
heDeskt
op/
Lapt
opt
hroughTy
peB
USBcable.

2.Wr
it
ethecodeandcompi
l
eiti
nAr
dui
noI
DE.

3.Sel
ectUSBpor
tinAr
dui
noI
DE.

4.Sel
ectAr
dui
noUnoDev
elopmentBoar
dinAr
dui
noI
DE.

5.Downl
oadt
hecodei
ntoAr
dui
noUnoDev
elopmentBoar
d
3
6.Runt
hecodei
nAr
dui
noUnoDev
elopmentBoar
d.

7.Obser
veandv
eri
fyt
heout
put
.

Postl
abQuest
ions:

1.Whatar
et her
egi
sterassoci
atedwi
theachpor
t?
2.Whatst
atementi
susedt osendananal
ogdatainI
Opi
nUsi
ngAr
dui
noI
DE?

4
5
Out
put
:

Code
/
*
Fade
Thisexampleshowshowt of
adeanLEDonpi
n9
usi
ngt heanal
ogWri
te(
)funct
ion.

TheanalogWri
te(
)functi
onusesPWM, soi
fy ou
wanttochangethepinyou'r
eusing,
besur eto
useanotherPWM capablepin.OnmostAr dui
no,
thePWM pinsareident
if
iedwith a"~"si
gn,
l
ike~3,~5,~6,~9,~10and~11.
*
/

i
ntbr
ight
ness=0;

voidset
up()
{
pinMode(9,
OUTPUT)
;
}

voidloop()
{
for(bri
ghtness=0;bri
ghtness<=255; br
ight
ness+=5){
analogWrit
e(9,br
ight
ness);
delay(
30);//Waitf
or30mi ll
isecond(
s)
}
for(bri
ghtness=255;bri
ghtness>=0; br
ight
ness-=5){
analogWrit
e(9,br
ight
ness);
delay(
30);//Waitf
or30mi ll
isecond(
s)
}
}

Resul
t:Thebr
ight
nessoft
heLED whi
chi
sconnect
edi
nanyoft
hePWM pi
nwassuccessf
ull
y
6
cont
rol
led.

You might also like