Error using bounce2 library example

I'm trying to utilize the bounce2 library for some button input. I got the following setup/error:

Macbook Pro 2011
OSX 10.9.4
Arduino Due
Dev 1.5.7

Arduino: 1.5.7 (Mac OS X), Board: "Arduino Due (Native USB Port)"

Build options changed, rebuilding all
Using library Bounce2 in folder: /Users/jamesklyne/Development/Arduino/libraries/Bounce2 (legacy)

/Applications/Arduino.app/Contents/Java/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=157 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due" -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/system/libsam -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/variants/arduino_due_x -I/Users/jamesklyne/Development/Arduino/libraries/Bounce2 /var/folders/gd/kh1g798j3j70fndzg461d8m80000gn/T/build5774478005493286172.tmp/sketch_jul11a.cpp -o /var/folders/gd/kh1g798j3j70fndzg461d8m80000gn/T/build5774478005493286172.tmp/sketch_jul11a.cpp.o 
/Applications/Arduino.app/Contents/Java/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=157 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Due" -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/system/libsam -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/sam/variants/arduino_due_x -I/Users/jamesklyne/Development/Arduino/libraries/Bounce2 -I/Users/jamesklyne/Development/Arduino/libraries/Bounce2/utility /Users/jamesklyne/Development/Arduino/libraries/Bounce2/Bounce2.cpp -o /var/folders/gd/kh1g798j3j70fndzg461d8m80000gn/T/build5774478005493286172.tmp/Bounce2/Bounce2.cpp.o 
/Users/jamesklyne/Development/Arduino/libraries/Bounce2/Bounce2.cpp: In member function 'void Bounce::attach(int)':
/Users/jamesklyne/Development/Arduino/libraries/Bounce2/Bounce2.cpp:27:31: error: '_BV' was not declared in this scope
    state = _BV(DEBOUNCED_STATE) | _BV(UNSTABLE_STATE);
                               ^
/Users/jamesklyne/Development/Arduino/libraries/Bounce2/Bounce2.cpp: In member function 'bool Bounce::update()':
/Users/jamesklyne/Development/Arduino/libraries/Bounce2/Bounce2.cpp:58:32: error: '_BV' was not declared in this scope
     state &= ~_BV(STATE_CHANGED);
                                ^
/Users/jamesklyne/Development/Arduino/libraries/Bounce2/Bounce2.cpp: In member function 'bool Bounce::read()':
/Users/jamesklyne/Development/Arduino/libraries/Bounce2/Bounce2.cpp:81:36: error: '_BV' was not declared in this scope
  return state & _BV(DEBOUNCED_STATE);
                                    ^
#include <Bounce2.h>

/* 
DESCRIPTION
====================
Simple example of the bounce library that switches the debug LED when a button is pressed.

CIRCUIT
====================
https://raw.github.com/thomasfredericks/Bounce-Arduino-Wiring/master/Bounce/examples/circuit-bounce-change-duration-retrigger.png
*/


#define BUTTON_PIN 2
#define LED_PIN 13



// Instantiate a Bounce object
Bounce debouncer = Bounce(); 

void setup() {
  // Setup the button
  pinMode(BUTTON_PIN,INPUT);
  // Activate internal pull-up
  digitalWrite(BUTTON_PIN,HIGH);
  
  // After setting up the button, setup debouncer
  debouncer.attach(BUTTON_PIN);
  debouncer.interval(5);
  
  //Setup the LED
  pinMode(LED_PIN,OUTPUT);
  
}

void loop() {
 // Update the debouncer
  debouncer.update();
 
 // Get the update value
 int value = debouncer.read();
 
 // Turn on or off the LED
 if ( value == HIGH) {
   digitalWrite(LED_PIN, HIGH );
 } else {
    digitalWrite(LED_PIN, LOW );
 }
 
}

Possibly the library is in the wrong folder.

_BV() is an avrlibc macro. The Due does not use avrlibc. The bounce2 library appears to be unsuitable for the Due.

