// 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};
int size = sizeof(PinAddress)/ sizeof(int); // determining the number of array cells for Dip-switch.
void setup() {
Serial.begin(9600);
//pin assignment for Dip-switch.
for(int i= 0; i<size; i++){
pinMode(PinAddress[i], OUTPUT);
}
//---------------------------------------
// 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/
}
void loop() {
/*
for(int i = 0; i<size; i++){
if( digitalRead(PinAddress[i])<1){
bitClear(myAddress, i);
}
}
*/
int x = digitalRead(PinAddress[0]);
if(x == 0 ){
bitClear(myAddress, 0);
}
Serial.print(PinAddress[1]);
delay(1000);
}