If the value of DT and CLK (pin interrupt of Arduino Uno) is the same, then the 'encoder0Pos' variable will be incremented / added, in addition to that condition, the 'encoder0Pos' variable is decremented. Finally, many of these rotary encoders come with a centre push button, which can be used to select menu items, reset a counter or do anything you can think of that might suit a momentary push button.
2 Bit ,2 steps over,096 revolutions - Code: Binary. Contoh Program Rotary Encoder Download The dual direction makes them useful for increasing or decreasing a value within a variable or navigating menus. In the 'doEncoder' function is calculated from the rotary encoder. Main Features - Compact and heavy-duty industrial model - Interface: CAN according to CAL - Housing: 8 mm - Shaft: 6 or 0 mm - Resolution: Max. In line 10 of the sketch above is used to enable the interrupt of pin 2 Arduino Uno. If (digitalRead(encoder0PinA) = digitalRead(encoder0PinB)) #define encoder0PinA 2 #define encoder0PinB 3
In the following tutorial, which will be used as an interrupt is PIN 2 of Arduino Uno, while PIN 3 is only used as a regular input.