Last active
March 11, 2019 03:06
-
-
Save IdrisCytron/9923d13020247c64b2e4c0f0131383cd to your computer and use it in GitHub Desktop.
Controlling LED on Maker pHAT using Raspberry Pi and Blynk app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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