Getting a compile error trying to use pins D18 and D19 on R4

Hi all, hoping someone can set me straight...

at the top of my code/project, I have a list of pins looking like

#define Pin_IN_cruise_resume       D2
#define Pin_IN_cruise_release       D3
.......
#define Pin_OUT_regen_brake       D12 
........
#define Pin_IN_dir_reverse             D18
#define Pin_IN_dir_forward            D19

all the same syntax and all that.

Then I set all of the input-pins up with

    pinMode(Pin_IN_cruise_resume,  INPUT_PULLUP);
    pinMode(Pin_IN_cruise_release,   INPUT_PULLUP);
......    
    pinMode(Pin_IN_dir_reverse,    INPUT_PULLUP);
    pinMode(Pin_IN_dir_forward,    INPUT_PULLUP);

again, all the same idea, all the same format. Somehow, the compiler likes everything except the last 2 pins D18 and D19. It says they do not exist
C:\Users....\Documents\Arduino\Myproject.ino:63:35: error: 'D18' was not declared in this scope

What am I doing wrong on D18 and D19 that I'm somehow doing right on D2 and D3? The board layout jpg shows these pins as D18 and D19? When I name them SCA and SCL (what's printed on the connector), same error.

Thanks a bunch...

I'm not familiar with your board. Have you tried to use A4 (for D18) and A5 (for D19) ?

on the R4 (and I thought on all UNO's but could be off), A4 and A5 are at the end of the shorter analog connector. D18 and D19 are on the long connector, all the way at the other end. It goes ......D11, D12, D13, GND, AREF, D18, D19.

Maybe my error is that A4/A5 are actually hard-wired into those two digital pins as well? That would be tough cuz I need 2 more pins...

Look at pins_arduino.h for this variant. Indeed pins A4 and A5 are wired to SDA and SDL. Also, there are no defines for D18 and D19.

#define WIRE_SDA_PIN      18 /* A4 */
#define WIRE_SCL_PIN      19 /* A5 */

You get interesting results if you print the value of SDA and SCL

18 for both

WIRE_SDA_PIN and WIRE_SCL_PIN output the expect the expected 18 and 19 values

Weird

More like an error in a #define in the core code for the board. Works OK for a Nano classic, of course

1 Like
1 Like

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