How to use arduino leonardo board instead of uno board?

Sorry for bothering,
I can't execute following web example with arduino leonardo board(same circuit or code),

but I am sure the web example function ok with arduino uno board,
Any experiences or others 2.42 inch oled with arduino leonardo board for reference?
Thanks a lot.

Welcome to the forum

On the Uno the SDA/SCL pins are A4 and A5 but on the Leonardo they are on pins 2 and 3

See Wire - Arduino Reference

Excause me,the example SDA/SCL pins connect to digital 11 and digital 13,not A4 and A5 on Uno board,what is the work reason?

In that case the screen is using the SPI interface rather than the I2C interface

However, on the Leo the SPI pins (MISO, MOSI and SCK) are not on the pins along the edge of the board as they are on the Uno but are only on the 6 pin ICSP header

image

Sorry for bothering you,
Do you mean pin mapping as below?
panel side SDA pin connect to MOSI pin on ICSP header,
panel side SCL pin connect to SCK pin on ICSP header,
panel side RES pin connect to RST pin on ICSP header,
How about the CS pin and D/C pin?

I modify connection as below,but no show anything
SDA pin connect to MOSI pin on ICSP header,
SCL pin connect to SCK pin on ICSP header,
RES pin connect to digital pin 8,
CS pin connect to digital pin 10,
D/C pin connect to digital pin 9,

It sounds like you are really confused so let's try and simplify things

I2C pins
On the Uno these are on pins A4 and A5
On the official Uno R3 there are also pins labelled SDA and SCL which are connected to A4 and A5 on the board so you can use either

On the Leo these are on pins 2 and 3 and also on pins marked SDA and SCL which are connected to pins 2 and 3 on the board so you can use either

SPI pins
On the Uno these are on pins 11, 12, 13 and also on the ICSP 6 pin header. The pins on this header are connected to pins 11, 12 and 13 so you may use either

On the Leo the SPI pins are only on the ICSP header so you must use them

The Uno
image

The Leo

In order to use the display you need to know which type of interface that it uses (I2C or SPI) and connect its pins to the correct pins on the Arduino board.

Are the pins on the display labelled and, if so, what are the labels ?

1 Like

Sorry for bothering you,
please refer to attached file.

That is very confusing as there are references to both SPI and I2C interfaces

I suggest that you follow the wiring diagram shown in the page that you linked to, ie

except that when using the Leo you connect to the corresponding pins on the 6 pin ICSP header instead of those on the edge of the board.

I think that only 2 connections to the header are required. The one that went to pin 13 of the Uno (SCK) and the one that went to pin 11 (MOSI) . The others can stay where they are

Sorry for bothering,
I think that only 2 connections to the header are required. The one that went to pin 13 of the Uno (SCK) and the one that went to pin 11 (MOSI) . The others can stay where they are

Same as I previous connection,
SDA pin connect to MOSI pin on ICSP header,
SCL pin connect to SCK pin on ICSP header,
RES pin connect to digital pin 8,
CS pin connect to digital pin 10,
D/C pin connect to digital pin 9,
The screen doesn't have show anything.

In that case I am out of ideas

Are you absolutely sure that the screen that you have is the same one shown in the page that you linked to ? Your board seems to have no resistors in positions R3 and R5 but R4 is populated. This would seem to mean that it has an SPI interface. Are you sure that you are connecting to the correct pins on the ICSP header ?

Sorry for bothering,
1.The same module pin definition and the oled moduleI can execute linked example with arduino uno board(same circuit and code)
2.I'm not sure if the panel part number is the same,I use ZJY242S0700BG01.

Did you check this yourself?

Sorry for bothering,
Yes,it's normal function with the same circuit and code on arduino uno board.

Does your example or library use SS for CS?

// Map SPI port to 'new' pins D14..D17
#define PIN_SPI_SS    (17)
#define PIN_SPI_MOSI  (16)
#define PIN_SPI_MISO  (14)
#define PIN_SPI_SCK   (15)

static const uint8_t SS   = PIN_SPI_SS;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK  = PIN_SPI_SCK;

would be pin 17 for Leonardo.

@rick3 There is no need to keep apologising, although it is nice of you to do so

Those who provide help and advice on the forum do so voluntarily and are happy to do so


Thanks for your support,
Please refer to attach file.

Thanks for your support.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.