Skip to content

Commit

Permalink
Merge pull request #48 from Capstone-Projects-2024-Spring/BP-77-Creat…
Browse files Browse the repository at this point in the history
…e-working-example-connecting-GPIO-inputs-and-a-Pygame-Zero-program

Add example program (janky, look at next sprint)
  • Loading branch information
tuk05348 committed Mar 11, 2024
2 parents efb863e + a34b55b commit 07f5768
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/PygameZero_GPIOZero_Button_Example.py
@@ -0,0 +1,23 @@
from gpiozero import Button
import pgzrun

WIDTH = 300
HEIGHT = 300

button = Button(2)

screen_text = ""

def update():
if button.is_pressed:
screen_text = "Pressed"

def draw():
if button.is_pressed:
screen_text = "Pressed"
else:
screen_text = "Not Pressed"
screen.clear()
screen.fill((255, 255, 255))
screen.draw.text(screen_text, fontsize=40, center=(150, 150), color=(0,0,0))
pgzrun.go()

0 comments on commit 07f5768

Please sign in to comment.