Skip to content

Instantly share code, notes, and snippets.

@IdrisCytron
Last active March 11, 2019 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IdrisCytron/9923d13020247c64b2e4c0f0131383cd to your computer and use it in GitHub Desktop.
Save IdrisCytron/9923d13020247c64b2e4c0f0131383cd to your computer and use it in GitHub Desktop.
Controlling LED on Maker pHAT using Raspberry Pi and Blynk app.
from gpiozero import LED
import BlynkLib
import time
led1 = LED(25)
BLYNK_AUTH = 'YourAuthToken'
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# Register Virtual Pins
@blynk.VIRTUAL_WRITE(1)
def my_write_handler(value):
print('Current V1 value: {}'.format(value[0]))
if int(format(value[0])) == 1:
led1.on()
else:
led1.off()
try:
while True:
blynk.run()
except KeyboardInterrupt:
sys.exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment