1、LED的原理图引脚接口
2、对应的GPIO数字
RGB_LED_B_NUM (GPIO1_B0): Bank = 1, group=1, X=0, pin_num=1*32 + 1*8 + 0 =40
RGB_LED_G_NUM (GPIO1_B0): Bank = 1, group=1, X=1, pin_num=1*32 + 1*8 + 1 =41
RGB_LED_R_NUM (GPIO1_B0): Bank = 1, group=1, X=2, pin_num=1*32 + 1*8 + 2 =42
3、led设备驱动
ls /sys/class/leds/
4、led相关属性
ls /sys/class/leds/rgb-led-r/
(a) brightness, 设置led的亮度,因为led是电平控制的,0为熄灭,非0为点亮,暂不支持控制亮度
echo "0" > /sys/class/leds/rgb-led-r/brightness #熄灭led
echo "1" > /sys/class/leds/rgb-led-r/brightness #点亮led
(b) trigger: 控制led工作模式
none: 禁止触发,ledb保持熄灭
echo "none" > /sys/class/leds/rgb-led-r/trigger #关闭led
timer: 根据设定时间间隔触发,配置delay_on 和delay_off 两个参数控制亮灭时长
echo "timer" > /sys/class/leds/rgb-led-r/trigger #定时触发led
echo "500" > /sys/class/leds/rgb-led-r/dealy_on #500ms亮
echo "500" > /sys/class/leds/rgb-led-r/dealy_off #500ms灭
其他模式...
5、控制led的shell脚本
./led_ctl.sh & (其中加& 表示后台运行)
led_ctl.sh 脚本如下
#! /usr/bin/bash
#turn off all leds
echo "none" > /sys/class/leds/rgb-led-r/trigger
echo "none" > /sys/class/leds/rgb-led-g/trigger
echo "none" > /sys/class/leds/rgb-led-b/trigger
echo "1" > /sys/class/leds/rgb-led-r/brightness
echo -e "\nTurn On rgb-led-r"
sleep 2s
echo "0" > /sys/class/leds/rgb-led-r/brightness
echo -e "\nTurn Off rgb-led-r"
sleep 2s
#led-g loops run
while true; do
echo "1" > /sys/class/leds/rgb-led-g/brightness
sleep 1s
echo "0" > /sys/class/leds/rgb-led-g/brightness
sleep 1s
done
ctl+c退出,使用ps查看进程,
kill -9 pid 可以关闭对应进程
标签:02,leds,led,--,echo,sys,rgb,class From: https://www.cnblogs.com/zblblog/p/18079951