#!/usr/bin/ruby # Must be run as root # Tom Trebisky 8-16-2018 # Blink the status LED on a Nanopi Fire3 # This is on GPIO B12, so bit 32+12 = 44 $bit = 44.to_s $base = "/sys/class/gpio" $export = "/sys/class/gpio/export" $unexport = "/sys/class/gpio/unexport" $gpiodir = $base + "/gpio" + $bit $gpioval = $gpiodir + "/value" def setup system "echo \"#{$bit}\" > #{$export}" end def cleanup system "echo \"#{$bit}\" > #{$unexport}" puts "" puts "All done" end def blink loop { sleep 0.5 system "echo 0 >#{$gpioval}" sleep 0.5 system "echo 1 >#{$gpioval}" } end setup begin blink rescue Interrupt cleanup end # THE END