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.

Basset

Member Since 25 Nov 2012
Offline Last Active Aug 26 2014 05:36 AM
-----

Topics I've Started

How do I pause a while loop using the onboard button?

16 May 2014 - 08:45 PM

Hello

 

After not using my netduino for almost a year I want to get back into it now that I am home from university for the summer.  I've been trying to brush up on what I learned, so bear with me if I mess something simple up.

 

So about a year ago I was pretty much just playing with the onboard led, learning about pwm and making it fade in and out as well as using the button to turn the led on and off as seen in one of the example videos.  However I am stuck at how to 'pause' the flashing or pulsing led with the button. Last year I was able to do it but if I pressed the button at the wrong time it would 'miss' the input in the while loop.

 

To summarize what I want to do is to be able to press the button to stop the blinking and then press it again to start the blinking again.

 

ex. controlling this code:

public static void Main()
{
 // write your code here
 OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
 while (true)
 {
 led.Write(true); // turn on the LED
 Thread.Sleep(250); // sleep for 250ms
 led.Write(false); // turn off the LED
 Thread.Sleep(250); // sleep for 250ms
 }
}

with the button.  I know I can put the button.Read() command in the while loop condition and then put all of that in another while loop, but this starts to fall apart when I go to more complex fading or other patterns that may take a second or too to get through so if I press the button when its not looking for it then the blinking continues on.

 

I believe the answer would have something to do with threading or event handlers but I can't seem to wrap my head around them, or been able to find an example for the netduino that does a similar thing.  If anyone has a good tutorial on how to build event handlers and making events (is this the right terminology?) as well as using threads it would be greatly appreciated.

 

I assume a similar method with threading would be used if I wanted to maybe blink an led while doing other things which I would also like to eventually learn how to do.

 

Thanks for your help!

 

 


Using a 7 segment display without a shift register

13 August 2013 - 11:15 PM

Hello,

 

I have been working on getting a 7 segment display to work with my Netduino plus 2 without a shift register and have gotten 1 digit out of 2 working so far.  The issue I am having is how to, for example, count down from 99 on the display.  I understand that 7 segment displays are multiplexed, it's just that i don't know how to implement that into the software.  Would threading be of use here?

 

Here is the code I have written so far, if there is a better way to do it please let me know!

 

Program.cs

Display.cs

 

 

I am a beginner so any critique on the code is appreciated.

 

Thanks for your help!


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.