Arduino Uno stops transmitting once rotary encoder is plugged in

I have a 5-24V rotary encoder I'm trying to get working for a sim racing wheel. Whenever I only have the 2 phase hooked up to D2 & D3 pins the arduino "works" (obv it's not getting any actually reading but it will send stuff through serial). However if I plug the rotary encoder in to 5v and grd then it just stops transmitting and I don't understand why. I don't have anything else connected to the board at all.

To be sure, please post a wiring diagram, and code unless You have crystall balls to send us.

Here is the code

/*     Arduino Rotary Encoder Tutorial
 *  by Dejan Nedelkovski,
 #define outputA 2
 #define outputB 3
 int counter = 0; 
 int aState;
 int aLastState;  
 void setup() { 
   pinMode (outputA,INPUT);
   pinMode (outputB,INPUT);
   Serial.begin (9600);
   // Reads the initial state of the outputA
   aLastState = digitalRead(outputA);   
 void loop() { 
   aState = digitalRead(outputA); // Reads the "current" state of the outputA
   // If the previous and the current state of the outputA are different, that means a Pulse has occured
   if (aState != aLastState){     
     // If the outputB state is different to the outputA state, that means the encoder is rotating clockwise
     if (digitalRead(outputB) != aState) { 
       counter ++;
     } else {
       counter --;
     Serial.print("Position: ");
   aLastState = aState; // Updates the previous state of the outputA with the current state

I'm not sure how to make it look fancy like I've seen in other picture but here is the diagram I drew up in paint

Sounds like the encoder is wired incorrectly and it is only 'transmitting' when not connected because the inputs are left floating. Check your wiring. I suspect there is a mistake. Of course without knowing what encoder you have and how it is wired I can't say what the mistake is.

I have this encoder if that helps. By check the wiring do you mean like crack it open and make sure nothing is like shorted or disconnected?

Not even the pull up resistors, as explained in the comments on the Amazon page?

If I change the INPUT to INPUT_PULLOUT it still doesn't work

How does your wiring compare to the description:

Wiring Output:
A phase, B phase, Vcc positive supply, V0, the shield wire.
Green = A phase, white = B phase, red = power +, black = V0
Note: AB two -phase outputs must not be connected directly to VCC, otherwise, they will burn the output transistor.
AB two -phase quadrature output rectangular pulse, the circuit output is NPN open collector output type ,the output of this type can and with additonal added pull-up resistor(not included) is directly connected MCU or PLC, such as 51 single or Mitsubishi PLC (PLC input mode should be connected to 0V switch function ).
If the encoder is not connected to the device can not be directly connected to oscilloscope ( open collector output without pull-up resistor when there is no voltage output) If you want the oscilloscope in AB two-phase output, work with two pull-up resistors(not included).

Okay I think I just don't understand how digital pull-ups work. I thought they could replace pullup resistors but whenever I put in pull up resistors in it works so thanks!

The internal pullups are like 35K to 50K, very weak.
10K external pullups down to maybe 1K are much better for a reliable signal.


If I change the INPUT to INPUT_PULLOUT it still doesn’t work

Think you mean


A circuit diagram would have helped.

Tom... :smiley: :+1: :coffee: :australia:

Run this sketch and Tools->SerialPlotter. The upper trace is OutputA and the lower trace is OutputB. They should produce pulses that are 90° out of phase (the edges on one channel should be in the middle of a pulse on the other). If a trace is flat when you turn the shaft, your connection is bad.

#define outputA 2
#define outputB 3

void setup()

  pinMode (outputA, INPUT);
  pinMode (outputB, INPUT);

void loop()
  Serial.print(digitalRead(outputA) + 2);
  Serial.print(' ');
1 Like

Perhaps he was thinking of a means of contraception? :rofl:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.