Hi there,
For a MIDI controller project I'm writing a piece of code which takes data from 8 mux's and store it in 8 array which I will use later in my program.
When I wan't to compile the program I get errors which I don't get a clue of.
I'm not a "real die hard programmer" My code is mostly a mix from tutorials, others forum topic and the theory from the Arduino website.
I hope someone else sees what went wrong because I'm staring at my screen for hours and don't see what I did wrong.
This is the code I wrote
//include libraries
#include <Bounce2.h>
//setpoints
#define MIDI_channel 16
#define bounce_time 5
//Pins to set bits from MUX's
#define pin_A 1
#define pin_B 2
#define pin_C 3
//Pins to get data from MUX's
#define data_pin_0 4 //data pin IC1
#define data_pin_1 5 //data pin IC2
#define data_pin_2 6 //data pin IC3
#define data_pin_3 7 //data pin IC4
#define data_pin_4 8 //data pin IC5
#define data_pin_5 9 //data pin IC5
#define data_pin_6 10 //data pin IC6
#define data_pin_7 11 //data pin IC7
//Value's to set bits from MUX's
int pin_A_value = 0;
int pin_B_value = 0;
int pin_C_value = 0;
//Array's to store data coming from MUX's
int digital_data_mux_0[] = {0,0,0,0,0,0,0,0};
int digital_data_mux_1[] = {0,0,0,0,0,0,0,0};
int digital_data_mux_2[] = {0,0,0,0,0,0,0,0};
int digital_data_mux_3[] = {0,0,0,0,0,0,0,0};
int digital_data_mux_4[] = {0,0,0,0,0,0,0,0};
int digital_data_mux_5[] = {0,0,0,0,0,0,0,0};
int analog_data_mux_6[] = {0,0,0,0,0,0,0,0};
int analog_data_mux_7[] = {0,0,0,0,0,0,0,0};
//Declare bounce objects
Bounce pin_0_debounced = Bounce();
Bounce pin_1_debounced = Bounce();
Bounce pin_2_debounced = Bounce();
Bounce pin_3_debounced = Bounce();
Bounce pin_4_debounced = Bounce();
Bounce pin_5_debounced = Bounce();
void setup() {
pinMode(pin_A, OUTPUT);
pinMode(pin_B, OUTPUT);
pinMode(pin_C, OUTPUT);
pinMode(data_pin_0, INPUT_PULLUP);
pinMode(data_pin_1, INPUT_PULLUP);
pinMode(data_pin_2, INPUT_PULLUP);
pinMode(data_pin_3, INPUT_PULLUP);
pinMode(data_pin_4, INPUT_PULLUP);
pinMode(data_pin_5, INPUT_PULLUP);
pinMode(data_pin_6, INPUT);
pinMode(data_pin_7, INPUT);
//Attach input pins to bounce object
pin_0_debounced.attach(data_pin_0);
pin_0_debounced.interval(bounce_time);
pin_1_debounced.attach(data_pin_1);
pin_1_debounced.interval(bounce_time);
pin_2_debounced.attach(data_pin_2);
pin_2_debounced.interval(bounce_time);
pin_3_debounced.attach(data_pin_3);
pin_3_debounced.interval(bounce_time);
pin_4_debounced.attach(data_pin_4);
pin_4_debounced.interval(bounce_time);
pin_5_debounced.attach(data_pin_5);
pin_5_debounced.interval(bounce_time);
}
void loop(){
for( int i = 0; i < 8; i++){
pin_A_value = bitRead(i,0);
pin_B_value = bitRead(i,1);
pin_C_value = bitRead(i,2);
digitalWrite(pin_A, pin_A_value);
digitalWrite(pin_B, pin_C_value);
digitalWrite(pin_C, pin_C_value);
delayMicroseconds(50); //Delay to stabalize signals
pin_0_debounced.update();
pin_1_debounced.update();
pin_2_debounced.update();
pin_3_debounced.update();
pin_4_debounced.update();
pin_5_debounced.update();
digital_data_mux_0[i] = pin_0_debounced.read();
digital_data_mux_1[i] = pin_1_debounced.read();
digital_data_mux_2[i] = pin_2_debounced.read();
digital_data_mux_3[i] = pin_3_debounced.read();
digital_data_mux_4[i] = pin_4_debounced.read();
digital_data_mux_5[i] = pin_5_debounced.read();
analog_data_mux_6[i] = analogRead(data_pin_6);
analog_data_mux_7[i] = analogRead(data_pin_7);
delay(2000); //2sec delay for test purpose only
}
}
This is (are) the error(s) I get
Arduino: 1.8.16 (Mac OS X), Board:"Arduino Uno"
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:22:6: error: redefinition of 'int pin_A_value'
int pin_A_value = 0;
^~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:28:5: note: 'int pin_A_value' previously defined here
int pin_A_value = 0;
^~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:23:6: error: redefinition of 'int pin_B_value'
int pin_B_value = 0;
^~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:29:5: note: 'int pin_B_value' previously defined here
int pin_B_value = 0;
^~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:24:6: error: redefinition of 'int pin_C_value'
int pin_C_value = 0;
^~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:30:5: note: 'int pin_C_value' previously defined here
int pin_C_value = 0;
^~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:28:24: error: redefinition of 'int digital_data_mux_0 []'
int digital_data_mux_0[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:33:5: note: 'int digital_data_mux_0 [8]' previously defined here
int digital_data_mux_0[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:29:24: error: redefinition of 'int digital_data_mux_1 []'
int digital_data_mux_1[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:34:5: note: 'int digital_data_mux_1 [8]' previously defined here
int digital_data_mux_1[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:30:24: error: redefinition of 'int digital_data_mux_2 []'
int digital_data_mux_2[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:35:5: note: 'int digital_data_mux_2 [8]' previously defined here
int digital_data_mux_2[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:31:24: error: redefinition of 'int digital_data_mux_3 []'
int digital_data_mux_3[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:36:5: note: 'int digital_data_mux_3 [8]' previously defined here
int digital_data_mux_3[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:32:24: error: redefinition of 'int digital_data_mux_4 []'
int digital_data_mux_4[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:37:5: note: 'int digital_data_mux_4 [8]' previously defined here
int digital_data_mux_4[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:33:24: error: redefinition of 'int digital_data_mux_5 []'
int digital_data_mux_5[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:38:5: note: 'int digital_data_mux_5 [8]' previously defined here
int digital_data_mux_5[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:34:23: error: redefinition of 'int analog_data_mux_6 []'
int analog_data_mux_6[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:39:5: note: 'int analog_data_mux_6 [8]' previously defined here
int analog_data_mux_6[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:35:23: error: redefinition of 'int analog_data_mux_7 []'
int analog_data_mux_7[] = {0,0,0,0,0,0,0,0};
^
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:40:5: note: 'int analog_data_mux_7 [8]' previously defined here
int analog_data_mux_7[] = {0,0,0,0,0,0,0,0};
^~~~~~~~~~~~~~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino: In function 'void setup()':
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:36:6: error: redefinition of 'void setup()'
void setup() {
^~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:50:6: note: 'void setup()' previously defined here
void setup() {
^~~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino: In function 'void loop()':
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller kopie.ino:54:6: error: redefinition of 'void loop()'
void loop() {
^~~~
/Users/Jazzy/Desktop/Model_2_midi_controller/Model_2_midi_controller.ino:82:6: note: 'void loop()' previously defined here
void loop(){
^~~~
exit status 1
Fout bij het compileren voor board Arduino Uno
Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren.
Thanks in advance!
Jazzy