0

I am trying to send a temporary signal through one of the GPIO pins on my Pi 4, like to light up an LED for 1 second then turn off. Is there are way to do this by clicking on a button on my HTML web page? Right now, I can only perform this function using a terminal command that calls a simple python script, like this one from thepihut.com

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
GPIO.output(18,GPIO.LOW)

I don't necessarily need to use Python, that is just the one I am most familiar with. If there is a way to embed it somehow in a button in a HTML or even PHP file using JavaScript or some other function, that would be stellar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.