1

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.

#!/bin/bash
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;]
fi

1 Answer 1

0

Maybe like this?

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .