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

Events Handlers and Buttons


  • Please log in to reply
3 replies to this topic

#1 kylebarker82

kylebarker82

    New Member

  • Members
  • Pip
  • 2 posts

Posted 25 December 2013 - 06:53 AM

I would like to use a 4 LED pattern written line by line to work with a button, onboard or off board doesn't matter, the switch to another pattern using the same button. I am new to all of this stuff, mostly with a little knowledge of building and playing with the components, I am always lost when it comes to programming. I just need a general idea of how to switch from one pattern to the next.

 

I'd like the sequence to start with this:

// byTwos

while (true)

{

  led1.Write(true);

  led2.Write(false);

  led3.Write(false);

  led4.Write(true);

  Thread.Sleep(100);

  led1.Write(false);

  led2.Write(true);

  led3.Write(true);

  led4.Write(false);

  Thread.Sleep(100);

}



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 December 2013 - 10:01 AM

Hi kylebarker82, Check out the "pushing the button" video on the projects page (in the how-to section). That should get you started working with buttons. Welcome to the Netduino community, Chris

#3 kylebarker82

kylebarker82

    New Member

  • Members
  • Pip
  • 2 posts

Posted 26 December 2013 - 10:53 PM

I've done that... I want it to cycle to another pattern when I push the button a second time...



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 27 December 2013 - 02:40 AM

Hi kyle,

I've done that... I want it to cycle to another pattern when I push the button a second time...

Do you have much experience with C# or C-style languages already? If not, we can point out some primers. Try creating an int variable that can be seen from your whole class (class or global scope). Then change that int value whenever you detect a button press and display your LED pattern on its current value. Chris




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.