# gpioExpanderService on mangOH Yellow?

**URL:** <https://mangoh.discourse.group/t/gpioexpanderservice-on-mangoh-yellow/4796>\
**Category:** mangOH Yellow\
**Created:** [July 8, 2020, 3:32pm UTC](https://mangoh.discourse.group/t/gpioexpanderservice-on-mangoh-yellow/4796 "2020-07-08T15:32:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulmeis](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@paulmeis](https://mangoh.discourse.group/u/paulmeis)\
**Post date:** [July 8, 2020, 3:32pm UTC](https://mangoh.discourse.group/t/gpioexpanderservice-on-mangoh-yellow/4796/1 "2020-07-08T15:32:55Z")

</div>

Hello,

I want to use the GPIO expander on my mangOh Yellow to drive the generic green led of the board.

In the past I used the gpioExpanderService app ([here](https://github.com/mangOH/GpioExpander/tree/608670c2466012c89a248e99e66a36a16872490a/gpioExpanderService)) to manage the GPIO expander of my mangOH Red.  
However this service seems to only be available for mangOH Red and mangOH Green.

Is there a service available for mangOH Yellow to do the same ?

Thank you for your time

BR

---

<div class="post-metadata">

**Author:** ![jchitty](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/jchitty/32/846_2.png) [@jchitty](https://mangoh.discourse.group/u/jchitty)\
**Post date:** [July 10, 2020, 6:57pm UTC](https://mangoh.discourse.group/t/gpioexpanderservice-on-mangoh-yellow/4796/2 "2020-07-10T18:57:55Z")

</div>

Hi,

On mangOH Yellow, there’s an app called `leds`, which drives all the software-controlled LEDs on the board. You can control that through the `dataHub` either using the Data Hub’s C APIs or using the `dhub` command-line tool.

The “generic” green LED appears in the Data Hub at resource path `/app/leds/mono/enable`.  
You can run the following command to see all the dataHub resources connected to the `leds` app:

`root@swi-mdm9x28-wp:~# dhub list /app/leds`

To turn on the LED using the `dhub` command-line tool, run:

`root@swi-mdm9x28-wp:~# dhub push /app/leds/mono/enable true`

To turn it off, run:

`root@swi-mdm9x28-wp:~# dhub push /app/leds/mono/enable false`

To control the LEDs using the Data Hub’s “Admin API” in C, you first need to give your component access to that API by adding the following to your Component.cdef:

```auto
requires:
{
    api:
    {
        dhubAdmin = admin.api
    }
}

```

This creates a client-side interface on your component that can be connected up to the server-side interface called “admin” on the `dataHub` app. You create that connection by adding the following to your app’s `.adef` file:

```auto
bindings:
{
    myExe.myComponent.dhubAdmin -> dataHub.admin
}

```

Now you can use the Data Hub’s Admin API to control the `/app/leds/mono/enable` resource in your component’s C code like this:

```auto
dhubAdmin_PushBoolean("/app/leds/mono/enable", 0, newState);

```

- The second parameter (`0`) is the timestamp you are assigning to the “sample” that you are pushing to that resource. `0` is a special value which means “now”.
- The last parameter (`newState`) is the boolean value of your “sample”.

So, this will push a new data sample to that resource, which will be delivered to the `leds` app, which will respond by setting the LED state to the value in that sample (`false` = off, `true` = on).

Cheers,

–Jen
