The easy way is going to be reading the value file for the gpio pin you
have set as input. In C:
FILE * f = fopen("/sys/class/gpio/gpio67/value", "r");
int val;
(void) fscanf(f, "%d", &val);
tada the variable val now holds a one or zero based on the state of the
gpio pin.
Another tutorial:
https://www.dummies.com/computers/beaglebone/setting-beaglebone-gpios-as-inputs/
For simple stuff like this, usually a quick Google search will have the
answers ;)
On Wed, Jul 17, 2019, 12:52 AM Megha Bhirade <[email protected]> wrote:
> Hi,
>
> i am new to beagle bone black board..
>
> i flashed new Debian Image to BBB and worked on simple LED blinking
> program in C. it is working fine(external LED connected in bread board), in
> Linux ubuntu
>
> next example i am trying to control that external LED using external
> switch :
>
> like this :
>
> system("echo out > /sys/class/gpio/gpio68/direction) for LED.
> system ("echo in > /sys/class/gpio/gpio67/direction) for switch.
>
> using these coding lines i am making LED high and Low in C file
> system("echo 1 > /sys/class/gpio/gpio68/value)
> system("echo 0 > /sys/class/gpio/gpio68/value)
>
> based on the switch status i need to make LED ON and LED OFF...
>
> how to read the state of GPIO in beagle bone black in C file???
>
> please help me any one ....
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beagleboard/42542757-ff67-4183-99f1-d54834768d60%40googlegroups.com
> <https://groups.google.com/d/msgid/beagleboard/42542757-ff67-4183-99f1-d54834768d60%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/CAOyeZdra57yOKBqjQK_Ua7OY%3DfCa2v_8X1ukFLx%2BCreAHznY7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.