SlideShare a Scribd company logo
1 of 12
Download to read offline
Print Statement using Python in Raspberry Pi 4
# This is a Print Statement Program in Python Language
'''
print('Hello Students')
print("I'm student")
'''
print('''
i like to learn
i like blue color.....
i like sports.....
....
.....
''')
a = 'LED'
print(a)
a = 10
a = 20
b = 20
c = a + b
print('c =',c)
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Engineering Funda Android App Projects YT Playlist
Led Interfacing with Raspberry Pi 4
# This is Led Blinking Program in Python Language
from gpiozero import LED
from time import sleep
led = LED(17) #define GPIO17 pin as LED
while True:
led.on() #LED ON
sleep(0.5) #0.5s delay
led.off() #LED 0FF
sleep(0.5) #0.5s delay
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Engineering Funda Android App Projects YT Playlist
Push Button Interfacing with Raspberry Pi 4
# This is Push Button Program in Python Language
from gpiozero import LED, Button
from time import sleep
led = LED(17) #Define GPIO17 as LED
button = Button(27) #Define GPIO27 as Button
while True:
if button.is_pressed:
#print("Button is Pressed")
led.on()
else:
#print("Button is not Pressed")
led.off()
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Take Input from User and Blink Led as per User Input
# This is a User input Program in Python Language
from gpiozero import LED
from time import sleep
print('''
Which number of LED you want to blink
1:red
2:blue
3:green
''')
#take input from user
led_input = int(input("Enter your option: "))
if(led_input == 1):
led=LED(17) #Define GPIO17 as red led
if(led_input == 2):
led=LED(27) #Define GPIO27 as blue led
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Engineering Funda Android App Projects YT Playlist
if(led_input == 3):
led=LED(22) #Define GPIO22 as green led
#take count input from user
count = int(input("How many times you want to blink led: "))
while count > 0:
led.on() #LED ON
sleep(0.5) #0.5s delay
led.off() #LED OFF
sleep(0.5) #0.5s delay
count = count - 1 #decrease count
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Buzzer Interfacing with Raspberry Pi 4
# This is Buzzer Program in Python Language
from gpiozero import Buzzer
from time import sleep
buzzer = Buzzer(23) #Define GPIO23 as buzzer
while True:
buzzer.on() #Buzzer ON
sleep(0.5) #0.5s delay
buzzer.off() #Buzzer OFF
sleep(0.5) #0.5s delay
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Light Dependent Resistor (LDR) Interfacing with Raspberry Pi 4
# This is Light Dependent Resistor (LDR) Program in Python Language
from gpiozero import LightSensor
ldr = LightSensor(17) #Define GPIO17 as LDR
'''
while True:
ldr.wait_for_light()
print("It's Light :)")
ldr.wait_for_dark()
print("It's Dark :(")
'''
#Let's print ldr value
while True:
print(ldr.value)
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Passive Inferred (PIR) Sensor Interfacing with Raspberry Pi 4
# This is Passive Inferred (PIR) Sensor Program in Python Language
from gpiozero import MotionSensor, LED
pir = MotionSensor(4) #Define GPIO4 as PIR
led = LED(17) #Define GPIO17 as LED
pir.when_motion = led.on
pir.when_no_motion = led.off
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Ultrasonic Sensor Interfacing with Raspberry Pi 4
# This is Ultrasonic Sensor Program in Python Language
from gpiozero import DistanceSensor
from time import sleep
sensor = DistanceSensor(echo=24, trigger=23, max_distance=1)
while True:
print("Distance: ", sensor.distance * 100, "cm")
sleep(0.5) #0.5s delay
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Motor Interfacing with Raspberry Pi 4
# This is Motor Program in Python Language
from gpiozero import Motor
from time import sleep
motor = Motor(forward=7, backward=8)
motor.forward()
sleep(5)
motor.backward()
sleep(5)
motor.stop()
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
BlueDot control Robot using Raspberry Pi 4
# This is BlueDot control Robot Program in Python Language
'''
Write Command on Lx-terminal: sudo pip3 install bluedot
Download The BlueDot Application:
https://play.google.com/store/apps/details?id=com.stuffaboutcode.bluedot&hl=en_GB
'''
from bluedot import BlueDot
from gpiozero import Robot
from time import sleep
bd = BlueDot()
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
robot = Robot(left = (7, 8), right = (9, 10))
def move(pos):
if pos.top:
robot.forward()
sleep(0.1)
elif pos.bottom:
robot.backward()
sleep(0.1)
elif pos.right:
robot.right()
sleep(0.1)
elif pos.left:
robot.left()
sleep(0.1)
def stop():
robot.stop()
bd.when_pressed = move
bd.when_moved = move
bd.when_released = stop
E
n
g
i
n
e
e
r
i
n
g
F
u
n
d
a
Engineering Funda Android App Projects YT Playlist

More Related Content

Similar to Raspberry Pi 4.pdf

Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Tom Paulus
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOKris Findlay
 
Raspberry pi pico projects raspberry pi projects
Raspberry pi pico projects raspberry pi projectsRaspberry pi pico projects raspberry pi projects
Raspberry pi pico projects raspberry pi projectsIsmailkhan77481
 
Hands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative TechnologistsHands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative Technologistsbennuttall
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi boardThierry Gayet
 
Interacting with Intel Edison
Interacting with Intel EdisonInteracting with Intel Edison
Interacting with Intel EdisonFITC
 
Security System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry PiSecurity System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry PiRaúl Peláez Berroteran
 
Raspberry pi-spectrum-analyzer-display-on-rgb-led-strip
Raspberry pi-spectrum-analyzer-display-on-rgb-led-stripRaspberry pi-spectrum-analyzer-display-on-rgb-led-strip
Raspberry pi-spectrum-analyzer-display-on-rgb-led-stripStefan Oprea
 
Raspberry Pi Introductory Lecture
Raspberry Pi Introductory LectureRaspberry Pi Introductory Lecture
Raspberry Pi Introductory LectureSyed Umaid Ahmed
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi andKellyn Pot'Vin-Gorman
 
Advanced View Arduino Projects List - Use Arduino for Projects.pdf
Advanced View Arduino Projects List - Use Arduino for Projects.pdfAdvanced View Arduino Projects List - Use Arduino for Projects.pdf
Advanced View Arduino Projects List - Use Arduino for Projects.pdfIsmailkhan77481
 
Embedded Rust and more
Embedded Rust and moreEmbedded Rust and more
Embedded Rust and moreKiwamu Okabe
 
Simple ETL in python 3.5+ with Bonobo, Romain Dorgueil
Simple ETL in python 3.5+ with Bonobo, Romain DorgueilSimple ETL in python 3.5+ with Bonobo, Romain Dorgueil
Simple ETL in python 3.5+ with Bonobo, Romain DorgueilPôle Systematic Paris-Region
 
Simple ETL in python 3.5+ with Bonobo - PyParis 2017
Simple ETL in python 3.5+ with Bonobo - PyParis 2017Simple ETL in python 3.5+ with Bonobo - PyParis 2017
Simple ETL in python 3.5+ with Bonobo - PyParis 2017Romain Dorgueil
 
Advanced View Arduino Projects List - Use Arduino for Projects (2).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (2).pdfAdvanced View Arduino Projects List - Use Arduino for Projects (2).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (2).pdfIsmailkhan77481
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshoptomtobback
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programsvineetdhand2004
 
Lab manual of Digital image processing using python by khalid Shaikh
Lab manual of Digital image processing using python by khalid ShaikhLab manual of Digital image processing using python by khalid Shaikh
Lab manual of Digital image processing using python by khalid Shaikhkhalidsheikh24
 

Similar to Raspberry Pi 4.pdf (20)

Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
 
Introduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIOIntroduction to Raspberry Pi and GPIO
Introduction to Raspberry Pi and GPIO
 
Raspberry pi pico projects raspberry pi projects
Raspberry pi pico projects raspberry pi projectsRaspberry pi pico projects raspberry pi projects
Raspberry pi pico projects raspberry pi projects
 
Hands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative TechnologistsHands on Raspberry Pi - Creative Technologists
Hands on Raspberry Pi - Creative Technologists
 
Rpy2 demonstration
Rpy2 demonstrationRpy2 demonstration
Rpy2 demonstration
 
Intro to the raspberry pi board
Intro to the raspberry pi boardIntro to the raspberry pi board
Intro to the raspberry pi board
 
Interacting with Intel Edison
Interacting with Intel EdisonInteracting with Intel Edison
Interacting with Intel Edison
 
Security System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry PiSecurity System with PIR sensor and Raspberry Pi
Security System with PIR sensor and Raspberry Pi
 
Raspberry pi-spectrum-analyzer-display-on-rgb-led-strip
Raspberry pi-spectrum-analyzer-display-on-rgb-led-stripRaspberry pi-spectrum-analyzer-display-on-rgb-led-strip
Raspberry pi-spectrum-analyzer-display-on-rgb-led-strip
 
Raspberry Pi Introductory Lecture
Raspberry Pi Introductory LectureRaspberry Pi Introductory Lecture
Raspberry Pi Introductory Lecture
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi and
 
Advanced View Arduino Projects List - Use Arduino for Projects.pdf
Advanced View Arduino Projects List - Use Arduino for Projects.pdfAdvanced View Arduino Projects List - Use Arduino for Projects.pdf
Advanced View Arduino Projects List - Use Arduino for Projects.pdf
 
Embedded Rust and more
Embedded Rust and moreEmbedded Rust and more
Embedded Rust and more
 
Simple ETL in python 3.5+ with Bonobo, Romain Dorgueil
Simple ETL in python 3.5+ with Bonobo, Romain DorgueilSimple ETL in python 3.5+ with Bonobo, Romain Dorgueil
Simple ETL in python 3.5+ with Bonobo, Romain Dorgueil
 
Simple ETL in python 3.5+ with Bonobo - PyParis 2017
Simple ETL in python 3.5+ with Bonobo - PyParis 2017Simple ETL in python 3.5+ with Bonobo - PyParis 2017
Simple ETL in python 3.5+ with Bonobo - PyParis 2017
 
Advanced View Arduino Projects List - Use Arduino for Projects (2).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (2).pdfAdvanced View Arduino Projects List - Use Arduino for Projects (2).pdf
Advanced View Arduino Projects List - Use Arduino for Projects (2).pdf
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshop
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programs
 
Lab manual of Digital image processing using python by khalid Shaikh
Lab manual of Digital image processing using python by khalid ShaikhLab manual of Digital image processing using python by khalid Shaikh
Lab manual of Digital image processing using python by khalid Shaikh
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 

More from Engineering Funda (20)

FPGA and CPLD comparision
FPGA and CPLD comparisionFPGA and CPLD comparision
FPGA and CPLD comparision
 
Photolithography
PhotolithographyPhotolithography
Photolithography
 
Evolution of logic complexity
Evolution of logic complexityEvolution of logic complexity
Evolution of logic complexity
 
VLSI design methodologies
VLSI design methodologies VLSI design methodologies
VLSI design methodologies
 
VLSI Design Flow
VLSI Design FlowVLSI Design Flow
VLSI Design Flow
 
Channel length Modulation
Channel length ModulationChannel length Modulation
Channel length Modulation
 
Integrated Electronics MCQ
Integrated Electronics MCQIntegrated Electronics MCQ
Integrated Electronics MCQ
 
Solid State Devices Interview and Viva Question
Solid State Devices Interview and Viva QuestionSolid State Devices Interview and Viva Question
Solid State Devices Interview and Viva Question
 
SSD MCQ
SSD MCQSSD MCQ
SSD MCQ
 
Signal and Systems GATE material
Signal and Systems GATE materialSignal and Systems GATE material
Signal and Systems GATE material
 
Fourier Series
Fourier Series Fourier Series
Fourier Series
 
Laplace transform
Laplace transformLaplace transform
Laplace transform
 
Z Transform
Z Transform Z Transform
Z Transform
 
Convolution
ConvolutionConvolution
Convolution
 
RARDAR Material
RARDAR MaterialRARDAR Material
RARDAR Material
 
RADAR classnote
RADAR classnoteRADAR classnote
RADAR classnote
 
Power Tubes MCQ
Power Tubes MCQPower Tubes MCQ
Power Tubes MCQ
 
Power Electronics interview questions
Power Electronics interview questionsPower Electronics interview questions
Power Electronics interview questions
 
Industrial Electronics MCQ
Industrial Electronics MCQIndustrial Electronics MCQ
Industrial Electronics MCQ
 
RC Triggering
RC TriggeringRC Triggering
RC Triggering
 

Recently uploaded

UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLManishPatel169454
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 

Recently uploaded (20)

UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 

Raspberry Pi 4.pdf

  • 1. Print Statement using Python in Raspberry Pi 4 # This is a Print Statement Program in Python Language ''' print('Hello Students') print("I'm student") ''' print(''' i like to learn i like blue color..... i like sports..... .... ..... ''') a = 'LED' print(a) a = 10 a = 20 b = 20 c = a + b print('c =',c) E n g i n e e r i n g F u n d a Engineering Funda Android App Projects YT Playlist
  • 2. Led Interfacing with Raspberry Pi 4 # This is Led Blinking Program in Python Language from gpiozero import LED from time import sleep led = LED(17) #define GPIO17 pin as LED while True: led.on() #LED ON sleep(0.5) #0.5s delay led.off() #LED 0FF sleep(0.5) #0.5s delay E n g i n e e r i n g F u n d a Engineering Funda Android App Projects YT Playlist
  • 3. Push Button Interfacing with Raspberry Pi 4 # This is Push Button Program in Python Language from gpiozero import LED, Button from time import sleep led = LED(17) #Define GPIO17 as LED button = Button(27) #Define GPIO27 as Button while True: if button.is_pressed: #print("Button is Pressed") led.on() else: #print("Button is not Pressed") led.off() E n g i n e e r i n g F u n d a
  • 4. Take Input from User and Blink Led as per User Input # This is a User input Program in Python Language from gpiozero import LED from time import sleep print(''' Which number of LED you want to blink 1:red 2:blue 3:green ''') #take input from user led_input = int(input("Enter your option: ")) if(led_input == 1): led=LED(17) #Define GPIO17 as red led if(led_input == 2): led=LED(27) #Define GPIO27 as blue led E n g i n e e r i n g F u n d a Engineering Funda Android App Projects YT Playlist
  • 5. if(led_input == 3): led=LED(22) #Define GPIO22 as green led #take count input from user count = int(input("How many times you want to blink led: ")) while count > 0: led.on() #LED ON sleep(0.5) #0.5s delay led.off() #LED OFF sleep(0.5) #0.5s delay count = count - 1 #decrease count E n g i n e e r i n g F u n d a
  • 6. Buzzer Interfacing with Raspberry Pi 4 # This is Buzzer Program in Python Language from gpiozero import Buzzer from time import sleep buzzer = Buzzer(23) #Define GPIO23 as buzzer while True: buzzer.on() #Buzzer ON sleep(0.5) #0.5s delay buzzer.off() #Buzzer OFF sleep(0.5) #0.5s delay E n g i n e e r i n g F u n d a
  • 7. Light Dependent Resistor (LDR) Interfacing with Raspberry Pi 4 # This is Light Dependent Resistor (LDR) Program in Python Language from gpiozero import LightSensor ldr = LightSensor(17) #Define GPIO17 as LDR ''' while True: ldr.wait_for_light() print("It's Light :)") ldr.wait_for_dark() print("It's Dark :(") ''' #Let's print ldr value while True: print(ldr.value) E n g i n e e r i n g F u n d a
  • 8. Passive Inferred (PIR) Sensor Interfacing with Raspberry Pi 4 # This is Passive Inferred (PIR) Sensor Program in Python Language from gpiozero import MotionSensor, LED pir = MotionSensor(4) #Define GPIO4 as PIR led = LED(17) #Define GPIO17 as LED pir.when_motion = led.on pir.when_no_motion = led.off E n g i n e e r i n g F u n d a
  • 9. Ultrasonic Sensor Interfacing with Raspberry Pi 4 # This is Ultrasonic Sensor Program in Python Language from gpiozero import DistanceSensor from time import sleep sensor = DistanceSensor(echo=24, trigger=23, max_distance=1) while True: print("Distance: ", sensor.distance * 100, "cm") sleep(0.5) #0.5s delay E n g i n e e r i n g F u n d a
  • 10. Motor Interfacing with Raspberry Pi 4 # This is Motor Program in Python Language from gpiozero import Motor from time import sleep motor = Motor(forward=7, backward=8) motor.forward() sleep(5) motor.backward() sleep(5) motor.stop() E n g i n e e r i n g F u n d a
  • 11. BlueDot control Robot using Raspberry Pi 4 # This is BlueDot control Robot Program in Python Language ''' Write Command on Lx-terminal: sudo pip3 install bluedot Download The BlueDot Application: https://play.google.com/store/apps/details?id=com.stuffaboutcode.bluedot&hl=en_GB ''' from bluedot import BlueDot from gpiozero import Robot from time import sleep bd = BlueDot() E n g i n e e r i n g F u n d a
  • 12. robot = Robot(left = (7, 8), right = (9, 10)) def move(pos): if pos.top: robot.forward() sleep(0.1) elif pos.bottom: robot.backward() sleep(0.1) elif pos.right: robot.right() sleep(0.1) elif pos.left: robot.left() sleep(0.1) def stop(): robot.stop() bd.when_pressed = move bd.when_moved = move bd.when_released = stop E n g i n e e r i n g F u n d a Engineering Funda Android App Projects YT Playlist