Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Led.dispose() turns on led...why?


  • Please log in to reply
3 replies to this topic

#1 Jamo

Jamo

    Member

  • Members
  • PipPip
  • 13 posts

Posted 27 June 2013 - 06:39 AM

This is a very basic question so hopefully I'll get a quick basic answer...

 

My function blinks the led awesome but when I dispose of the led object the led turns back on and stays on until I call the function again and blink it, but then again once led.dispose(); is run the led turns on.

        public void Blink_Onboard_Led(int blinks)        {            // Blink LED once if blinks is negative or too large             if (blinks < 1 || blinks > 1000) { return; }            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);                        for (int i = 0; i < blinks; i++)            {                         led.Write(true);                Thread.Sleep(250);                led.Write(false);                Thread.Sleep(250);            }            led.Dispose();        }

What should I do to keep the led off?



#2 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 27 June 2013 - 06:49 AM

It so happens that the pin you are claiming is electrically connected to an on-board LED. When disposing the pin, it reverts to its default config and usage. I'm not sure but, could it be the pin (and thus the LED) is used as a power indicator on your board?

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 June 2013 - 07:38 AM

Hi Jamo, Are you using a Netduino 1 or a Netduino 2? On Netduino 1, the ports revert to "input, pull-up" mode when you dispose them...which would make the LED turn on once it was disposed. It's put into output low mode during initialization--which is why it's turned off by default. Chris

#4 Jamo

Jamo

    Member

  • Members
  • PipPip
  • 13 posts

Posted 27 June 2013 - 08:13 AM

Hi Chris, it's a Netduino 1.

 

Thanks for letting me know that, at least now I know what it is.

 

Cheers mate,

James






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.