Pages: [1]   Go Down
Author Topic: How to change from standard to other digital input  (Read 209 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 46
I just want to learn more :)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I like to use Digital input 9 and 10
but dont know how to change in this code

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 ?...
« Last Edit: May 25, 2013, 11:57:03 am by Midway » Logged

Massachusetts, USA
Offline Offline
Tesla Member
Karma: 212
Posts: 8966
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: