Hi all,
I've got a project where i'm selecting 4 channels using 2 dipswitches. I breadboarded it using two slider switches and it worked great. However, i've had PCB's made and now only one of the channels work correctly.
All the hardware is definitely connected correctly was just wondering if there's something in the code stopping it from working as it did on the breadboard with the arduino uno.
I'll post the few lines from the full code for the dipswitches. Any help would be very much appreciated!
const byte dipSwitchPins[] = {4, 5}; // Pins for dip switches
void setup() {
pinMode(dipSwitchPins[0], INPUT_PULLUP); // Dip switch 1
pinMode(dipSwitchPins[1], INPUT_PULLUP); // Dip switch 2
}
void loop() {
// Read dip switches to set MIDI channel
byte dipSwitchState = digitalRead(dipSwitchPins[0]) | (digitalRead(dipSwitchPins[1]) << 1);
channelNo = map(dipSwitchState, 0, 3, 1, 2);
}
7 posts - 3 participants