Pages: [1]   Go Down
Author Topic: What does this Error mean and can I fix it?  (Read 573 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
 *  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 {
public:
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();


private:
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
 (Pressed/ON/Hold/Released/OFF)
 
 */



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'

« Last Edit: March 21, 2013, 11:39:19 am by LufiaCloud » Logged

Croatia
Offline Offline
Sr. Member
****
Karma: 11
Posts: 433
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 21, 2013, 11:39:07 am by Shpaget » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16523
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Lefty
Logged

0
Offline Offline
Shannon Member
****
Karma: 161
Posts: 10445
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2934
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: