(this request is a duplication of the newsgroup alt.microcontrollers !!!)
I'm having trouble getting my head around programming a pic (from scratch)
Basically i want it to do :-
Loop look at 3 inputs (not analogue) compare with the inputs that were stored in the last loop around if they are the same wait say .5 sec then loop again if the inputs are different then output (for a relay) for .5 sec
this project, i thought would be fairly easy or so i thought.
Anyone willing to help me write a program if it is that easy.
Any help would be most appreciated or am i getting too old for this technology !!
Disclaimer: this is from the top of my head and untested in any way, form or fashion.
I'm assuming that you do NOT want to trigger on the first time around in the loop, since there is no known/specified "previous value". If there is, remove the firstTime variable and its if statement (but not the call to ActivateRelay), and initialize previousBits to that specified inital value.
I've left out the pic-specific bits above - InitializeHardware should set up your three inputs as such, and the relay bit as output.
GetInputs should read from the port where your three inputs are connected. (I assume they are connected to the same port)
Make sure that you filter out any other input lines on that same port by using the AND operator and a bit mask. In C, assuming your inputs are on e.g. bit 0, bit 4, and bit 7 of an 8 bit port, you'd do something like this: