Hello I'm creating a cgi script to turn on one led (Red) while blue is off and vice versa it's more like a quiz buzzer Here's a code


ch=gpio read 16 if test $ch -eq 1 then

gpio -g write 12 0
gpio -g write 12 1

My Red led is in Pin 32 and blue in 36 And I want to determine whether one of the Pin is in Write state I'm using Wiringpi is there any built in function that returns Boolean value of Pin write state? If not pls help me to get the code work Thank you

  • Actually you are using the wiringPi gpio utility. Have you looked at the documentation (man gpio)? – joan Jan 15 '18 at 9:48
  • Yes I have looked into and found gpio read pinno Does the work but I'm unable to store the command returned value to a variable – sten Jan 16 '18 at 15:53
  • Have a look at abyz.me.uk/rpi/pigpio/examples.html#Shell_gpiotest in particular m=$(pigs mg $1) # save mode and similar to show a way. – joan Jan 16 '18 at 16:31
  • Usually you can use backticks to store results of a command in a variable: $ AA=`date` $ echo $AA Wed Jan 17 09:18:27 EST 2018 – Maksym Jan 17 '18 at 14:19

Browse other questions tagged or ask your own question.