0

I was able to control an led from a web page using the following code. when I call http://myip/pinon.php it will light up the LED and http://myip/pinoff.php will turn off the LED.

pinon.php

<?php
          system(“ gpio-g mode 24 out “) ; 
           system(“ gpio-g write 24 1”) ; ?>

pinoff.php

<?php
          system(“ gpio-g mode 24 out “) ; 
          system(“ gpio-g write 24 0”) ; ?>

Now I want to read input through GPIO pin when I access http://myip/readgpio.php file.

Is it possible to display a message "button pressed" on the web page(readgpio.php) When a button is pressed or when there is a voltage change on the GPIO pin?

2

Yes, just like you are using gpio utility to write to a pin you can use it to read a pin using the command:

gpio read <pin>

Some documentation and examples here.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.