I’m having what seems to be a problem that should be easy to fix, but I’m too new to figure it out. I’ll post the whole sketch but the error indicates that the issue is in an included library. --Sketch is too long so I had to cut most of it out.
/*----------------------------------------------------------------------------
-Arduino IDE 1.0.5
-Hardware
-Arduino Mega 2560 R3
-NEMA 14 0.9deg (400 step/rev) 11Ncm stepper motor
-SilentStepStick stepper motor driver
-Adafruit Ultimate GPS Breakout [ID:746]
-Adafruit RGB backlight negative LCD 20x4 + extras (RGB on black) [ID:498]
-Adafruit i2c / SPI character LCD backpack[ID:292]
FUNCTIONS
-Adjustable number of turns per day (TPD)
-increments of 5
-Adjustable direction
-clockwise
-counterclockwise
-both
-Adjustable turn frequency
-turn the watch ever n number of minutes?
-calculate number of turns per cycle, depending on cycle frequency
-Full wind
-run continuously, to wind a watch from a dead stop. 800 turns.
-GPS receiver
-get time for clock to display on screen.
-Turn counter
-displays number of turns since midnight.
----------------------------------------------------------------------------*/
#include <TimerOne.h>
#include <Wire.h>
//INSERT THE NEXT 4 INCLUDES AFTER INCLUDING WIRE LIBRARY
//#include <buttons.h>
#include <LiquidTWI2.h>
#include <MENWIZ_LiquidTWI2.h>
#include <buttons.h>
#include <EEPROM.h>
//---------------------------------------------------
#include <AccelStepper.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <Time.h>
//////////////////////////////////////////////////////////
// CONSTANTS //
//////////////////////////////////////////////////////////
const int ESCAPE_BUTTON = 9; //Escape Button
const int CONFIRM_BUTTON = 10; //Confirm Button
const int DOWN_BUTTON = 12; //Down Button
const int UP_BUTTON = 11; //Up Button
const int w1ACT = 8; //button to activate/deactivate watch slot
const int w1SLEEP = 24; //Driver Sleep Pin
const int w1LED = 43; //feedback light on w1ACT
const long REV = 6400; //number of steps in 1 revolution of motor
const long RPM = 8; //Speed at which the motor will spin
const long MINUTES_IN_DAY = 1440; //minutes in 24 hours
const int w1FULL_WIND = 800; //Revolutions to fully wind from stop
char* w1ACTIVE_STAT[]={"STATUS: OFF", "STATUS: ON"}; //Used for Status screen.
//////////////////////////////////////////////////////////
// GLOBAL VARIABLES //
//////////////////////////////////////////////////////////
int w1TPD = 650; //Turns per day
int w1DIR = 0; //0=CW, 1=CCW, 2=BOTH used in menu
int w1DIRECTION = 1; //Used in functions to determine direction
int w1CYCLE_TIME = 15; //Minutes between cycles
int w1CYCLE_TIME_S = w1CYCLE_TIME*60; //Seconds between cycles
int w1CYCLE_TIME_LAST = w1CYCLE_TIME; //Used to determine change in CYCLE_TIME
long w1STEPS ; //Use in WIND_NOW() function & full wind, and loop cleanup
int w1FULL_WIND_STATUS = 0; //0=OFF, 1=unidirectional, 2=bidirectional
int w1FULL_WIND_COUNT = 1; //Used to determine when to switch direction
boolean w1ACTIVE = 1; //Is this slot turned on or off?
boolean w1ACT_STATE = 0; //Used for determining w1ACTIVE
boolean w1ACT_LAST_STATE = 0; //Used for determining w1ACTIVE
int w1TURN_COUNTER = 0; //Counts number of turns so far, since midnight
long w1COUNTER_START = 0; //Used for turn counter to count steps
int LAST_HOUR = 0; //Used to reset turn counter
boolean DST = 1; //Is DST in effect or not?
boolean DST_LAST = DST;
int ZONE_OFFSET = -5; //time zone offset
int ZONE_OFFSET_LAST = ZONE_OFFSET; //time zone offset
boolean TIME_SET_FLAG = false; //Check if time has been synced to GPS
int TIME_HOUR = 0; //For clock on statusScreen screen
int TIME_MIN = 0;
int TIME_SEC = 0;
unsigned long SEC_COUNTER = 0; //Used to see if a second has passed
//////////////////////////////////////////////////////////
// OBJECTS //
//////////////////////////////////////////////////////////
menwiz menu;
LiquidTWI2 lcd(0x20);
//CREATE ACCELSTEPPERS
AccelStepper w1STEPPER(1, 23, 22); //1 pin=driver, 23=step pin, 22=direction pin
//GPS
HardwareSerial GPSSerial = Serial1;
Adafruit_GPS GPS(&GPSSerial);
//////////////////////////////////////////////////////////
// SETUP //
//////////////////////////////////////////////////////////
void setup()
{
Serial.begin(19200);
SEC_COUNTER = now();
// SET UP LCD
lcd.setMCPType(LTI_TYPE_MCP23008);
lcd.begin(20, 4);
//CHECK IF SETTINGS ARE STORED IN MEMORY & LOAD IF SO
if (EEPROM.read(0) == 1)
{
w1TPD = EEPROM.read(1) * 256 + EEPROM.read(2);
w1DIR = EEPROM.read(3);
w1CYCLE_TIME = EEPROM.read(4);
ZONE_OFFSET = EEPROM.read(5) - 12;
ZONE_OFFSET_LAST = ZONE_OFFSET;
DST = EEPROM.read(6);
DST_LAST = DST;
}
//CONFIG PINS NOT PART OF MENU NAV
pinMode(w1ACT, INPUT_PULLUP);
pinMode(w1LED, OUTPUT);
digitalWrite(w1LED, w1ACTIVE);
pinMode(w1SLEEP, OUTPUT);
digitalWrite(w1SLEEP, HIGH);
//ACCELSTEPPERS
w1STEPPER.setMaxSpeed((REV*RPM)/60.0); //APPROX 8RPM
w1STEPPER.setAcceleration((REV*RPM)/60.0); //takes 1 sec to reach full speed
//GPS
GPS.begin(9600);
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
}
The error reported is:
Arduino: 1.0.5 (Windows NT (unknown)), Board: “Arduino Mega 2560 or Mega ADK”
In file included from Winder_from_internet.ino.ino:36:
C:\Users\Tim\Documents\Arduino\libraries\Buttons/buttons.h:25: error: redefinition of ‘class Button’
C:\Users\Tim\Documents\Arduino\libraries\Buttons/buttons.h:25: error: previous definition of ‘class Button’
And the library contents are:
/*
* 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)
*/
Line 25 is class Button. I can’t see any other definition of the Class “Button”
Can anybody help me fix this? I apologize if I’ve left anything out.