I'm using a class that I found on github to control the GPIO pins. That class can be found here: https://github.com/halherta/RaspberryPi-GPIOClass-v2
From what I understand this class works by writing the direction and values to a file in sys/class/gpio somewhere. I wrote some code off of the demo used in the github repository and it compiled fine, but when I tried to run it I got a Permission Denied error. After this, I changed the permissions with
sudo chmod 777
and tried running the same code but now I get this:
could not write to SYSFS GPIO export device: Device or resource busy
The code I'm using is:
int main (void)
{
string state;
GPIOClass* gpio17 = new GPIOClass("19");
GPIOClass* gpio27 = new GPIOClass("26");
gpio17->setdir_gpio("out");
gpio27->setdir_gpio("out");
gpio17->setval_gpio("0");
gpio27->setval_gpio("0");
for(;;)
{
usleep(1000000);
gpio17->getval_gpio(state);
if(state == "0"){gpio17->setval_gpio("1");}
else { gpio17->setval_gpio("0");}
gpio27->getval_gpio(state);
if(state == "0") { gpio27->setval_gpio("1");}
else {gpio27->setval_gpio("0");}
}
}
How can I stop Raspbian from using up the GPIO so I can use it?