1

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

#!/bin/bash

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

gpio -g write 12 0
else
gpio -g write 12 1
fi

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

closed as unclear what you're asking by Milliways, techraf, Steve Robillard, Jacobm001 Jan 19 '18 at 2:17

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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.