Thursday, June 4, 2020

Raspberry Pi Blink in shell



#!/bin/sh

# release the pin on exit
trap 'echo 0 >/sys/class/gpio/gpio23/value;echo 23 >/sys/class/gpio/unexport' 0

echo 23 >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio23/direction

while true; do
  echo 1 >/sys/class/gpio/gpio23/value
  sleep 1
  echo 0 >/sys/class/gpio/gpio23/value
  sleep 1
done


# for input:
#  echo 23 >/sys/class/gpio/export
#  echo in >/sys/class/gpio/gpio23/direction
# read value:
#  cat /sys/class/gpio/gpio23/value
# release a pin
#  echo 23 >/sys/class/gpio/unexport

No comments:

Post a Comment