I'm working on a project to drive Sure 3216 Displays, and need to be able to, if possible, define the number of displays used at run time. Currently I have the following statement in my code that helps define settings used in the code before both setup() and loop() are called.
#define Number_of_Displays 1
I want to add a 2 position SMD dip switch to the board that can be connected to two pins on an ATMEGA to help define number of displays connected at run time. The way I wanted the switches to work is as follows:
00 = 1 display 01 = 2 displays 10 = 3 displays 11 = 4 displays
Since the #define is at the beginning of the code, is there anyway to have that # dependent on the switch configuration?
I'm thinking of having the following in the setup() routine, or at the beginning of loop():
if (digitalRead(7) == LOW && digitalRead(8) == LOW) {
Number_of_Displays = 1
}
else if (digitalRead(7) == LOW && digitalRead(8) == HIGH) {
Number_of_Displays = 2
}
else if (digitalRead(7) == HIGH && digitalRead(8) == LOW) {
Number_of_Displays = 3
}
else if (digitalRead(7) == HIGH && digitalRead(8) == HIGH) {
Number_of_Displays = 4
}
is this possible