I need a simple program that will write to gpio. I can't find one anywhere. The example in the mmra documentation does not work. I picked gpio14 because the Sprakfun example that writes to this pin using system calls works just fine. But my program does not work.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mraa.h>
#include <math.h>
#include <mraa/gpio.h>
int main(int argc, char **argv)
{
mraa_gpio_context gpio;
gpio = mraa_gpio_init(14); <--- to get gpio14 to toggle change this to 36
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
int value = 0;
for (;;) {
if(value == 0)value = 1;
else value = 0;
mraa_gpio_write(gpio,value);
printf("output is %d\n",value);
sleep(1);
}
mraa_gpio_close(gpio);
return 0;
}
The loop runs and prints out output is 1 then output is 0. I have an oscilloscope on the pin and it stays low.
Using this Sparkfun tutorial I can move the pin high so I know my setup is correct. If someone can just give me an example of code that works with all the includes and such that would be very helpful.