PIN state VS Variable read
I am putting together a project which will have some options selected by dip switch settings. I have enough pins to dedicate a pin to each dip switch.
My question: is it better to scan the dip switches at startup and then store those values in a variable or is it OK to look at the pins that the dip switches are connected to every time I want to check the option? Is it slower to read the PIN state as opposed to reading the variable?
Thanks
Chris
Pin State vs. Variable State
Hello,
I do not know how much as I am a nubee at this(this is my first response/1st post).
But the are several questions that you must think about and answer.
1) Does the input data ever change while the pic is running?
If the data to be read CAN change or MUST be 'allowed' to change then you want to read
the data after the pic starts.
2) Dip switch or BCD switch?
Using a DIP switch, (a 4 switch ((position)) used here for example, you have a maximum of
4 inputs for your 4 bits. I use a lot of Greyhill 94 HAB 16 switches. These are 16 position
4 BIT output units. So as you can see that this only uses 4 pins on the chip but you can
have 16 unique input conditions. This save the number of inputs used.
The downside is a few more line of code to decode what each position of the switch
represents. So again you need to figure out exactly what you need your inputs to do.
I hope this helps and not muddy the waters.
73,
Terry, K9HA (sneaky-geek)