mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Remove with blocks for consistency, re: #239
This commit is contained in:
@@ -221,8 +221,8 @@ Capture a picture with the camera module every time a button is pressed::
|
|||||||
from picamera import PiCamera
|
from picamera import PiCamera
|
||||||
|
|
||||||
button = Button(2)
|
button = Button(2)
|
||||||
|
camera = PiCamera()
|
||||||
|
|
||||||
with PiCamera() as camera:
|
|
||||||
camera.start_preview()
|
camera.start_preview()
|
||||||
frame = 1
|
frame = 1
|
||||||
while True:
|
while True:
|
||||||
@@ -676,7 +676,8 @@ connected to a :class:`MCP3008` analog to digital converter::
|
|||||||
|
|
||||||
from gpiozero import MCP3008
|
from gpiozero import MCP3008
|
||||||
|
|
||||||
with MCP3008(channel=0) as pot:
|
pot = MCP3008(channel=0)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print(pot.value)
|
print(pot.value)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user