2 Replies Latest reply on Sep 8, 2015 11:31 AM by Vignoli

    Invalid GPIO pin specified (2 and 8)

    Vignoli
          #include <iostream>
          #include <stdio.h>
          #include <unistd.h>
      #include "mraa.hpp"
          using namespace mraa;
          using namespace std;
      
      
          void exec(void*);
          Gpio* pin_2 = new Gpio(2);
          Gpio* pin_8 = new Gpio(8);
          bool state;
          int main()
          {
              state = 1;
              mraa_init();
              pin_8->dir(DIR_OUT);
              pin_2->dir(DIR_IN);
              pin_8->write(1);
              pin_2->isr(EDGE_FALLING,&exec,NULL);
              while(1);
              return MRAA_SUCCESS;
      
      
          }
      
      
          void exec(void* args){
          cout << pin_2->read() << endl;
              pin_8->write(0);
          }
      
      
      


      Trying to build this pushbutton and led application with interrupts, but I'm getting this message on Eclipse when running:

      root@edison:~# echo $PWD'>'
      /home/root>
      root@edison:~# chmod 755 /tmp/sample;/tmp/sample ;exit
      terminate called after throwing an instance of 'std::invalid_argument'
        what():  Invalid GPIO pin specified
      Aborted
      logout
      
      
      

       

      Been reading similar problems and corespondent solutions, but they don't seen to apply to my situation. Thanks for your help! Also would appreciate some tips about my program in general.