# Turning LED on and off?

**URL:** <https://mangoh.discourse.group/t/turning-led-on-and-off/1400>\
**Category:** mangOH Red\
**Created:** [May 9, 2018, 4:14pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400 "2018-05-09T16:14:17Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 9, 2018, 4:14pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/1 "2018-05-09T16:14:17Z")

</div>

I tried the two sample applications that come with mangoh red. They one crashes and the other just does not seem to do anything, one is gpioCf3Demo and timerLed, I’m trying to understand how to turn on an LED and the off, but I can’t seem to be able to do that. Can anyone give me a hint as to where to find the right documented libraries so I can make a code myself.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [May 9, 2018, 9:19pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/2 "2018-05-09T21:19:15Z")

</div>

Are you trying to control an LED that’s on the mangOH board or have you connected an LED to a specific GPIO?

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 9, 2018, 9:54pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/3 "2018-05-09T21:54:50Z")

</div>

I tried to connect an LED to GPIO 22 at first as per gpioCf3Demo but the program crashed, so the I ran TimerLED just to see if that worked but I don’t see any of the LED of my mangOH blink which should make the D750 blink I tried searching for which one might be but nothing blinks. I tried to make one from scratch just so that I could un derstand how to make an LED turn on and off. So I used the following code:

```
#include "legato.h"
#include "interfaces.h"

COMPONENT_INIT
{
	LE_INFO("Initiating LED ON");
	le_gpioPin7_SetPushPullOutput(LE_GPIOPIN7_ACTIVE_HIGH, true);
	LE_INFO("Pin7 read PP - High: %d", le_gpioPin7_Read());
	le_gpioPin7_Activate();
	le_gpioPin7_Deactivate();
    le_gpioPin7_SetPushPullOutput(LE_GPIOPIN7_ACTIVE_LOW, false);
LE_INFO("Pin7 read PP - Low: %d", le_gpioPin7_Read());
	//le_gpioPin7_Activate();
	//le_gpioPin7_EnablePullup();
	//le_gpioPin7_Deactivate();
}

```

although I think I went somewhere wrong because now that pin is permanently on

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [May 9, 2018, 10:03pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/4 "2018-05-09T22:03:30Z")

</div>

Which module are you using? wp85, 76, etc.

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 9, 2018, 10:04pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/5 "2018-05-09T22:04:56Z")

</div>

I have the the mangOH red wp7601-1

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 9, 2018, 10:18pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/6 "2018-05-09T22:18:25Z")

</div>

I’m pugging my LED in series with a resistor 300 ohm to pin number 7 according to the user manual

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://mangoh.discourse.group/u/davidc)\
**Post date:** [May 9, 2018, 11:50pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/7 "2018-05-09T23:50:43Z")

</div>

Hiya,

Question: When you say PIN 7, which connector are you referring to?

Looking at the schematic for the mangOH Red, I see that GPIO7 is brought out to the IOT connector GPIO3.

Please note that the IoT interface is at a voltage level of 1V8 … which may be (just) enough to turn on a RED led (voltage drop of 1.7V nominal), but probably NOT enough to turn on a green LED (2V2) and definitely not enough to turn on a white or blue LED (3V3-3V6 depending on brand).

And … I’m not sure if the WP can source or sink enough current (up to 20mA) directly from the I/O pin to light up a led without causing damage to the WP.

ciao, Dave

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 10, 2018, 12:13am UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/8 "2018-05-10T00:13:07Z")

</div>

I’m referring to the raspberry pi connectors, pin number 7 found on schematic on page 24 of user guide.

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 10, 2018, 12:18am UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/9 "2018-05-10T00:18:44Z")

</div>

and ground is connected to pin 25

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 10, 2018, 7:05pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/10 "2018-05-10T19:05:04Z")

</div>

Any help please dfrey?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [May 10, 2018, 7:11pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/11 "2018-05-10T19:11:49Z")

</div>

Raspberry Pi header pin 7 is labeled as `WP_GPIO_3_lvl` in the schematic which can be traced to `WP_GPIO_3` and finally to `GPIO24` on the “outer ring” of the cf3 module. So 24 is the GPIO number that you want to use in your code. Aside from that, your code won’t appear to do much because you turn the GPIO on and then immediately turn it off.

Maybe take a look at the [heartbeat app](https://github.com/mangOH/Heartbeat) for a demonstration of LED blinking.

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [May 11, 2018, 2:43am UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/12 "2018-05-11T02:43:53Z")

</div>

Thank you. It turns out I was not naming it correctly. I was going by the following naming convention  
[http://legato.io/legato-docs/latest/sampleApps\_gpioCf3.html](http://legato.io/legato-docs/latest/sampleApps_gpioCf3.html)  
Thank you for your help

---

<div class="post-metadata">

**Author:** ![dtnam](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dtnam](https://mangoh.discourse.group/u/dtnam)\
**Post date:** [October 9, 2018, 8:41am UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/13 "2018-10-09T08:41:52Z")

</div>

Did you finish the project timerLed? Could you please give me a code, I wanna use the onboard Led but cannot find it out. mangoh\_gpioExpPin4 is nothing happen. \_gpioExpPin24 is too.

---

<div class="post-metadata">

**Author:** ![erickhj](https://avatars.discourse-cdn.com/v4/letter/e/bcef8e/32.png) [@erickhj](https://mangoh.discourse.group/u/erickhj)\
**Post date:** [October 9, 2018, 2:53pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/14 "2018-10-09T14:53:31Z")

</div>

I could not find the code, but I remember that physically I connected to pin 7 (positive side) and pin 25 (ground) then as far as naming convention goes in your code you would call pin 7 pin 24 in code dont know why but thats what it is and well the sample code I have at the beginning did turn on the led and off supper fast so maybe add a timer to it.

---

<div class="post-metadata">

**Author:** ![awneil](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/awneil/32/486_2.png) [@awneil](https://mangoh.discourse.group/u/awneil)\
**Post date:** [October 9, 2018, 3:51pm UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/15 "2018-10-09T15:51:07Z")

</div>

> [@erickhj](#):
>
> call pin 7 pin 24 in code dont know why

@dfrey explained why in his post of [10 May](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/11)

---

<div class="post-metadata">

**Author:** ![dtnam](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dtnam](https://mangoh.discourse.group/u/dtnam)\
**Post date:** [October 10, 2018, 4:49am UTC](https://mangoh.discourse.group/t/turning-led-on-and-off/1400/16 "2018-10-10T04:49:15Z")

</div>

I tested with heartbeat app, pin14 =\> button and pin34 =\> LED display but nothing happen even though I used logread -f to see. Could anyone show me the code? I appreciate, it’s really hard to follow mangOH red.  
heartbeat.heartbeatComponent.mangoh\_button -\> gpioExpanderServiceRed.mangoh\_gpioExpPin14  
heartbeat.heartbeatComponent.mangoh\_led -\> gpioService.le\_gpioPin34  
pin7 =\> button and pin24 =\> LED I changed wp86 to wp7607 but it did not work
