Please read the post at the start of any forum , entitled "How to use this Forum".
Can you please post a copy of your circuit please, not the circuit that is published, but a circuit drawn by you of YOUR project.
If you have any wiring problems, reverse engineering will probably find it.
How are you monitoring the outputs of the 23017?
Hi @TomGeorge ,
I am monitoring the outputs with LEDs and also i use an oscilloscope to visualize the outputs signals .
i didn't drew a circuit yet because i still looking for the solution i did the samething like in the github link. I can send you a picture of my circuit.
I tried with this sketch , i found it in the iDE exemples, the I2C scanner.
it seems that there is something wrong . the compilation is not finished it's blocked as you can see in the screenshoot!
here is the code that i used I added serial.print to see where the compilation is blocked
</>
< #include <Wire.h>
void setup() {
Serial.begin(19200);
Serial.println("before");
Wire.begin(); //creates a Wire object//Wake up i2c bus
Serial.println("Wake up i2c bus");
// set I/O pins to outputs
Wire.beginTransmission(0x20); //begins talking to the slave device// MCP23017 Adress
Serial.println("begins talking to the slave device");
Wire.write(0x00); //selects the IODIRA register
Serial.println("selects the IODIRA register");
Wire.write(0x00); //this sets all port A pins to outputs
Serial.println("set all port A pins to outputs");
//**********************//
Wire.endTransmission(); //stops talking to device
Serial.println("stop talking to device");
Serial.println("end stup");
}
void loop(){
Serial.println("begin loop");
Wire.beginTransmission(0x20); //starts talking to slave device
Serial.println("starts talking to slave device 2");
Wire.write(0x12); //selects the GPIOA pins
Serial.println("selects the GPIOA pins 2");
Wire.write((byte)0X01); // turns on pins 0 and 1 of GPIOA
Serial.println(" turns on pins 0 of GPIOA");
Wire.endTransmission(); //ends communication with the device
Serial.println("ends communication with the device 2");
Serial.println("end loop");
}
</>
The compilation stops here //***********************//
Hi,
Sorry no.
You leave the SDA and SCK wires connected as in the first image.
But connect one resistor between SDA and 5V, and another resistor between SCK and 5V.
#include <Wire.h>
void setup() {
Serial.begin(19200);
Serial.println(“before”);
Wire.begin(); //creates a Wire object//Wake up i2c bus
Serial.println(“Wake up i2c bus”);
// set I/O pins to outputs
Wire.beginTransmission(0x20); //begins talking to the slave device// MCP23017 Adress
Serial.println(“begins talking to the slave device”);
Wire.write(0x00); //selects the IODIRA register
Serial.println(“selects the IODIRA register”);
Wire.write(0x00); //this sets all port A pins to outputs
Serial.println(“set all port A pins to outputs”);
//**********************//
Wire.endTransmission(); //stops talking to device
Serial.println(“stop talking to device”);
Serial.println(“end stup”);
}
void loop(){
Serial.println(“begin loop”);
Wire.beginTransmission(0x20); //starts talking to slave device
Serial.println(“starts talking to slave device 2”);
Wire.write(0x12); //selects the GPIOA pins
Serial.println(“selects the GPIOA pins 2”);
Wire.write((byte)0X01); // turns on pins 0 and 1 of GPIOA
Serial.println(" turns on pins 0 of GPIOA");
Wire.endTransmission(); //ends communication with the device
Serial.println(“ends communication with the device 2”);
Serial.println(“end loop”);
}
i tried with both this code ysed the lib <wire .h> and I used also the lib adafruit_MCP23017 in an other code i'll send it
just tell me how should i put the code tags ?
Hi,
If you go to the IDE and select Edit ,then select Copy for Forum.
This will automatically copy your code to the clipboard with the needed tags.
Then you go to your post and just paste.
It should be in its own scrolling screen.
Hi,
Try this Adafruit library code I have edited.
It compiles but I have not run it.
It should make output 0 on the 23017 turn on and off each second, the UNO onboard LED should also flash with it.
#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)
// Connect pin #18 through a ~10kohm resistor to 5V (reset pin, active low)
// Input #0 is on pin 21 so connect a button or switch from there to ground
Adafruit_MCP23017 mcp;
int OnboardLED =13;
void setup() {
mcp.begin(); // use default address 0
mcp.pinMode(0, OUTPUT);
pinMode(OnboardLED, OUTPUT); // use the p13 LED as debugging
}
void loop() {
// The LED will 'echo' the output
// digitalWrite(13, mcp.digitalWrite(0));
mcp.digitalWrite(0,HIGH);
digitalWrite(OnboardLED,HIGH);
delay(1000);
mcp.digitalWrite(0,LOW);
digitalWrite(OnboardLED,LOW);
delay(1000);
}
Tom...
PS. Make sure you have the 4K7 resistors installed.