wim_s_button_box_code.ino (6.4 KB)
I cant seem to figure out what is wrong with my code this is the error I am getting .
#include <Keypad.h>
#include <Joystick.h>
//DEFINITIONS
#define ENABLE_PULLUPS
#define NUMROTARIES 1 //replace "?" with number of rotary encoders you are using
#define NUMBUTTONS 7 //replace "?"with number of buttong you are using
#define NUMROWS 3 //replace "?" with number of rows you have
#define NUMCOLS 2 //replace "?" with number of columns you have
//BUTTON MATRIX
//first change number of rows and columns to match your button matrix,
//then replace all "?" with numbers (starting from 0)
byte buttons[NUMROWS][NUMCOLS] = {
{0, 1, 2},
{3, 4, 5},
{6, 7, 8},
},
struct rotariesdef {
byte pin1;
byte pin2;
int ccwchar;
int cwchar;
volatile unsigned char state;
};
//ROTARY ENCODERS
//each line controls a different rotary encoder
//the first two numbers refer to the pins the encoder is connected to
//the second two are the buttons each click of the encoder wil press
//do NOT exceed 31 for the final button number
rotariesdef rotaries[NUMROTARIES] {
{0, 1, 22, 23, 0}, //rotary 1
};
And this is my error message
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Micro"
wim_s_button_box_code:18:1: error: too many initializers for 'byte [2] {aka unsigned char [2]}'
},
^
wim_s_button_box_code:18:1: error: too many initializers for 'byte [2] {aka unsigned char [2]}'
wim_s_button_box_code:18:1: error: too many initializers for 'byte [2] {aka unsigned char [2]}'
wim_s_button_box_code:20:1: error: expected unqualified-id before 'struct'
struct rotariesdef {
^~~~~~
wim_s_button_box_code:33:1: error: 'rotariesdef' does not name a type
rotariesdef rotaries[NUMROTARIES] {
^~~~~~~~~~~
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino: In function 'void CheckAllPotentiometers()':
wim_s_button_box_code:142:41: error: 'potentiometerPin1' was not declared in this scope
currentOutputLevel = getAverageOutput(potentiometerPin1);
^~~~~~~~~~~~~~~~~
wim_s_button_box_code:143:3: error: 'zAxis_' was not declared in this scope
zAxis_ = map(currentOutputLevel, 0, 1023, 0, 255);
^~~~~~
wim_s_button_box_code:147:41: error: 'potentiometerPin2' was not declared in this scope
currentOutputLevel = getAverageOutput(potentiometerPin2);
^~~~~~~~~~~~~~~~~
wim_s_button_box_code:148:3: error: 'RxAxis_' was not declared in this scope
RxAxis_ = map(currentOutputLevel, 0, 1023, 0, 255);
^~~~~~~
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino: In function 'void rotary_init()':
wim_s_button_box_code:193:13: error: 'rotaries' was not declared in this scope
pinMode(rotaries[i].pin1, INPUT);
^~~~~~~~
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino:193:13: note: suggested alternative: 'rowPins'
pinMode(rotaries[i].pin1, INPUT);
^~~~~~~~
rowPins
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino: In function 'unsigned char rotary_process(int)':
wim_s_button_box_code:206:41: error: 'rotaries' was not declared in this scope
unsigned char pinstate = (digitalRead(rotaries[_i].pin2) << 1) | digitalRead(rotaries[_i].pin1);
^~~~~~~~
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino:206:41: note: suggested alternative: 'rowPins'
unsigned char pinstate = (digitalRead(rotaries[_i].pin2) << 1) | digitalRead(rotaries[_i].pin1);
^~~~~~~~
rowPins
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino: In function 'void CheckAllEncoders()':
wim_s_button_box_code:219:26: error: 'rotaries' was not declared in this scope
Joystick.setButton(rotaries[i].ccwchar, 1); delay(50); Joystick.setButton(rotaries[i].ccwchar, 0);
^~~~~~~~
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino:219:26: note: suggested alternative: 'rowPins'
Joystick.setButton(rotaries[i].ccwchar, 1); delay(50); Joystick.setButton(rotaries[i].ccwchar, 0);
^~~~~~~~
rowPins
wim_s_button_box_code:225:26: error: 'rotaries' was not declared in this scope
Joystick.setButton(rotaries[i].cwchar, 1); delay(50); Joystick.setButton(rotaries[i].cwchar, 0);
^~~~~~~~
C:\Users\Camden Ramos\Desktop\wim_s_button_box_code\wim_s_button_box_code.ino:225:26: note: suggested alternative: 'rowPins'
Joystick.setButton(rotaries[i].cwchar, 1); delay(50); Joystick.setButton(rotaries[i].cwchar, 0);
^~~~~~~~
rowPins
exit status 1
too many initializers for 'byte [2] {aka unsigned char [2]}'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.