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's Content

There have been 5 items by Basset (Search limited from 26-April 23)


By content type

See this member's

Sort by                Order  

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

Posted by Basset on 19 May 2014 - 02:46 AM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for the insight on the naming conventions. Kinda reminds me of this xkcd: http://xkcd.com/927/




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

Posted by Basset on 17 May 2014 - 04:25 AM in Netduino Plus 2 (and Netduino Plus 1)

Thank you for your help!  

 

I tried the two examples you listed earlier in the year and as you said it wasn't all that reliable.  I have tried the last example you posted and it works perfectly!  Seeing how it's written up gives me some ideas on how I can expand it now and adapt it to other projects I am working on.

 

One more question: in your variables and some other peoples they lead with an underscore and I was wondering what it was for?  I have seen some people in tutorials use them inside methods and I assume they are to keep things more structured when the program gets more advanced but I am not sure.




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

Posted by Basset on 16 May 2014 - 08:45 PM in Netduino Plus 2 (and Netduino Plus 1)

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!

 

 




#52170 Using a 7 segment display without a shift register

Posted by Basset on 14 August 2013 - 11:11 PM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for the replies.

 

I forgot to put my setup in the first post but I am running each led with a 330 resistor and driving the common anode pins with transistors.  I don't currently have any shift registers so that is why I'm driving it directly from the netduino.  A few shift registers will be added to my next order to clean it up a bit.

 

I have been able to display 2 different characters on the display now however I am still unsure on how to "push" new characters to the screen.  In my code it is just a while loop switching between displaying the first digit and the second digit, preventing me from sending it a new character.  I would like to be able to write a function that writes to the display and keeps it there until another command is set.  I believe this is accomplished by threading a method to keep the screen 'alive' and send it an event(?) to update it.  I haven't used events or threading before however so I'm not sure how to implement it yet so any help is appreciated. 

 

Here it is displaying 'HI':

Posted Image

 

And the updated code.

 

Thanks!




#52133 Using a 7 segment display without a shift register

Posted by Basset on 13 August 2013 - 11:15 PM in Netduino Plus 2 (and Netduino Plus 1)

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.