-3

when I go to upload the code, I get Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::FastADC(bool)'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `bounds(int, int, int)'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `isin(int, int, int, int, int)'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::iKEY'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::iDEFAULT_THRESHOLD'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::iARV_VALUES'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::LastTime'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::iKEY_DEBOUNCE_DELAY'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::LastKey'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::bRepeat'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::GetKey()'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::KeyName(int)'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::sKEY'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::AnyKey()'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\DFRkeypad\DFRkeypad.cpp.o (symbol from plugin): In function `DFRkeypad::FastADC(bool)':

(.text+0x0): multiple definition of `DFRkeypad::iKEY_REPEAT_DELAY'

sketch\sketch_apr20b.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here

C:\Users\taran\AppData\Local\Temp\ccECMeQj.ltrans0.ltrans.o: In function `main':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup'

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1 Error compiling for board Arduino/Genuino Uno.

the code is

#include "DFRkeypad.h"



const char* DFRkeypad::sKEY[]=                          { "---",       "Right",   "Up", "Down", "Left", "Select", "???" };

const int DFRkeypad::iARV_VALUES[DFRkeypad::eNUM_KEYS]= { 1023,        0,         143,  328,    504,     740,      -1   };

int DFRkeypad::iKEY[DFRkeypad::eNUM_KEYS]=              { 0,           0,         0,    0,      0,       0,         0   };



int DFRkeypad::iDEFAULT_THRESHOLD=50;       // default threshold for keypad ADC and resistor network inaccuracies

int DFRkeypad::iKEY_DEBOUNCE_DELAY=100;     // default debounce time for keys on keypad (100ms)

int DFRkeypad::iKEY_REPEAT_DELAY=250;       // default repeat delay for keys on keypad (250ms)

byte DFRkeypad::LastKey=DFRkeypad::eNO_KEY;

unsigned long DFRkeypad::LastTime=0;

bool DFRkeypad::bRepeat=false;



// defines for setting and clearing register bits

#ifndef cbi

#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))

#endif

#ifndef sbi

#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

#endif



void DFRkeypad::FastADC(bool bFast) // modify ADV prescale divider to accelerate analogRead() if necessary

{

  if(bFast)

  {

    // set prescaler to 16 (16MHz ADC clock, divided by prescale 16 divided by 13 ADC clocks per conversion=77kHz sample rate)

    sbi(ADCSRA,ADPS2);

    cbi(ADCSRA,ADPS1);

    cbi(ADCSRA,ADPS0);

  }

  else // if(bFast)

  {

      // set prescaler to 128 (16MHz ADC clock, divided by prescale 128 divided by 13 ADC clocks per conversion=9.6kHz sample rate)

    sbi(ADCSRA,ADPS2);

    sbi(ADCSRA,ADPS1);

    sbi(ADCSRA,ADPS0);

  } // if(bFast) ... else

} // void DFRkeypad::FastADC(bool bFast)



int bounds(int val, int lower, int upper) // restrict val to interval [lower;upper]

{

  if(val<lower) return lower;

  if(val>upper) return upper;

  return val;

} // int bounds(int val, int lower, int upper)



bool isin(int val, int min, int max, int center, int threshold) // find out if value is within +/- threshold around center

{

  return val>=bounds(center-threshold, min, max) && val<=bounds(center+threshold, min, max);

} // bool isin(int val, int min, int max, int center, int threshold)



const char* const DFRkeypad::KeyName(int val) // get verbose key name

{

  return sKEY[bounds(val, eNO_KEY, eINVALID_KEY)];

} // const char* const DFRkeypad::KeyName(int val)



bool DFRkeypad::AnyKey() // quick test if any key is pressed on the keypad

{

  return analogRead(KEYPAD)<1023-iDEFAULT_THRESHOLD; // anything _not_ eNO_KEY is a valid key

} // bool DFRkeypad::AnyKey()



byte DFRkeypad::GetKey() // get key ID on DFR LCD keypad shield

{

  if(bRepeat && millis()<LastTime+iKEY_REPEAT_DELAY) return eNO_KEY;



  int i, count=0, key=eNO_KEY, val;

  memset(iKEY, 0, sizeof(iKEY));                // clear the key histogram



  while(millis()<LastTime+iKEY_DEBOUNCE_DELAY)  // sample analog values from keyboard until debounce time exceeded

  {

    val=analogRead(KEYPAD);                     // read analog value from keyboard resistor array

    for(i=eNO_KEY; i<eNUM_KEYS-1; ++i)

      if(isin(val, 0, 1023, iARV_VALUES[i], iDEFAULT_THRESHOLD)) break; // if within threshold for key, the ID has been found



    ++iKEY[i];                                  // increment histogram bin for this key

  } // while(millis()<LastTime+iKEY_DEBOUNCE_TIME)



  for(i=eNO_KEY; i<eNUM_KEYS-1; ++i)            // enumerate histogram bins

    if(iKEY[i]>count) { key=i; count=iKEY[i]; } // find key ID that has been sampled most of the time during debouncing



  if(eNO_KEY!=key && LastKey==key)   { bRepeat=true;   key=eNO_KEY; }

  else                               { bRepeat=false;   LastKey=key; }



  LastTime=millis();

  return key;

} // byte DFRkeypad::GetKey()
  • Select your code in your post and press ctrl-K to format it as code... – dda Apr 20 '18 at 15:51
  • Update your question with the code that will not compile and the error message. – VE7JRO Apr 20 '18 at 23:40
2

You know that LCD shield buttons are usually multiplexed to the analog pin A0? If I've googled correct schematics, this applies to this one too. Therefore no pin change interrupts nor external interrupts can be used.

Maybe analog comparator module with correct threshold.

  • can someone help me with my project, the problem is up top – taran Apr 19 '18 at 21:32
0

You are including the AnalogDebounce.h library but you are not using any code in the loop() to poll/refresh which button (if any) is pressed. Have a look at the "BasicUse" example here: https://github.com/MatCat/AnalogDebounce. There is also a library for the DFRkeypad: https://github.com/DFRobot/LCD-KeyPad-Shield. My first suggestion is to write a very simple sketch using a library that works with your keypad so yo can verify the buttons are working as intended.

There is a line of code in your sketch that makes absolutely no sense to me: if (diceOne + diceTwo == 5, 4, 3, 2, 6 ). I don't think you can compare dice 1 + 2 to a comma separated list of integers. Try this: if((diceOne + diceTwo > 1) && (diceOne + diceTwo < 7))

  • when I try and upload the LCD keypad- shield or the AnalogDebounce to the Arduino, it says error compiling, plz help – taran Apr 20 '18 at 22:05
  • Update your question with the code that will not compile and the error message. – VE7JRO Apr 20 '18 at 22:14
  • Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno" C:\Users\taran\Documents\Arduino\sketch_apr20b\sketch_apr20b.ino:1:23: fatal error: DFRkeypad.h: No such file or directory #include "DFRkeypad.h" ^ compilation terminated. exit status 1 Error compiling for board Arduino/Genuino Uno. – taran Apr 20 '18 at 22:33
  • It looks like you have not installed the DFRkeypad library from Github. – VE7JRO Apr 20 '18 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.