Professional Documents
Culture Documents
Workshop-Iot Sem-02 PDF
Workshop-Iot Sem-02 PDF
Workshop-Iot Sem-02 PDF
PRACTICAL NO. 1
OBJECTIVE
To identify different electrical and electronic components like resistor, capacitor, diode &
transistor.
To prepare circuit on breadboard.
To operate and measure various electronic parameters using multi-meter.
APPARATUS
Resistor
Capacitor
Diode
Transistor
Multi-meter
Breadboard
Connecting leads
Hook up wires
LED
9V Battery
Battery Clip
THEORY
Resistor
A resistor is an electrical component that limits or regulates the flow of electrical
current in an electronic circuit.
The general formula of resistor is: R=
Different types of resistors are carbon composition resistor, wire wound resistor,
carbon film resistor etc., the most commonly used resistor is carbon resistor, the
color coding of carbon resistor is given bellow.
Fig.1.2. Breadboard
Multi-meter
A multi-meter is an instrument for measuring voltage, current, resistance and
other electronic measurements.
The two test leads are touched to electrical circuits, and the control dial is used to
determine the measurement which will be taken.
Procedure
ii) Keep the positive probe to the center pin (Base) of the transistor.
iii) Touch the negative probe to the pin-1 (Emitter). You will see some voltage in
the multi-meter.
iv) Similarly touch the negative probe to the pin-3 (collector) with respect to the
pin-2. You will see some voltage in the multi-meter.
v) It will ensure that it is a NPN transistor. The logic behind this is, in NPN
transistor
Emitter (E) - N type material - Equivalent to cathode of the diode
Base (B) - P type material - Equivalent to anode of the diode
Collector(C) - N type material - Equivalent to cathode of the diode
vi) If the multi-meter positive probe is connected to anode and negative probe is
connected to cathode, then it will show voltage. If the connections are
interchanged it will not show any value.
b) Steps to identify NPN type transistor:
i) Keep the Multi-Meter in the Diode mode.
ii) Keep the positive probe to the pin-1 (Emitter) of the transistor.
iii) Touch the negative probe to the center pin (Base). You will see some voltage
in the multi-meter.
iv) Similarly touch the negative probe to the center pin (Base) with respect to the
pin-3 (collector). You will see some voltage in the multi-meter.
v) It will ensure that it is a PNP transistor. The logic behind this is, in PNP
transistor
Emitter (E) - P type material - Equivalent to anode of the diode
Base (B) - N type material - Equivalent to cathode of the diode
Collector(C) - P type material - Equivalent to anode of the diode
vi) If the multi-meter positive probe is connected to anode and negative probe is
connected to cathode, then it will show voltage. If the connections are
interchanged it will not show any value.
c) Steps to test the transistor:
i) Keep the multi-meter in the Continuity mode.
ii) If the transistor is an NPN, connect the positive multi-meter lead to the Base
and the negative to the Collector terminal.
iii) The multi-meter should indicate continuity, the reading should be about same
as reading obtained when the individual diode was tested across its terminals.
iv) With the positive multi-meter lead still connected to the Base terminal of the
transistor, connect the negative lead to the Emitter terminal. The multi-meter
should again indicate a forward diode junction.
Note: If the multi-meter does not indicate continuity between the base-
collector or base-emitter, the transistor is open.
v) Connect the negative multi-meter lead to the Base and the positive lead to the
Collector. The multi-meter should indicate infinity or no connectivity.
vi) With the negative multi-meter lead connected to the Base, reconnect the
positive lead to the Emitter. There should, again, be no indication of
continuity.
PRACTICAL NO. 10
AIM: - To prepare shapes and graphics using Turtle and Scratch programs
respectively in Raspberry Pi 3.
OBJECTIVE
To generate various geometrical shapes using turtle in python programming
To generate various graphics using scratch programming
APPARATUS
Monitor with VGA cable and adapter for power supply.
Micro USB power supply cable and adapter.
USB based Keyboard and mouse.
Micro SD card.
Micro SD card reader
Raspberry Pi model 3 board.
HDMI to VGA Converter
THEORY
“Turtle” is a Python feature like a drawing board, which lets us command a turtle to draw all
over it. We can use functions like turtle.forward(…) and turtle.right(…) which can move the
turtle around. Commonly used turtle methods are:
METHOD PARAMETER DESCRIPTION
fillcolor() Color name Changes the color of the turtle will use to fill a polygon
end_fill() None Close the polygon and fill with the current fill color
To make use of the turtle methods and functionalities, we need to import turtle ”turtle” comes
packed with the standard Python package and need not be installed externally. The roadmap for
executing a turtle program follows 4 steps:
1. Import the turtle module
2. Create a turtle to control.
3. Draw around using the turtle methods.
4. Run turtle.done().
Scratch is a visual programming tool which allows the user to create animations and games with
a drag-and-drop interface. It allows you to create your own computer games, interactive stories,
and animations using some programming techniques without actually having to write code. It’s a
great way to get started programming on the Raspberry Pi with young people. In scratch
programming we don’t need to remember the instructions, as it is a graphical programming
language. We need to drag and drop the instruction from the list provided.
PROCEDURE
Turtle Programming
vgec.right(90)
vgec.forward(30)
vgec.backward(30)
vgec.right(45)
vgec.left(90)
vgec.backward(30)
vgec.left(45)
vgec.right(90)
vgec.forward(90)
for i in range (8):
branch()
vgec.left(45)
vgec.color(random.choice(colours))
Scratch Programming
CONCLUSION
PRACTICAL NO.2
AIM: - To measure voltage, current, frequency and phase difference using Digital
Oscilloscope (DSO).
OBJECTIVE
APPARATUS
Function Generator.
DSO.
Multimeter.
BNC connector.
Crocodile pins [ 1 red and 1 black]
Wire cutter.
Coaxial/Twisted Cable.
Insulation tape.
THEORY
A.C. (Alternating Current): Alternating current is the current in which the polarity of source
continuously changes on a fixed frequency. Different types of AC waveforms are shown in
figure below:
The RMS value is the effective value of a varying current. It is the equivalent steady DC value
which gives the same effect. For an Example, a lamp connected to 6V AC supply will shine with
the same brightness when connected to a steady 6V DC supply.
Peak Value is the maximum value attained by an alternating quantity during one cycle. The
sinusoidal alternating quantity obtains its peak value at 90°.
D.C. (Direct Current): A flow of electricity that goes in one direction only. Direct current can
be obtained from an alternating current supply by use of rectifier and battery is a good dc power
supply.
1] With DC Offset: DC offset is a mean amplitude displacement from zero. In Audacity it can be
seen as an offset of the recorded wave form away from the center zero point.DC offset is a
potential source of clicks,distortion and loss of audio volume.
2] Without DC Offset: When describing a periodic function in the time domain, the DC offset, or
is the mean amplitude of the waveform. If the mean amplitude is zero, there is no DC offset. A
waveform with no DC offset is known as a DC balanced or DC free waveform
PROCEDURE
To prepare DSO probe
Take the BNC connector and open it
Take the coaxial cable of required length
Connect the centre of the coaxial cable wire to the centre of the BNC connector
Connect the rest of the wire surrounding the circular ring available.
Close the BNC connector
At the other end of the coaxial cable connect the banana pins with the centre cof coaxial
cable connected with red colour banana clip and surrounding wire to the black colour
banana clip.
Check the continuity of banana clips with surrounding body of BNC and centre of BNC
connector with Black and red colour banana clips respectively.
To operate DSO and function generator
Turn on DSO.
Select appropriate language
Test the channel and DSO probe by connecting probe at Channel 1 the BNC connector
and red banana clip on 5Vp-p pulse connection near the DSO screen and connect black
banana pin to the ground connection near DSO screen.
Connect the DSO channel 1 to the output of the function generator through DSO probe.
Vary the Volts/Division knob of channel1 and time/division knob present at Horizontal
axis to see the waveform clearly.
Adjust the trigger knob near zero line so that a steady waveform can be seen on the
screen.
Measure amplitude, frequency and other parameters from the functionality available on
the DSO.
Change the waveform and observe the changes.
Change frequency and amplitude from function generator of the waveform and observe
the changes
Observe the changes arising by changing the amplitude of DC offset in the function
generator on the DSO screen.
CONCLUSION :
PRACTICAL NO: 3
OBJECTIVE
APPARATUS
THEORY
Earth Leakage Circuit Breaker (ELCB)
An Earth Leakage Circuit Breaker (ELCB) is a safety device used in electrical installations
with high earth impedance to prevent shock. If there is no fault anywhere in a circuit
supplying single-phase alternating power to a unit such as an electrical appliance, machine or
other equipment, the current flowing to the unit at any instant in the "hot" or "live" wire
should exactly match the current flowing away from the unit in the neutral wire. Similarly,
there should be no current flowing in the unit's safety "ground" or "earth" wire.
An ELCB is a specialized type of latching relay that has a building's incoming mains power
connected through its switching contacts so that the ELCB disconnects the power in an earth
leakage (unsafe) condition. The ELCB detects fault currents from live (hot) to the earth
(ground) wire within the installation it protects. If sufficient voltage appears across the
ELCB's sense coil, it will switch off the power, and remain off until manually reset. An Earth
Leakage Circuit Breaker is a safety device used in electrical installations with high Earth
Impedance to prevent shock. It detects small stray voltages on metal enclosures.
Circuit breakers used in residential and light commercial installations are referred to as
miniature circuit breakers (MCBs). Miniature circuit breakers typically include an electrical
contact mounted on a movable contact carrier which rotates away from a stationary contact in
order to interrupt the current path.
An MCB is a device designed to protect a circuit's wiring from the serious damage which
would be caused if it has to carry a current which is too high to withstand. Such a current
could easily heat up the wires so much that their insulation melts. If that situation were
allowed to develop further it would soon cause the conductor in a cable to short out and to
burn so hot that they could easily cause a house fire.
Before circuit breakers were invented, simple wire fuses were used. The wire in the fuses was
deliberately made much thinner than the wires in the circuits they were intended to protect.
Thus, if a fault condition occurred, as the current in the circuit grew higher and higher, a
point would be reached at which the thin wire of the fuse would get so hot that it would melt
all safely contained within the body of the fuse - and thus break the flow of current in the
circuit it was protecting.
The problem with fuses is that depending on their design, as some are faster-acting than
others - it can take a significantly longer amount of time for them to operate compared with
today's very-fast-acting circuit breakers. That fact means that, if a circuit overload current
fault condition occurs, considerable damage can still occur both to the circuit wiring and/or to
the unit it is supplying with power. Then, after the fault condition has been fixed, the melted
or "blown" fuse wire in a rewire-able type of fuse has to be replaced. A circuit breaker, if it is
still in good condition, only needs to be reset.
Miniature circuit breakers are compact devices used in distribution boards for protection
against overload and short circuit. The overload protection is achieved by a thermal trip
mechanism using a bimetallic strip. An electromagnetic trip mechanism is also incorporated
For light load in domestic appliances like fans, tube lights, bulbs, iron, are protected by 5A
current rated MCB and heavy load like geyser, air conditioner, washing machine are
protected by 15A current rated MCB.
A. Thermal operation
In thermal operation, the extra heat produced by the high current warms the bimetal
strip. This results in bending the bimetallic strip and trips the operating contacts. The
thermal operation is slow. Hence, it is not suitable for speedy disconnection required
to clear fault currents. However, it is ideal for operation in the event of small but
prolonged overload currents. Thus, in general the thermal operation is suitable for
opening the circuit in the event of excessive current due to the overloaded machines.
B. Magnetic operation
The magnetic operation, on the other hand is suitable for protection against high short
circuit currents. This magnetic operation is due to the magnetic field set up by a coil
carrying the current, which attracts an iron part to trip the breaker when the current
becomes large enough. The magnetic operation is very fast and is used for braking
fault currents. In most cases of MCB s, both types are provided so that overload
currents and short circuit currents are handled with the same degree. It should
however be remembered that the mechanical operation of opening the contacts takes a
definite minimum time, typically 20ms, so that there can never be the possibility of
truly instantaneous operation. In many installations, MCBs are preferred over fuses
mainly because there is no need of rewiring the fuse wire or replacing the cartridge.
MCBs are available in a range of 0.5A to 63A normal operating current and for the
entire range, the, physical dimensions are almost identical.
Advantages of MCB
Procedure
1. Steps to connect single way switch with lamp (as per fig 3.3 given below)
a) Connect single way switch with electrical wire to lamp holder.
b) Connect lamp in lamp holder
c) Connect 3 pin or 2 pin plug with electrical wire and connect it with the circuit.
d) Connect the plug to the 230V AC.
e) By turning on and off the switch check the status of the lamp.
2. Steps to connect 2-way switch with lamp (as per fig 3.4 given below)
a) Connect 2 way switch with electrical wire to lamp holder as shown in figure.
b) Connect lamp in lamp holder
c) Connect 3 pin or 2 pin plug with electrical wire and connect it with the circuit.
d) Connect the plug to the 230V AC.
Conclusion
PRACTICAL NO.4
AIM: - To prepare series and parallel circuit on General Purpose Circuit Board
(GPCB)
OBJECTIVE
APPARATUS
Resistor
GPCB
Hook up wires
Solder and de-solder iron
Solder wire
Multi-meter
THEORY
Series Resistor Circuit: Resistors are said to be connected in “Series”, when they are daisy
chained together in a single line. Since all the current flowing through the first resistor has no
other way to go it must also pass through the second resistor and the third and so on. Resistors in
series have a common current flowing through them as the current that flows through one
resistor must also flow through the others as it can only take one path. There is a voltage drop
across each resistor. Equivalent resistance is given as:
𝑅 = 𝑅 + 𝑅 +⋯.𝑅
Parallel Resistor Circuit: In a parallel resistor network the circuit current can take more than one path
as there are multiple paths for the current. Then parallel circuits are classed as current dividers. Since
there are multiple paths for the supply current to flow through, the current may not be the same through
all the branches in the parallel network. However, the voltage drop across all of the resistors in a parallel
resistive network is the same. Then, Resistors in Parallel have a Common Voltage across them and this is
true for all parallel connected elements. The equivalent resistance is given as
1 1 1 1
= + + ……
𝑅 𝑅 𝑅 𝑅
Soldering
Soldering is a joining process wherein coalescence is produced by heating below 800°F, using a
non-ferrous filler metal with a melting point below that of the base metal. The metals to be
joined dictate the flux, solder, and heating methods to be used. Base metals are selected for
specific properties such as electrical conductivity, weight, and corrosion resistance.
Joint design: They should be designed with the requirements of solder and their
limitations in mind.
Pre-cleaning: The surfaces must be thoroughly cleaned to allow the solder to wet the base
metal.
Fluxing: A flux must be provided to remove traces of surface film or oxides and to
prevent formation of oxides during the soldering operation.
Proper fixtures or alignment of parts must be maintained to insure a sound soldered joint.
Heating of the base metals should be uniform or even on base metals, to insure good
penetration of the filler alloy into the joint. If a noncorrosive flux is used no further
cleaning is necessary. The use of a corrosive flux makes flux residue removal imperative.
1. Joint fitting: A clearance of 0.005" is suitable for most soldering. When soldering
precoated metals, a clearance of 0.001" is recommended for maximum mechanical
strength.
2. Types of cleaning include:
Mechanical - Scotch Brite pad, emery cloth
Chemical - cleaning using acids to remove rust, scale or sulfides. Most commonly used
acids are hydrochloric and sulphuric.
3. Application of flux
Flux should be capable of removing oxides and stop them from reforming.
Safety Precautions
Most of solder wires or solder paste contain lead (solder alloy is mixture of tin and lead). During
soldering operation lead may produce fumes that are dangerous for your health. In addition,
soldering wire usually has a flux in the middle of wire. There are different types of cored solder
with different solder to flux rate. Flux containing rosin (colophony) produces solder fumes that,
if inhaled, can be hazardous.
Keep flammable liquids and materials (such as alcohol, solvent etc.) away from the work
area.
Wear eye protection.
Do not cut off a grounding prong on an iron plug to make it fit an ungrounded receptacle.
Hold wires to be heated with tweezers, pliers or clamps to avoid receiving burns on your
fingers from objects that are heated.
Wear ESD (Electro-Static Discharge) protection if you are going to solder electro-static
sensitive components such as CMOS components. For most of DIY projects it will be
good enough to wear ESD wrist straps.
Wash your hands with soap and water after soldering.
De-Soldering
While being able to make good solder joints is very important, another skill that can be equally
important is to know how to de-solder well. Every electronic project will have one problem or
another and often this will involve de-soldering a joint. It could be that a wrong component has
been used, the circuit needs changing, or a soldered joint is not satisfactory. If any de-soldering
is not done well, then it can damage a printed circuit board or components, leading to costly or
time consuming rebuild. De-soldering a joint may not be easy. Coupled to this, if heat is applied
to the joint for too long, it is likely to damage the printed circuit board, if one is used, or it can
easily damage a component. It is therefore necessary to tackle any jobs with care, and by using
the right tools. Below mentioned tools can be used for de-soldering:
1. Copper Braid
Copper braid is commonly used to de-solder electronic components. This technique
involves melting the solder flux and then allowing the copper braid to absorb it. The braid
is placed on the solid solder and gently pressed with a heated soldering iron tip. The tip
melts the solder, which is quickly absorbed by the braid. This is an efficient but slow
method of de-soldering components since each soldered joint must be worked on
individually.
2. Solder Sucker
Solder sucker is basically a small tube connected to a vacuum pump. Its purpose is to
suck the molten flux off of pads. A heated soldering iron tip is first placed on the solid
solder until it melts. The solder sucker is then placed directly on the molten flux and a
button on its side is pushed that quickly sucks the flux.
3. Heat Gun
De-soldering with a heat gun is generally used to de-solder SMD components, though it
can also be employed for through-hole components. In this method, the board is placed
on a perfectly flat place and a heat gun is pointed directly at the components to be de-
soldered for a few seconds. This quickly melts the solder and on the pads, loosening the
components. They are then immediately lifted with the help of tweezers. The downside of
this method is that it is very difficult to use for small, individual components since the
heat can melt the solder on nearby pads, which can dislodge components that are not be
de-soldered. Also, the molten flux can flow to nearby traces and pads, causing electrical
shorts. It is therefore very important to keep the board as flat as possible during this
process.
PROCEDURE:
1. Solder needs a clean surface on which to adhere.
Buff the copper foil of a PC board with steel wool before soldering.
Remove any oil, paint, wax, etc. with a solvent, steel wool, or fine sandpaper.
2. To solder, heat the connection with the tip of the soldering iron for a few seconds, then
apply the solder.
Heat the connection, not the solder.
Hold the soldering iron like a pen, near the base of the handle.
Both parts that are being soldered have to be hot to form a good connection.
3. Keep the soldering tip on the connection as the solder is applied.
Solder will flow into and around well-heated connections.
Use just enough solder to form a strong connection.
4. Remove the tip from the connection as soon as the solder has flowed where you want it to
be. Remove the solder, then the iron.
5. Don't move the connection while the solder is cooling.
6. Don't overheat the connection, as this might damage the electrical component you are
soldering.
Transistors and some other components can be damaged by heat when soldering.
A crocodile clip can be used as a heat sink to protect these components.
7. Soldering a connection should take just a few seconds.
8. Inspect the joint closely. It should look shiny.
If you are soldering a wire (called the lead) onto a PC board (on the track), it
should have a volcano shape.
If the connection looks bad, reheat it and try again.
9. Wipe the tip of the iron on a damp sponge to clean it. The tip should now be shiny.
10. Unplug the soldering iron when it is not in use and place it on stand.
11. Heat the de-solder iron.
12. Place on the joint the de-solder iron which you want to de-solder.
13. Suck the heated part.
CONCLUSION:
PRACTICAL NO.5
OBJECTIVE
APPARATUS
Personal Computer
Internet connection
THEORY: ❯
HTML is abbreviation of Hyper Text Markup Language. HTML is the standard markup
language for creating Web pages. HTML describes the structure of Web pages using markup.
HTML elements are the building blocks of HTML pages. HTML tags label pieces of content
such as "heading", "paragraph", "table", and so on. Browsers do not display the HTML tags, but
use them to render the content of the page. Only the content inside the body section is displayed
in a browser.
Web pages can be created and modified by using professional HTML editors. However, for
learning HTML we should use a simple text editor like Notepad (PC) or TextEdit (Mac) because
it is better to learning HTML.
HTML Tags:
Images are defined with the <img> tag. The <img> tag is empty, it contains attributes
only, and does not have a closing tag.
CSS stands for Cascading Style Sheets. CSS describes how HTML elements are to be
displayed on screen, paper, or in other media. CSS saves a lot of work. It can control the
layout of multiple web pages all at once.
HTML Attributes:
HTML Entities:
Reserved characters in HTML must be replaced with character entities. Characters that are not
present on your keyboard can also be replaced by entities. Some characters are reserved in
HTML. If you use the less than (<) or greater than (>) signs in your text, the browser might mix
them with tags. Character entities are used to display reserved characters in HTML. Browser
may not support all entity names, but the support for number is good.
A common character entity used in HTML is the non-breaking space: .A non-
breaking space is a space that will not break into a new line.
→ is entity number and → is entity name for rightwords arrows(→).
PROCEDURE
Observation
The profile page for website and its HTML code is attached with the practical
Conclusion
PRACTICAL NO. 6
OBJECTIVE
To study various elements present on Raspberry Pi 3 board
To study specification of Raspberry Pi 3 Board.
To learn to install operating system in Raspberry Pi 3 boards.
APPARATUS
Monitor with VGA cable and adapter for power supply.
Micro USB power supply cable and adapter.
USB based Keyboard and mouse.
Micro SD card.
Micro SD card reader
Raspberry Pi model 3 board.
HDMI to VGA Converter
Desktop with SD card formatter software installed.
THEORY
The name, Raspberry Pi, was the combination of the desire to create an alternative fruit-based
computer (such as Apple, BlackBerry, and Apricot) and a nod to the original concept of a simple
computer that can be programmed using Python (shortened to Pi).
PROCEDURE
Install SD card formatter software on the desktop.
Insert the Micro SD memory card into card reader and using desktop read the same.
Open the SD card formatter software and select the drive which accesses the micro SD
card reader.
Select the quick format option in it.
Click on Format button.
Download from https://www.raspberrypi.org/downloads zip file of NOOBS (New Out of
Box Software) version 2.8.
Unzip the file into the micro SD card
Remove the card reader and from it the micro SD card reader.
Insert the micro SD card to the slot of micro SD card available on the raspberry pi board.
Connect the USB keyboard and mouse to the Raspberry Pi 3 board.
Connect the monitor through VGA to HDMI converter to the raspberry Pi 3 board.
CONCLUSION:
PRACTICAL NO. 7
OBJECTIVE
To learn command terminal instructions
To edit python program in nano editor
APPARATUS
Monitor with VGA cable and adapter for power supply.
Micro USB power supply cable and adapter.
USB based Keyboard and mouse.
Micro SD card.
Micro SD card reader
Raspberry Pi model 3 board.
HDMI to VGA Converter
THEORY
Raspbian features a terminal called LXTerminal where you can issue text commands to the
system. This is equivalent to the command prompt in Windows Operating System.
Nano Editor is a feature provided in terminal of Raspbian, which helps in editing the python
program or build a new python program. GNU Nano is at the easy-to-use end of command-line
editors. It's installed by default in board.
PROCEDURE
Command Terminal Instructions
Open the terminal window by clicking on the third icon on the right of the Menu bar and
use the instructions as follows:
1. pwd: Stands for present working directory and should show default “/home/pi” as
2. ls –la: One of the key aspects of using a terminal is being able to navigate your file
system. This command is used for the same.
3. sudo: Some commands that make permanent changes to the state of your system require
you to have root privileges to run. The command sudo temporarily gives your account (if
you're not already logged in as root) the ability to run these commands, provided your
user name is in a list of users ('sudoers'). When you append sudo to the start of a
command and press enter you will be asked for your password, if that is entered correctly
then the command you want to run will be run using root privileges. Be careful though,
some commands that require sudo to run can irreparably damage your system so be
careful.
4. apt: You can use the apt command to install software in Raspbian. This is the 'package
manager' that is included with any Debian-based Linux distributions (including
Raspbian). It allows you to install and manage new software packages on your Pi.
5. sudo apt install <package name>: In order to install a new package, you would type
sudo apt install <package-name> (where <package-name> is the package that you want
to install).
6. sudo apt update: Running sudo apt update will update a list of software packages that
are available on your system.
7. sudo apt upgrade: If a new version of a package is available, then sudo apt upgrade will
update any old packages to the new version.
8. sudo apt remove <package-name>: removes or uninstalls a package from your system.
9. sudo ip addr: Enables to see the IP address of the Raspberry Pi board
10. sudo apt-get update: Synchronizes the list of packages on your system to the list in the
repositories. Use it before installing new packages to make sure you are installing the
latest version.
11. apt-get upgrade: Upgrades all of the software packages you have installed.
12. clear: Clears previously run commands and text from the terminal screen.
13. date: Prints the current date.
14. find / -name example.txt: Searches the whole system for the file example.txt and
outputs a list of all directories that contain the file.
15. nano example.txt: Opens the file example.txt in the Linux text editor Nano.
16. raspi-config: Opens the configuration settings menu.
18. cp: makes a copy of a file and places it at the specified location eg: cp
file_a/home/other_user/
19. mv: moves a file and places it at the specified location eg: mv file_a/home/other_user/
20. rm: removes the specified file
21. mkdir: This makes a new directory, e.g. mkdir new_dir
22. cat: Lists the contents of files e.g. cat some_file
Nano editor
1. To open a new nano file or make changes in existing file in terminal type sudo nano
filename to open a new file or open existing file.
2. Write the python program
3. Press Ctrl+O to save the file with extension .py
4. Press Ctrl+X to exit the file
CONCLUSION
PRACTICAL NO. 8
OBJECTIVE
To learn basics to prepare a python program
To prepare a program to add, subtract, multiply and divide two numbers in python.
APPARATUS
Monitor with VGA cable and adapter for power supply.
Micro USB power supply cable and adapter.
USB based Keyboard and mouse.
Micro SD card.
Micro SD card reader
Raspberry Pi model 3 board.
HDMI to VGA Converter
THEORY
There are countless definitions of what computer programming is, one among them is:
“Programming is how you get computers to solve problems.”
There are two key phrases here which are important:
You: without the programmer (you), the computer is useless. It does what you tell it to do.
Solve Problems: Computers are tools. They are complex tools, admittedly, but they are not
mysterious or magical. They exist to make tasks easier. Computer programs (or software) are
what makes computers work. Without software, modern computers are just complicated
machines for turning electricity into heat. It’s software on your computer that runs your
operating system, browser, email, games, and movie player – just about everything.
Programming is a creative task: there is no right or wrong way to solve a problem, in the same
way that there is no right or wrong way to paint a picture. There are choices to be made, and one
way may seem better than another, but that doesn’t mean the other is wrong! With the right skills
and experience, a programmer can craft software to solve an unlimited number of problems –
from telling you when your next train will arrive to playing your favorite music. The possibilities
are constrained only by your imagination.
Python has been selected as a good place to start when learning about programming, by
providing a rich set of coding tools while still allowing simple programs to be written without
fuss. This allows beginners to gradually be introduced to the concepts and methods on which
modern programming languages are based without requiring them to know it all from the start. It
is very modular with lots of additional libraries that can be imported to quickly extend the
functionality. You will find that over time, this encourages you to do the same, and you will want
to create your own modules that you can plug into your own programs, thus taking your first
steps into structured programming. These three concepts are the basic logical structures in
computer programming:
Sequence: running instructions in order
Selection: making choices
Repetition: doing the same thing more than once
Programs are often referred to as code and hence programming is also known as coding.
To create Python programs you need a text editor to write your code and a Python interpreter
which takes your code and runs it. An editor, interpreter and other useful tools (such as a file
browser) are often bundled together into an Integrated Development Environment (IDE), which
makes the process of creating programs much easier. We will be using Thonny Python IDE for
preparing python programming in raspberry pi 3. There are three key areas in Python IDE
Files: This is where all your programs will be stored. Each filename will end in .py meaning that
the file is a Python file.
Editor: This is where you will create your programs.
REPL: This stands for “Read-Eval-Print Loop”. Your program will run in the REPL, which is
where you will see any output and provide any input.
Output
Print command is used to generate the output in python
e.g. print(“Hi”)
This will generate the output Hi as the data in the “” is taken as text or string data type variable.
e.g. print (count)
This will consider count as a variable and generate the output value the one stored in the variable
count.
Input
Input command is used to generate take input from the user and use it in the program for some
purpose.
e.g. count = input(“Enter the value”)
This will generate the output in REPL as
Enter the value
After which one can enter the value. This value will be assigned to the variable count.
Syntax
Set of rules and regulation followed to perform a program. Instruction if not written in proper
syntax will generate error and will not be allowed to run by the program.
Variables
There are several types of data types available in variables. Few to be mentioned here are string,
character, Boolean, integer, float, real etc.
Symbol Function
= Assignment
== Equal to comparison
< Less than
> Greater than
+ Addition
- Subtraction
/ Division
* Multiplication
PROCEDURE
From symbol of raspberry pi i.e. start menu, select programming tab, from which select
Thonny Python IDE and open it.
Create a new file and save it with extension .py to indicate that it is a python program.
Write the programs in the editor section
Save the program
Run the program and view the output in python shell or REPL section
Program 1: Addition of two numbers
var1 = input(“Enter the first number to add “)
var2 = input(“Enter the second number to add “)
a = int(var1)
b = int(var2)
add = a+b
print(“The sum of two given numbers = “, add)
CONCLUSION
PRACTICAL NO. 9
OBJECTIVE
To blink LED using Raspberry Pi 3
To control the brightness of LED using Raspberry Pi 3
APPARATUS
Monitor with VGA cable and adapter for power supply.
Micro USB power supply cable and adapter.
USB based Keyboard and mouse.
Micro SD card.
Micro SD card reader
Raspberry Pi model 3 board.
HDMI to VGA Converter
LED
Breadboard
Hook up wires
330Ω resistor
THEORY
The LED can be interfaced to raspberry pi 3 using the General Purpose Input output pins on the
board. The pin diagram of the GPIO is as follows:
PROCEDURE
Let us connect GPIO 18 i.e. pin number 12 to the LED
Connect GPIO 18 to positive leg of LED on the breadboard
Connect negative leg of LED to 330Ω resistor.
Connect the other end of the resistor to the ground pin of GPIO i.e. pin number 6
Open Thonny Python and write the program.
Save the program in python format and run it
We can see blinking and control brightness of LED using these programs.
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
while (True):
GPIO.output(18, True)
time.sleep(0.5)
GPIO.output(18, False)
time.sleep(0.5)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm_led=GPIO.PWM(18,100)
pwm_led.start(100)
try:
while True:
duty_s=input(“enter brightness”)
duty=int(duty_s)
pwm_led.ChangeDutyCycle(duty)
time.sleep(0.5)
finally:
GPIO.cleanup()
CONCLUSION