Hi, I'm using an arduino uno and a mpc23017 IC@ bus and I'm having a problem with other libraries, namely Serial and the function delay.
Ive been using the code from Tutorial: Arduino and the I2C bus – Part Two | tronixstuff.com
ive noticed when i insert delay into the loop it fails to write, otherwise all i see is the rapid changeing of the leds.
Debugging is also hard because i cant get serial print to work, or keep led13 on for an appreciable amount of time.
note that i've been using Serial successfully otherwise(@115200 baud)
note that delay is only used before wire.begin or after, not during transmission.
is there any know conflictions between delay() and IC2 protocol, or for that matter, Serial output to the PC?
/*
Example 41.1 - Microchip MCP23017 with Arduino
http://tronixstuff.com/tutorials > chapter 41
John Boxall | CC by-sa-nc
*/
// pins 15~17 to GND, I2C bus address is 0x20
#include "Wire.h"
void setup()
{
Wire.begin(); // wake up I2C bus
// set I/O pins to outputs
Wire.beginTransmission(0x20);
Wire.write(0x00); // IODIRA register
Wire.write(0x00); // set all of port A to outputs
Wire.endTransmission();
pinMode(13,OUTPUT);
}
void loop()
{
Wire.beginTransmission(0x20);
Wire.write(0x12); // GPIOA
Wire.write(16); // port A
Wire.endTransmission();
//delay(500); causes failure
}
i'm a new to IC2, and probably missed the obvious=)
thanks
there is also no Serial.println, this code is for testing delay();
Serial.println is not as important to me as delay();
feel free to move this to Programming Questions if this is a clash in the libraries and not a fundamental misunderstanding of IC2 or of the "Wire".library.
if it's the latter scenario, i'm all ears!
i have two 10k resistor is the place of each 4.7k
Edit,
i have them disconnected from 5v because when they are biased, the chip will not change state
Edit
i have reset connected to pin 13 which shows as being always on. (LED)
how is this different from 5v? (unless of course wire uses that pin for something?)
this code makes the leds run through a cycle, nearly too fast to see, and then waits for .5 sec.
/*
Example 41.1 - Microchip MCP23017 with Arduino
http://tronixstuff.com/tutorials > chapter 41
John Boxall | CC by-sa-nc
*/
// pins 15~17 to GND, I2C bus address is 0x20
#include "Wire.h"
void setup()
{
Wire.begin(); // wake up I2C bus
// set I/O pins to outputs
Wire.beginTransmission(0x20);
Wire.write(0x00); // IODIRA register
Wire.write(0x00); // set all of port A to outputs
Wire.endTransmission();
Wire.beginTransmission(0x20);
Wire.write(0x01); // IODIRB register
Wire.write(0x00); // set all of port B to outputs
Wire.endTransmission();
}
void binaryCount()
{
for (byte a=0; a<256; a++)
{
Wire.beginTransmission(0x20);
Wire.write(0x12); // GPIOA
Wire.write(a); // port A
Wire.endTransmission();
Wire.beginTransmission(0x20);
Wire.write(0x13); // GPIOB
Wire.write(a); // port B
Wire.endTransmission();
}
}
void loop()
{
binaryCount();
delay(500);
}