1、话不多说上代码
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <sys/stat.h> #include <unistd.h> void setLEDtrigger() { FILE *fp; char trigger[] = "none"; char dir[100]; sprintf(dir, "/sys/class/leds/fpga_led1/trigger"); if ((fp = fopen(dir, "w")) == NULL) { printf("Failed to open the file %s ", dir); } else { fwrite(trigger, sizeof(trigger), 1, fp); fclose(fp); } } void setLEDBrightness() { FILE *fp; char dir[100]; char brightness_char[] = "0"; sprintf(dir, "/sys/class/leds/fpga_led1/brightness"); if ((fp = fopen(dir, "w")) == NULL) { printf("Failed to open the file %s ", dir); } else { fwrite(brightness_char, sizeof(brightness_char), 1, fp); fclose(fp); } } int main(int argc, char** argv) { setLEDtrigger(); setLEDBrightness(); return 0; }
2、