Go Down

Topic: how to program a MAX23017 so that I can use all pin outs (Read 659 times) previous topic - next topic

hello i recently got some MAX23017 port expanders but i am having trouble controlling them. i know that there are 2 port on this IC and so far i have only been able to get the 0 output on port A to work using the adafruit library. How do i use this library to control the port expander (they only need to be outputs)?

i would like to be able to use these port expanders to control a BCD to decimal decoder (74141) to drive some IN-12 nixie tubes.

how would i use this library and if it cannot be done can it be done with the wire library?

johnwasser

Did you try setting the pin number to something other than 0 to try other pins?  Here is the example code re-written to use Pin 15 instead of Pin 0

Code: [Select]

#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)

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

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

  mcp.pinMode(15, OUTPUT);
}


// flip the pin #15 up and down

void loop() {
  delay(100);

  mcp.digitalWrite(15, HIGH);

  delay(100);

  mcp.digitalWrite(15, LOW);
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

so what pin on the max23017 would be 15?

i did try other numbers but i could not the get the test led to light up :/

is there anything special in the way i wire these up that i need to do?

Riva

I do believe our resident expert and all round guru Nick Gammon has done some trials using this chip to interface to a LCD matrix display but I cannot remember where.

johnwasser


so what pin on the max23017 would be 15?


Like I said in the code:  pin 8 (port B bit 7)
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e



so what pin on the max23017 would be 15?


Like I said in the code:  pin 8 (port B bit 7)


sorry i did not notice :D

do i put the 4.7k resitors before the first IC or at the end of the SCL and SDA lines?

alo how would i control the outputs of another max23017 chip on the i2c with its A0 pin high and A1 and A2 low?

johnwasser



>  do i put the 4.7k resitors before the first IC or at the end of the SCL and SDA lines?

I don't know if it matters but I would put them near the ATmega.

> alo how would i control the outputs of another max23017 chip on the i2c with its A0 pin high and A1 and A2 low?

Since the examples use:
Code: [Select]
mcp.begin();      // use default address 0
My guess would be:
Code: [Select]
mcpA.begin(0);      // use default address 0
mcpB.begin(1);      // use address 1
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

also how would i do this using just the wire library? that would then allow me to use my pcf8574AP IC's :D

Nick Gammon

Some stuff about I2C and that port expander:

http://www.gammon.com.au/i2c


Here I drove an LCD screen with one:

http://www.gammon.com.au/forum/?id=10940

Quote
alo how would i control the outputs of another max23017 chip on the i2c with its A0 pin high and A1 and A2 low?


Use the appropriate I2C address.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up