Need some help,

I'm getting an error (see below) when verifying, any help or guidance would be appreciated.

C:\Users\pwmcg\AppData\Local\Temp\ccNTOcr5.ltrans0.ltrans.o: In function main': C:\Users\pwmcg\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/main.cpp:43: undefined reference to setup'
collect2.exe: error: ld returned 1 exit status

exit status 1

thanks,

Paul

Compilation error: exit status 1

Welcome to the forum

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

You have not posted your sketch (HINT) but the compiler is complaining that it does not have the required setup() function in it

Please post your full sketch

#include <Joystick.h>
#include <Keypad.h>

//DEFINITIONS
#define ENABLE_PULLUPS
//#define NUMROTARIES ? //replace "?" with number of rotary encoders you are using
#define NUMBUTTONS 6 //replace "?"with number of buttong you are using
#define NUMROWS 2 //replace "?" with number of rows you have
#define NUMCOLS 3 //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}
};

//BUTTON MATRIX PART 2
byte rowPins[NUMROWS] = {2,3}; //change "?" to the pins the rows of your button matrix are connected to
byte colPins[NUMCOLS] = {A0,A1,A2}; //change "?" to the pins the rows of your button matrix are connected to

Keypad buttbx = Keypad( makeKeymap(buttons), rowPins, colPins, NUMROWS, NUMCOLS);

void loop() {

CheckAllButtons();

}
;

void CheckAllButtons(void) {
if (buttbx.getKeys())
{
for (int i=0; i<LIST_MAX; i++)
{
if ( buttbx.key[i].stateChanged )
{
switch (buttbx.key[i].kstate) {
case PRESSED:
case HOLD:
//Joystick.setButton(buttbx.key[i].kchar, 1);
break;
case RELEASED:
case IDLE:
//Joystick.setButton(buttbx.key[i].kchar, 0);
break;
}
}
}
}
}
;

Thanks for posting the code but

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

As I suspected, no setup() function

What is the origin of the code ? This forum or a school assignment ?

I have seen it before, and the code seems to be taken from this: https://forum.arduino.cc/t/button-matrix-check-and-question-about-encoders/885387

You deleted that parts that are not used, but you deleted a little too much. As UKHeliBob already noticed, the "setup()" function is missing. And I think that a Joystick object needs to be declared and initialized.

To be fair it was the compiler that noticed it first :smiley:

Just a personal project to add a button box for gaming.

I had a look at the link you sent. You are correct, I deleted way too much.

Still not really any closer though. The code on that other post throws a lot of errors. It isn't liking the Joystick_ entry.

This is an example for the Joystick library that is available in the Library Manager: arduino-JOYSTICK/Read.ino at master · gmarty2000-ARDUINO/arduino-JOYSTICK · GitHub

Can you explain what the project is ? How many buttons, leds and so on.
Do you want your Arduino board to emulate a joystick or do you want to read a joystick or don't you use a joystick at all ? Which Arduino board do have ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.