riccardo
Member
Hello,
I am having a problem using an MCP45HVX1 digital pot and a common SH1106 OLED display together on the same bus.
Using an Arduino; If I talk to the display, sometimes the POT will glitch, and if I talk to the POT, the screen gets messed up.
Below is a simple sketch which should slowly turn up the pot resistance value, and display the value on the OLED display.
As it is, the screen shows the incrementing number up until about 60 when it starts bouncing around and eventually becomes just a line and goes blank. THe POT resistance remains at the minimum apart from a few small glitches.
If i comment out the just POT related code, I get the same result.
If i comment out the just Screen related code, the pot resistance changes just fine, but occasionally the display will go all white, or staart flashing.
Apart from physically disconnecting one device from the bus while the other is written, Is there a wa to have these two items working together on the same bus?
I am having a problem using an MCP45HVX1 digital pot and a common SH1106 OLED display together on the same bus.
Using an Arduino; If I talk to the display, sometimes the POT will glitch, and if I talk to the POT, the screen gets messed up.
Below is a simple sketch which should slowly turn up the pot resistance value, and display the value on the OLED display.
C:
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
int value = 0;
char displayStr[25]; // Text output buffer
void setup(void) {
u8g2.begin();
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_5x8_tf);
Wire.begin();
pinMode(42, OUTPUT);
digitalWrite(42, HIGH); // Connect Wiper
}
void loop(void) {
sprintf(displayStr, " Value %i ", value);
u8g2.drawStr(0, 8, displayStr); // Display Text: X(pixels[0-127]), Y(lines[0-7)
u8g2.sendBuffer(); // transfer internal memory to the display
delay(100);
Wire.beginTransmission(0x3C); // transmit to POT_ADDRESS
delayMicroseconds(10);
Wire.write(0x00); // Select wiper register
delayMicroseconds(10);
Wire.write(value); // sends POT value bytes
delayMicroseconds(10);
Wire.endTransmission(); // stop transmitting
value++;
delay(100);
}
As it is, the screen shows the incrementing number up until about 60 when it starts bouncing around and eventually becomes just a line and goes blank. THe POT resistance remains at the minimum apart from a few small glitches.
If i comment out the just POT related code, I get the same result.
If i comment out the just Screen related code, the pot resistance changes just fine, but occasionally the display will go all white, or staart flashing.
Apart from physically disconnecting one device from the bus while the other is written, Is there a wa to have these two items working together on the same bus?