Advertisement
Guest User

BeagleBoneBlack GPIO C++ Library Test

a guest
Feb 12th, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. //============================================================================
  2. // Name        : gpio_test.cpp
  3. // Author      : James Howard
  4. // Version     :
  5. // Copyright   :
  6. // Description : Hello World in C++, Ansi-style
  7. //============================================================================
  8.  
  9. #include <iostream>
  10. #include <stdio.h>
  11. #include <unistd.h>
  12. #include "lib/gpio/GPIOManager.h"
  13. #include "lib/gpio/GPIOConst.h"
  14.  
  15. using namespace std;
  16.  
  17. int main() {
  18.   GPIO::GPIOManager* gp = GPIO::GPIOManager::getInstance();
  19.   int pin = GPIO::GPIOConst::getInstance()->getGpioByKey("USR3");
  20.  
  21.   cout << "USR3 LED Flash GPIO Test" << endl;
  22.  
  23.   while(1) {
  24.       gp->setValue(pin, GPIO::HIGH);
  25.       cout << "LED On" << endl;
  26.       sleep(1);
  27.  
  28.       gp->setValue(pin, GPIO::LOW);
  29.       cout << "LED Off" << endl;
  30.       sleep(1);
  31.   }
  32.  
  33.   gp->~GPIOManager();
  34.  
  35.   return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement