INTRODUCTION
Blynk is a popular Internet of Things platform with a drag-n-drop mobile application builder that allows to visualize sensor data and control electronics remotely. This week we will show you how to control LED on Maker pHAT using Raspberry Pi and Blynk.
VIDEO
This video will show you how to control LED on Maker pHAT using Raspberry Pi and Blynk app. We used python library for programming.
HARDWARE PREPARATION
Sample Program
This code will allow you to control LED on Maker pHAT (Raspberry Pi’s GPIO pin) using Blynk app. Please replace YourAuthToken to your Blynk token.
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) |
Thank You
References
- blynk-library-python from vshymanskyy
Thanks for reading this tutorial. If you have any technical inquiry, please post at Cytron Technical Forum.
2 thoughts on “Controlling LED on Maker pHAT Using Raspberry Pi and Blynk”
Hi, for further technical inquiry, you can post at Cytron Technical Forum together with detail hardware setup and error. Thanks.
this is not working