Audio Board + MCP23017

Status
Not open for further replies.

danixdj

Well-known member
Hi, i have a problem with my mcp23017 on i2c bus and Audio Board.

if sgtl5000_1.enable(); all the communication to MPC23017 are stopped.

Whitout this code sgtl5000_1.enable(); all works fine..

MCP ADDRESS:
_mcp1.begin(3);

What i must to do?

Thank you...

Dani
 
I have a pair of MCP23017s running with the audio board using the Adafruit_MCP23017 library. You can see a chunk of my code here. Post your code and we can take a look.
 
No sorry... now it works but only for 2/3 min and after all crash.

code:


#include <Adafruit_MCP23017.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>

// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=203,45
AudioAnalyzePeak peak1; //xy=437,54
AudioConnection patchCord1(i2s1, 0, peak1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=211,165
// GUItool: end automatically generated code

Adafruit_MCP23017 _left1;
Adafruit_MCP23017 _left2;

void setup() {

sgtl5000_1.enable();
AudioMemory(10);
sgtl5000_1.lineInLevel(0);

_left1.begin(7);
_left2.begin(6);
Wire.setClock(400000);
int k=0;
for(k=0;k<16;k++) { _left1.pinMode(k, OUTPUT); _left2.pinMode(k, OUTPUT);
_left1.digitalWrite (k, HIGH); _left2.digitalWrite (k, HIGH);}

}

void loop() {


if (peak1.available()) {
leftpeak = peak1.read() *40;
if (leftpeak < 16 && leftpeak > 0) { int i = 0;
for(i=0;i<leftpeak;i++) {
_left1.digitalWrite (leftpeak-1, LOW);}}
else {int k=0; for(k=0;k<16;k++) { _left1.digitalWrite (k, HIGH);}}}
}
 
Formatted for readability

Code:
#include <Adafruit_MCP23017.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>

// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=203,45
AudioAnalyzePeak peak1; //xy=437,54
AudioConnection patchCord1(i2s1, 0, peak1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=211,165
// GUItool: end automatically generated code

Adafruit_MCP23017 _left1;
Adafruit_MCP23017 _left2;

void setup() { 
	sgtl5000_1.enable();
	AudioMemory(10);
	sgtl5000_1.lineInLevel(0);

	_left1.begin(7); 
	_left2.begin(6); 
	Wire.setClock(400000);
	
	int k=0;
	for(k=0;k<16;k++) {
		_left1.pinMode(k, OUTPUT);
		_left2.pinMode(k, OUTPUT); 
		_left1.digitalWrite (k, HIGH);
		_left2.digitalWrite (k, HIGH);
	} 

}

void loop() {
	if (peak1.available()) {
		leftpeak = peak1.read() *40;
		if (leftpeak < 16 && leftpeak > 0) {
			int i = 0;
			for(i=0;i<leftpeak;i++) {
				_left1.digitalWrite (leftpeak-1, LOW);
			}
		} else {
			int k=0; 
			for(k=0;k<16;k++) { 
				_left1.digitalWrite (k, HIGH);
			}
		}
	}
}
 
Solved!!

I must to soldering fiscally also the GND on the address pin of MCP, not only +3V.. i don't now why...
Now all works fine! :)
 
Status
Not open for further replies.
Back
Top