current_state=$(cat "/sys/class/gpio/gpio$gpio_pin/value")
if [ "$current_state" -eq 0 ]; then
control_led "$gpio_pin" 1
else
control_led "$gpio_pin" 0
fi
}
Main loop to blink LEDs
while true; do
Turn on the green LED
control_led "$GREEN_LED_GPIO" 1
sleep 1
# Turn off the green LED
control_led "$GREEN_LED_GPIO" 0
sleep 1
# Toggle the red LED
toggle_led "$RED_LED_GPIO"
sleep 1
!/bin/bash
Ingenic T21 - Define GPIO pin numbers
GREEN_LED_GPIO=75 RED_LED_GPIO=78
Export GPIO pins
echo "$GREEN_LED_GPIO" > /sys/class/gpio/export echo "$RED_LED_GPIO" > /sys/class/gpio/export
Set the direction to "out"
echo "out" > "/sys/class/gpio/gpio$GREEN_LED_GPIO/direction" echo "out" > "/sys/class/gpio/gpio$RED_LED_GPIO/direction"
Function to control LED state
function control_led { local gpio_pin=$1 local state=$2
}
Function to toggle LED state
function toggle_led { local gpio_pin=$1
}
Main loop to blink LEDs
while true; do
Turn on the green LED
done
chmod +x leds.sh
run ./leds.sh -sh: ./leds.sh: not found
what???