Professional Documents
Culture Documents
Roll No.:8427
Practical 2
Aim: Perform LED Glow on Raspberry Pi
Code:
You are now ready to write some code to switch the LED on. Turn on your Pi
and open the terminal window.
nano LED.py
Once you have typed all the code and checked it, save and exit editor with
“Ctrl+x”
then “y” then “enter”.
Output:
Name: Tejas Dhulugade
Roll No.:8427
Name: Tejas Dhulugade
Roll No.:8427
Practical 3
Aim : Execute linux Commands on Raspberry Pi
1. ls command
2. mkdir command
3. cd command :-
4. rmdir command
5. If-config command
Name: Tejas Dhulugade
Roll No.:8427
6. Ping command
7. sudo raspi-config
Practical 4
Aim: Controlling Raspberry Pi with Telegram
Code:
Configuration code for Telegram:
Name: Tejas Dhulugade
Roll No.:8427
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-pip
sudo pip install telepot
clear
mkdir TelegramLEDdemo
cd TelegramLEDdemo
while 1:
time.sleep(1)
Name: Tejas Dhulugade
Roll No.:8427
Running Code:
Output:
Name: Tejas Dhulugade
Roll No.:8427
Name: Tejas Dhulugade
Roll No.:8427
Practical 5
Aim: RFID Interface with Raspberry Pi
Code:
RFID Steps:
sudo apt-get update
sudo apt-get upgrade
sudo raspi-config
Select interfacing option and then select spi
Click yes and the ok hence finish
Reboot
lsmod /grep spi
sudo apt-get install python-spidev python3-spidev
cd
pwd *if /home/pi is displayed then we are on correct
path* git clone https://github.com/lthiery/SPI-Py.git
cd SPI-Py
sudo python setup.py install
clear
cd
pwd
git clone https://github.com /pimylifeup/MFRC522-pythin.git
cd MFRC522-python
🡪nano filename.py
Writing.py
import RPi.GPIO as GPIO
import SimpleMFRC522
reader =SimpleMFRC522.SimpleMFRC522()
try:
text=raw_input(‘enter new data on
card’) print(“now place card”)
reader.write(text)
print(“data written”)
Name: Tejas Dhulugade
Roll No.:8427
finally:
GPIO.cleanup()
Reading.py
import RPi.GPIO as GPIO
import SimpleMFRC522
reader=SimpleMFRC522()
try:
id,text=reader.read()
print(id)
print(text)
finally:
GPIO.cleanup()
Output:
Name: Tejas Dhulugade
Roll No.:8427
Practical 6
Aim : Show Pulse Width Modulation on Raspberry Pi
Code: import RPi.GPIO as GPIO import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(19,GPIO.OUT) P
= GPIO.PWM(19,100)
P.start(0) while(1):
for x in range(50):
P.ChangeDutyCycle(x) time.sleep(0.1) for x in
range(50):
P.ChangeDutyCycle(50-x) time.sleep(0.1)
Output :
Name: Tejas Dhulugade
Roll No.:8427
Practical 7
Aim: Show how RPi Camera capture the image
Code:
Create two separate file:
CODE-
import pi camera
from time import sleep
cam =picamera.PiCamera()
cam =cam.start preview()
cam.annotate text "Hello World!!!” #displays text on image
for in range(5):
sleep(3)
cam.capture( ‘/home/pi/camerademo/pic%s.jpg’ % i)
cam.stop_preview()
CODE-
import picamera
from time import sleep
cam=picamera.PiCamera()
cam.start_prevlew()
cam.start recording(home/pl/camerademo/fan.h264)
sleep(10)
cam.stop recording()
cam.stop preview()
Output:
Name: Tejas Dhulugade
Roll No.:8427
Practical 8
Name: Tejas Dhulugade
Roll No.:8427
Practical 9
Name: Tejas Dhulugade
Roll No.:8427
Aim: Show the working of Fingerprint module on Raspberry Pi
Connection :
Code : It will Automatically generate when you will install fingerprint module
Output :
Name: Tejas Dhulugade
Roll No.:8427