X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=server%2Factuator.c;h=2967c6c59ebdfe526a5be0c929abceed96029882;hb=14d73a4af10b05dd7d4d5e22f737a3684d0515cd;hp=ff51732bb38861b227b05d1f3f284c5931a82d88;hpb=689d255c3005c3dac937780824b598469e486149;p=matches%2FMCTX3420.git diff --git a/server/actuator.c b/server/actuator.c index ff51732..2967c6c 100644 --- a/server/actuator.c +++ b/server/actuator.c @@ -147,7 +147,20 @@ void Actuator_SetValue(Actuator * a, double value) //TODO: Set actuator switch (a->id) { - case ACTUATOR_TEST0: + case ACTUATOR_TEST0: //LED actuator test code, should blink onboard LED next to Ethernet port + FILE *LEDHandle = NULL; //code reference: http://learnbuildshare.wordpress.com/2013/05/19/beaglebone-black-controlling-user-leds-using-c/ + char *LEDBrightness = "/sys/class/leds/beaglebone\:green\:usr0/brightness"; + if(value == 1) { + if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL) { + fwrite("1", sizeof(char), 1, LEDHandle); + fclose(LEDHandle); + } + else if(value == 0) { + if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL) { + fwrite("0", sizeof(char), 1, LEDHandle); + fclose(LEDHandle); + } + else perror("Pin value should be 1 or 0"); break; case ACTUATOR_TEST1: break;