Go Down

Topic: How to change from standard to other digital input (Read 498 times) previous topic - next topic


May 25, 2013, 06:42 pm Last Edit: May 25, 2013, 06:57 pm by Midway Reason: 1
I like to use Digital input 9 and 10
but dont know how to change in this code

Code: [Select]

static boolean rotating=false;
void rotEncoder()
 rotating=true; // If motion is detected in the rotary encoder,
                // set the flag to true

void setup() {

 // Attach Interrupts
 attachInterrupt(0, rotEncoder, CHANGE);  // ISR for rotary encoder

void loop() {

   delay(2);  // debounce by waiting 2 milliseconds
              // (Just one line of code for debouncing)
   if (digitalRead(4) == digitalRead(2))  // CCW
   else                          // If not CCW, then it is CW

   rotating=false; // Reset the flag

Yes, i know.. but how ?...


The only two 'external' interrupts on the Arduino UNO are 0 and 1 on pins 2 and 3.

If you want to use other pins you will have to use Pin Change Interrupts.  You can find out more about them with Google.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up