1 //Code to blink an LED - just to illustrate that it's pretty easy
2 //Only important thing is which name to address the LED by
9 int main(int argc, char** argv) {
10 FILE *LEDHandle = NULL;
11 char *LEDBrightness = "/sys/class/leds/beaglebone:green:usr0/brightness";
12 printf("\nStarting LED blink program wooo!\n");
14 if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL){
15 fwrite("1", sizeof(char), 1, LEDHandle);
19 if((LEDHandle = fopen(LEDBrightness, "r+")) != NULL){
20 fwrite("0", sizeof(char), 1, LEDHandle);
28 //Sample code that should read a pressure sensor pin (conversion factors
29 //are just random numbers). Again pretty simple.
33 double pressure(char *string) {
34 int value = atoi(string);
35 double millivolts = (value / 4096.0) * 1800; //convert input to volts
36 double pressure = (millivolts - 500.0) / 10.0; //convert volts to pressure
41 int fd = open("/sys/devices/platform/tsc/ain2", O_RDONLY); //open pin signal
44 int ret = read(fd, buffer, sizeof(buffer)); //get data
47 double kpa = pressure(buffer);
48 printf("digital value: %s kilopascals: %f\n", buffer, kpa);