How do you do this? I've been digging around and I can see that I should do this and supply my own external pull up resistors but I don't know exactly how to disable them. The pages I've been reading never explicity state how.
I'm trying to enable I2C between a leonardo and an uno, but I think the i2c bus is slowing down considerably because of the internal pullups. I want to switch to two 4.7k resistors but I can't figure out how to disable the internal ones. I know that the Wire library enables the internals by default, but how do I edit the library or disable the pullups in my sketch?
Maybe I just haven't been reading the right forums or articles, but if anyone could point me in the right direction that would be much appreciated.
EDIT: So the problem is probably with my setup or code, I'll put it down here. Everything I have before setup is importing libraries and variables like my mac, ip, placeholders for output, pwm, etc.
Master:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
while(!Serial){
}
Wire.begin();
Ethernet.begin(mac, ip);
delay(1000);
server.begin();
if(server.available()){
Serial.println("Client Available");
}
}
void loop() {
// put your main code here, to run repeatedly:
ethernetwrite();
}
void ethernetwrite() {
EthernetClient client = server.available();
while(client) {
if(client.find("P")) {
output = client.parseInt();
pwm = client.parseInt();
Serial.println("Begin Transmitting");
Wire.beginTransmission(14);
Wire.write(output);
Wire.write('\t');
Wire.write(pwm);
Wire.endTransmission();
Serial.println("Done Transmitting");
Serial.print(output);
Serial.print('\t');
Serial.println(pwm);
}
}
}
Slave:
void setup() {
Wire.begin(14);
Wire.onReceive(wirewrite);
// * - Base frequencies:
// * o The base frequency for pins 3, 9, 10, and 11 is 31250 Hz.
// * o The base frequency for pins 5 and 6 is 62500 Hz.
// * - Divisors:
// * o The divisors available on pins 5, 6, 9 and 10 are: 1, 8, 64,
// * 256, and 1024.
// * o The divisors available p1on pins 3 and 11 are: 1, 8, 32, 64,
// * 128, 256, and 1024.
// Leg 1
pinMode(leg[1], OUTPUT); setPwmFrequency(leg[1],8); analogWrite(leg[1], offset);
// Leg 2
pinMode(leg[2], OUTPUT); setPwmFrequency(leg[2],8); analogWrite(leg[2], offset);
// Leg 3
pinMode(leg[3], OUTPUT); setPwmFrequency(leg[3],8); analogWrite(leg[3], offset);
// Leg 4
pinMode(leg[4], OUTPUT); setPwmFrequency(leg[4],8); analogWrite(leg[4], offset);
// Mirror
pinMode(leg[0], OUTPUT); setPwmFrequency(leg[0],clkdivisor); analogWrite(leg[0], 255);
}
void loop() {
int time = 10;
time = time*128/clkdivisor;
// box(time, 255, 1); // box(delay time, radius pwm, pwm step size);
// autodisplay();
updateL();
}
void updateL(){
if (output == 0) pwm = 255 - pwm;
switch (output) {
case 1: pin = 3; break;
case 2: pin = 9; break;
case 3: pin = 10; break;
case 4: pin = 11; break;
case 0: pin = 5; break;
}
//if (output < 5) {
analogWrite(pin, pwm);
//}
}
void wirewrite(int numBytes) {
String message;
while(Wire.available()>0) {
char c = Wire.read();
message.concat(c);
}
output = Wire.parseInt();
pwm = Wire.parseInt();
}
When I send data to the master, on the serial monitor it freezes in the first wiring transmission or in the next few, and my slave doesn't seem to respond to the message being sent over i2c. My controls for my device and setup worked prior to my attempts with the Wire library, so there's no problem there.
EDIT: I also am sending a message that looks like this: "P1 103" every .4 seconds or so, but I usually can't get past the first transmission between the arduinos
I think the i2c bus is slowing down considerably because of the internal pullups
; I2C is clocked, so it's speed is not dependent on the external resistor. You have to set the I2C clock to a higher frequency, if you want more speed.I think the i2c bus is slowing down considerably because of the internal pullups
- no, it isn't.if anyone could point me in the right direction that would be much appreciated
- if you could post your code that would be much appreciated.