码迷,mamicode.com
首页 > 其他好文 > 详细

am335x -- led 控制

时间:2015-02-06 00:43:05      阅读:427      评论:0      收藏:0      [点我收藏+]

标签:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(void)
{
 

FILE *p=NULL;
 int i=0;
 p = fopen("/sys/class/gpio/export","w");
 fprintf(p,"%d",38);
 fclose(p);
 p = fopen("/sys/class/gpio/gpio38/direction","w");
 fprintf(p,"out");
 fclose(p);
 for(i=0;i<100;i++)
 {
  p = fopen("/sys/class/gpio/gpio38/value","w");
  fprintf(p,"%d",1);
  sleep(1);
  fclose(p);
  p = fopen("/sys/class/gpio/gpio38/value","w");
  fprintf(p,"%d",0);
  sleep(1);
  fclose(p);
 }
 p = fopen("/sys/class/gpio/unexport","w");
 fprintf(p,"%d",38);
 fclose(p);
 return 0;
}

am335x -- led 控制

标签:

原文地址:http://www.cnblogs.com/zym0805/p/4276208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!