SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By Iggy
#3806
Hi all,

I've decided to build my own timer for my lawn sprinkler system. I'm quite new at working with mircocontollers but have a decent understandin g of digital electronics and extensive programming experience from learning Assembly 20 years ago to working as a professional Java developer currently.

I thought building a sprinkler timer would be a useful and fun project to start with on learning about microcontollers. The timer consists of a PIC 16F84A (running at 20MHz), a 16x2 LCD, two switches and 3 relays to control each of the Zones of my sprinkler system.

So far I have implented the interface to the LCD to display the time based on a clock made from the Timer0 interrupt. After a few issues getting the timing correct for the LCD Module, I now have a working clock that displays on the LCD. The next step I have been working on is to get the first of the two switches wired and code written to put the clock in "set" mode. I wired the switch (momentary SPST) to ground and to RA0 (PORTA - 0) and put a little code in place to reset the seconds whenever the switch is pressed. What I found is that when ever I move my hand close to the switch or the wire coming from RA0 it is as if I have pressed the switch and completed the circuit. So my question is - is this "normal" behavior for the PIC ports when used as inputs and how/what should I do to ensure the switch is the only thing that triggers the port pin?

Any guidance will be greatly appreciated.

If anyone has any questions or interest in the sprinkler timer I'm building, I'm more than happy to share what little knowledge I have.

Thanks!
By Iggy
#3811
All,

I figured it out. Mostly just a newbie mistake on my part. I had the switch wired too simply. I changed it to tie RA0 to GND via a resistor and then to Vdd via the switch. Works great now.
RA0 LOW with switch off - HIGH with switch on. Duh...

Les