Pages: 1 2 [3] 4   Go Down
Author Topic: I2C bus "problems"  (Read 2869 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
./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
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:


* tabs.jpg (41.58 KB, 242x222 - viewed 12 times.)
« Last Edit: July 27, 2012, 05:55:17 am by dxw00d » Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just rebooted machine.

SAME error.

Code:
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:
#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.
Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,

That is the problem.

Standby for updates on what is now happening.

Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Update:

Sketch runs.

No output from MCP output pin 0.

Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 619
Posts: 33966
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
mcp.pinMode(0, OUTPUT);

Logged

Oz
Offline Offline
God Member
*****
Karma: 4
Posts: 727
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!

Logged

Pages: 1 2 [3] 4   Go Up
Jump to: