Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

LED flash


#!/bin/bash
# Filename: countLED.sh
# Version: 270716
# Author: robz
# Raspberry Pi script, flashes an LED number in "flash.txt" times. 
# GPIO pin 18 flash for new-pvr.sh, flashes number of shows downloaded.
# Requires an LED on pin 18 with a 470ohm resistor to a ground pin.
# An alternative is to use the green activity LED, comment code appropriately.
# Sudo crontab entries for this to work with new-pvr.sh:
# @reboot /home/pi/Downloads/scripts/countLED.sh > /dev/null 2>&1
# 00 18 * * * /usr/bin/pkill countLED.sh > /dev/null 2>&1

cdn="$(cat /home/pi/Downloads/scripts/flash.txt)"   # Current number of shows.
[ "$cdn" -lt "1" ] && exit

cleanup ()
{
echo "18" > /sys/class/gpio/unexport
# echo "mmc0" > /sys/class/leds/led0/trigger
}

trap 'cleanup > /dev/null 2>&1; exit' SIGTERM SIGHUP ERR EXIT

echo "18" > /sys/class/gpio/export                  # Activate GPIO pin 18.
echo "out" > /sys/class/gpio/gpio18/direction       # Designate as an output.

while true; do                                      # Continuous loop.
    for ((n=1; n<=cdn; n++)); do                    # Count shows loop.
        echo 1 > /sys/class/gpio/gpio18/value       # GPIO 18 high, LED on.
      # echo 1 > /sys/class/leds/led0/brightness    # Activity LED on.
        sleep .1
        echo 0 > /sys/class/gpio/gpio18/value       # GPIO 18 low, LED off.
      # echo 0 > /sys/class/leds/led0/brightness    # Activity LED off.
        sleep .2
    done
    sleep 4
done



No comments: