Raspberry Pi でパトランプ(回転灯)

サンプル

#!/bin/bash

# GPIO 4 に出力
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction
echo "0" > /sys/class/gpio/gpio4/value

for ((i=0; i<10; i++)); do
  echo "ON"
  echo "1" > /sys/class/gpio/gpio4/value
  sleep 3

  echo "OFF"
  echo "0" > /sys/class/gpio/gpio4/value
  sleep 2
done

echo "4" > /sys/class/gpio/unexport