Development Of Led Applications - Embest SBC8600B User Manual

Hide thumbs Also See for SBC8600B:
Table of Contents

Advertisement

Embest Technology Co., Ltd

3.12.1 Development of LED Applications

1) Compose source code led_acc.c to instruct the two LEDs on SBC8600B to blink
in the mode of accumulator;
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#define LED1 "/sys/class/leds/sys_led/brightness"
#define LED2 "/sys/class/leds/user_led/brightness"
int main(int argc, char *argv[])
{
}
2) Execute the following instruction in Ubuntu Linux system to implement cross
Copyright © 2017 Embest Technology
int f_led1, f_led2;
unsigned char i = 0;
unsigned char dat1, dat2;
if((f_led1 = open(LED1, O_RDWR)) < 0){
printf("error in open %s",LED1);
return -1;
}
if((f_led2 = open(LED2, O_RDWR)) < 0){
printf("error in open %s",LED2);
return -1;
}
for(;;){
i++;
dat1 = i&0x1 ? '1':'0';
dat2 = (i&0x2)>>1 ? '1':'0';
write(f_led1, &dat1, sizeof(dat1));
write(f_led2, &dat2, sizeof(dat2));
usleep(300000);
}
Example Application
SBC8600B-UM-V2.0
89

Advertisement

Table of Contents
loading

Table of Contents