Go Down

Topic: I2C bus "problems" (Read 8278 times) previous topic - next topic


I just installed the library into my arduino/libraries folder, and selected toggle from the examples->adafruit-blah-blah->toggle menu entry.

Compiled first time.


Because I am an idiot - been told enough times - where in the libraries directory did you put them?
I had to mess about putting them in the adafruit_mcp23017 directory.


Code: [Select]




Ok, I did get the name of the directory in the libraries right.

Copied all the files from the archive to there and in the "toggle" directory copied the file and renamed the copy .ino

Ran the IDE and complied.

Same error.

Maybe 'puta need a reboot.


It sounds like there is a second copy of the example sketch being loaded from somewhere somehow.

Maybe you have left something lying around somewhere where it shouldn't be.


Jul 27, 2012, 12:48 pm Last Edit: Jul 27, 2012, 12:55 pm by dxw00d Reason: 1
copied the file and renamed the copy .ino

Are you saying you now have a .pde and a .ino? Check the tabs in the IDE when you open the example - Are there two toggle tabs? The IDE will open both if they are present.

Edit: like this:


Just rebooted machine.

SAME error.

Code: [Select]

toggle:50: error: redefinition of 'Adafruit_MCP23017 mcp'
toggle:14: error: 'Adafruit_MCP23017 mcp' previously declared here
toggle.cpp: In function 'void setup()':
toggle:52: error: redefinition of 'void setup()'
toggle:16: error: 'void setup()' previously defined here
toggle.cpp: In function 'void loop()':
toggle:61: error: redefinition of 'void loop()'
toggle:26: error: 'void loop()' previously defined here


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 #0 is on pin 21 so connect an LED or whatever from that to ground

Adafruit_MCP23017 mcp;
void setup()

  mcp.begin();      // use default address 0

  mcp.pinMode(0, OUTPUT);

// flip the pin #0 up and down

void loop()

  mcp.digitalWrite(0, HIGH);


  mcp.digitalWrite(0, LOW);

I'm open to what is going on.



That is the problem.

Standby for updates on what is now happening.



Sketch runs.

No output from MCP output pin 0.


Ok, and have you got the MCP wired up as it details in the top of that sketch?


Kind of glad I checked again.

Pin 21!

For pete's sake!  Why not pick a more abstract pin.

I didn't design the board with access to pin 21 of the MCP.

I have wires on pins 1, 2 and 3.

Running the centipede sketch again, it is interesting that PIN ONE has gone high - but isn't going LOW.

(Oooops.  Just looked at multi-metre.  it has gone low.)

Go figure.


And another update:

After digging the board out and getting to pin 21:
(the results please.)

And slightly increasing the delay values to a better value....

The pin levels toggle.


I shall now implement the sketch into my sketch if I can.



I shall have to do a lot of reading about those libraries.

How do I set what pins do what?

I can't see any setup stuff in it to tell it what pin does what.


I can't see any setup stuff in it to tell it what pin does what.

how about this line in your previously posted code
Code: [Select]
mcp.pinMode(0, OUTPUT);


Yeah, ok, I walked into that.

But that is pin 21.

That is about the .....


Stupid me!

I was reading port B as A and so from the get go, I was looking at the wrong pin for output!

Stand by!

Go Up