Documentation Talk:NGW/NGW100 LEDs
From AVRFreaks Wiki
HI, here a sample code to do it in C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char** argv)
{
printf("--Blinking leds on ngw100 using led classe from kernel--\n");
FILE *fp;
fp = fopen("/sys/class/leds/a/brightness","a"); // open file in ascii mode
if ( fp == NULL)
{
perror("fopen()");
exit(1);
}
while (1)
{
if ( 255 == fputc('1',fp)) // 1 lit up the A led
{
perror("fprintf()\n");
}
fflush(NULL); // Empty the internal file buffer
sleep(1); // wait 1 second
if ( 255 == fputc('0',fp)) // unlit the led
{
perror("fprintf()\n");
}
fflush(NULL);
sleep(1);
}
return 0;
}
