Go Down

Topic: What does this Error mean and can I fix it? (Read 809 times) previous topic - next topic

Mar 21, 2013, 05:29 pm Last Edit: Mar 21, 2013, 05:39 pm by LufiaCloud Reason: 1
I am trying to program my joystick shield to be able to just activate a button and I continue to get this error. I even have the arduino library for buttons and I still get this error. What is my problem and is it fixable? Thanks! -A Highschool Student

Code: [Select]
*  buttons.h
*  One-shot and hold functions for buttons.
*  Created by Franky on 29/01/09.
*  Licensed under LGPL (free to modify and use as you wish)

#include <inttypes.h>

#define OneShot 0
#define Memory 1
#define Timer 2
#define OneShotTimer 3
#define MemoryTimer 4

#define ON 1
#define OFF 0
#define Pressed 2
#define Released 3
#define Hold 4

typedef uint8_t byte;

class Button {
Button(byte type);
void assign(byte pin);
byte check();
byte check(byte mode_v);
// Setters
void setMode(byte type_v);
void setTimer(unsigned int t);
void setRefresh(unsigned int r);
void turnOnPullUp();
void turnOffPullUp();

byte pin;
byte mode;
unsigned long hold_timer;
unsigned long refresh_timer;
unsigned int hold_level;
unsigned int hold_refresh;
bool previous;


Button modes:

- OneShot: OneShot only, returns 2 values (ON/OFF)
- Memory: Returns (Pressed/ON/Released/OFF)
- Timer: Hold System (OFF/ON/Hold)
- OneShotTimer: Combi OneShot & Timer (ON/Hold/OFF)
- MemoryTimer: Combi Memory & Timer


core.a(main.cpp.o): In function `main':
C:\Users\IAN\Desktop\arduino-1.0.3-windows\arduino-1.0.3\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'
C:\Users\IAN\Desktop\arduino-1.0.3-windows\arduino-1.0.3\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to `loop'


Mar 21, 2013, 05:37 pm Last Edit: Mar 21, 2013, 05:39 pm by Shpaget Reason: 1
Please post your entire code, using code tags.

I would also hazard a guess and say: Yes, it is fixable. But not until you show us what needs fixing.


I think you will have to post your sketch for anyone to help you on this matter. Use the code tag # above the edit window and past your sketch into it.



The message means your sketch has no loop or setup functions.

But it looks like a library you are compiling.  You need a test sketch to use the library perhaps?
[ I won't respond to messages, use the forum please ]

I am a beginner at coding and all I know is that for my project (I have an Uno) I need to write a code that would send a serial over when I press a button to either c# or c++ that would read it and then transfer that into a keystroke. (I am trying to play emulator games, mainly Megaman)


I need to write a code that would send a serial over when I press a button to either c# or c++ that would read it and then transfer that into a keystroke
It sounds like you are going to need a Leonardo, not an UNO.
My GitHub:


The code you posted is just a C++ header file and cannot compile by itself. The Arduino IDE is primarily designed to compile Arduino sketches, which are C/C++ files with two mandatory functions, setup() and loop(). But before coding your Button class you should become familiar with how Arduino manages pushbuttons, both in hardware (digital pins, pull-up and pull-down resistors) and software (digitalRead). In the Learning and Reference section of the main Arduino site you will find tutorials and examples. From the IDE you can select File - Examples - 02.Digital - Button, just to get you started.

Go Up