There is some problem with minnowboard turbot GPIO

There is some problem with minnowboard turbot GPIO

We got the following error message when using GPIO:

what():Invalid GPIO pin specified

Aborted(core dumped)

The program was adjusted from mraa/example/c++/blink-IO.cpp . We assumed the pin number to be 340(accross from wiki), is anything wrong?

 

 

void

 
sig_handler(int signo)

 
{

 
if (signo == SIGINT) {

 
printf("closing IO%d nicely\n", iopin);

 
running = -1;

 
}

 
}

 
int

 
main(int argc, char** argv)

 
{

 
iopin=340;

 
 

 
signal(SIGINT, sig_handler);

 
 

 
//! [Interesting]

 
mraa::Gpio* gpio = new mraa::Gpio(iopin);

 
if (gpio == NULL) {

 
return mraa::ERROR_UNSPECIFIED;

 
}

 
mraa::Result response = gpio->dir(mraa::DIR_OUT);

 
if (response != mraa::SUCCESS) {

 
mraa::printError(response);

 
return 1;

 
}

 
 

 
while (running == 0) {

 
response = gpio->write(1);

 
sleep(1);

 
response = gpio->write(0);

 
sleep(1);

 
}

 
delete gpio;

 
return response;

 
//! [Interesting]

 
}

 

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Problem has solved! pin number should be 25 instead of 340, and you should run your program with root permission

Leave a Comment

Please sign in to add a comment. Not a member? Join today