0% found this document useful (0 votes)
22 views29 pages

Wokwi Lab Module 2

The document describes an Arduino program for controlling components like LEDs, sensors, and relays. It includes the code and circuit diagrams for several programs that can control an LED, read sensor values, display to an LCD, and toggle a relay. The programs demonstrate basic Arduino programming concepts.

Uploaded by

syednashita786
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)
22 views29 pages

Wokwi Lab Module 2

The document describes an Arduino program for controlling components like LEDs, sensors, and relays. It includes the code and circuit diagrams for several programs that can control an LED, read sensor values, display to an LCD, and toggle a relay. The programs demonstrate basic Arduino programming concepts.

Uploaded by

syednashita786
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/ 29

PRDGRAM-04 WOKWE TRA $ONCSENSDR

AM

SOMRDNENTS
1) LED
)ResisteS
3) HC-SROtulbrasonicdistonce An8AA-
4) AnduủnoVNO.
PROGRAM
4detineEcHO-PINQ
dineTRIG-PIN3
VDid setupl )

Azial.beqn Cus200),
pinNpleLED_LUILTN,OUTPl
pinMode(TRIG PIN, OUTPT);
pin Mode ECHOLPIN, INPUT);

Apal naddistancaCM)

digialntt(IRIG-PINLOW)
,
delayMicoSQLOrds (a);
ldigialwrūt (TRIG- PIN,HIGH
dely
MicA0SRLOnda lib),;
dBQlownit (TRIGPIN,LOW):
nt ctin =pulsesn
CCHOLIN
,HIGH
sehusnusatin t D034)2
vod leop)
Aoatdstanoe =heatlistaneeCMUs
boot iaNeasby = istance <J60
digitalWnibeCiÈD-BUJLTIN,ŠNasby)
heiial.peint(
"Meawed detae";
delay ib0);

-
Circuit Diagram Ultra Sonic Sensor

IOREF
LRESET
3.3V
-AREF
GND
13
12
~1:
-10
I
GND
GND
Vin
IRIO
ICKO
GNC

TX:
IRX+¢
LOUTRT
LMeaueddistame:|
Measused sdstancei 174.JA
|Meased
distancei t.s
MeaMeddistancei |t. ay
Meoed ditaÉ: 11.16
PROGRAM-02 WOKWE TR SANSQR
AUM
sing WOKWI

COMRONENIS
A) LED
2) RECIEVER
3) LogcsAradyse(3 Channe
Amduno VNO
RRoS&AI
int EDA=13,
t LED2=l3
uint LED3= I)
nt IR1 2;
tIRas3,
int IR3 4j
ntvalQ=0
intval30
vord setupl

pinMode (TR4, INPUT);


pinMode (TK2, )NPUT);
pinMede (IR3, 1NPUT);
pinMode CLEDA , DUTPUT);
pin Mode CLEDR,OUTPUT),;
pinMode(LED3, OUUT),
eial.biqin (a600);
3
valiedigitalReadTR1);
valascgitalReadIR)
valz e digitalKead(iR3)i
Cvat)
diqitalWsilelLEDA,IGH);

dig ctalWste(LEDS,Low)
?

Cvalaz=)
digitadaite(LEDA,HLGH)i

else.

dkqitalWhite (LEDa,LOW)

vads=so){
digitalwnia (LED3,HIG);

diqitalote (LED3,LOns

dolay(aool,
Circuit Diagram IR Sensor

JOR

858B888A

4Y

8 AE
TPUE
R ROEiec
Command:4
G15 sampls
G83 Sample
5)Sampls
Snsampe
88? sampdes
455SAmples
0arsamples
0AK8Amples
PROSRAM-03 WOKWE KEYPAR.

eyad wsingwekwi
COMPONENT
4)ED
a)R_RECIEV ER
Loc sinaye C8
Channeu)
40AHdino UŃÔ.
RROSRAM
int LEDA s 13;
nt LED2:12,
ntLED3s41,

nt IRa3j
unt TR34
nt val4:Oj
invalaz0;
|üntval3=0)

votd stthup){
pino
Mode (IRA, NPUT);
puMode (IRa, JNPUT);
pinMode (IR3, INPUT);
pinMode (LED4,0UTPUT);
pinMDde (LED&, DUTPU);
pinModeLLED3,DUTPUT);
aiat. beqin 9K00):

idlooplOf
vatiz daitaRad (TRA);
wal diotalkead CTRa)
wols doitalkead CTR3;

digitalwite(LEDAl6u)

Aigitalwte CLEDALOW);

(valaz0)
igitalaite (LEna,
HLGH),
3

diaitalwile (LEDA,LOW);

Lval3eeo)f
digitalWute CLEDSHIGH)

lediaitalWite (LED3,LDW);
delay (200o);
Circuit Diagram Keypad Interface

85888B

AE*
1353
ET
430T

43YY
LOUTRU

R RecieY
Emmand:4 Addsen:o nd
3 damples
Samples
139 4ampes
203 nples
5 samdes
343 amples
411 samples
|449 sampe
PROSRAM-Dt WOKWT TRAEEIC U6HTS

Trayic digA usingNOKWI

SODMRONENS
4)LED
a) Resists.
3)lAndino UNO

RRRSRAM
#incdud "LED.
tinclude ^TiaticightA
dRhineLED-PIN-1d
deineleDPINe 3
deine LED_PIN34
doineLED_fIN45
a
t ehineLED-PIN5 6
#dline LED-AN-G +

tdehin SHORT 100


fdehine LONG 50

Trolcigt t,

t4s newTraticightCLEDPNI,
LEO-PIN-2,LEDN 3);
tR 2rwTHateaight
(LED_PIN4,LEDN2, LED-PINk
VadlacplUE
testTrako4(tA,ta);
toTaicalt,t
testsos( tA,ta)

Void testHEDlLED* lod)i


Jed>tnl
dolayioo0),;
Ladcf);
delay liDDo))
3

VeidshoEunk
(Tralhiclught)
dolay (SHDRT),

dala (SHbe)

Vaid ong GinklSottdlighto+)¥


t→nAu:
aelayLONG),

dlay(LON4);
dolay(1boD)í

delayliDO0);

vad trsiraia(Trayidight+ta,
ayickight *a)4

ta-+hed>U
ta→qheen→ 640;
tayellN Dn(;
delay 1
t Doco);

ty→nd

dlay oco);

l1yllw-> Dnl5
ta→ud→ml);
tasheun 0,
taelowa0
delay (iboD),
tesragicaltt,ta);

ved 4eSs(TrafeAght ta, TraicAightt ta)i

tSos(ta);
oAL)S

vodsos(TrakpicAighttt)€.
Yes lint iso,i<3 it+) shogtBink(H);?
dtaylso0);
oACint ie0:iK2i4+) shetŘlink4)5
đolay s( oO0);
Circuit Diagram Traf c Lights demonstration

8X
7+X

UTA

O
ND

AS
AEE
4353N
€T
ON9 00
fi
RROSRAM-D5JED RUk egan
Ae
LED Bink BuoqranmuWbną WOKWI

SoMeONENTS
4)LED Rasiutet
2)REsteS
3)AAdino UNO

RROSR&M
veid stupl)E
pinMdeLED-RUTLTIN,DUIPU;

|Veid loop)i
diqitawwite(
LEDBUTTIN,
H4u);
Aslaytioool;
aiaitalwsúe (LEDBUILTIN, LOw)
5 doayDoD),
Circuit Diagram LED Blink

aX
I+X1

5
l6OND
ONS
6^
AS
AE

AND
PROGRAM 06 ER FADEPROGRAM

LED Fade Puoqram Uing hDEWT

CoMPDNENIS
)ED
2)Rentes
3) Adwino ŲND

RROGRAN
Hdeine LED_PING
# dełine FADE
SPEEP A6.

Const intgt PROGMEM


Qamma&Ils
0,0,0 0,0,0D,0,0,0,0,0,0,o, 0,0
0,0,00,00OD60,0o,L, L
Ll,, L LL2 2,2,242,2,2
2,3,3,3,3, 3,3 34 4,444 4,4,5,5,5,
to_,10,11,)1,1L,12,12, 13, 13, 1314 l4, 15, 5, 16,16,
a9,18,18,14,,des0,al a) 2dddd3, 24,24,25,
|25, 2b,a, a8,4,A,30,31,32, 3ad,33,34 35, 35 36,
33,38,34,34,40,41L,42,4,44,45,46,24?, 48, h4,50,50,
5,5a,54, 55, 56,5 58, A, Go,GL,bd, b3, 64,6 6, 62,68,
|69,30,12,13,34,35,44,18, 4,81,&Q 83,85,8G, 81, 81,
,92,93, 95,96, 98,59,10), 102, 1b4,1D5,109,(D9,J10,112,14,
1s,1a,1a,12D,122,24,126,124
124,131,131, 135,I31,)3,(40l4a,
|44,6, J48,150,1sa154,15658,160,l62,164, 16, (69, 11,3,45,
80, 18d,184,186,189,1Q1, 43, 196,198,a0D) Q03,D5,Q0Ý, Q10,QI3,
Ns8 220, Q23,9a5,a48,231,Q33,a39Q4, 24t, 242, 944,25a,255
veid setup()
pin Mode(LEDPIN,DVTAND);

veidIbepl)
\eACintis0; i<a55; iH){
analegWüle(LEDfIN,am Yead bye (2qamAs D
dolay EADE_SFEGDDi

forlínti255; i>0ji-)1
analogwrik (1EDPIN,pgmread byte kqammo8 (I)N;
dalayCFADE
SPEED
Circuit Diagram LED Fade

eX
[+X|

uTA
ON9
6
O
O0
AS
AEE

OND

-
RROGRAM-04co SPLAY

A
LCD RİSploy using WOKWE

SOMPONENTS
4)|| LCD 6x2
Reisto
3) Andun UND

5 PRDGEAM
ADcude <liauidystal. A
taidcsytal Jediast,lb,4,82),
Void setup()i
dca. begirltb,)
ded.psntt elo Wesd");

void loop()
Circuit Diagram LCD Display Interface

O
OND
OND

AE

2
QND

-
HelloComputer an LCO
RRDGRAM-08 RELAY
ALM
Rolay ing WOKWT
OMAONENtS
12| LED

3) Relay Module
4)Adino UNO

RROGRAM
#incude <wineh
int myRelay 3R-
walatilecbyte nelaysate =LDw

intmyount
vaid setup)f
Sesial begin (a600);
while!eaial);
eaial.pinttn
("MCRAEDE C
! eNected");
jnMode (my Relay,Tput)
digttal wiz tmyRalay LDwi
Alaystat= LOw;
Beuial puntth ("RELAY
OFE );
3
ved loeplUi
oat myTemp 10,
dosial nt (mylount) slal.psint("Temp:" Jeuadçsit(muTeinp
4), Jial.psintlh(AF^)
fi
CmyTempzlbo
i 22Melantah ow)$

dola (a00s);
pLReay LOwl),
3
MmyCauntmylount t;
selay(5000),

vĐd pull
ReloyHIGnCDE
Cnulastatel=
HIGM)
digitawhte CmyPelayHlGH)
helaystatz aHIĜM;
Besiatpaintl ("RELA ON D

|ved. pulRelayDNC)1

digit-ailwnit CmyRolayLDw
eloystathe LDW
seial.pittn ('R6LAHDEF");_
Circuit Diagram Relay Interface

AREF
IOREF I 13
12
RESET.
~11
3.3V. -10
9
amu
Vin
Ae
4
A2
A: 2
A4 TX+1
AS IRX+0

50OM NO
MCP9RDR Conneeed
RELAY DEF

RELAY ON

You might also like