I'm trying to make a program for beaglebone to let me control the gpio pins. I tried to use sprintf() but doesn't accept input as I know.
I have to re-write couple files in the beaglebone like
gpio export active the pin gpio gpio$pin/direction pin mode in/out gpio gpio$pin/value pin value 1/0
guys..!! just need a idea how to accomplish my goal.
I'm newbie in c++. any information or comment I'll appreciated thks guys for your time.
Here is a tutorial on using c++ to control the LEDs: http://derekmolloy.ie/beaglebone-controlling-the-on-board-leds-using-c/
Halfway down the page is the C++ code. Take this implementation, but instead of writing to the LED device files, write the appropriate information to the GPIO device files, like in this manual:
http://elinux.org/images/3/33/GPIO_Programming_on_the_Beaglebone.pdf
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main(){
std::fstream fs;
fs.open("/sys/kernel/debug/omap_mux/gpmc_ad4");
fs << "7";
fs.close();
fs.open("/sys/class/gpio/export");
fs << "32";
fs.close();
fs.open("/sys/class/gpio/gpio32/direction");
fs << "out";
fs.close();
fs.open("/sys/class/gpio/gpio32/value");
fs << "1"; // "0" for off
fs.close();
// select whether it is on, off or flash
return 0;
}