0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry Pi のACT LEDを点灯させるC++プログラム

Last updated at Posted at 2016-03-01

ただの,メモです.

# include <fcntl.h> //for O_RDWR
# include <unistd.h> //for open, close

int main(int argc, char** args) {
    /*O_RDWR は読み書きどちらも許可するモード*/
    /*PWR LEDを点灯させるときは,led1に変更する*/
    int trigger = open("/sys/class/leds/led0/trigger"      , O_RDWR); 
    int bright  = open("/sys/class/leds/led0/brightness", O_RDWR); 
    
    //初期化的なの
    write(trigger, (char*) "none", 4); //3rd arg is the size of 2nd arg
    
    //ACT点灯
    write(bright, (char*) "1", 1);
    //3秒休止
    sleep(3);
    //ACT消灯
    write(bright, (char*) "0", 1);
    
    //終了処理的なの
    write(trigger, (char*) "mmc0", 4); //メモリアクセスでACT点滅に戻す
    
    close(bright);
    close(trigger);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?