Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
View: 5348|Reply: 6

LED SD Card indicator

[Copy link]

3

Threads

10

Posts

62

Credits

Registered member

Rank: 2

Credits
62
QQ
Post time 2016-7-30 03:46:51 | Show all posts |Read mode
Hello guys.
the fact is, in armbian LED indicators on the board are useless somehow !
in mine red LED won't turn on and green LED blinks and stays on, so i made a use from them
i will write here how to make red LED like SD Card indicator LED so at SD Card activities LED would blink (Like green LED in Raspberry Pi)
i did try to do this for green LED, it worked but when i put the code in startup it didn't affected the green LED and it only worked for red LED. so in this guid we will use green LED as ON/OFF status of device and red LED as SD Card activty indicator.

1- Open terminal and login with root user or use this command to login as root
  1. su
Copy the Code
2- Type this command to open rc.local with nano text editor
  1. nano /etc/rc.local
Copy the Code
3- add this before exit 0
  1. echo none >/sys/class/leds/red_led/trigger
  2. echo mmc0 >/sys/class/leds/red_led/trigger
  3. echo 1 >/sys/class/leds/green_led/brightness
Copy the Code
4- then press Ctrl + X then Y
5- It's Done ! Reboot now to test how this works
  1. reboot
Copy the Code
Enjoy.


www.m3ni.com [url=http://www.orangepi.org/orang

10

Threads

217

Posts

1842

Credits

Gold member

Rank: 6Rank: 6

Credits
1842
Post time 2016-7-30 06:25:38 | Show all posts
I got an idea in your post.
I made the script which checks a package update.

1.Change in /etc/sudoers
$ sudo visudo

The following 1 line is added to the end.

orangepi ALL=(ALL) NOPASSWD: ALL

2.Create this script(pkg_checker.sh) in $HOME

  1. #!/bin/bash
  2. sudo apt-get -s upgrade > /tmp/apt.log
  3. #grep -c "The following packages will be upgraded" /tmp/apt.log
  4. check=`grep -c "The following packages will be upgraded" /tmp/apt.log`
  5. #echo $check
  6. rm /tmp/apt.log
  7. if [ $check -ne 0 ] ; then
  8. # Update package EXIST
  9.   sudo sh -c "echo 0 > /sys/class/leds/red_led/brightness"
  10.   sudo sh -c "echo heartbeat > /sys/class/leds/red_led/trigger"
  11.   sudo sh -c "echo 1 > /sys/class/leds/red_led/brightness"
  12. else
  13. # Update package NOT EXIST
  14.   sudo sh -c "echo none > /sys/class/leds/red_led/trigger"
  15.   sudo sh -c "echo 0 > /sys/class/leds/red_led/brightness"
  16. fi
Copy the Code

3.Add execute permission to this script.
chmod 777 pkg_checker.sh

4.Execute this script.
If there is update package,RED-LED become blink.

5.Add crontab
0 * * * * /home/orangepi/pkg_checker.sh




3

Threads

10

Posts

62

Credits

Registered member

Rank: 2

Credits
62
QQ
 Author| Post time 2016-7-30 18:37:59 From the mobile phone | Show all posts
Thanks! I will test it on my pi when i got home, also could you manage to make green LED blink for sd card activity? When i attempted to do that on startup it would just get stock and would be on. Not blinking. I think we have to find the original command in armbian to disable the "heartbeat" trigger for it that starts at startup, unfortunately i didn't found it

1

Threads

5

Posts

92

Credits

Registered member

Rank: 2

Credits
92
Post time 2016-11-23 06:03:18 | Show all posts
Actually M3NI I had fixed that already, if you run your program at that boot level if you pay attention, actually works... But! After it continues booting (I don't know why or when honestly) the system itself changes it function for it default (Default-ON), so the solution is to start the green LED just when your start your GUI, any of them, so my solution is (if you are using xserver ofcourse).
- Test you have all x servers dependencies (you must try a "startx" command into a terminal and it should open your GUI.
- At your home direction (usually in armbian is /home/pi/) check your .xinitrc file and if you don't have it create it
- Edit that text starting your graphical interface and sending the GREEN LED FUNCTION together.

FOR EXAMPLE if you are starting XFCE4
  1. exec echo heartbeat >/sys/class/leds/green_led/trigger &
  2. exec startxfce4
Copy the Code

if your xserver goes to that file for your personal configuration, and you are using Orange Pi's defauilt GUI, xfce4, it should start your graphical interface AND start beating your led, obviously you should use any function you want there.

Cheers!

3

Threads

20

Posts

163

Credits

Registered member

Rank: 2

Credits
163
Post time 2017-8-16 09:00:32 | Show all posts
Could the original script of blinking red on SDCard access have the same problem?  It is in my /etc/rc.local but it never seems to work.  Should I maybe put it in one of the rcn.d directories?  Oh wait all those are 777 and rc.local is 755.  Maybe I should chmod 777 rc.local.  I'll give that a try.

I know it should work somehow becuase if I SU then execute the two echo statements the LED starts working as defined.

5

Threads

21

Posts

341

Credits

Intermediate member

Rank: 3Rank: 3

Credits
341
Post time 2017-8-22 04:12:46 | Show all posts
Very nice, i used it :-)

1

Threads

9

Posts

137

Credits

Registered member

Rank: 2

Credits
137
Post time 2017-12-15 15:08:01 | Show all posts
How to blink red led when access USB SSD ?
You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2018-12-19 12:35 GMT+8 , Processed in 0.030504 second(s), 23 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list