Netduino home hardware projects downloads community

Jump to content


Photo

Variations on a theme of ButtonApp (Mini)


  • Please log in to reply
1 reply to this topic

#1 Dr Who

Dr Who

    Advanced Member

  • Members
  • PipPipPip
  • 261 posts
  • LocationNYC

Posted 26 December 2015 - 06:41 AM

Hello!

After being away from the Netduino world for far too long, I decided to take a try and apply something I bought from Sparkfun earlier this month, It's their illuminated button.

 

See here:

10442-03.jpg

 

 

 

I have it mounted on their breakout board:

10467-04.jpg

 

It's the white one shown, but I picked Red since its almost always that color when we build ours on breadboards with the Netduino Mini involved.

 

And the code? I'm glad someone ask:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoMini;

/* NOTE: make sure you change the deployment target from the Emulator to your Netduino before running this
 * Netduino sample app.  To do this, select "Project menu > ButtonApp Properties > .NET Micro Framework" and 
 * then change the Transport type to USB (or Serial).
 * Finally, close the ButtonApp properties tab to save these settings. */

namespace ButtonApp
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
           
            OutputPort led = new OutputPort(Pins.GPIO_PIN_17, false);
            Thread.Sleep(350);
            InputPort button = new InputPort(Pins.GPIO_PIN_16, false, Port.ResistorMode.Disabled);
            bool buttonState = false;
            Thread.Sleep(350);
            while (true)
            {
                buttonState = button.Read();
                led.Write(!buttonState);
            }          
        }

    }
}

For those us who are really curious, I stuck one of my trustworthy SN7437 parts in between the two ports chosen.

 

After the usual fiddling with the FTDI device to talk to the device, it worked and the code deployed as if its been run there before. 


Edited by Dr Who, 26 December 2015 - 06:51 AM.


Doctor Who
"This signature does not exist!"

#2 FourT2

FourT2

    Advanced Member

  • Members
  • PipPipPip
  • 63 posts
  • LocationSeattle, WA

Posted 26 December 2015 - 06:54 AM

Cool! I have to check out this button, will add it for my next order from SparkFun. Thanks for sharing!






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.