Sockit 硬件接口编程——点亮一个LED
2024-09-01 21:43:50
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[]; sprintf(dir, "/sys/class/leds/fpga_led1/trigger"); if ((fp = fopen(dir, "w")) == NULL) {
printf("Failed to open the file %s\n", dir);
}
else {
fwrite(trigger, sizeof(trigger), , fp);
fclose(fp);
}
} void setLEDBrightness()
{
FILE *fp; char dir[];
char brightness_char[] = ""; sprintf(dir, "/sys/class/leds/fpga_led1/brightness"); if ((fp = fopen(dir, "w")) == NULL) {
printf("Failed to open the file %s\n", dir);
}
else {
fwrite(brightness_char, sizeof(brightness_char), , fp);
fclose(fp);
}
} int main(int argc, char** argv)
{ setLEDtrigger();
setLEDBrightness(); return ;
}
2、
最新文章
- centos6配置网卡
- Linux文件标示
- aspx注入靶机源码
- 在AngularJS应用中实现认证授权
- sublime text3-代码片段配置
- MySQL 删除数据表
- Spark Streaming连接TCP Socket
- awk使用的实例
- Linux Command Line(II): Intermediate
- 2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路
- React Native控件之Listview
- HBase案例:HBase 在人工智能场景的使用
- Apache2.4反向代理设置
- SWT table性能改善 -- 使用VirtualTable
- (第十二周)Bug修正报告
- 问题:从键盘读取特定类型的数据(使用Scanner读取int类型)
- Mac下Jmeter快速安装与入门-模拟测试Post请求及设置Http头
- iostat -x命令诊断
- C# .net 获取外网ip
- Ubuntu安装sublime Text 3并配置可以输入中文