setup is a classic 16x2 LCD with i2c module run off a Raspberry Pico and have failed at understanding how to set the gpio 4 and 5 as SDC and SCL using the Arduino ide.
every example and video I have found is in python and they set a value to the pins but I have no idea what function it is for Arduino ide and the syntax for that.
secondly the 3.3v will be enough to set the SDC and SCL lines? I can power the display from the 5v
to have a bright display but do the SDC and SCL have to be logic converted to 5v for the lcd?
There are LCD displays for 3.3V, that will be easier.
A 5V LCD display needs to be powered with 5V. It has probably pullup resistors from SDA to 5V and from SCL to 5V.
In the schematic of Adafruit for the I2C backpack module, they use are 4k7 pullup resistors.
That means that a current from 5V via the 4k7 flows into SDA and SCL. Since the Raspberry Pi Pico does not have 5V tolerant pins, you need a I2C level shifter.
After strugling I finally discovered, thanks to this post, that SCL0 and SDA0 on Pico are GPIO 5 and 4.
And I made my OLED 128x64 worked with U8g2 library, using Arduino IDE 1.0.
And the following i2c sniffer code that searches addresses:
#include <Wire.h> //include Wire.h library
void setup()
{
Wire.begin(); // Wire communication begin
Wire.setClock(100000);
Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
while (!Serial); // Waiting for Serial Monitor
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address; //variable for error and I2C address
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for (address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
else if (error == 4)
{
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for the next I2C scan
}