Pages: [1]   Go Down
Author Topic: MCP2300x behaviour  (Read 746 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a MCP23009 IC that I want to use as out put. So far so good, I used it once before as input and the ..17 as output, but...

I get a strange result. The LEDs will blink, but only if I connect them anode/plus to the V+ and cathode/minus to the mcp pin

This is the source:

Code:

#include <Wire.h>
#include "MCP23009.h"

// Basic toggle test for i/o expansion. flips pin #0 of a MCP23009 i2c
// pin expander up and down. Public domain

// Connect pin #1 of the expander to Analog 5 (i2c clock)
// Connect pin #2 of the expander to Analog 4 (i2c data)
// Connect pins #3, 4 and 5 of the expander to ground (address selection)
// Connect pin #6 and 18 of the expander to 5V (power and reset disable)
// Connect pin #9 of the expander to ground (common ground)

// Output #0 is on pin 10 so connect an LED or whatever from that to ground

// Note, based on MCP23009, but I modified it a bit
// (lib was originally made for mcp23008
// that code checks for addresses < 7 and my mcp has the address pin connected to 5V (and so has address 0x27)

MCP23009 mcp;

void setup() { 
  mcp.begin(0x27);      // use default address 0

  for (int i=0; i< 8; i++)
    mcp.pinMode(i, OUTPUT);
}

// werkt wel, maar soms omgekeerd (dus de OUTPUT als GND?!)

// flip the pin #0 up and down

void loop() {

  for (int i=0; i< 8; i++) {
    //mcp.pinMode(i, OUTPUT);
    delay(1000);
    mcp.digitalWrite(i, HIGH);

    delay(1000);

    mcp.digitalWrite(i, LOW);
  }
}

Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The MCP23009 outputs are open-drain.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, that explains a lot smiley-wink

Thanks!!! So now I just need to rewire the signals...
Logged

Pages: [1]   Go Up
Jump to: