Sameer
Published © MIT

Getting Started with Raspberry Pi Zero W and Python 3

Intro to getting started with Raspberry Pi Zero W using Python3.

BeginnerProtip1 hour23,282
Getting Started with Raspberry Pi Zero W and Python 3

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
PIR Sensor, 7 m
PIR Sensor, 7 m
×1

Software apps and online services

VS Code
Microsoft VS Code

Story

Read more

Schematics

Schematics

Code

Code

Python
# import library for GPIO
import RPi.GPIO as GPIO
# print GPIO info
print(GPIO.RPI_INFO)

# time library
import time

# Port of PIR
pir_port = 14

# Setup GPIO mode to Broadcom
GPIO.setmode(GPIO.BCM)

# configure the pin as input pin
GPIO.setup(pir_port,  GPIO.IN)

# do the loop
try:
    while (True):
        # if the input is zero, nobody is there at the sensor
        if GPIO.input(pir_port) == 0:
            print("000")
        else:
            # found somebody at the sensor
            print("111")
        # wait for 1 sec whether you detect someone or not
        time.sleep(1)
# If user presses ^C cleanup the GPIO
except KeyboardInterrupt:
    GPIO.cleanup()
print("Exiting")

Credits

Sameer

Sameer

2 projects • 65 followers
IOT fan tinkering with "things" and developing mobile apps that connect to hardware

Comments