Go Down

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

majenko

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.

lost_and_confused

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.


majenko

Code: [Select]

./libraries/Adafruit_MCP23017
./libraries/Adafruit_MCP23017/README.txt
./libraries/Adafruit_MCP23017/license.txt
./libraries/Adafruit_MCP23017/Adafruit_MCP23017.cpp
./libraries/Adafruit_MCP23017/keywords.txt
./libraries/Adafruit_MCP23017/examples
./libraries/Adafruit_MCP23017/examples/button
./libraries/Adafruit_MCP23017/examples/button/button.pde
./libraries/Adafruit_MCP23017/examples/toggle
./libraries/Adafruit_MCP23017/examples/toggle/toggle.pde
./libraries/Adafruit_MCP23017/Adafruit_MCP23017.h

lost_and_confused

Majenko,

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.


majenko

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.

dxw00d

#35
Jul 27, 2012, 12:48 pm Last Edit: Jul 27, 2012, 12:55 pm by dxw00d Reason: 1
Quote
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:

lost_and_confused

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


sketch:

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()
{
  delay(100);

  mcp.digitalWrite(0, HIGH);

  delay(100);

  mcp.digitalWrite(0, LOW);
}


I'm open to what is going on.

lost_and_confused

Thanks,

That is the problem.

Standby for updates on what is now happening.


lost_and_confused

Update:

Sketch runs.

No output from MCP output pin 0.


majenko

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

lost_and_confused

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.


lost_and_confused

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.

Hurray.

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


lost_and_confused

Majenko:

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.

Grumpy_Mike

Quote
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);


lost_and_confused

Yeah, ok, I walked into that.

But that is pin 21.

That is about the .....

AARRGGHH!

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