Questions about GPIO
#8
(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:
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);
}
}
Also what determines the pin number? Thanks for your help!

You've got the right general idea.  See http://falsinsoft.blogspot.com/2012/11/a...space.html and
http://linux-sunxi.org/GPIO


Messages In This Thread
GPIO ports - by igna09 - 12-31-2015, 04:31 AM
RE: GPIO ports - by o9guy - 12-31-2015, 10:28 AM
RE: GPIO ports - by limitlesscodes - 02-07-2016, 01:56 PM
RE: GPIO ports - by tllim - 02-07-2016, 08:25 PM
RE: GPIO ports - by limitlesscodes - 02-10-2016, 12:25 AM
RE: GPIO ports - by tllim - 02-10-2016, 06:53 PM
Questions about GPIO - by limitlesscodes - 02-14-2016, 05:49 PM
RE: Questions about GPIO - by patrickhwood - 02-14-2016, 07:12 PM
RE: Questions about GPIO - by limitlesscodes - 02-15-2016, 06:05 PM
RE: Questions about GPIO - by limitlesscodes - 02-16-2016, 03:15 PM
RE: Questions about GPIO - by patrickhwood - 02-16-2016, 11:45 PM
RE: Questions about GPIO - by limitlesscodes - 02-17-2016, 03:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  GPIO specifications in device tree ramstadt 1 3,503 01-16-2019, 03:17 PM
Last Post: ramstadt
  +PINEBOOK Q4OS Pinebook Questions StewB 0 2,428 08-24-2017, 03:53 PM
Last Post: StewB
  Low-Level-GPIO-Access Thoams131 2 4,616 01-11-2017, 02:54 PM
Last Post: Thoams131
Question PPS-GPIO Sebastian 11 18,214 07-12-2016, 07:25 PM
Last Post: tllim
  C#.NET / Mono GPIO library? abutler77 0 3,151 06-12-2016, 10:34 PM
Last Post: abutler77
  Lazarus and GPIO gbestwick 0 2,391 05-22-2016, 08:51 PM
Last Post: gbestwick
  GPIO javascript library. neeeds 1 3,969 02-19-2016, 11:31 PM
Last Post: limitlesscodes

Forum Jump:


Users browsing this thread: 5 Guest(s)