On my embedded system, I can toggle a user led with: echo > 1 sys/class/leds/beaglebone:green:usr2/value.

Similarly, I can find the value of a GPIO (gpio60) (set to input), with more sys/class/gpio/gpio60/value

I've been trying to write a script to set the state of the user led based on that of the input. The following produces no errors, but doesn't actually work.

cd ../../../
if [ sys/class/gpio/gpio60/value = 0 ]; then
echo 1 > sys/class/leds/beaglebone:green:usr2/brightness;
[else echo 0 > sys/class/leds/beaglebone:green:usr2/brightness;]

Maybe like this?

if [ $(cat sys/class/gpio/gpio60/value) -eq 0 ]; then
 echo 1 > sys/class/leds/beaglebone:green:usr2/brightness
 echo 0 > sys/class/leds/beaglebone:green:usr2/brightness

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.