ZC-4 Rotary Switch Profile Selector

Introduction

The ZonePro series of audio processors from dbx only allow for more than 4 profile selections when using a ZC-4 Zone Controller. The wiring guide for this item uses switches that require the profile number is encoded in a 4 bit binary number giving up to 16 selections. I want profile selections to be easy to use for the staff that interact with the audio systems the ZonePro controls.

Required Parts

Setting Up Hardware

I need to take pictures of this.

Schematic

Software

Code Download: Rotary_Switch_to_Relay_Binary.zip

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Interprets rotary switch position into 4 bit binary value for use with ZC-4 Zone controller
// Requires 4 digital pins (4, 5, 6, and 7) and one analog pin (A1)
// Use a voltage divider to change the value of the analog input. resistor values will change depending on the number of positions on the switch. 
// I provide resistance values for a common 11 position switch below.

int profileNumber = 1;

// Resistor Values for Voltage Divider
// 1 kOhm divider resistor (between +5v and GND)
// Variable Resistors for 11 Profiles: 47, 150, 330, 470, 1k, 1.5k, 2.2k, 3.6k, 4.7k, 15k, open
// Connect 1k to +5v, variable resistor, and analog input
// Connect Variable resistor to 1k and GND

void setup() {
  pinMode(A1, INPUT); //Rotary Switch Input
  pinMode(4,OUTPUT); //Relay 1
  pinMode(5,OUTPUT); //Relay 2
  pinMode(6,OUTPUT); //Relay 3
  pinMode(7,OUTPUT); //Relay 4
  Serial.begin(9600);
}

void switchPosition (int AI) {
  Serial.print(AI);
  Serial.print("\n");
  int mappedValue = map(AI, 0, 1023, 0, 10); //Change last variable to number of switch positions - 1
  switch(mappedValue) {
    case 0:
      profileNumber = 1;
      digitalWrite(4,LOW); 
      digitalWrite(5,LOW); 
      digitalWrite(6,LOW); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 1:
      profileNumber = 2;
      digitalWrite(4,HIGH); 
      digitalWrite(5,LOW); 
      digitalWrite(6,LOW); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 2:
      profileNumber = 3;
      digitalWrite(4,LOW); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,LOW); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 3:
      profileNumber = 4;
      digitalWrite(4,HIGH); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,LOW); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 4:
      profileNumber = 5;
      digitalWrite(4,LOW); 
      digitalWrite(5,LOW); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 5:
      profileNumber = 6;
      digitalWrite(4,HIGH); 
      digitalWrite(5,LOW); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 6:
      profileNumber = 7;
      digitalWrite(4,LOW); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 7:
      profileNumber = 8;
      digitalWrite(4,HIGH); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,LOW); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 8:
      profileNumber = 9;
      digitalWrite(4,LOW); 
      digitalWrite(5,LOW); 
      digitalWrite(6,LOW); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 9:
      profileNumber = 10;
      digitalWrite(4,HIGH); 
      digitalWrite(5,LOW); 
      digitalWrite(6,LOW); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 10:
      profileNumber = 11;
      digitalWrite(4,LOW); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,LOW); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 11:
      profileNumber = 12;
      digitalWrite(4,HIGH); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,LOW); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 12:
      profileNumber = 13;
      digitalWrite(4,LOW); 
      digitalWrite(5,LOW); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 13:
      profileNumber = 14;
      digitalWrite(4,HIGH); 
      digitalWrite(5,LOW); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 14:
      profileNumber = 15;
      digitalWrite(4,LOW); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
    case 15:
      profileNumber = 16;
      digitalWrite(4,HIGH); 
      digitalWrite(5,HIGH); 
      digitalWrite(6,HIGH); 
      digitalWrite(7,HIGH); 
      Serial.print("Profile ");
      Serial.print(profileNumber);
      Serial.print("\n");
      break;
  }
}

void loop() {
  int readSwitch = analogRead(A1);
  switchPosition(readSwitch);
  delay(100);
}

All content and code, unless otherwise specified, is copyright 2004 - 2018 Callen Magnuson.

mmmh... spam...