// device number variable.
//The maximum number available is 6 pins (6 bit). By increasing the pins, the number can be increased.
// 63= 111111 in binaryю.
byte myAddress = 63;
//-------------------------
// pins on the board for connecting Dip-switch. "{12, 11, 10, 9, 8, 7}"
int PinAddress[] = {12, 11, 10, 9, 8, 7};
void setup() {
int size = sizeof(PinAddress)/ sizeof(int); // determining the number of array cells for Dip-switch.
//pin assignment for Dip-switch.
for(int i= 0; i<size; i++){
pinMode(PinAddress[i], INPUT);
}
//---------------------------------------
// reading jumpers positions in Dip-switchand and forming an number using bit Clearing. "
// bitClear(variable, the number of the bit to be cleared.); " https://alexgyver.ru/lessons/bitmath/
for(int i = 0; i<=size; i++){
if(digitalRead(PinAddress[i])== LOW){
bitClear(myAddress, i);
}
//----------------------------------------
}
// test
Serial.begin(9600);
Serial.print(myAddress);
}
//-------------------------------------------
void loop() {
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
sw1:1a
sw1:2a
sw1:3a
sw1:4a
sw1:5a
sw1:6a
sw1:7a
sw1:8a
sw1:8b
sw1:7b
sw1:6b
sw1:5b
sw1:4b
sw1:3b
sw1:2b
sw1:1b