02-15-2016, 06:05 PM
(02-14-2016, 07:12 PM)patrickhwood Wrote:I read through them, so from what I am able to understand my program would only work if the kernel supports GPIO access from sysfs, will the Pine64 support this(I really hope to hear yes)? Also, say I am trying to blink an LED, can you be so kind as to tell my a pin number on the GPIO that can do that?(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