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

Thread: MCP23017 and Teensy 3.6 button sketch not working

  1. #1

    MCP23017 and Teensy 3.6 button sketch not working

    Hi All,
    I know there is a thread similar to this one but i could not fix my issue with it :/

    I'm currently building a sequencer for my modular synthesizer following ExtraLife videos (for Arduino UNO) : https://www.youtube.com/watch?v=Zm5z...NYhx3t&index=3

    I'm trying to use the MCP23017 with the Teensy 3.6 to be able to acces button input and control LED.
    To dive into this, i downloaded the Adafruit_MCP23017 library and tried the first example.
    This example is for the Arduino UNO, in order to make it work with the teensy, i feed the MCP23017 with 3.3V instead of 5V and i added two 4.7k ohms pullup resistors between SCL0 (Pin 19) and SDA0(Pin 18).
    The rest remain exactly the same.

    Nothing happens to the pin13 LED when i press the button.

    I have tripple checked my wiring, im pretty sure there is something simple that i did not get but i could find it on my own

    Below photos of the breadboard, and wiring "diagram"
    and code of the Example "button" in Adafruit_MCP23017.h library

    Thank you in advance for your attention <3

    Alix


    Click image for larger version. 

Name:	IMG_1931.jpg 
Views:	2 
Size:	163.0 KB 
ID:	18757
    Click image for larger version. 

Name:	IMG_1932.jpg 
Views:	5 
Size:	170.6 KB 
ID:	18756
    Click image for larger version. 

Name:	IMG_1929.jpg 
Views:	4 
Size:	165.1 KB 
ID:	18758
    Click image for larger version. 

Name:	mcp23017diagram.jpg 
Views:	5 
Size:	78.2 KB 
ID:	18760
    Click image for larger version. 

Name:	IMG_1928.jpg 
Views:	4 
Size:	168.7 KB 
ID:	18759



    Code:
    #include <Wire.h>
    #include "Adafruit_MCP23017.h"
    
    // Basic pin reading and pullup test for the MCP23017 I/O expander
    // public domain!
    
    // Connect pin #12 of the expander to Analog 5 (i2c clock)
    // Connect pin #13 of the expander to Analog 4 (i2c data)
    // Connect pins #15, 16 and 17 of the expander to ground (address selection)
    // Connect pin #9 of the expander to 5V (power)
    // Connect pin #10 of the expander to ground (common ground)
    // Connect pin #18 through a ~10kohm resistor to 5V (reset pin, active low)
    
    // Input #0 is on pin 21 so connect a button or switch from there to ground
    
    Adafruit_MCP23017 mcp;
      
    void setup() {  
      mcp.begin();      // use default address 0
    
      mcp.pinMode(0, INPUT);
      mcp.pullUp(0, HIGH);  // turn on a 100K pullup internally
    
      pinMode(13, OUTPUT);  // use the p13 LED as debugging
    }
    
    
    
    void loop() {
      // The LED will 'echo' the button
      digitalWrite(13, mcp.digitalRead(0));
    }

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,354
    Try running File > Examples > Wire > Scanner. After uploading, make sure you have Teensy selected in Tools > Ports, then open the Arduino Serial Monitor.

    What does it print in the serial monitor?

  3. #3
    Thank you for this quick reply !
    It says :

    Scanning...
    No I2C devices found

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,354
    That means no communication is working between Teensy and the MCP23017 chip. While not good, at least this mean you know to focus on the power and I2C wires. There's no point worrying about the pushbutton yet. First you need to get the wiring fixed so the scanner can detect the MCP23017 chip.

    I can confirm MCP23017 definitely does work with Teensy 3.6, when connected properly. I have personally used MCP23017 many times with Teensy 3.6. It will work once the wiring is done right.

  5. #5
    Thank you for this advice,
    after checking a rechecking the wiring (that is already simple)
    I changed the position of the chip on the breadboard, and tadam !
    I apologies for such stupid issue, and i hope this can help some people in their troubleshooting journey !
    thanks again Paul for the support (and for these wonderfull pieces of hardware that i will now be able to play with all night long)

Posting Permissions

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