More problems with #define

I have a pins header file "pins.h", but the interpreter?? is not substituting the #define statements.
in my main.ino file one of the first lines is:
#include "pins.h" // therefore all of my pin_names are now GLOBOL
```` //Pin Names #define RST_1 13 #define RST_2 12 #define CE_1 11 #define CE_2 10 #define CLK_1 9 #define CLK_2 8 #define RD_1 7 #define RD_2 6 #define SCL 3 #define SDA 2 #define txPin 1 #define rxPin 0 //Pin Modes pinMode(rxPin, INPUT); pinMode(txPin, OUTPUT); // Digital Ports pinMode(RST_1, OUTPUT); pinMode(RST_2, OUTPUT); pinMode(CE_1, OUTPUT); pinMode(CE_2, OUTPUT); pinMode(CLK_1, OUTPUT); pinMode(CLK_2, OUTPUT); pinMode(RD_1, OUTPUT); pinMode(RD_2, OUTPUT); `````` I get this error: error: expected constructor, destructor, or type conversion before '(' token pinMode(RD_1, OUTPUT); on all of my defines.

Please use Code Tags </> or Blockquote to preserve line endings.

1 Like

'pinMode()' is a function call, not a declaration. You can't put a function call outside a function. The 'pinMode()' calls are typically put in your 'setup()' function.

//Pin Modes 
pinMode(rxPin, INPUT); 
pinMode(txPin, OUTPUT); 
// Digital Ports 
pinMode(RST_1, OUTPUT); 
pinMode(RST_2, OUTPUT); 
pinMode(CE_1, OUTPUT); 
pinMode(CE_2, OUTPUT); 
pinMode(CLK_1, OUTPUT); 
pinMode(CLK_2, OUTPUT); 
pinMode(RD_1, OUTPUT); 
pinMode(RD_2, OUTPUT); 

Put all the above within setup()

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