GPIO activate on startup
-
Hi,
is it possible to activate on startup a GPIO-Pin to activate an Optokoppler?
Cheers
-
Hi,
noone who can help me?
i tryed it with this as script but it's not working:
case "$1" in
start)
echo „18“ > export
echo "out" > gpio18/direction
echo "1" > gpio18/value
;;
stop)
echo "0" > gpio18/value
;;
restart|reload)
Add your restart / reload code here!
;;
*)
esacexit $?
Cheers
-
Hi,
really no one who can help here?
I only want to have for example GPIO18 as output when recalbox is starting to controle a optocoupler.Cheers
-
@naitreia you can create the
custom.sh
file in/recalbox/share/system/
like this :#!/bin/sh # # Start optocoupler # # Support for optocoupler # # GPIO numbers should be from this list # 0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25 # Note that the GPIO numbers that you program here refer to the pins # of the BCM2835 and *not* the numbers on the pin header. # So, if you want to activate GPIO7 on the header you should be # using GPIO4 in this script. Likewise if you want to activate GPIO0 # on the header you should be using GPIO17 here. start() { echo -n "Starting opto: " # Set up GPIO 18 and set to output echo "18" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio18/direction # Write output echo "1" > /sys/class/gpio/gpio18/value echo "OK" } stop() { echo -n "Stopping opto: " # Set up GPIO 18 and set to output echo "18" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio18/direction # Write output echo "0" > /sys/class/gpio/gpio18/value # Clean up echo "18" > /sys/class/gpio/unexport echo "OK" } case "$1" in start) start ;; stop) stop ;; restart|reload) stop start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit $?
don't forget
chmod 755 custom.sh
You can try to use it with
/etc/init.d/S99custom start
you should get
# /etc/init.d/S99custom start Starting opto: OK
-
Thx for this i will try it today!
-
@naitreia I corrected 2 errors in the scripts above, please be sure to copy the code after this post