Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: teensy / MCP23017 keypad / button matrix library?

  1. #1
    Junior Member
    Join Date
    Aug 2015
    Posts
    7

    teensy / MCP23017 keypad / button matrix library?

    Hi,
    I'm trying to use a keypad library with teesny 3.2. When I compile the example I get a bunch of errors that look to be related to the wire.h library. It compilles fine for Arduino Uno.
    The library in question is written for use with the MCP23017 port expander, and is called Keypad_MC17. Here's the code:
    Code:
    /* file CustomKeypad_MC17 Feb 2/13
    ||@file CustomKeypad.pde
    || @version 1.0
    || @author Alexander Brevig
    || @contact alexanderbrevig@gmail.com
    ||
    || @description
    || | Demonstrates changing the keypad size and key values.
    || #
        Use with I2C i/o G. D. (Joe) Young Feb 28/12
    
        Use with MCP23008 I2C i/o G. D. (Joe) Young Jul 29/12
        Use with MCP23016 I2C i/o G. D. (Joe) Young Feb 2/13
        Use with MCP23017 I2C i/o G. D. (Joe) Young May 19/14
    */
    #include <Keypad_MC17.h>
    #include <Keypad.h>        // GDY120705
    #include <Wire.h>
    
    //#define I2CADDR 0x24
    #define I2CADDR 0x20
    const byte ROWS = 4; //four rows
    const byte COLS = 5; //five columns
    //define the cymbols on the buttons of the keypads
    char hexaKeys[ROWS][COLS] = {
      {'0','1','2','3','W'},
      {'4','5','6','7','X'},
      {'8','9','A','B','Y'},
      {'C','D','E','F','Z'}
    };
    byte rowPins[ROWS] = {8, 9, 10, 11}; //connect to the row pinouts of the keypad
    byte colPins[COLS] = {0, 1, 2, 3, 4}; //connect to the column pinouts of the keypad
    
    //initialize an instance of class NewKeypad
    Keypad_MC17 customKeypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS, I2CADDR); 
    
    void setup(){
      Wire.begin( );
      customKeypad.begin( );        // GDY120705
      Serial.begin(9600);
    }
      
    void loop(){
      char customKey = customKeypad.getKey();
      
      if (customKey != NO_KEY){
        Serial.println(customKey);
      }
    }
    I get the following errors in the console:
    Code:
    In file included from C:\Users\EDDEVA~1\AppData\Local\Temp\arduino_modified_sketch_680515\CustomKeypad_MC17.ino:16:0:
    
    E:\Google Drive\Arduino_cloud\libraries\Keypad_MC17/Keypad_MC17.h: In constructor 'Keypad_MC17::Keypad_MC17(char*, byte*, byte*, byte, byte, byte)':
    
    E:\Google Drive\Arduino_cloud\libraries\Keypad_MC17/Keypad_MC17.h:49:48: error: no matching function for call to 'TwoWire::TwoWire()'
    
       Keypad(userKeymap, row, col, numRows, numCols) { i2caddr = address; }
    
                                                    ^
    
    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/Wire.h:26:0,
    
                     from E:\Google Drive\Arduino_cloud\libraries\Keypad_MC17/Keypad_MC17.h:44,
    
                     from C:\Users\EDDEVA~1\AppData\Local\Temp\arduino_modified_sketch_680515\CustomKeypad_MC17.ino:16:
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:94:12: note: candidate: constexpr TwoWire::TwoWire(uintptr_t, const TwoWire::I2C_Hardware_t&)
    
      constexpr TwoWire(uintptr_t port_addr, const I2C_Hardware_t &myhardware)
    
                ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:94:12: note:   candidate expects 2 arguments, 0 provided
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:76:7: note: candidate: constexpr TwoWire::TwoWire(const TwoWire&)
    
     class TwoWire : public Stream
    
           ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:76:7: note:   candidate expects 1 argument, 0 provided
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:76:7: note: candidate: constexpr TwoWire::TwoWire(TwoWire&&)
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire/WireKinetis.h:76:7: note:   candidate expects 1 argument, 0 provided
    
    Multiple libraries were found for "Keypad.h"
     Used: E:\Google Drive\Arduino_cloud\libraries\Keypad
     Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Keypad
    Error compiling for board Teensy 3.2 / 3.1.
    Is there an easy fix for this, or alternatively a different library I can use for this port expander and Teensy?

    To contextualise, I've built a step sequencer PCB with a 4x8 button matrix, and in a couple of days hope to show it at a synth demo. I figured it would be easier to build a PCB than to try and breadboard it given the amount of switches, and (perhaps foolishly) didn't investigate the code too much assuming this library would just work with Teensy.

    Any pointers greatly appreciated!!

  2. #2
    I'm not sure what the problem is here but generally I'd suggest checking out the Teensy enhanced I2C (Wire) library replacement, i2c_t3: https://github.com/nox771/i2c_t3

    It will also give you the ability to use the additional I2C ports on the Teensy, though if you're in a hurry it should work as a direct replacement without modifying much else in your code if you're using SCL/SDA 0 - per the page all you should need to do is this: "change the #include <Wire.h> to #include <i2c_t3.h>".

    This library is included with Teensyduino (so you should already have it on your machine), but the link above has good documentation (I think there's something on PJRC's tutorial pages about it too).

    I don't know if this will solve your problem, but it's something to think about and if the libraries you have aren't working as expected it couldn't hurt to try something else. Just make backups of everything you modify first

  3. #3
    And... hello to another synth-oriented maker!

  4. #4
    Junior Member
    Join Date
    Aug 2015
    Posts
    7
    nice one, I'll try that. Thanks for the suggestion, will let you know how I get on!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •