"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10809 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" "-IC:\\Users\\Bob\\Documents\\Arduino\\libraries\\LiquidCrystal_I2C" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries\\Wire\\src" "-IC:\\Users\\Bob\\Documents\\Arduino\\libraries\\LiquidMenu-1.4.1\\src" "-IC:\\Users\\Bob\\Documents\\Arduino\\libraries\\Button" "C:\\Users\\Bob\\Documents\\Arduino\\libraries\\Button\\Button.cpp" -o "C:\\Users\\Bob\\AppData\\Local\\Temp\\arduino_build_360648\\libraries\\Button\\Button.cpp.o"
In file included from C:\Users\Bob\Documents\Arduino\libraries\Button\Button.cpp:21:0:
C:\Users\Bob\Documents\Arduino\libraries\Button\Button.h:5:18: error: expected ')' before 'pin'
Button (uint8_t pin, bool pullup = false, uint16_t debounceDelay = 50)
^
C:\Users\Bob\Documents\Arduino\libraries\Button\Button.cpp:93:1: error: expected '}' at end of input
}
^
C:\Users\Bob\Documents\Arduino\libraries\Button\Button.cpp:93:1: error: expected unqualified-id at end of input
Using library LiquidCrystal_I2C at version 1.1.2 in folder: C:\Users\Bob\Documents\Arduino\libraries\LiquidCrystal_I2C
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Using library LiquidMenu-1.4.1 at version 1.4.0 in folder: C:\Users\Bob\Documents\Arduino\libraries\LiquidMenu-1.4.1
Using library Button in folder: C:\Users\Bob\Documents\Arduino\libraries\Button (legacy)
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
https://playground.arduino.cc/Code/Button/
I downloaded from here.
On line 93 there is no extra bracket needed and line 5 don't I need the arguments in the parenthesis?
/*
||
|| @file Button.cpp
|| @version 1.6
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Provide an easy way of making buttons
|| #
||
|| @license
|| | Copyright (c) 2009 Alexander Brevig. All rights reserved.
|| | This code is subject to AlphaLicence.txt
|| | alphabeta.alexanderbrevig.com/AlphaLicense.txt
|| #
||
*/
//include the class definition
#include "Button.h"
/*
|| <<constructor>>
|| @parameter buttonPin sets the pin that this switch is connected to
|| @parameter buttonMode indicates PULLUP or PULLDOWN resistor
*/
Button::Button(uint8_t buttonPin, uint8_t buttonMode){
this->pin=buttonPin;
pinMode(pin,INPUT);
buttonMode==PULLDOWN ? pulldown() : pullup();
state = 0;
bitWrite(state,CURRENT,!mode);
}
/*
|| Set pin HIGH as default
*/
void Button::pullup(void){
mode=PULLUP;
digitalWrite(pin,HIGH);
}
/*
|| Set pin LOW as default
*/
void Button::pulldown(void){
mode=PULLDOWN;
//digitalWrite(pin,LOW);
}
/*
|| Return the bitWrite(state,CURRENT, of the switch
*/
bool Button::isPressed(void){
bitWrite(state,PREVIOUS,bitRead(state,CURRENT));
if (digitalRead(pin) == mode){
bitWrite(state,CURRENT,false);
} else {
bitWrite(state,CURRENT,true);
}
if (bitRead(state,CURRENT) != bitRead(state,PREVIOUS)){
bitWrite(state,CHANGED,true);
}else{
bitWrite(state,CHANGED,false);
}
return bitRead(state,CURRENT);
}
/*
|| Return true if the button has been pressed
*/
bool Button::wasPressed(void){
if (bitRead(state,CURRENT)){
return true;
} else {
return false;
}
}
/*
|| Return true if state has been changed
*/
bool Button::stateChanged(void){
return bitRead(state,CHANGED);
}
/*
|| Return true if the button is pressed, and was not pressed before
*/
bool Button::uniquePress(void){
return (isPressed() && stateChanged());
}
Trying to try out the liquidmenu examples but this is holding me up.