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

Thread: Arduino 1.0.5 + Teensy 3 + I2C = not working

  1. #1

    Unhappy [SOLVED] Arduino 1.0.5 + Teensy 3 + I2C = not working

    Hey everybody I have two MCP23008 and MCP23017 chips I'm trying to run with Teensy 3. If I compile and run the code with Arduino 1.0.5 it won't work. But if I open the exactly same sketch with my older Arduino 1.0.3 install it works completely perfectly Id use the 1.0.3 version but I also need the MIDI library for Teensy 3 which is not present in that version (?). Any ideas what might be wrong?
    Last edited by poltergeist; 09-25-2013 at 09:05 PM.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,447
    Post the code or a link to it. Please don't make me guess which code you might be using!

  3. #3
    Quote Originally Posted by poltergeist View Post
    If I compile and run the code with Arduino 1.0.5 it won't work.
    Do you mean, that you can compile the sketch on the PC but not upload?
    I have the same version of Arduino and I found I had trouble with the I2C bus.
    Please take a look here

  4. #4
    you're right. I also forgot to mention that i'm using the Adafruit MCP23017 library
    I have a multiplexed grid of LED's connected to the expander.

    Here's my code:

    Code:
    #include <Wire.h>
    #include "Adafruit_MCP23017.h"
    
    Adafruit_MCP23017 mcp;
      
    void setup() {  
      mcp.begin(1);      // address is 1
    
      for(int i=0;i<16;i++){
        mcp.pinMode(i, OUTPUT);
        mcp.digitalWrite(i, LOW);
      }
        mcp.digitalWrite(10, HIGH);//row 4
        mcp.digitalWrite(7, HIGH);//row 3
        mcp.digitalWrite(4, HIGH);//row 2
        mcp.digitalWrite(1, HIGH);//row 1
    }
    
    void loop() {
      
        mcp.digitalWrite(12, HIGH); // col 1
        mcp.digitalWrite(15, LOW); // col 4
        delay(100);
        mcp.digitalWrite(15, HIGH); // col 4
        mcp.digitalWrite(14, LOW); // col 3
        delay(100);
        mcp.digitalWrite(14, HIGH); // col 3
        mcp.digitalWrite(13, LOW); // col 2
        delay(100);
        mcp.digitalWrite(12, LOW); // col 1
        mcp.digitalWrite(13, HIGH); // col 2
        delay(100);
    }
    could it be the library? its based on the Wire.h but I see absolutely no reason why it wouldn't be working.

  5. #5
    Quote Originally Posted by dave View Post
    Do you mean, that you can compile the sketch on the PC but not upload?
    I have the same version of Arduino and I found I had trouble with the I2C bus.
    Please take a look here
    It compiles and uploads but the I2C chips won't respond. But I'm on windows. I actually haven't checked if the board is responding. Give me a sec to try that
    EDIT: The board does not crash, just the I2C chips do not respond.
    Last edited by poltergeist; 09-25-2013 at 08:27 PM.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,447
    Pullup resistors are required with Teensy3 and I2C. Can you confirm if you've got pullup resistors connected on SDA and SCL?

  7. #7
    Oddly enough, I didn't since it worked fine with the older version.. I just added two 4.7k resistors and it worked again like a charm. Thank you very much.
    Though I still can't understand how would the IDE version would make any difference..

  8. #8
    Senior Member
    Join Date
    Jan 2013
    Posts
    966
    The IDE did not make a difference, the pull-up resistors did. There are several excellent sources that explore the pull-up resistors topic in detail:

    This article discusses the effects of varying pull-up-resistors

    And Nick Gammons website is generally a good read

    Also this particular IO expander chip can be used up to 1.7 MHz I2C bus frequency. If it's needed for your projects) is another question, but if you do want it there is a limitation of the "normal" I2C library as that only supports 400KHz.
    The Teensy3 can easily go up to 1.8MHz. In order to unleash the beast you can use the I2C library that user NOX71 has posted here on the forum.

    Also if you are unsure whether an I2C chip is responding then you can use the I2C scanner Sketch that is on Nick Gammons site and other places. This wil provide you with the Addresses of all I2C devices that can be found on the bus.

  9. #9
    Great source indeed thank you very much!

Posting Permissions

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