Not exactly what you want but you should be able to get there from here:

// All you need to do this example is an Arduino and a jumper in pin 2.
// Push and let go the button once, led blinks. Again, led turns off.
// Button is debounced and wired directly to ground or, the button can 
// be a jumper from pin 2 grounded on USB connector. Tested with jumper.
// By GoForSmoke for free public use. Using Arduino 1.0.5-r2

/*
This sketch uses millis() timing but only the low bytes. Unsigned math
 lets this work just as well as with all 32 bits.
 This sketch has 3 separated code blocks. 
 --- 1 for the button that changes buttonState only after a debounced change.
 --- 1 that processes changes in buttonState to control led blink.
 --- 1 that blinks the led when it's supposed to.
 Each code block could be replaced by another with minimal change to the others.
 More blocks can be added, they don't have to deal with the led but they could.
 If you want to merge sketches then here is one strategy to do it.
 */

// Look Ma, no extra libraries!

const byte ledPin =  13;      // this is the onboard led pin
const byte buttonPin = 2;


byte ledPinState = 0;
byte blinkLed = 0; // led stays off when 0, blinks when 1
const word ledBlinkMs = 1000U; // blink interval
word ledBlinkNowMs = 0U; // low 16 bits of millis()
word ledBlinkStartMs = 0U; // 16 bit blink (on or off) time ms

// button variables
byte buttonRead;  // wired for pullup -- if down then LOW, if up then HIGH 
byte lastButtonRead = HIGH; // so debounce knows previous read
byte checkDebounce = 0; // only checks decounce after every button pin change
byte lastButtonState = 0; // last stable button state
byte buttonState = 0;  // stable button state
// 0 = button is up after debounce
// 1 = button is down after debounce
// button debounce timing variables
const word debounceMs = 300; // debounced when reads for debounceMs ms are the same
word debounceMillisLowByte = 0; // only need to count to 10, don't need 32 bits
word msNow = 0; // don't worry, unsigned rollover makes it work 


byte processState = 0;  // the button gets pushed and released twice
// 0 = 1st press has not happened, led blink is OFF, looking for press
// 1 = 1st press is down, led blink is ON, looking for release
// 2 = 1st push relesased, led blink stays ON, looking for 2nd press
// 3 = 2nd press is down, led blink is OFF, looking for release
// there is no state 4, 2nd push release changes state to 0


void setup() 
{
  Serial.begin( 115200 );
  Serial.println( F( "\n Blinking Status Light with ON/OFF Button" ));
  Serial.println( F( "Ground pin 2 to press the button else not pressed\n" ));

  pinMode( ledPin, OUTPUT );  // default is LOW 
  pinMode( buttonPin, INPUT_PULLUP ); // my button connects to ground, not 5V
  // however that means that when the button is pressed the pin is LOW.
}

void loop() // make sure that loop() runs fast and stays in the "now".
{

  // BUTTON CODE BLOCK, it handles debouncing. 
  // the task is to set the variable buttonState when a Stable Button State is reached.
  // other sensor code could change the same variable if desired

  // read the pin which may be changing fast and often as the jumper contacts the housing
  buttonRead = digitalRead( buttonPin ); // momentary state

  // msNow gets the low bytes of millis() to time the very short debounce time
  msNow = (word)( millis() & 0xFFFF ); // set once, used in 2 places

  if ( buttonRead != lastButtonRead )
  {
    debounceMillisLowByte = msNow;
    checkDebounce = 1;
  }
  else if ( checkDebounce )
  { 
    if ( msNow - debounceMillisLowByte >= debounceMs ) // stable button state achieved
    {
      buttonState = !buttonRead; // mission accomplished, button is stable
      // note that buttonState is opposite buttonRead
      checkDebounce = 0; // stop debounce checking until pin change
    }
  }
  lastButtonRead = buttonRead;
  //
  // End of the BUTTON CODE BLOCK

  //==================================================================================

  // LED CONTROL CODE BLOCK that uses buttonState and processState
  if ( lastButtonState != buttonState )
  {
    lastButtonState = buttonState;

    // debug type prints -- also testing some loading, does it alter the blink much?
    Serial.println( F( "============================================================" ));    
    Serial.print( F( "processState " ));
    Serial.print( processState );
    Serial.print( F( "  buttonState " ));
    Serial.println( buttonState );
    Serial.print( F( "  millis " ));
    Serial.println( msNow ); // the low 16 bits of millis, rolls over at 65535+1
    Serial.println( F( "============================================================" ));    

    switch ( processState )
    {
    case 0: // 0 = 1st press has not happened, led is OFF, looking for press
      if ( buttonState == 1 ) // button is pressed 
      {
        processState = 1;
        blinkLed = 1;
        ledPinState = 0;
        ledBlinkStartMs = (word) ( millis() & 0xFFFF )- ledBlinkMs; 
      }
      break; // note that until the 1st press, this case runs over and over

    case 1: // 1 = 1st press is down, led is ON, looking for release
      if ( buttonState == 0 ) // button is released 
      {
        processState = 2;
      }
      break; // note that until the 1st release, this case runs over and over

    case 2: // 2 = 1st push relesased, led stays ON, looking for 2nd press
      if ( buttonState == 1 ) // button is pressed 
      {
        processState = 3;
        blinkLed = 0;
      }
      break; // note that until the 2nd press, this case runs over and over

    case 3: // 3 = 2nd press is down, led is OFF, looking for release
      if ( buttonState == 0 ) // button is released 
      {
        processState = 0; // back to the start
      }
      break; // note that until the 2nd release, this case runs over and over
    } 
  }
  // End of the LED CONTROL CODE

  //==================================================================================

  // LED BLINK CODE BLOCK
  if ( blinkLed )
  { 
    ledBlinkNowMs = (word) ( millis() & 0xFFFF );

    if ( ledBlinkNowMs - ledBlinkStartMs >= ledBlinkMs )
    { 
      ledPinState = !ledPinState;
      digitalWrite(ledPin, ledPinState );
      ledBlinkStartMs = ledBlinkNowMs;
    }
  }
  else
  {
    ledPinState = LOW;
    digitalWrite(ledPin, LOW );
  }
  // End of the LED BLINK CODE

  //==================================================================================

  // Want to add serial commands and args input? 
  // this is a good spot. Serial is so slow it can usually go last.
}

Well, it looks like the Due was a waste of money for someone just getting into this. Nothing seems compatible/portable and very out of date. Guess it's a good thing I ordered an Uno as well. This doesn't bode well for future hardware...

Thanks for the help and pointers guys. Enough googling and I may be able to come up with some usable libraries for due. Hopefully I can get good enough to actually make some worth sharing myself.

The code I gave you doesn't use a library though the debounce could be contorted into one.
I also have multi-button and multiplexed button debounce routines.

The library you have may work if you or someone codes a work-around/replacement for the BV_ macro.

The Due is freaking awesome and I say that as someone who didn't grow up using that term.

I definitely see the potential of the Due, even though I don't have all the skills yet to correctly implement them at this point. I was hoping the software was at least somewhat comparable to the Uno. I picked up an Uno, should get here tomorrow, and hopefully that will take me down the path of fully utilizing the Due, and hopefully expanding it.

Did you try the code I posted? It should work.

the Bounce2.cpp file shows you what _BV is in a comment on line 40, it's a macro:
#define _BV(bit) (1 << (bit))
put that line near the top of Bounce2.cpp (not in a function) and you should be good to go.

#define _BV(bit) (1 << (bit))

Some people think that code like ( 1 << bitNum ) is just too cryptic.

So they replace it with the totally non-cryptic _BV( bitNum ).

Which is more documented for the past 40+ years?

Thanks Karma.

I added the following to the top of my Bounce.cpp file:

#ifdef _BV
// All cool.
#else
#define _BV(bit) (1 << (bit))
#endif