Hi, im trying to control the gpio of Raspberry Pi Zero W using Blynk
I tried using the following code to test the connection,
import blynklib
BLYNK_AUTH = 'YourAuthToken'
# initialize Blynk
blynk = blynklib.Blynk(BLYNK_AUTH)
WRITE_EVENT_PRINT_MSG = "[WRITE_VIRTUAL_PIN_EVENT] Pin: V{} Value: '{}'"
# register handler for virtual pin V4 write event
@blynk.handle_event('write V4')
def write_virtual_pin_handler(pin, value):
print(WRITE_EVENT_PRINT_MSG.format(pin, value))
###########################################################
# infinite loop that waits for event
###########################################################
while True:
blynk.run()
its works and i can get outputs by toggling a button set to a virtual pin.
then i added
@blynk.handle_event('write V4')
def write_virtual_pin_handler(pin, value):
print(WRITE_EVENT_PRINT_MSG.format(pin, value))
if int(value) == 1:
GPIO.output(led_pin, GPIO.HIGH)
else:
GPIO.output(led_pin, GPIO.LOW)
but my led doesn’t light up when i toggle the button.
Please advice.
PS: i did define and setup the led pins.