🛠 LED et bouton USER : triggers kernel et gpio-keys

BeaglePlay (TI Sitara AM6254 / AM625) · debutant · Schéma : IMG-beagleplay-debutant-2-led-et-bouton-user.svg — Les 5 LED gpio-leds du BeaglePlay reliées au système de triggers du noyau et le bouton USER connecté à la ligne GPIO0_18 via gpio-keys

Objectives

Get familiar with BeaglePlay I/O without writing a driver: control the five gpio-leds LEDs defined in the device tree via the /sys/class/leds interface, change their triggers (heartbeat, cpu, mmc, gpio), and read the USER button declared as gpio-keys on GPIO line GPIO0_18, using evtest.

Hardware

Complete code

# Lister les LED déclarées par le device tree
ls /sys/class/leds/

# Voir les triggers disponibles puis activer heartbeat
cat /sys/class/leds/green:heartbeat/trigger
echo heartbeat | sudo tee /sys/class/leds/green:heartbeat/trigger

# Pilotage manuel
echo none | sudo tee /sys/class/leds/green:heartbeat/trigger
echo 1 | sudo tee /sys/class/leds/green:heartbeat/brightness
echo 200 | sudo tee /sys/class/leds/green:heartbeat/delay_on

# Bouton USER (gpio-keys, GPIO0_18) : écouter les événements
sudo evtest        # choisir l'entrée gpio-keys, appuyer : BTN_0 down/up

Expected verification

ls /sys/class/leds/ displays the LEDs from the device tree; after echo heartbeat, the LED blinks at the kernel's rate. sudo evtest lists an entry named after the button; pressing it prints EV_KEY / BTN_0 / value 1 followed by value 0. If you write gpio to the trigger file, the LED only responds to brightness.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials