diff --git a/examples/DCCInterface_TurntableControl/DCCInterface_TurntableControl.ino b/examples/DCCInterface_TurntableControl/DCCInterface_TurntableControl.ino index c4a815a..e9467a3 100644 --- a/examples/DCCInterface_TurntableControl/DCCInterface_TurntableControl.ino +++ b/examples/DCCInterface_TurntableControl/DCCInterface_TurntableControl.ino @@ -19,6 +19,9 @@ #include #include +// Define the Arduino input Pin number for the DCC Signal +#define DCC_PIN 2 + // The lines below define the pins used to connect to the A4988 driver module #define A4988_STEP_PIN 4 #define A4988_DIRECTION_PIN 5 @@ -243,8 +246,14 @@ void setupDCCDecoder() { Serial.println(F("Setting up DCC Decorder...")); - // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up - Dcc.pin(0, 2, 1); + // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up + // Many Arduino Cores now support the digitalPinToInterrupt() function that makes it easier to figure out the + // Interrupt Number for the Arduino Pin number, which reduces confusion. +#ifdef digitalPinToInterrupt + Dcc.pin(DCC_PIN, 0); +#else + Dcc.pin(0, DCC_PIN, 1); +#endif // Call the main DCC Init function to enable the DCC Receiver Dcc.init( MAN_ID_DIY, 10, CV29_ACCESSORY_DECODER | CV29_OUTPUT_ADDRESS_MODE, 0 ); diff --git a/examples/NmraDccAccessoryDecoder_1/NmraDccAccessoryDecoder_1.ino b/examples/NmraDccAccessoryDecoder_1/NmraDccAccessoryDecoder_1.ino index bd316bb..21d7a43 100644 --- a/examples/NmraDccAccessoryDecoder_1/NmraDccAccessoryDecoder_1.ino +++ b/examples/NmraDccAccessoryDecoder_1/NmraDccAccessoryDecoder_1.ino @@ -7,6 +7,9 @@ NmraDcc Dcc ; DCC_MSG Packet ; +// Define the Arduino input Pin number for the DCC Signal +#define DCC_PIN 2 + struct CVPair { uint16_t CV; @@ -98,8 +101,14 @@ void setup() Serial.println("NMRA DCC Example 1"); - // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up - Dcc.pin(0, 2, 1); + // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up + // Many Arduino Cores now support the digitalPinToInterrupt() function that makes it easier to figure out the + // Interrupt Number for the Arduino Pin number, which reduces confusion. +#ifdef digitalPinToInterrupt + Dcc.pin(DCC_PIN, 0); +#else + Dcc.pin(0, DCC_PIN, 1); +#endif // Call the main DCC Init function to enable the DCC Receiver Dcc.init( MAN_ID_DIY, 10, CV29_ACCESSORY_DECODER | CV29_OUTPUT_ADDRESS_MODE, 0 ); diff --git a/examples/NmraDccAccessoryDecoder_Pulsed_8/NmraDccAccessoryDecoder_Pulsed_8.ino b/examples/NmraDccAccessoryDecoder_Pulsed_8/NmraDccAccessoryDecoder_Pulsed_8.ino index 040a8b7..cc78237 100644 --- a/examples/NmraDccAccessoryDecoder_Pulsed_8/NmraDccAccessoryDecoder_Pulsed_8.ino +++ b/examples/NmraDccAccessoryDecoder_Pulsed_8/NmraDccAccessoryDecoder_Pulsed_8.ino @@ -18,6 +18,9 @@ // Un-Comment the line below to Enable DCC ACK for Service Mode Programming Read CV Capablilty //#define ENABLE_DCC_ACK 15 // This is A1 on the Iowa Scaled Engineering ARD-DCCSHIELD DCC Shield +// Define the Arduino input Pin number for the DCC Signal +#define DCC_PIN 2 + #define NUM_TURNOUTS 8 // Set Number of Turnouts (Pairs of Pins) #define ACTIVE_OUTPUT_STATE LOW // Set the ACTIVE State of the output to Drive the Turnout motor electronics HIGH or LOW @@ -118,8 +121,14 @@ void setup() { Serial.begin(115200); - // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up - Dcc.pin(0, 2, 1); + // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up + // Many Arduino Cores now support the digitalPinToInterrupt() function that makes it easier to figure out the + // Interrupt Number for the Arduino Pin number, which reduces confusion. +#ifdef digitalPinToInterrupt + Dcc.pin(DCC_PIN, 0); +#else + Dcc.pin(0, DCC_PIN, 1); +#endif // Call the main DCC Init function to enable the DCC Receiver Dcc.init( MAN_ID_DIY, DCC_DECODER_VERSION_NUM, CV29_ACCESSORY_DECODER, 0 ); diff --git a/examples/NmraDccMultiFunctionDecoder_1/NmraDccMultiFunctionDecoder_1.ino b/examples/NmraDccMultiFunctionDecoder_1/NmraDccMultiFunctionDecoder_1.ino index 76dc2b7..4046b60 100644 --- a/examples/NmraDccMultiFunctionDecoder_1/NmraDccMultiFunctionDecoder_1.ino +++ b/examples/NmraDccMultiFunctionDecoder_1/NmraDccMultiFunctionDecoder_1.ino @@ -1,5 +1,8 @@ #include +// Define the Arduino input Pin number for the DCC Signal +#define DCC_PIN 2 + struct CVPair { uint16_t CV; @@ -167,8 +170,14 @@ void setup() pinMode( DccAckPin, OUTPUT ); digitalWrite( DccAckPin, LOW ); - // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up - Dcc.pin(0, 2, 0); + // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up + // Many Arduino Cores now support the digitalPinToInterrupt() function that makes it easier to figure out the + // Interrupt Number for the Arduino Pin number, which reduces confusion. +#ifdef digitalPinToInterrupt + Dcc.pin(DCC_PIN, 0); +#else + Dcc.pin(0, DCC_PIN, 1); +#endif // Call the main DCC Init function to enable the DCC Receiver //Dcc.init( MAN_ID_DIY, 10, CV29_ACCESSORY_DECODER | CV29_OUTPUT_ADDRESS_MODE, 0 ); diff --git a/examples/NmraDccMultiFunctionMotorDecoder/NmraDccMultiFunctionMotorDecoder.ino b/examples/NmraDccMultiFunctionMotorDecoder/NmraDccMultiFunctionMotorDecoder.ino index 230d115..20b18f0 100644 --- a/examples/NmraDccMultiFunctionMotorDecoder/NmraDccMultiFunctionMotorDecoder.ino +++ b/examples/NmraDccMultiFunctionMotorDecoder/NmraDccMultiFunctionMotorDecoder.ino @@ -32,6 +32,7 @@ // This section defines the Arduino UNO Pins to use #ifdef __AVR_ATmega328P__ +// Define the Arduino input Pin number for the DCC Signal #define DCC_PIN 2 #define LED_PIN_FWD 5 @@ -42,6 +43,7 @@ // This section defines the Arduino ATTiny85 Pins to use #elif ARDUINO_AVR_ATTINYX5 +// Define the Arduino input Pin number for the DCC Signal #define DCC_PIN 2 #define LED_PIN_FWD 0 @@ -217,8 +219,14 @@ void setup() pinMode(MOTOR_PWM_PIN, OUTPUT); - // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up + // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up + // Many Arduino Cores now support the digitalPinToInterrupt() function that makes it easier to figure out the + // Interrupt Number for the Arduino Pin number, which reduces confusion. +#ifdef digitalPinToInterrupt Dcc.pin(DCC_PIN, 0); +#else + Dcc.pin(0, DCC_PIN, 1); +#endif Dcc.init( MAN_ID_DIY, 10, FLAGS_MY_ADDRESS_ONLY | FLAGS_AUTO_FACTORY_DEFAULT, 0 ); @@ -292,8 +300,8 @@ void loop() #ifdef DEBUG_FUNCTIONS Serial.println("LED On"); #endif - digitalWrite(LED_PIN_FWD, newDirection ? LOW : HIGH); - digitalWrite(LED_PIN_REV, newDirection ? HIGH : LOW); + digitalWrite(LED_PIN_FWD, newDirection ? HIGH : LOW); + digitalWrite(LED_PIN_REV, newDirection ? LOW : HIGH); } else { diff --git a/examples/NmraDcc_ARD_DCCSHIELD/NmraDcc_ARD_DCCSHIELD.ino b/examples/NmraDcc_ARD_DCCSHIELD/NmraDcc_ARD_DCCSHIELD.ino index 9a43221..dfa372d 100644 --- a/examples/NmraDcc_ARD_DCCSHIELD/NmraDcc_ARD_DCCSHIELD.ino +++ b/examples/NmraDcc_ARD_DCCSHIELD/NmraDcc_ARD_DCCSHIELD.ino @@ -26,6 +26,9 @@ // Un-Comment the line below to Enable DCC ACK for Service Mode Programming Read CV Capablilty #define ENABLE_DCC_ACK 15 // This is A1 on the Iowa Scaled Engineering ARD-DCCSHIELD DCC Shield +// Define the Arduino input Pin number for the DCC Signal +#define DCC_PIN 2 + NmraDcc Dcc ; struct CVPair @@ -101,8 +104,14 @@ void setup() Serial.println("NMRA DCC Iowa Scaled Engineering ARD-DCCSHIELD Example"); - // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up - Dcc.pin(0, 2, 1); + // Setup which External Interrupt, the Pin it's associated with that we're using and enable the Pull-Up + // Many Arduino Cores now support the digitalPinToInterrupt() function that makes it easier to figure out the + // Interrupt Number for the Arduino Pin number, which reduces confusion. +#ifdef digitalPinToInterrupt + Dcc.pin(DCC_PIN, 0); +#else + Dcc.pin(0, DCC_PIN, 1); +#endif // Call the main DCC Init function to enable the DCC Receiver Dcc.init( MAN_ID_DIY, 10, CV29_ACCESSORY_DECODER, 0 );