I am having trouble doing the tutorial for switches and libgpio.
http://www.claydowling.com/blog:reading_buttons_with_gpio
Manually, I am using a toggle switch and need to set the input via gpioctl in one line.
gpioctl -c 31 IN
gpioctl -c 31 PU
Does not work, Must be one line like so:
gpioctl -c 31 IN PU
No problem at all. Now I am coming to learn C library libgpio and I am trying to do the same.
Set the toggle button pin 31 to both IN and PU.
My problem is the tutorial only sets the pin with libgpio function input:
gpio_pin_input(handle, button_pin);
I can trigger the LED with one toggle of the switch, beyond that it does not detect any input(due to missing PU resistor)
When I add the following for pullup it seems the entire input fails according to
gpio 31 is blank. It is not set to either IN or OUT. Prior to running my app it is set to Pin31 IN PU by default.
So how do I combine these two functions? gpio_pin_input and gpio_pin_pullup
It seems there is something I missed. This should be common.
The same for the output side. How to set OUT PU with libgpio?
If I manually adjust the pins from another shell with my program running then the switch and LED works fine.
gpioctl -c 31 IN PU
http://www.claydowling.com/blog:reading_buttons_with_gpio
Manually, I am using a toggle switch and need to set the input via gpioctl in one line.
gpioctl -c 31 IN
gpioctl -c 31 PU
Does not work, Must be one line like so:
gpioctl -c 31 IN PU
No problem at all. Now I am coming to learn C library libgpio and I am trying to do the same.
Set the toggle button pin 31 to both IN and PU.
My problem is the tutorial only sets the pin with libgpio function input:
gpio_pin_input(handle, button_pin);
I can trigger the LED with one toggle of the switch, beyond that it does not detect any input(due to missing PU resistor)
When I add the following for pullup it seems the entire input fails according to
gpioctl -l
where the IN mode never gets set or PU.gpio 31 is blank. It is not set to either IN or OUT. Prior to running my app it is set to Pin31 IN PU by default.
Code:
gpio_pin_input(handle, button_pin);
gpio_pin_pullup(handle, button_pin);/*My ADDED line*/
gpio_pin_output(handle, led_pin);
gpio_pin_low(handle, led_pin);
gpio_pin_low(handle, button_pin);
It seems there is something I missed. This should be common.
The same for the output side. How to set OUT PU with libgpio?
If I manually adjust the pins from another shell with my program running then the switch and LED works fine.
gpioctl -c 31 IN PU