On a embbeded Linux system, the LEDs are commonly controlled by sysfs interface.
This example demonstrates how to control the LEDs by sysfs with echo
command or led_test
application.
Hardware Preparation:
- Hardware debugging environment to see chapter2.
- MYD-AM335x series development board
Software Preparation:
- Linux Kernel 4.1.18
- echo, led_test application
Test Steps:
-
Copy cross compiled
<WORKDIR>/Examples/led/led_test
to/usr/bin
directory of the MYD-AM335x series development board. -
View the device node of MYD-AM335X LED devices as below:
1
2# ls /sys/class/leds
myc:green:user1 myd:green:user2 myd:green:user3 -
Control the MYD-AM335X LED by
echo
command as below:1
2
3
4
5
6
7
8
9D3:
#echo "1" > /sys/class/leds/myc:green:user1/brightness
#echo "0" > /sys/class/leds/myc:green:user1/brightness
D39:
#echo "1" > /sys/class/leds/myd:green:user2/brightness
#echo "0" > /sys/class/leds/myd:green:user2/brightness
D40:
#echo "1" > /sys/class/leds/myd:green:user3/brightness
#echo "0" > /sys/class/leds/myd:green:user3/brightness -
View the device node of MYD-AM335X-Y LED devices as below:
1 |
# ls /sys/class/leds |
- Control the MYD-AM335X-Y LED by
echo
command as below:
1 |
D3: |
- View the device node of MYD-AM335X-J LED devices as below:
1 |
# ls /sys/class/leds |
- Control the MYD-AM335X-J LED by
echo
command as below:
1 |
D3: |
- Control the LEDs by ‘led_test’ application as below:
1 |
# led_test -h |
近期评论