# Need a C#.NET programmable hardware button(s)



## FordGT90Concept (Aug 6, 2010)

I wrote an app for reminding me to take my meds probably 3-4 years ago.  It works to remind me, but I have a suspcision that is working too well (end up taking twice the dose of meds than I should).  So, what I need is a button to hit to register I took the meds as I take them.  Problem is, I can't find any available.

The device has to use USB because my sole COM port is already used.

It would also be a bonus if there was an LED display for each button (if there is more than one) so I could put a message on each button that is associated with the action the button will take.


If I would have to engineer my own, I wouldn't know where to start. 


This is the only one I found but I'd rather the switch not be on the floor:
http://www.thinkgeek.com/computing/usb-gadgets/c8a8/


----------



## PVTCaboose1337 (Aug 6, 2010)

I have done something like this in the past, not the programming of the button but I will leave that to you.  What I have done is get a USB mouse, and then "customized" the drivers to act as a macro key.  You could take apart the mouse down to bare board and buttons.  Regarding LCD displays for the buttons, not gonna happen!

My use was for the mouse to act as a "foot pedal" for a racing game.  I got it to work ok, but then I realized that foot pedals in real cars were variable for a reason.

EDIT:  Oh hey someone made a usb self destruct button.  Might work for you:  http://xe.bz/aho/18/

EDIT2:  Looks pretty neat:  http://www.create.ucsb.edu/~dano/CUI/


----------



## FordGT90Concept (Aug 6, 2010)

Oh my.  I have no doubt that last one could do what I want but I think it is way over my head.  Maybe I would be best off using serial?  I could plug my UPS in via USB cable but I'd rather not.


----------



## PVTCaboose1337 (Aug 6, 2010)

I know someone is gonna recommend you get an Arduino to do all the dirty work.  I know I have one sitting on my desk.  They have a little learning curve, but are fun for more than just "I need a button."  I programmed mine to detect when my case temperature goes over a certain temp, and then it turns on a light and a piezo buzzer.  I used a thermistor to do this.


----------



## FordGT90Concept (Aug 6, 2010)

Well, if it is not too expensive, I probably wouldn't have a problem buying it so long as I can make it work.  I'd probably like to keep it under $50.  If it has all the displays too, probably under $100.

Arduino doesn't look as intimidating as CUI32.


----------



## PVTCaboose1337 (Aug 6, 2010)

FordGT90Concept said:


> Well, if it is not too expensive, I probably wouldn't have a problem buying it so long as I can make it work.  I'd probably like to keep it under $50.  If it has all the displays too, probably under $100.
> 
> Arduino doesn't look as intimidating as CUI32.



Ok I have these things for arduino:

The arduino:  http://www.sparkfun.com/commerce/product_info.php?products_id=666

I also have the xBee but you don't really need that.  Just get the Arduino.  It might also be helpful to get a few of these:  http://www.sparkfun.com/commerce/product_info.php?products_id=7957

That way you can have multiple programs and then just program, pull, and repeat.  Not necessary though, and a little advanced to be programming your own IC's.  

Other than the arduino you just need a switch.

EDIT:  Might want a breadboard too for testing.  I also know they make a LCD add on for the arduino, but I don't have that so I won't say anything about it.  http://www.ladyada.net/learn/lcd/charlcd.html


----------



## FordGT90Concept (Aug 6, 2010)

Do you think it would be capable of running 4 switches + 4 text displays?  Could it even run text displays?



Edit: Something like this?
http://www.virtualvillage.com/lcd-k....html?utm_source=googlebase&utm_medium=shcomp


----------



## PVTCaboose1337 (Aug 6, 2010)

FordGT90Concept said:


> Do you think it would be capable of running 4 switches + 4 text displays?  Could it even run text displays?



4 switches, depending on type, $1 per switch MAX.  Send me a PM of where you live and I can give you an electronics store there.  

Regarding text displays:  http://www.ladyada.net/learn/lcd/charlcd.html 

Nice tutorial, however I have never done it.  Seem to be around $10 per display.  

So your total cost is: 

Arduino - $30
Displays - $40
Switches - $5 
Random Wires - Free
Breadboard and wires (optional) - $10

~$75-85


----------



## FordGT90Concept (Aug 6, 2010)

Could any of the Arduino models support 2 of those 2-line LCDs?


Also, how would I make my C#.NET application interface with an Arduino?


----------



## PVTCaboose1337 (Aug 6, 2010)

FordGT90Concept said:


> Could any of the Arduino models support 2 of those 2-line LCDs?
> 
> 
> Also, how would I make my C#.NET application interface with an Arduino?



Yes.  Would have to find some cheap ones though.  I get all my parts from Digikey for electronics...  however, LCD's seem expensive there:  http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=29121-ND

Here would be a good choice:  http://www.electronics123.com/s.nl/it.A/id.53/.f

I order from Goldmine alot:  http://www.goldmine-elec-products.com/prodinfo.asp?number=G15318 - ONLY $1.49 for a single line.  Not bad!

Regarding interfacing with the Arduino:

Googlefu:  http://www.technicana.com/physical-computing/73-connect-to-the-arduino-with-c-


----------



## FordGT90Concept (Aug 6, 2010)

I think I would have to go with a backlit version (its dark in here).

So, which model of the Arduino would I have to get to handle 2 LCDs and 4 buttons?


Also, is there any way to make the assembled device look presentable?


Edit: I stumbled across Phidget which would definitely work but it is hella expensive ($169.00 with only one, non-backlit LCD). 


Edit: Currently, I'm thinking Phidgets is the easiest way to go but the price is steep and I would still have to make an enclosure for it.  I would have to program two of the buttons to scroll through the list and two to actually do something.  In a way, that is almost preferable.  Maybe that's what I'll end up using.


----------



## PVTCaboose1337 (Aug 6, 2010)

I think that Phidget thing is a bad idea.  If you have problems with an Arduino there are plenty of people on the forums to help you out.  I have never heard of the Phidget and would be unsure of how many people could help you out.  

Anyway for 2 LCD's you would have to get the Arduino standard (Duemilanove).  You would then BARELY have enough room for 4 switches.


----------



## FordGT90Concept (Aug 7, 2010)

I was thinking about putting an LED on it too: on for alarm on and off for alarm off.  Would the Duemilanove have room for 1 LED, 4 Switches, and 2 backlit LCDs?  Also, does USB provide enough power to run all that stuff?


I found Phidget from a developer blog on Microsoft's site.  I checked the code and they have a library for C#.  It would be very easy to code for from the looks of it.  I didn't find much code on the buttons though.


----------



## PVTCaboose1337 (Aug 11, 2010)

FordGT90Concept said:


> I was thinking about putting an LED on it too: on for alarm on and off for alarm off.  Would the Duemilanove have room for 1 LED, 4 Switches, and 2 backlit LCDs?  Also, does USB provide enough power to run all that stuff?
> 
> 
> I found Phidget from a developer blog on Microsoft's site.  I checked the code and they have a library for C#.  It would be very easy to code for from the looks of it.  I didn't find much code on the buttons though.



Sorry for the late response.  You would be powering the thing from an outside power source, either one 9v battery or an AC to DC transformer.  Regarding the extra LED, I think you might wanna get the Arduino Mega cause you have ALOT of stuff to add on.


----------



## FordGT90Concept (Aug 11, 2010)

I decided to wait on the project due to cost of the Phidgets.

I also decided that a joystick with push button support is better than 4 buttons.  So it would be:

1 LCD
1 joystick/button
1 LED
1 60mm fan

How easy would it be to plug a fan into an Arduino?  I'm hoping I could still power it with USB.


----------



## PVTCaboose1337 (Aug 19, 2010)

Fans are just like LED's that spin.  Anyway, I am back at homebase (Texas) and am going to try to code a little something to interact with my Arduino to do something similar to what I think you are doing.  I will tell you how it goes.  I have no LCD's but that is really not that tough now is it?  Will tell you how it goes.

EDIT:  BTW, it might help you to get a little electronics knowledge.  If you need some help at anytime on this feel free to PM me!  I will check it more often than this thread!


----------



## FordGT90Concept (Aug 19, 2010)

The project has been put in the back burner for the time being.  If you want to fiddle with the idea, great!  The most important thing is C# has to be able to communicate with it (receive input from and send messages to).

If you can manage to remotely turn an LED on and off, I ought to be able to use similar code to send the text to display.


The difference between LEDs and DC motors is DC motors (fans) are often modulated.  They don't draw a constant stream of power--they pulse.  They can wreck havok on sensitive circuits.


----------



## PVTCaboose1337 (Aug 19, 2010)

FordGT90Concept said:


> The project has been put in the back burner for the time being.  If you want to fiddle with the idea, great!  The most important thing is C# has to be able to communicate with it (receive input from and send messages to).
> 
> If you can manage to remotely turn an LED on and off, I ought to be able to use similar code to send the text to display.
> 
> ...



Ford, from what I have learned about motors, motors can really only run on AC power, current that moves back and forth.  However any motor that runs on DC has a neat trick to allow the motor to run on DC.  They will have it cut the current every half turn so it makes it act as AC current (kinda).  I can understand that, yes, this can cause havok on sensitive circuits, as the current will spike when the motor comes to that "cut", but that is negligible IMO.  If you are worried use a voltage regulator, as it will solve all problems.  

PS, you know more about electronics than I thought!


----------

