Post Offer Free
Oky Newstar Technology Co., Ltd
Oky Newstar Technology Co., Ltd  

Gold Index: 7733

You are here: home  > Sensors for Arduino  > Magnetic Rotary Encoder Module for Arduino With Demo Code

Magnetic Rotary Encoder Module for Arduino With Demo Code 

Place of Origin: Guangdong, China (Mainland) 
inquire
Add to My Favorites
HiSupplier Escrow
Share |

Product Detail

Model No.: Rotary encoder module


 
 
 
<st

 

 

 

Magnetic Rotary Encoder Module for Arduino With Demo Code

Rotary encoder module for arduino with demo code

 

 

Specifications:

 

Rotary encoder can be counted by rotating forward and reverse direction during rotation of the output pulse frequency,
Unlike counter rotating potentiometer, this rotation counts are not limited.
With the buttons on the rotary encoder can be reset to its initial state, that starts counting from 0.

 


******************
ARDUINO test code:
const int interruptA = 0; / / Interrupt 0 (pin 2)
const int interruptB = 1; / / Interrupt 1 (pin 3)

int CLK = 2; / / PIN2
int DAT = 3; / / PIN3
int BUTTON = 4; / / PIN4
int LED1 = 5; / / PIN5
int LED2 = 6; / / PIN6
int COUNT = 0;

void setup ()
  {
   attachInterrupt (interruptA, RoteStateChanged, FALLING);
  / / AttachInterrupt (interruptB, buttonState, FALLING);
   pinMode (CLK, INPUT);
   digitalWrite (2, HIGH); / / Pull High Restance
   pinMode (DAT, INPUT);
   digitalWrite (3, HIGH); / / Pull High Restance
   pinMode (BUTTON, INPUT);
   digitalWrite (4, HIGH); / / Pull High Restance
   pinMode (LED1, OUTPUT);
   pinMode (LED2, OUTPUT);
    Serial.begin (9600);
  }

void loop ()
{
   if (! (digitalRead (BUTTON)))
     {
      COUNT = 0;
      Serial.println ("STOP COUNT = 0");
      digitalWrite (LED1, LOW);
      digitalWrite (LED2, LOW);
      delay (2000);
     }
      Serial.println (COUNT);
}

/ / -------------------------------------------
void RoteStateChanged () / / When CLK FALLING READ DAT
{
  if (digitalRead (DAT)) / / When DAT = HIGH IS FORWARD
    {
     COUNT;
     digitalWrite (LED1, HIGH);
     digitalWrite (LED2, LOW);
     delay (20);
    }
  else / / When DAT = LOW IS BackRote
    {
     COUNT -;
     digitalWrite (LED2, HIGH);
     digitalWrite (LED1, LOW);
     delay (20);
    }
}

 

 

Competitive Advantage:

 

1. Convenient & Friendly Customer Service
2. Low Prices Direct From Factory Suppliers
3. Fast Delivery Around the World. 
4. High Quality With Global Standards. 
5. 1 Year Factory Warranty
6. Safe Shipping Way and Payment

 

bigPhoto
 Ms. Erica Teng

Tel: 86-755-23578860
Contact to this supplier

Related Search

Find more related products in following catalogs on Hisupplier.com

Company Info

Oky Newstar Technology Co., Ltd [China (Mainland)]


Business Type:Manufacturer
City: Shenzhen
Province/State: Guangdong
Country/Region: China (Mainland)

You May Like: