0% found this document useful (0 votes)
4 views

CS3691-ES and IOT -Lab Manual

The document is a record notebook for practical work conducted by students in a specific semester and branch, detailing experiments performed using the Keil simulator for 8051 microcontroller programming. It includes various assembly language programs, procedures for executing them, and results from experiments related to data transfer, ALU operations, and basic embedded C programming. Additionally, it introduces the Arduino platform and its components, emphasizing its accessibility for non-engineers.

Uploaded by

arunk741921
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)
4 views

CS3691-ES and IOT -Lab Manual

The document is a record notebook for practical work conducted by students in a specific semester and branch, detailing experiments performed using the Keil simulator for 8051 microcontroller programming. It includes various assembly language programs, procedures for executing them, and results from experiments related to data transfer, ALU operations, and basic embedded C programming. Additionally, it introduces the Arduino platform and its components, emphasizing its accessibility for non-engineers.

Uploaded by

arunk741921
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/ 91

RECORD NOTE BOOK

Reg.No.

Certified that this is the bonafide record of work done by Selvan /


Selvi………………………………....….... of the…………..….. Semester…………………...……….
……………..………………..……….……..………branch during the year .................................. in
the ................................................................................................................................ Laboratory.

Staff – in-Charge Head of the Department

Submitted for the university Practical Examination on …………………………...

Internal Examiner External Examiner


LIST OF EXPERIMENTS

PAGE
S.No DATE NAME OF THE EXPERIMENT NO MARK SIGNATURE
LIST OF EXPERIMENTS

PAGE
S.No DATE NAME OF THE EXPERIMENT NO
MARK SIGNATURE
LIST OF EXPERIMENTS

PAGE
S.No DATE NAME OF THE EXPERIMENT NO MARK SIGNATURE
EXP NO: 1
8051ASSEMBLY LANGUAGE PROGRAM USING
DATE KEIL SIMULATOR

AIM:
To write 8051 Assembly Language Program for an 8-bit addition using Keil simulator and
Execute it.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keilμvision5IDE 1

INTRODUCTIONTO8051SIMULATORS:

A simulator is software that will execute the program and show the results exactly to the
program running on the hardware, if the programmer finds any errors in the program while simulating
the program in the simulator, he can change the program and re-simulate the code and get the
expected result, before going to the hardware testing. The programmer can confidently dump the
program in the hardware when he simulates his program in the simulator and gets the expected results.
8051 controller is a most popular 8-bit controller which is used in a large number of embedded
applications and many programmers write programs according to their application. So testing their
programs in the software simulators is a way. Simulators will help the programmer to understand the
errors easily and the time taken for the testing is also decreased.
These simulators are very useful for students because they do need not to build the complete
hardware for testing their program and validate their program very easily in an interactive way.

Listof8051Simulators:
The list of simulators is given below with their features:
1. MCU 8051: MCU 8051 is an 8051 simulator that is very simple to use and has an interactive
IDE (Integrated Development Environment). It is developed by Martin Os mera and most
important of all is that it is completely free. There are many features for this IDE they are
 It supports both C and assembly language for compilation and simulation

5
 It has an in-built source code editor, graphical notepad, AS CII charts, Assembly symbol
viewer, etc. It also supports several 8051 ICs like at89c51, A89S52, 8051, 8052, etc.
 It will support certain electronic simulations like LED, 7segment display, LCD etc. which
will help in giving the output when you interface these things to the hardware directly.
 It has tools like hexadecimal editors, base converters ,special calculator, file
converters, inbuilt hardware programmers, etc.
 It has syntax validation, pipazetate- completionist.
Youcandownloadthistoolfromhttps://sourceforge.net/projects/mcu8051ide/files/.

2. EDSIM 51: This is a virtual 8051 interfaced with virtual peripherals like 7 segment display, motor,
keypad, UART etc. This simulator is exclusively for students developed by James Rogers, The
features of this simulator are
 Have virtual peripherals like ADC, DAC with scope toddies play, comparator etc.
 Supports only assembly language
 IDE is completely written in JAVA and supports all the OS.
 Completely free and with user guide, examples, etc.
Youcandownloadthissimulatorfromthehttps://www.edsim51.com/index.html.

3. 8051 IDE: This simulation software is exclusively for the Windows operating system
(98/xp). The features of this simulator are
 Text editor, assembler, and software simulate inone single program.
 Has facilities like Breakpoint setter, execute to break point, predefined simulator watch
window, etc.
 It is available in both free version and paid version.
Youcandownloadthistoolfromhttps://www.acebus.com/win8051.htm

4. KEILµVision:KEIL is the most popular software simulator. It has many features like
interactive IDE and supports both C and assembly languages for compilation and simulation.

Youcandownloadandgetmoreinformationfromhttps://www.keil.com/c51/.

6
INSTALLATIONOFKEILSOFTWARE

Setup Keil IDE for Programming


KeilµVisionIDEisapopularwaytoprogramMCUscontainingthe8051 architectures. It supports over
50 microcontrollers and has good debugging tools including logic analyzers and watch windows.
Inthisarticle,wewillusetheAT89C51ED2microcontroller,whichhas:
 64KBFLASHROM
 On-chip EEPROM
 256BytesRAM
 In-System programming for uploading the program
 3Timer/counters
 SPI,UART,PWM

The Keil µVision icon.


To start writing a new program, you need to create a new project. Navigate to project —> New
µVision project. Then save the new project in a folder.

Aftersavingthefile,anewwindowwillpopupaskingyoutoselectyourmicrocontroller.
As discussed, we are using AT89C51/AT89C51ED2/AT89C52, so select this controller under the
Microchip section (as Atmel is now a part of Microchip).

7
Select ‘Yes’in the next pop-up, as we do not need this file in our project.

Our project work space is now ready!

Fromhere,weneedtocreateafilewherewecanwriteourCcode.NavigatetoFile—>New. Once the file is


created, save it with .c extension in the same project folder.

8
Next, we have to add that .cor .asm file to our project workspace. Select Add Existing Files and
then select the created .c or .asm file to get it added.

Theworkspaceandprojectfileareready.

9
PROCEDURE

1. Create an project, go to “Project “and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device
forTarget.
3. Select thedeviceAT89C51ED2orAT89C51orAT89C52
4. Add Startup file Next goto“File”andclick“New”.
5. Write a program on the editor window and save it with. As mextension.
6. Add this source file to Group and click on“BuildTarget”orF7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.8.

PROGRAM:

ORG0000H
CLR C
MOVA,#20H
ADD A, #21H
MOV R0, A
END

OUTPUT:

Accumulator (A) = 0x41


R0 = 0x41

RESULT:

Thus the above program 8051 assembly language program using keil simulator was executed
successfully.

10
EXP NO: 2
TESTDATATRANSFERBETWEENREGISTERSAN
DATE DMEMORY

AIM:
TowriteandexecuteanAssemblylanguageprogramtotransferdatabetweenregistersand
memory.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keilμvision5IDE 1

PROCEDURE

1. Create an ewproject, goto“Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for
the Target.
3. SelectthedeviceAT89C51ED2orAT89C51orAT89C52
4. Add Startup file Next goto “File”and click “New”.
5. Write a program on the editor window and save it with. asmextension.
6. Add this source file to Group and click on“BuildTarget”orF7.
7. Go to debugging mode to see the result of the simulation by clicking Runor Step run.

PROGRAM:
TYPE-I:
ORG 0000H
CLR C
MOVR0,#55H
MOVR1,#6FH
MOV A, R0
MOV 30H, A
MOV A, R1
MOV 31H, A
END
11
OUTPUT:

RAM[30H] = 85
RAM[31H] = 111

PROGRAM:
TYPE-II:
ORG0000H
CLR C
MOVR0,#30H
MOVR1,#40H
MOVR7,#06H
BACK:MOVA,@R0
MOV@R1,A
INC R0
INCR1
DJNZR7,BACK
END
OUTPUT:

RAM[40H] = 1
RAM[41H] = 2
RAM[42H] = 3
RAM[43H] = 4
RAM[44H] = 5
RAM[45H] = 6

RESULT:
Thus the above program test data transfer between register and memory was executed successfully.

12
EXP NO: 3
ALU OPERATIONS
DATE

AIM:
To write and execute the ALU program using the Keil simulator.

SOFTWARETOOLSREQUIRED:

S.No Software Requirements Quantity


1 Keilμvision5IDE 1

PROCEDURE

1. Create a new project, goto“Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create New Project Select Device for
Target.
3. SelectthedeviceAT89C51ED2orAT89C51orAT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asmex tension.
6. Add this source file to Group and click on“BuildTarget”orF7.
7. Go to debugging mode to see the result of simulation by clicking Run or step run.

PROGRAM:

ORG0000H
CLR C
//ADDITION
MOVA,#20H
ADD A, #21H
MOV 41H, A

//SUBTRACTION
MOV A, #20H
SUBB A, #18H
MOV 42H, A

//MULTIPLICATION
MOV A, #03H
13
MOVB,#04H

MUL AB

MOV 43H, A

//DIVISION

MOVA,#95H

MOVB,#10H

DIV AB

MOV44H,A

MOV45H,B

//AND

MOVA,#25H

MOVB,#12H

ANL A, B

MOV 46H, A

//OR

MOVA,#25H

MOVB,#15H

ORL A, B

MOV 47H, A

//XOR

MOVA,#45H

MOV B,#67H

14
XRL A, B

MOV48H,A

//NOT

MOVA,#45H

CPL A

MOV49H,A

END

OUTPUT:

Address Data

900 08

RESULT:

Thus the above program ALU operations was executed successfully.

15
EXP NO: 4
WRITE BASIC PROGRAMS USING EMBEDDED C
DATE

AIM:
To write a basic embedded C program to control a port 0pin0connectedtoan8051
Microcontroller using a Keil simulator.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keilμvision5IDE 1

PROCEDURE

1. Create a new project, goto “Project” and close the current project “Close Project”.
2. Next Go to the Project New μVision Project and Create a New Project Select Device for
the Target.
3. Select the device AT89C51ED2orAT89C51orAT89C52
4. Add Startup file Next go to “File” and click “New”.
5. Write a program on the editor window and save it with .asmextension.
6. Add this source file to Group and click on“BuildTarget”orF7.
7. Go to debugging mode to see the result of the simulation by clicking Runor Step run.

PROGRAM:
#include<REG51.h>i
nt i,j;
sbitLED=P2^0; void
main()
{
while(1)
{

16
LED = 0;
for(j=0;j<10000;j++);
LED = 1;
for(j=0;j<10000;j++);
}
}

OUTPUT:

Address Data
9000 80

LED connected to P2.0 blinks continuously


(P2.0 alternates between 0 and 1).

RESULT:

Thus the above program writer Basic program using embedded was executed successfully.

17
EXP NO: 5
ARITHMETIC PROGRAMS USING EMBEDDED C
DATE

AIM:
To write an embedded program for addition, subtraction, multiplication, and division
Using the Keil simulator.

SOFTWARE REQUIRED:

S.No Software Requirements Quantity


1 Keilμvision5IDE 1

PROCEDURE

1. Createanewproject, goto“Project” andclosethecurrentproject “Close Project”.


2. NextGototheProjectNewμvisionProjectandCreateNewProjectSelectDevicefor Target.
3. SelectthedeviceAT89C51ED2orAT89C51orAT89C52
4. AddStartupfileNextgoto“File”and click“New”.
5. Writea programon theeditor window and save itwiththe.asm extension.
6. AddthissourcefiletoGroup andclick on“BuildTarget”orF7.
7. Gotodebugging modetoseetheresultof thesimulation byclickingRunor Step run.

PROGRAM:
#include<REG51.H>
unsigned char a, b;
void main()
{
a=0x10;
b=0x04;
P0=a-b;
P1=a+b;
P2=a*b;
P3=a/b;
while(1);
}
18
OUTPUT:

Port P0= 0x0C (16 - 4 = 12)

Port P1= 0x14 (16 + 4 = 20)

Port P2= 0x40 (16 × 4 = 64)

Port P3= 0x04 (16 ÷ 4 = 4)

RESULT:

Thus the program using embedded C was executed successfully.

19
EXP NO: 6
INTRODUCTION TO THEARDUINO PLATFORM
DATE

AIM:
Tostudy the basicsof Arduino Unoboard and ArduinoIDE 2.0 software.

Hardware& SOFTWARETOOLS REQUIRED:

S.No. Hardware& Software Requirements Quantity


1 ArduinoIDE 2.0 1
2 ArduinoUno Board 1

INTRODUCTIONTO ARDUINO:

Arduinoisaproject,open-sourcehardware,andsoftwareplatformusedtodesignandbuildelectronic
devices. It designs and manufactures microcontroller kits and single-board interfaces for building
electronicsprojects.TheArduinoboardswereinitiallycreatedtohelpstudentswiththenon-technical
background. The designs of Arduino boardsuse a variety of controllers and microprocessors.
Arduinoisaneasy-to-useopenplatform forcreatingelectronicprojects.Arduinoboardsplayavital role in
creating different projects. It makes electronics accessible to non-engineers, hobbyists, etc.
The various components present on the Arduino boards are a Microcontroller, Digital Input/output
pins, USB Interface and Connector, Analog Pins, reset buttons, Power buttons, LEDs, Crystal
oscillators, and Voltage regulators. Some components may differ depending on the type of board.
The most standard and popular board used over time is Arduino UNO. The ATmega328
Microcontroller present on the UNO board makes it rather powerful than other boards. There are
various types of Arduino boards used for different purposes and projects. The ArduinoBoards are
organized using the Arduino (IDE), which can run on various platforms. Here, IDE stands for
Integrated Development Environment. Let's discuss some common and best Arduino boards.

20
TYPESOFARDUINO BOARDS
1) ArduinoUNO
Arduino UNO is based on an ATmega328P microcontroller. It is easy to use compared to other
boards, such as the Arduino Mega board, etc. The Arduino UNO includes 6 analog pin inputs, 14
digitalpins,aUSBconnector,apowerjack,andanICSP(In-CircuitSerialProgramming)header.It is the
most used and of standard form from the list of all available Arduino Boards.

2) ArduinoNano
TheArduinoNanoisasmallArduinoboardbasedonATmega328PorATmega628Microcontroller.
TheconnectivityisthesameastheArduinoUNOboard.TheNanoboardisdefinedasasustainable,
small,consistent,andflexiblemicrocontrollerboard.ItissmallinsizecomparedtotheUNOboard.
Thedevicesrequired tostartourprojects usingtheArduinoNanoboardareArduinoIDEand mini-
USB.TheArduinoNanoincludesanI/Opinsetof14digitalpinsand8analogpins.Italsoincludes 6 Power
pins and 2 Reset pins.

3) ArduinoMega
The Arduino Mega is based on the ATmega2560 Microcontroller. The ATmega2560 is an 8-bit
microcontroller.WeneedasimpleUSBcabletoconnecttothecomputerandtheACtoDCadapter or battery
to get started with it. It has the advantage of working with more memory space. The
ArduinoMegaincludes54I/Odigitalpinsand16AnalogInput/Output(I/O),ICSPheader,areset

21
button, 4 UART (Universal Asynchronous Reciever/Transmitter) ports, USB connection, and a
power jack.

4) ArduinoMicro
TheArduinoMicroisbasedontheATmega32U4Microcontroller.Itconsistsof20setsofpins.The 7 pins
from the set are PWM (Pulse Width Modulation) pins, while 12 pins are analog input pins. The other
components on board are a reset button, a 16MHz crystal oscillator, an ICSP header, and a micro-
USB connection. The USB is built in the Arduino Micro board.

5) ArduinoLeonardo
The basic specification of the Arduino Leonardo is the same as the Arduino Micro. It is also based
ontheATmega32U4Microcontroller.Thecomponentspresentontheboardare20analoganddigital pins,
a reset button, a 16MHz crystal oscillator, an ICSP header, and a micro USB connection.

22
6) ArduinoDue
The Arduino Due is based on the 32-bit ARM core. It is the first Arduino board that has been
developed based on the ARM Microcontroller. It consists of 54 Digital Input/Output pins and 12
Analog pins. The Microcontroller present on the board is the Atmel SAM3X8E ARM Cortex-M3
CPU. It has two ports, namely, a native USB port and a Programming port. The micro side of the
USB cable should be attached to the programming port.

7) ArduinoLilypad
The Arduino LilyPad was initially created for wearable projects and e-textiles. It is based on the
ATmega168Microcontroller.ThefunctionalityofLilypadisthesameasotherArduinoBoards.Itis
around,lightweightboardwithaminimalnumberofcomponentstokeepthesizeoftheboardsmall.
TheArduinoLilypadboardwasdesignedbySparkfunandLeah.ItwasdevelopedbyLeahBuechley. It has
9 digital I/O pins.

8) ArduinoBluetooth
TheArduinoBluetoothboardisbasedonATmega168Microcontroller.Itisalsonamedas Arduino BT
board. The components present on the board are 16 digital pins, 6 analog pins, reset button,
16MHzcrystaloscillator,ICSPheader,andscrewterminals.Thescrewterminalsareusedforpower. The
Arduino Bluetooth Microcontroller board can be programmed over the Bluetooth as a wireless
connection.

23
9) ArduinoDiecimila
The Arduino Diecimila is also based on the ATmeg628 Microcontroller. The board consists of 6
analog pin inputs, 14 digital Input/Output pins, a USB connector, a power jack, an ICSP (In-Circuit
SerialProgramming)header,andaresetbutton.Wecanconnecttheboardtothecomputerusingthe
USBandcan powerontheboardwiththehelpof anACtoDCadapter.TheDiecimilawasinitially
developedtomark the10000deliveredboardsofArduino.Here,Diecimila means10,000inItalian.

10) ArduinoRobot
TheArduinoRobotiscalledasthetinycomputer.Itiswidelyusedinrobotics.Theboardcomprises of the
speaker, five-button, color screen, two motors, an SD card reader, a digital compass, two
potentiometers, and five floor sensors. The Robot Library can be used to control the actuators and
the sensors.

24
11) ArduinoEthernet
The Arduino Ethernet is based on the ATmega328 Microcontroller. The board consists of 6 analog
pins, 14 digital I/O pins, crystal oscillator, reset button, ICSP header, a power jack, and an RJ45
connection. With the help of the Ethernet shield, we can connect our Arduino board to the internet.

12) ArduinoZero
The Arduino Zero is generally called as the 32-bit extension of the Arduino UNO. It is based on
ATmel's SAM21 MCU. The board consists of 6 analog pin inputs, 14 digital Input/Output pins, a
USBconnector,apowerjack,andanICSP(In-CircuitSerialProgramming)header,UARTportpins, a
power header, and AREF button. The Embedded debugger of Atmel is also supported by the
ArduinoZero.ThefunctionofDebuggeristoprovideafulldebuginterface,whichdoesnotrequire
additional hardware.

25
13) ArduinoEsplora
TheArduinoEsploraboardsalloweasyinterfacingofsensorsandactuators.Theoutputsandinputs
connected on the Esplora board make it unique from other types of Arduino boards. The board
includes outputs, inputs, a small microcontroller, a microphone, a sensor, a joystick, an
accelerometer, a temperature sensor, four buttons, and a slider.

14) ArduinoPro Micro


ThestructureofArduinoProMicroissimilartotheArduinoMiniboard,excepttheMicrocontroller
ATmega32U4.Theboardconsistsof12digitalInput/outputpins,5PWM(PulseWidthModulation) pins,
Tx and Rx serial connections, and 10-bit ADC (Analog to Digital Converter).

TRODUCTION TO ARDUINO UNO:


The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was named
UNO to label the first release of Arduino Software. It was also the first USB board released by
Arduino. It is considered a powerful board used in various projects. Arduino. cc developed the
Arduino UNO board. Arduino UNO is based on an ATmega328P microcontroller. It is easy to use
compared to other boards, such as the Arduino Mega board, etc. The board consists of digital and
analog Input/Output pins (I/O), shields, and other circuits. The Arduino UNO includes 6 analog pin
inputs,14digitalpins,aUSBconnector,apowerjack,andanICSP(In-CircuitSerialProgramming) header.
It is programmed based on IDE, which stands for Integrated Development Environment. It
canrunonbothonlineandofflineplatforms.The IDE iscommontoallavailableboardsofArduino.

26
The Arduino board is shown below:

The components of Arduino UNO board are shown below:

Let's discuss each component in detail.

o ATmega328Microcontroller-Itisasingle-chipMicrocontrolleroftheATmelfamily.Theprocessor code
inside it is of 8-bit. It combines Memory (SRAM, EEPROM, and Flash), Analog to Digital
Converter, SPI serial ports, I/O lines, registers, timers, external and internal interrupts, and
oscillator.
o ICSP pin- TheIn-Circuit Serial Programming pin allows the userto program usingthe firmware of the
Arduino board.
o Power LEDIndicator- The ONstatus of theLEDshows the power is activated.When thepower is OFF,
the LED will not light up.
o DigitalI/Opins-ThedigitalpinshavethevalueHIGHorLOW.ThepinsnumberedfromD0toD13 are
digital pins.
o TXandRXLED's-The successful flowofdataisrepresentedbythelightingofthese LED's.
o AREF-The Analog Reference (AREF) pin is used to feed a reference voltage to the Arduino UNO
board from the external power supply.

27
o Resetbutton- Itis usedtoadd aResetbuttontotheconnection.
o USB-Itallowstheboardtoconnecttothecomputer.ItisessentialfortheprogrammingoftheArduino UNO
board.
o CrystalOscillator-TheCrystaloscillatorhasafrequencyof16MHz,whichmakestheArduinoUNO a
powerful board.
o VoltageRegulator-Thevoltageregulatorconvertstheinputvoltageto5V.
o GND- Groundpins. The groundpinactsasapinwithzero voltage.
o Vin-Itisthe input voltage.
o Analog Pins- The pins numbered from A0 to A5 are analog pins. The function of Analog pins is to
readtheanalogsensorusedintheconnection.ItcanalsoactasGPIO(GeneralPurposeInputOutput) pin.

TECHNICALSPECIFICATIONSOFARDUINOUNO
ThetechnicalspecificationsoftheArduinoUNOarelistedbelow:
o There are 20 Input/Output pins present on the Arduino UNO board. These 20 pins include 6 PWM
pins, 6 analog pins, and 8 digital I/O pins.
o ThePWM pins arePulse WidthModulationcapable.
o ThecrystaloscillatorpresentinArduinoUNOcomeswithafrequency of 16MHz.
o ItalsohasanArduino-integratedWIFImodule.SuchArduinoUNOboardisbasedontheIntegrated WIFI
ESP8266 Module and ATmega328P microcontroller.
o Theinputvoltageofthe UNO boardvariesfrom 7Vto20V.
o Arduino UNO automatically draws power from the external power supply. It can also draw
powerfrom the USB.

28
ARDUINO UNO PINOUT
TheArduinoUNOisastandardboardofArduino,whichisbasedonan ATmega328P microcontroller. It is
easier to use than other types of Arduino Boards.
TheArduinoUNO Board,with thespecification ofpins, isshown below:

Let'sdiscusseachpinindetail.
ATmega328 Microcontroller- It is a single chip Microcontroller of the ATmel family. The processor core
insideitisof8-bit.Itisalow-cost,lowpowered,andasimplemicrocontroller.The ArduinoUNOandNano models
are based on the ATmega328 Microcontroller.
Voltage Regulator: The voltageregulator convertsthe input voltage to 5V. Theprimaryfunctionof voltage
regulator is to regulate the voltage level in the Arduino board. For any changes in the input voltage of the
regulator, the output voltage is constant and steady.
GND - Ground pins.Theground pins are usedto ground the circuit.
TXD and RXD: TXD and RXD pins are used for serial communication. The TXD is used for transmitting the
data, and RXD is used for receiving the data. It also represents the successful flow of data.

29
USB Interface: The USB Interface is used to plug-in the USB cable. It allows the board to connect to the
computer. It is essential for the programming of the Arduino UNO board.
RESET: Itisusedtoadda Reset buttontothe connection.
SCK: It stands forSerial Clock. These are the clock pulses, which are used to synchronize the transmission
of data.
MISO: It stands forMaster Input/ Slave Output. The save line in the MISO pin is used to send the data to
the master.
VCC: It is the modulated DC supply voltage, which is used to regulate the IC's used in the connection. It is
alsocalledastheprimaryvoltageforIC'spresentontheArduinoboard.TheVccvoltagevaluecanbenegative or
positive with respect to the GND pin.
Crystal Oscillator-The Crystal oscillator has a frequency of 16MHz, which makes the Arduino UNO a
powerful board.
ICSP: It stands forIn-Circuit Serial Programming. The users can program the Arduino board's firmware
usingtheICSPpins.Theprogramorfirmwarewiththeadvancedfunctionalitiesisreceivedbymicrocontroller with
the help of the ICSP header. The ICSP header consists of 6 pins.
Thestructure of the ICSPheaderisshownbelow:

SDA: It stands for Serial Data. It is a line used by the slave and master to send and receive data. It is called
as a data line, while SCL is called as a clock line.
SCL:It stands forSerial Clock.It is defined as the linethat carries the clock data. It is used to synchronize the
transfer of data between the two devices. The Serial Clock is generated by the device and it is called as master.
SPI: It stands forSerial Peripheral Interface. It is popularly used by the microcontrollers to communicate
with one or more peripheral devices quickly. It uses conductors for data receiving, data sending,
synchronization, and device selection (for communication).
MOSI:ItstandsforMasterOutput/ SlaveInput. TheMOSIand SCKare drivenbytheMaster.
SS:ItstandsforSlaveSelect.ItistheSlaveSelectline,whichisusedbythemaster.Itactsastheenableline.
I2C:Itisthetwo-wireserialcommunicationprotocol.ItstandsforInterIntegratedCircuits.TheI2Cisaserial
communicationprotocolthatusesSCL(SerialClock)andSDA(SerialData)toreceiveandsenddatabetween two
devices.

30
3.3Vand5V aretheoperatingvoltagesoftheboard.

INTRODUCTIONTOARDUINOIDE2.0:

The Arduino IDE 2.0 is an open-source project, currently in its beta-phase. It is a big step from it's
sturdy predecessor, Arduino IDE 2.0, and comes with revamped UI, improved board & library
manger, autocomplete feature and much more.
Inthistutorial,wewillgothroughstepbystep,howtodownloadandinstallthesoftware.
Download theeditor
Downloading the Arduino IDE 2.0 is done through the Arduino Software page. Here you will also
find information on the other editors available to use.

Requirements
 Windows -Win10 andnewer,64 bits
 Linux- 64 bits
 MacOS X - Version 10.14:"Mojave" or newer, 64 bits

Installation
Windows
Download URL:https://www.arduino.cc/en/software
To install the Arduino IDE 2.0 on a Windows computer, simply runthe file downloaded from the
software page.

31
Followtheinstructionsintheinstallationguide.Theinstallationmaytakeseveralminutes.

YoucannowusetheArduinoIDE2.0onyourwindowscomputer!

HowtousetheboardmanagerwiththeArduinoIDE2.0
The board manager is a great tool for installing the necessary cores to use your Arduino boards. In
this quick tutorial, we will take a look at how to install one, and choosing the right core for your
board!
Requirements
 ArduinoIDE 2.0 installed.
Why use the board manager?
The board manager is a tool that is used to install different cores on your local computer. So whatis
a core, and why is it necessary that I install one?
Simply explained, a core is written and designed for specific microcontrollers. As Arduino
haveseveral different types of boards, they also have different type of microcontrollers.

Forexample,an ArduinoUNO has an ATmega328P,which uses the AVR core, whilean Arduino
Nano 33 IoT has a SAMD21 microcontroller, where we need to use theSAMD core.
Inconclusion,touseaspecificboard,weneedtoinstallaspecificcore.
Installingacore
Installingacoreisquickandeasy,butlet'stakealookatwhatweneedtodo.
1. OpentheArduinoIDE2.0.
2. With theeditoropen,let'stakea lookattheleft column.Here,wecanseea couple oficons. Let's

32
click the on the "computer chip"icon.

1. Alistwillnowappearofallavailablecores.Nowlet'ssayweareusingan Nano33
IoTboard,andwewanttoinstallthecore.Simplyenterthenameinthesearchfield,andthe right core
(SAMD) will appear, where the Nano 33 IoT features in the description. Click on the
"INSTALL"button.

4. Thiswillbeginaninstallationprocess,whichinsome casesmaytakeseveral minutes.

33
5. When it is finished, we can take a look at the core in the boards manager column, where it
should say "INSTALLED".

You have nowsuccessfully downloadedand installed a coreon your machine, and you can
startusing your Arduino board!

34
HowtouploadasketchwiththeArduinoIDE2.0
In the Arduino environment, we write sketches that can be uploaded to Arduino boards. In this
tutorial, we will go through how to select a board connectedto yourcomputer,and how to uploada
sketch to that board, using the Arduino IDE 2.0.
Requirements
 ArduinoIDE 2.0 installed.
VerifyVSUpload
There are two main tools when uploading a sketch to a board: verify and upload. The verify tool
simply goes through your sketch, checks for errors and compiles it. The upload tool does the same,
but when it finishes compiling the code, it also uploads it to the board.
A good practice is to use the verifying tool before attempting to upload anything. This is a
quickway of spotting any errors in your code, so you can fix them before actually uploading the
code. Uploading a sketch
Installingacoreisquickandeasy,butlet'stakealookatwhatweneedtodo.
1. OpentheArduinoIDE2.0.
2. With the editor open, let's take a look at the navigation bar at the top. At the very left, there is
a checkmark and an arrow pointing right. The checkmark is used to verify, and the arrow
is used to upload.

3. Clickontheverifytool(checkmark).Sinceweareverifyinganemptysketch,wecanbesure itis
going to compile. After a few seconds, we can see the resultof the action in the console (black
box in the bottom).

35
1. Now we know that our code is compiled, and that it is working. Now, before we can upload
thecodetoourboard,wewillfirstneedtoselecttheboardthatweareusing.Wecandothis
bynavigatingtoTools>Port > {Board}. Theboard(s) that areconnectedto your computer
shouldappearhere,andweneedtoselectitbyclickingit.Inthiscase,ourboardisdisplayed as
COM44 (Arduino UNO).

5. With the board selected, we are good to go! Click on the upload button, and it will start
uploading the sketch to the board.
6. When it is finished, it will notify you in the console log. Of course, sometimes there are
some complications when uploading, and these errors will be listed here as well.

36
You have now uploaded as ketch to your Arduino board!

HowtoinstallandusealibrarywiththeArduinoIDE2.0
A large part of the Arduino programming experience is the use of libraries. Thousands of libraries
can be found online, and the best-documented ones can be found and installed directly through the
editor. In this tutorial, we will go through how to install a library using the library manager in the
Arduino IDE 2.0. We will also show how to access examples from a library that you have installed.
Requirements
 Arduino IDE 2.0 installed.
Why use libraries?
Libraries are incredibly useful when creating a project of any type. They make our development
experiencemuchsmoother, andtherealmostaninfiniteamountoutthere.Theyareusedtointerface with
many different sensors, RTCs, Wi-Fi modules, RGB matrices and of course with other components
on your board.
Arduino has many official libraries, but the real heroes are the Arduino community, who develop,
maintain and improve their libraries on a regular basis.
Installingalibrary
Installingalibraryisquickandeasy,butlet'stakealookatwhatweneedtodo.
1. OpentheArduinoIDE2.0.
2. With theeditoropen,let'stakea lookattheleft column.Here,wecanseea couple oficons. Let's
click the on the "library"icon.

37
3. A list will now appear of all available libraries, where we can also search for the library we
wanttouse.Inthisexample,wearegoingtoinstallthe RTCZerolibrary.Clickonthe
"INSTALL"button to install the library.

4. Thisprocessshouldnottaketoolong,butallowuptoa minute toinstallit.

38
5. Whenitisfinished,wecantakealookatthelibraryinthelibrarymanagercolumn,whereit should say
"INSTALLED".

Youhavenowsuccessfullydownloadedandinstalledalibraryonyourmachine.

39
Includingalibrary
Tousealibrary,youfirstneedtoincludethelibraryatthetopofthesketch.

Almost all libraries come with already made examples that you can use. These are accessible through
File>Examples>{Library}>{Example}.Inthisexample,wearechoosing the RTCZero >
SimpleRTC.

The chosen example will now open up in a newwindow, and you can start using it however
youwant to.

40
RESULT:

Thus the above program introduction to the Arduino platform was executed sucessfully.

41
EXP NO: 7
INTRODUCTION TO ARDUINO PROGRAMMING
DATE

AIM:
Towriteandexecute differentArduinoprogramming foranalog,digitalsignalsand serial
communication.

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No Hardware& Software Requirements Quantity


1 ArduinoIDE 2.0 1
2 ArduinoUNODevelopmentBoard 1
3 Jumper Wires few

4 ArduinoUSB Cable 1

5 Joystick Module 1

PROCEDURE:

42
CONNECTION:

Arduino UNO Pin ArduinoDevelopmentBoard


2 LED

PROGRAM:

DIGITAL WRITE:
void setup() {
pinMode(2,OUTPUT);
}
void loop() {
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);

43
CONNECTION:

Arduino UNOPin ArduinoDevelopmentBoard


2 LED
5 S1 (SW1)

DIGITALREAD:
void setup() {
pinMode(2,OUTPUT);
pinMode(5,INPUT_PULLUP);
}
voidloop(){
intsw=digitalRead(5);
if(sw==1)
{
for(inti=0;i<5;i++)
{
digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);

}
}
else
{
digitalWrite(2,LOW);
}
}

44
CONNECTION:

Arduino UNOPin ArduinoDevelopmentBoard Joystick Module


2 LED
VCC or 5V +5V
GND GND
A0 VRxor VRy

ANALOG READ:
void setup() {
pinMode(2,OUTPUT);
Serial.begin(9600);
}
voidloop(){
intjoystick=analogRead(A0);
Serial.println(joystick);

if(joystick>800)
digitalWrite(2, HIGH);
else
digitalWrite(2,LOW);

delay(500);
}

45
CONNECTION:

Arduino UNO Pin ArduinoDevelopmentBoard


3 LED

PWMPins: 3,5,6,9,10,11

ANALOG WRITE:
void setup() {
pinMode(3,OUTPUT);
}
voidloop(){
for(inti=0;i<256;i++){
analogWrite(3,i);
delay(20);
}
for(inti=255;i>=0;i--){
analogWrite(3,i);
delay(20);
}
}

46
CONNECTION:

Arduino UNO Pin ArduinoDevelopmentBoard


4 LED

SERIAL COMMUNICATION:
voidsetup() {
Serial.begin(9600);
pinMode(4,OUTPUT);
}

void loop() {
if(Serial.available()>0)
{
chardata=Serial.read();
Serial.println(data);
if(data=='1'){
digitalWrite(4,HIGH);
}
else if(data=='2'){
digitalWrite(4,LOW);
}
}
}

RESULT:
Thus the above program introduction to Arduino programming was executed successfull

47
EXP NO: 8 DIFFERENT COMMUNICATION METHODS WITH IOT
DATE DEVICES (Zigbee, GSM, Bluetooth)

AIM:
To Explore differentcommunicationmethodswithIoTdevices (Zigbee,GSM, Bluetooth).

DIFFERENTCOMMUNICATION METHODS:

IoTdevices requirereliable andefficient communication methods totransmit data andinteractwith other


devices or systems. Here are three commonly used communication methods for IoT devices:

Zigbee:
Zigbee is a low-power wireless communication protocol designed for short-range
communication between devices. It operates on the 2.4 GHz frequency band and supports mesh
networking, allowing devicestocommunicatewitheachotherthroughintermediatenodes.Zigbeeis
commonly used in home automation, industrial control, and smart energy applications.

GSM(GlobalSystemforMobile Communications):
GSMisawidelyusedcellularnetworktechnologythatenablesIoTdevicestoconnecttothe
internetusingSIMcards.Itoperatesonvariousfrequencybandsandprovideswidecoverage,making it
suitable for applications that require long-range communication. GSM is commonly used in
applications such as asset tracking, remote monitoring, and smart cities.

Bluetooth:
Bluetooth is a short-range wireless communication technology that operates on the 2.4 GHz
frequency band. It is commonly used for connecting IoT devices to smartphones, tablets, and other
nearby devices. Bluetooth Low Energy (BLE) is a power-efficient version of Bluetooth that is ideal
forbattery-poweredIoTdevices.Bluetoothiswidelyusedinapplicationssuchaswearabledevices,
healthcare monitoring, and home automation.

48
Each communication method has its advantages and limitations, and the choice depends on
the specific requirements of the IoT application. Factors to consider include range, power
consumption, data rate, security, and interoperability with other devices or systems.

RESULT:

Thus the above program using different communication methods with IOT devices
(Zigbee,GSM,Bluetooth) was executed successfully.

49
EXP NO: 9
BLUETOOTH COMMUNICATION
DATE

AIM:
TowriteaprogramtocontrolanLED using aBluetoothmodule.

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No Hardware& Software Requirements Quantity


1 ArduinoIDE 2.0 1
2 ArduinoUNODevelopmentBoard 1
3 Jumper Wires few

4 ArduinoUSB Cable 1

5 HC-05Bluetooth Module 1

PROCEDURE

50
CONNECTIONS:

Arduino UNOPin BluetoothModule ArduinoDevelopmentBoard


VCC 5V -
GND GND -
2 Tx -
3 Rx -
4 - LED

PROGRAM:

#include<SoftwareSerial.h>Softwar
eSerialmySerial(2,3);//rx,tx void
setup() {mySerial.begin(9600);
Serial.begin(9600);
pinMode(4,OUTPUT);
}
void loop() {
if(mySerial.available()>0)
{
char data=mySerial.read();
Serial.println(data);
if(data=='1'){
digitalWrite(4,HIGH);
Serial.println("LED ON");
}
else if(data=='2'){
digitalWrite(4,LOW);
Serial.println("LEDOFF");
}
}
}

51
RESULT:

Thus the above program using Bluetooth communication executed successfully .

52
EXP NO: 10
ZIGBEE COMMUNICATION
DATE

AIM:
Towriteaprogramtocontrol anLEDusing a Zigbeemodule.

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No Hardware& Software Requirements Quantity


1 ArduinoIDE 2.0 1
2 ArduinoUNODevelopmentBoard 2
3 Jumper Wires few

4 ArduinoUSB Cable 2

5 ZigbeeModule 2

PROCEDURE

53
CONNECTIONS:

TRANSMITTER:

Arduino UNOPin ZigbeeModule


VCC 5V
GND G
2 Tx
3 Rx

PROGRAM:
TRANSMITTERSIDE:

#include<SoftwareSerial.h>Software
SerialmySerial(2,3);//rx,tx void
setup() {
mySerial.begin(9600);
Serial.begin(9600);
}

voidloop(){
mySerial.write('A');
Serial.println('A');
delay(100);
mySerial.write('B');
Serial.println('B');
delay(100);
}

54
CONNECTIONS:

RECEIVER:
Arduino UNOPin ZigbeeModule ArduinoDevelopmentBoard
- 5V 5V
- G GND
2 Tx -
3 Rx -
4 - LED1

RECEIVER SIDE:
#include<SoftwareSerial.h>Software
SerialmySerial(2,3);//rx,tx void
setup() {
mySerial.begin(9600);
Serial.begin(9600);
pinMode(4,OUTPUT);
}

void loop() {
if(mySerial.available()>0)
{
chardata=mySerial.read();
Serial.println(data);
if(data=='A')

digitalWrite(4,HIGH);else
if(data=='B')
digitalWrite(4,LOW);
}
}

55
RESULT:

`Thus the above program using Zigbee communication executed successfully.

56
EXP NO:11 INTRODUCTIONTOTHERASPBERRYPI
DATE PLATFORM

IntroductiontoRaspberryPiPicoW:

TheRaspberry Pi Pico Wis a compact and affordable microcontroller board developed by the
Raspberry Pi Foundation. Building upon the success of the Raspberry Pi Pico, the Pico W variant
brings wireless connectivity to the table, making it an even more versatile platform for embedded
projects. In this article, we will provide a comprehensive overview of the Raspberry Pi Pico W,
highlighting its key features and capabilities.
Features:
 RP2040microcontrollerwith2MBofflash memory
 On-boardsingle-band2.4GHzwireless interfaces(802.11n)
 MicroUSBB portforpower anddata(and forreprogramming the flash)
 40pins21mmx51mm‘DIP’style1mmthickPCBwith0.1″through-holepinsalsowithedge
castellations
 Exposes26multi-function3.3VgeneralpurposeI/O(GPIO)
 23GPIOaredigital-only,withthreealso being ADC-capable
 Canbesurface mountedasa module
 3-pinARMserialwiredebug(SWD) port
 Simpleyethighlyflexiblepowersupply architecture
 Variousoptionsforeasilypoweringtheunitfrommicro-USB,externalsupplies,orbatteries
 Highquality, lowcost,highavailability
 ComprehensiveSDK,softwareexamples,and documentation
 Dual-coreCortex M0+at upto 133MHz
 On-chipPLLallows variablecore frequency
 264kBytemulti-bankhigh-performanceSRAM

RaspberryPiPico W:
TheRaspberryPiPicoWisbasedontheRP2040microcontroller,whichwasdesignedbyRaspberry Pi in-
house. It combines a powerful ARM Cortex-M0+ processor with built-in Wi-Fi connectivity,
openinguparangeofpossibilitiesforIoTprojects,remotemonitoring,andwirelesscommunication.
ThePicoWretainsthesameformfactorastheoriginalPico,makingitcompatiblewithexistingPico
accessories and add-ons.

57
RP2040 Microcontroller:
At the core of the Raspberry Pi Pico W isthe RP2040 microcontroller. It features a dual-core ARM
Cortex-M0+ processor running at 133MHz, providing ample processing power for a wide range of
applications. The microcontroller also includes 264KB of SRAM, which is essential for storing and
manipulating data during runtime. Additionally, the RP2040 incorporates 2MB of onboard flash
memory for program storage, ensuring sufficient space for your code and firmware.

WirelessConnectivity:
The standout feature of the Raspberry Pi Pico W is its built-in wireless connectivity. It includes an
onboard Cypress CYW43455 Wi-Fi chip, which supports dual-band (2.4GHz and 5GHz) Wi-Fi
802.11b/g/n/ac. This allows the Pico W to seamlessly connect to wireless networks, communicate
withotherdevices,andaccessonlineservices.ThewirelesscapabilityopensupnewavenuesforIoT
projects, remote monitoring and control, and real-time data exchange.

GPIOand Peripherals:
Similar to theRaspberry Pi Pico, the Pico W offers a generous number of GPIO pins, providing
flexibility for interfacing with external components and peripherals. It features 26 GPIO pins, of
which 3 are analog inputs, and supports various protocols such as UART, SPI, I2C, and PWM. The
PicoWalsoincludesonboardLEDindicatorsandamicro-USBportforpoweranddataconnectivity.

MicroPythonandC/C++ Programming:
TheRaspberryPiPicoWcanbeprogrammedusingMicroPython,abeginner-friendlyprogramming
language that allows for rapid prototyping and development. MicroPython provides a simplified
syntaxandhigh-levelabstractions,makingiteasyfornewcomerstogetstarted.Additionally,the

58
Pico W is compatible with C/C++ programming, allowing experienced developers to leverage the
rich ecosystem of libraries and frameworks available.

ProgrammableInput/Output(PIO)StateMachines:
One of the unique features of the RP2040 microcontroller is the inclusion of Programmable
Input/Output (PIO) state machines. These state machines provide additional processing power and
flexibility for handling real-time data and timing-critical applications. The PIO state machines can be
programmed to interface with custom protocols, generate precise waveforms, and offload tasks from
the main processor, enhancing the overall performance of the system.

Open-SourceandCommunity Support
AswithallRaspberryPiproducts,thePicoWbenefitsfromthevibrantandsupportiveRaspberryPi
community.RaspberryPiprovidesextensivedocumentation,includingdatasheets,pinoutdiagrams, and
programming guides, to assist developers in understanding the board’s capabilities. The
communityoffersforums,onlinetutorials,andprojectrepositories,allowinguserstoseekhelp,share
knowledge, and collaborate on innovative projects.

59
The Raspberry Pi Pico W brings wireless connectivity to the popular Raspberry Pi Pico
microcontroller board. With its powerful RP2040 microcontroller, built-in Wi-Fi chip, extensive
GPIOcapabilities,andcompatibilitywithMicroPythonandC/C++programming,thePicoWoffers a
versatile and affordable platform for a wide range of embedded projects. Whether you are a
beginneroranexperienceddeveloper,theRaspberryPiPicoWprovidesauser-friendlyandflexible
platform to bring your ideas to life and explore the exciting world of wireless IoT applications.

RESULT:

Thus the above program using introduction other as Raspberry Pi platform was executed
successfully.

60
EXP NO: 12
INTRODUCTION TO PYTHON PROGRAMMING
DATE

GettingStartedwithThonnyMicroPython(Python)IDE:
If you want to program your ESP32 and ESP8266 with MicroPython firmware, it’s very handy to
use an IDE. you’ll have your first LED blinking using MicroPython and Thonny IDE.

What is MicroPython?
MicroPython is a Python 3 programming language re-implementation targeted for microcontrollers
andembeddedsystems.MicroPythonisverysimilartoregularPython.Apartfromafewexceptions, the
language features of Python are also available in MicroPython. The most significant difference
between Python and MicroPython is that MicroPython was designed to work under constrained
conditions.
Because of that, MicroPython does not come with the entire pack of standard libraries. It only
includesasmallsubsetofthePythonstandardlibraries,butitincludesmodulestoeasilycontroland interact
with the GPIOs, use Wi-Fi, and other communication protocols.

61
ThonnyIDE:
Thonnyisanopen-sourceIDEwhichisusedtowriteanduploadMicroPythonprogramstodifferent
developmentboardssuchasRaspberryPiPico,ESP32,andESP8266.Itisextremelyinteractiveand easy to
learn IDE as much as it is known as the beginner-friendly IDE for new programmers. With the help
of Thonny, it becomes very easy to code in Micropython as it has a built-in debugger that helps to
find any error in the program by debugging the script line by line.

You can realize the popularity of Thonny IDE from this that it comes pre-installed in Raspian OS
whichisanoperatingsystemforaRaspberryPi.ItisavailabletoinstallonrWindows,Linux,and Mac OS.

A) InstallingThonnyIDE –WindowsPC
ThonnyIDEcomesinstalledbydefaultonRaspbianOSthatisusedwiththeRaspberryPiboard. To install
Thonny on your Windows PC, follow the next instructions:
1. Go to https://thonny.org
2. DownloadtheversionforWindows andwaitafewseconds whileitdownloads.

3.Runthe .exefile.

62
4. Followtheinstallationwizard tocompletethe installationprocess.Youjustneedtoclick“Next”.

5. After completing the installation, open Thonny IDE. A window as shown in the following figure
should open.

63
CONNECTIONS:

RaspberryPiPico Pin Raspberry Pi Pico


DevelopmentBoard
GP16 LED

PROGRAM

LED:
frommachineimportPin
import time
LED= Pin(16, Pin.OUT)
while True:
LED.value(1)
time.sleep(1)

LED.value(0)
time.sleep(1)

64
CONNECTIONS:

RaspberryPiPico Pin Raspberry Pi Pico


DevelopmentBoard
(RGB)
GP16 R
GP17 G
GP18 B
GND COM

RGB:
frommachineimportPin
fromtimeimportsleep_ms,sleep
r=Pin(16,Pin.OUT)
y=Pin(17,Pin.OUT)
g=Pin(18,Pin.OUT)

while True:
r.value(1)
sleep_ms(1000)
r.value(0)
sleep_ms(1000)
y.value(1)
sleep(1)
y.value(0)
sleep(1)
g.value(1)
sleep(1)
g.value(0)
sleep(1)

65
CONNECTIONS:

RaspberryPiPico Pin Raspberry Pi Pico


DevelopmentBoard
GP16 LED
GP15 SW1

SWITCHCONTROLLEDLED:
frommachineimportPin
from time import sleep
led=Pin(16,Pin.OUT)
sw=Pin(15,Pin.IN)
while True:
bt=sw.value()
if bt== True:
print("LEDON")
led.value(1)
sleep(2)led.value
(0)
sleep(2)led.value
(1) sleep(2)
led.value(0)
sleep(2)
else:
print("LEDOFF")
sleep(0.5)

RESULT:

Thus the above program using introduction to python programming was executed successfully.

66
EXP NO: 13
INTERFACING SENSORS WITH RASPBERRY PI
DATE

AIM:
TointerfacetheIR sensorandUltrasonic sensor withRaspberryPico.

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No Hardware& Software Requirements Quantity

1 Thonny IDE 1
2 RaspberryPiPicoDevelopmentBoard 1
3 Jumper Wires few

4 Micro USB Cable 1

5 IR Sensor 1

6 Ultrasonicsensor 1

PROCEDURE

67
CONNECTIONS:

RaspberryPiPico Raspberry Pi Pico


IRSensor Module
Pin DevelopmentBoard
GP16 BUZZER -
GP15 - OUT
- 5V VCC
- GND GND

PROGRAM:

IRSensor:
frommachineimportPin
from time import sleep
buzzer=Pin(16,Pin.OUT)
ir=Pin(15,Pin.IN)
while True:
ir_value=ir.value()

ifir_value==True:
print("BuzzerOFF")
buzzer.value(0)
else:
print("BuzzerON")
buzzer.value (1)
sleep(0.5)

68
CONNECTIONS:

RaspberryPiPico Pin Raspberry Pi Pico


UltrasonicSensor Module
DevelopmentBoard
GP16 BUZZER -
GP15 - ECHO
GP14 - TRIG
- 5V VCC
- GND GND

ULTRASONIC SENSOR:

frommachineimportPin,PWM import
utime
trigger=Pin(14,Pin.OUT)
echo = Pin(15, Pin.IN)
buzzer=Pin(16,Pin.OUT)

defmeasure_distance():
trigger.low()
utime.sleep_us(2)
trigger.high()
utime.sleep_us(5)
trigger.low()
while echo.value() == 0:
signaloff=utime.ticks_us()
while echo.value() == 1:
signalon=utime.ticks_us()

timepassed = signalon - signaloff


distance=(timepassed*0.0343)/2 return
distance

whileTrue:
dist = measure_distance()
print(f"Distance:{dist}cm") if
dist <= 10:
buzzer.value(1)
utime.sleep(0.01)
else:
buzzer.value(0)
utime.sleep(0.01)
utime.sleep(0.5)

69
RESULT:

Thus the above program using interfacing sensors with Raspberry Pi was executed successfully.

70
EXP NO: 14 COMMUNICATE BETWEEN ARDUINO AND
DATE RASPBERRY PI

AIM:
Towriteandexecute theprogram toCommunicatebetweenArduinoandRaspberry PI
usinganywirelessmedium (Bluetooth)

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No Hardware& Software Requirements Quantity

1 Thonny IDE 1

2 RaspberryPiPicoDevelopmentBoard 1
3 ArduinoUnoDevelopment Board 1
4 Jumper Wires few

5 Micro USB Cable 1


6 BluetoothModule 2

PROCEDURE
CONNECTIONS:

Arduino UNOPin ArduinoDevelopmentBoard Bluetooth Module


2 - Tx
3 - Rx
- GND GND
- 5V 5V

PROGRAM:

MASTER
ARDUINO:
#include<SoftwareSerial.h>Software
SerialmySerial(2,3);//rx,tx void
setup() {
mySerial.begin(9600);
voidloop(){
mySerial.write('A');
delay(1000);
mySerial.write('B');
delay(1000);
}
CONNECTIONS:

RaspberryPiPico Pin Raspberry Pi Pico


Bluetooth Module
DevelopmentBoard
GP16 LED -
VCC - +5V
GND - GND
GP1 - Tx
GP0 - Rx

SLAVE
RASPBERRY PI PICO
frommachineimportPin,UART uart
= UART(0, 9600)
led=Pin(16,Pin.OUT)

whileTrue:
ifuart.any()>0:
data=uart.read()
print(data)
if "A" in data:
led.value(1)print('LED
on \n')
uart.write('LEDon\n')

elif "B" in data:


led.value(0)print('LED
off \n')
uart.write('LEDoff\n')
RESULT:

Thus the above program using communicate between Arduino andRaspberry


EXP NO: 15
CLOUD PLATFORM TO LOG THE DATA
DATE

AIM:
To set up a cloud platform to log the data from IoT devices.

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No. Software Requirements Quantity

1 Blynk Platform 1

CLOUDPLATFORM-BLYNK:

Blynk is a smart platform that allow users to create the internet of Thing application without the need
for coding or electronics knowledge. It is based on the idea of physical programming & provides
aplatformtocreateandcontroldeviceswhereuserscanconnectphysicaldevicestotheInternetand control
them using a mobile app.

Setting up Blynk 2.0Application


To control the LED using Blynk and Raspberry Pi Pico W, you need to create a Blynk project and
set up a dashboard in the mobile or web application. Here’s how you can set up the dashboard:
Step1:Visitblynk.cloudandcreateaBlynkaccountontheBlynkwebsite.Oryoucansimplysign in using
the registered Email ID.
Step 3: Give any name to the Template such as Raspberry Pi Pico W. Select ‘Hardware Type’ as
Other and ‘Connection Type’ as Wi-Fi.

So template will be created now.


Step4:Now weneedtoadda‘NewDevice’now.

Selecta New Device from ‘Template’.


Selectthedevicefromatemplatethatyoucreatedearlierandalsogiveanynametothedevice.Click on Create.

A new device will be created. You will find the Blynk Authentication Token Here. Copy it as it is
necessary for the code.
Step5:Now go to the dashboard and select ‘Web Dashboard’.

From the widget box drags witch and placation the dashboard screen.
Step6:

OntheswitchboardclickonSettingsandhereyouneedtosetuptheSwitch.Giveanytitletoitand Create
Datastream as Virtual Pin.

Configure the switch setting sasperthe image belowand click on create.


Configurethe finalsteps again.
With this Blynk dashboard set up, you can now proceed to program the Raspberry Pi Pico W board
to control the LED.

Step7:

To control the LED with a mobile App or Mobile Dashboard, you also need to setup the Mobile
Phone Dashboard. The process is similarly explained above.

InstalltheBlynkapponyoursmartphoneTheBlynkappisavailableforiOSandAndroid.Download and
install the app on your smartphone. then need to set up both the Mobile App and the Mobile
Dashboard in order to control the LED with a mobile device. The process is explained above.

1. Open Google PlayStore Apponan android phone


2. Open Blynk.App
3. LogInto youraccount (usingthe sameemailandpassword)
4. SwitchtoDeveloperMode
5. Find the“RaspberryPiPicoPicoW”templatewecreatedontheweb and tap onit
6. Tap on the “Raspberry Pi Pico Pico W” template (this template automatically comes because we
created it on our dashboard).
7. tap onplusiconontheleft-rightside ofthewindow
8. Addone buttonSwitch
9. NowWe SuccessfullyCreatedan android template
10. itwillworksimilarlytoawebdashboardtemplate

RESULT:

Thus the above program using cloud platform log data was executed successfully.
EXP NO: 16 LOG DATA USING RASPBERRY PI AND UPLOAD IT TO
DATE THE CLOUD PLATFORM

AIM:
To write and execute the program Log Data using Raspberry PIand up loadittothecloud
platform

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No Hardware& Software Requirements Quantity


1 Thonny IDE 1
2 RaspberryPiPicoDevelopmentBoard few

3 Jumper Wires 1

4 Micro USB Cable 1

PROCEDURE
CONNECTIONS:

RaspberryPiPico Pin Raspberry Pi Pico


LCDModule
DevelopmentBoard
- 5V VCC
- GND GND
GP0 - SDA
GP1 - SCL

PROGRAM:
frommachineimportPin,I2C,ADC
from utime import sleep_ms
frompico_i2c_lcdimportI2cLcd
import time
import network
importBlynkLib
adc= machine.ADC(4)
i2c=I2C(0,sda=Pin(0),scl=Pin(1),freq=400000)
I2C_ADDR=i2c.scan()[0]
lcd=I2cLcd(i2c,I2C_ADDR,2,16)

wlan=network.WLAN()
wlan.active(True)
wlan.connect("Wifi_Username","Wifi_Password")

BLYNK_AUTH = 'Your_Token'

#connectthenetwork wait
= 10
whilewait>0:
ifwlan.status()<0orwlan.status()>=3: break
wait-= 1
print('waitingforconnection...')
time.sleep(1)

#Handleconnectionerror if
wlan.status() != 3:
raiseRuntimeError('networkconnectionfailed') else:
print('connected')
ip=wlan.ifconfig()[0]
print('IP: ', ip)

"ConnectiontoBlynk" #
Initialize Blynk
blynk= BlynkLib.Blynk(BLYNK_AUTH)

lcd.clear()

whileTrue:
ADC_voltage = adc.read_u16() * (3.3 / (65536))
temperature_celcius=27-(ADC_voltage-0.706)/0.001721
temp_fahrenheit=32+(1.8*temperature_celcius)
print("Temperature in C: {}".format(temperature_celcius))
print("Temperature in F: {}".format(temp_fahrenheit))

lcd.move_to(0,0)
lcd.putstr("Temp:")
lcd.putstr(str(round(temperature_celcius,2)))
lcd.putstr("C ")
lcd.move_to(0,1)
lcd.putstr("Temp:")
lcd.putstr(str(round(temp_fahrenheit,2)))
lcd.putstr("F")
time.sleep(5)

blynk.virtual_write(3,temperature_celcius)
blynk.virtual_write(4, temp_fahrenheit)
blynk.log_event(temperature_celcius)

blynk.run()

time.sleep(5)

RESULT:

Thus the above program using log data using Raspberry Pi and upload it to the cloud platform was
executed successfully.
EXP NO: 17
DESIGN AN IOT-BASED SYSTEM
DATE

AIM:
To design a Smart Home Automation IOT-basedsystem

HARDWARE&SOFTWARETOOLS REQUIRED:

S.No Hardware& Software Requirements Quantity


1 Thonny IDE 1
2 RaspberryPiPicoDevelopmentBoard few

3 Jumper Wires 1

4 Micro USB Cable 1

5 LEDorRelay 1

PROCEDURE
CONNECTIONS:
RaspberryPiPico Pin Raspberry Pi Pico
DevelopmentBoard
GP16 LED1

PROGRAM:

import time
import network
importBlynkLib
frommachineimportPin
led=Pin(16, Pin.OUT)

wlan=network.WLAN()
wlan.active(True)
wlan.connect("Wifi_Username","Wifi_Password")
BLYNK_AUTH = 'Your_Token'

#connectthenetwork wait
= 10
whilewait>0:
ifwlan.status()<0orwlan.status()>=3: break
wait-= 1
print('waitingforconnection...')
time.sleep(1)

#Handleconnectionerror if
wlan.status() != 3:
raiseRuntimeError('networkconnectionfailed') else:
print('connected')
ip=wlan.ifconfig()[0]
print('IP: ', ip)

"ConnectiontoBlynk" #
Initialize Blynk
blynk= BlynkLib.Blynk(BLYNK_AUTH)
@blynk.on("V0")#virtualpinV0
defv0_write_handler(value):#readthevalue if
int(value[0]) == 1:
led.value(1)#turntheledon else:
d.value(0) #turntheledoff
while True:
blynk.run()
RESULT:

Thus the above program using Designan IOT basedsystem

You might also like