MRAA pinmap (Failed to initialize)

GanniniGannini New Member Posts: 1

Hi, I'm trying to control the pin of the UP2 board.
When I tried the example provided by MRAA github
mraa/examples/c/led.c (Sorry for the chaotic typesetting below)

include <stdio.h>
include <stdlib.h>
include <unistd.h>

/* mraa header */
include "mraa/led.h"
include "mraa.h"

/* LED name */
define USER_LED 0

/* trigger type */
define LED_TRIGGER "heartbeat"

int
main(void)
{
mraa_result_t status = MRAA_SUCCESS;
mraa_led_context led;
int val;

/* initialize mraa for the platform (not needed most of the time) */
mraa_init();

//! [Interesting]
/* initialize LED */
led = mraa_led_init(USER_LED);
if (led == NULL) {
    fprintf(stderr, "Failed to initialize LED\n");
    mraa_deinit();
    return EXIT_FAILURE;
}

with the error output:
Failed to initialize LED

But when I tried mraa/examples/hellomraa
It will run correctly with the output:
hello mraa
Version: v2.0.0
Running on UP2

I surmise that problem is I didn't link the pinmapping (pin definition) file correctly, but I can't figure out what should I do.
Or is there any problem I have not found yet?
Thanks!

Tagged:
Sign In or Register to comment.