🛠 GPIO duos : commander les broches de l'Arduino depuis Linux

Arduino Tian (id: tian) · avance · Schéma : IMG-tian-avance-1-tian-gpio-partages-linux.svg — Arduino Tian en vue éclatée : une même broche physique reliée à la fois au SAMD21 et au contrôleur GPIO de l'AR9342, terminal Linux avec « echo 0 > /sys/class/gpio/export », LED clignotée depuis un script shell.

Objectives

Leverage the Tian's most advanced concept: I/O pins are physically connected to both processors. The Arduino sketch controls them conventionally, but Linux can also claim them via the kernel's standard sysfs interface (/sys/class/gpio), documented in the official Tian datasheet with a mapping table between Arduino pins and Linux GPIO numbers. You will blink an LED from a shell script, without touching the sketch.

Hardware

Procedure

# Côté SSH Linux — N = numéro GPIO correspondant à votre broche,
# à lire dans la table officielle broche Arduino -> GPIO de la Tian.
# > 
# celle de la Yun, utiliser la table du document officiel archivé.

N=21   # exemple de valeur, À REMPLACER par la valeur de la table officielle
echo $N > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio$N/direction

while true; do
  echo 1 > /sys/class/gpio/gpio$N/value
  sleep 0.5
  echo 0 > /sys/class/gpio/gpio$N/value
  sleep 0.5
done

Expected Verification

The LED blinks at 1 Hz controlled solely by the shell script — the SAMD21 is not involved. Next diagnostic step: upload a sketch that sets the same pin to a fixed state, then rerun the script: the final visible state is that of the last writer. This proves that the hardware is shared and that it is up to you to arbitrate.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials