02-14-2016, 07:12 PM
(02-14-2016, 05:49 PM)limitlesscodes Wrote: Hey Pine64 backers! I am having difficulty figuring out how I would use C to take user input, button presses, and light LEDs with the GPIO, I understand C fairly well but have no experience with interfacing with"GPIO." Here is the best program I could think of although I believe there is a much better way to do this:
Also what determines the pin number? Thanks for your help!Code:/*
*Simple pulsing of GPIO example
*/
#include <stdio.h>
#include <string.h>
FILE *zero, *one;
int main(int argc, char *argv[])
{
zero = fopen("/sys/class/gpio/gpio206/value", "w");
one = fopen("/sys/class/gpio/gpio206/value", "w");
while(1)
{
fputs("0\n", zero);
fflush(zero);
fputs("1\n", one);
fflush(one);
}
}
You've got the right general idea. See http://falsinsoft.blogspot.com/2012/11/a...space.html and
http://linux-sunxi.org/GPIO