I’m new in blynk community and i making a project and i need to control a servo motor with a button in Blynk app.
I have the code bellow:
import RPi.GPIO as GPIO
import time
servoPIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)
GPIO.setwarnings(False)
p = GPIO.PWM(servoPIN, 50) # GPIO 17 for PWM with 50Hz
p.start(2.5) # Initialization
p.ChangeDutyCycle(12.5)
time.sleep(0.5)
p.ChangeDutyCycle(2.5)
time.sleep(0.5)
p.stop()
GPIO.cleanup()
What i need is: every time i will push the button, the app shall be run this code.
Anyone knows how i do this ?
I will appreciatte any helps.
Thank you.