Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
433a19b
fixed test_pwm_output_device_alt_values
May 3, 2023
195d772
fix recalcuating bound time
May 3, 2023
cab7a3f
Merge pull request #105 from martinohanlon/issue-103
MarcScott May 11, 2023
84a6b59
Merge pull request #104 from martinohanlon/issue-101
MarcScott May 11, 2023
6b01440
v 0.4.2
May 12, 2023
409939a
fix version no
May 14, 2023
a5f53ac
Merge pull request #107 from martinohanlon/dev
MarcScott May 15, 2023
d8bc0ab
LED() documentation has "pin" rather than "pwm" for second parameter
SRManz May 7, 2024
2af708e
Merge pull request #114 from SRManz/patch-1
MarcScott May 8, 2024
dcec24e
fix docblock of RGBLED pulse and cycle still referring to on_color in…
maghiel May 7, 2025
dcd67a4
Merge pull request #121 from maghiel/doc-rgbled_effects
pjbRPF Jul 21, 2025
5a164ad
Add MotionSensor
pjbRPF Oct 15, 2025
ee33c27
updates after QA
pjbRPF Oct 15, 2025
92616c4
Remove function calls from callbacks example and increased bouncetime…
pjbRPF Oct 17, 2025
73ddd80
use pico_led for MotionSensor example so not relying on second extern…
pjbRPF Oct 17, 2025
6ea3150
Merge pull request #126 from RaspberryPiFoundation:feature/MotionSensor
pjbRPF Oct 17, 2025
8c1a2e4
Add missing documentation for MotionSensor class
pjbRPF Oct 17, 2025
82a566f
Merge pull request #131 from RaspberryPiFoundation:130-missing-docume…
pjbRPF Oct 17, 2025
63ab7cb
Update changelog.rst
pjbRPF Oct 31, 2025
95d9822
Update conf.py
pjbRPF Oct 31, 2025
773b8db
Update __init__.py
pjbRPF Oct 31, 2025
75c8867
Update setup.py
pjbRPF Oct 31, 2025
ef127fc
Merge branch 'main' into dev
pjbRPF Oct 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ Button
:inherited-members:
:members:

MotionSensor
------------

.. autoclass:: MotionSensor
:show-inheritance:
:inherited-members:
:members:

Switch
------

Expand Down
11 changes: 11 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ Change log

.. currentmodule:: picozero

0.5.0 - 2025-10-31
-----------

+ Introduced ``MotionSensor`` class for PIR sensors

0.4.2 - 2023-05-12
------------------

+ Bug fix relating to DigitalInputDevice bounce times
+ Updated tests after a change in micropython 1.20+

0.4.1 - 2022-12-22
------------------

Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def __getattr__(cls, name):
# -- Project information -----------------------------------------------------

project = 'picozero'
copyright = '2022, Raspberry Pi Foundation'
copyright = '2025, Raspberry Pi Foundation'
author = 'Raspberry Pi Foundation'

# The full version, including alpha/beta/rc tags
release = '0.4.1'
release = '0.5.0'


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -101,4 +101,4 @@ def __getattr__(cls, name):
# -- Autodoc configuration ------------------------------------------------

autodoc_member_order = 'groupwise'
autodoc_default_flags = ['members']
autodoc_default_flags = ['members']
15 changes: 15 additions & 0 deletions docs/examples/motion_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from picozero import MotionSensor
from time import sleep

pir = MotionSensor(2)

print("PIR Motion Sensor Example")
print("Waiting for motion...")

while True:
if pir.motion_detected:
print("Motion detected!")
sleep(1)
else:
print("No motion")
sleep(0.5)
16 changes: 16 additions & 0 deletions docs/examples/motion_sensor_callbacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from picozero import MotionSensor, pico_led
from time import sleep

pir = MotionSensor(2)

# Set up event callbacks
pir.when_motion = pico_led.on
pir.when_no_motion = pico_led.off

# Keep the program running
try:
while True:
sleep(1)
except KeyboardInterrupt:
print("\nShutting down...")
pico_led.off() # Make sure LED is off when exiting
11 changes: 11 additions & 0 deletions docs/recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ Turn the :obj:`pico_led` on when a :class:`Button` is pressed and off when it is

.. literalinclude:: examples/button_led.py

Motion sensor
-------------

Detect motion using a PIR (Passive Infrared) sensor:

.. literalinclude:: examples/motion_sensor.py

Use callbacks to respond to motion events:

.. literalinclude:: examples/motion_sensor_callbacks.py

RGB LEDs
--------

Expand Down
3 changes: 2 additions & 1 deletion picozero/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__name__ = "picozero"
__package__ = "picozero"
__version__ = '0.4.1'
__version__ = '0.5.0'
__author__ = "Raspberry Pi Foundation"

from .picozero import (
Expand Down Expand Up @@ -28,6 +28,7 @@
DigitalInputDevice,
Switch,
Button,
MotionSensor,

AnalogInputDevice,
Potentiometer,
Expand Down
Loading