I have a BeagleBone Black with Debian installed. I successfully ssh'd into it with MobaXterm and wrote the following code (have written/compiled/run this in both nano and gedit):
#include <iostream>
#include <stdio.h>
#include <unistd.h>
using namespace std;
int main(){
cout << "LED Flash Start" << endl;
FILE *LEDHandle = NULL;
const char *LEDBrightness="/sys/class/leds/beaglebone:green:usr0/brightness";
for(int i=0; i<10; i++){
if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL){
fwrite("1", sizeof(char), 1, LEDHandle);
fclose(LEDHandle);
}
usleep(1000000);
if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL){
fwrite("0", sizeof(char), 1, LEDHandle);
fclose(LEDHandle);
}
usleep(1000000);
}
cout << "LED Flash End" << endl;
}
basically I followed the steps shown here: http://elinux.org/Beagleboard:C/C%2B%2B_Programming
The code compiles and runs. In the terminal it displays the expected output however on the BeagleBone Black the USR0 led never changes from its usual heartbeat pattern. Does anyone know why this could be?
Thanks in advance.