user28706: My question is related to my previous question.
These encoder programs outputs two line per pule/tick.
Here is the part of the code I want to use:
void loop()
{
    // Read the status of the inputs
    debouncerA.update();
    debouncerB.update();

    int8_t EncVariation = 0;

    if (debouncerA.rose())
    { // if input A changed from low to high, it was CW if B is high too
        EncVariation = (debouncerB.read()) ? 1 : -1;
    }
    else if (debouncerA.fell())
    { // if input A changed from high to low, it was CW if B is low too
        EncVariation = (debouncerB.read()) ? -1 : 1;
    }
    else if (debouncerB.rose())
    { // if input B changed from low to high, it was CCW if A is high too
        EncVariation = (debouncerA.read()) ? -1 : 1;
    }
    else if (debouncerB.fell())
    { // if input B changed from high to low, it was CCW if B is low too
        EncVariation = (debouncerA.read()) ? 1 : -1;
    }
//
  if (EncVariation != 0) {

        encoder0Pos = encoder0Pos + EncVariation;

        int degs = (encoder0Pos * 6) % 360 ;

        if(degs<0){ degs = 360 + degs; }

        Serial.println (degs);
   }
}

For three inputs/ticks this outputs like:
6
12 
18
24
30
36
But I only need the second ones like:
12
24
36
How can I do that?
(I need it to send the relevant data do a PC.)
I spend so long time on it couldnt find any solution.

user10394: IF and only IF you want exactly what you have asked for which is alternate lines not to be output then this is a very crude and quick solution.
Outside of loop() add this declaration:
bool skipNextLine = true;  // true skips the odd lines, false skips even lines

And change the end of your code like this:
  if (EncVariation != 0) {
    encoder0Pos = encoder0Pos + EncVariation;
    int degrees = (encoder0Pos * 6) % 360 ;
    if(degrees<0){ deg = 360 + degs; }
    if (!skipNextLine)
    {  // This will skip alternate lines
        Serial.println (deg);
        skipNextLine = true;
    }
    else
    {
        skipNextLine = false;
    }
  }


28706: <p>My question is related to my previous <a href="https://arduino.stackexchange.com/questions/33607/problem-to-convert-rotary-encoder-output-to-angle">question</a>.
These encoder programs outputs two line per pule/tick.</p>

<p>Here is the part of the code I want to use:</p>

<pre><code>void loop()
{
    // Read the status of the inputs
    debouncerA.update();
    debouncerB.update();

    int8_t EncVariation = 0;

    if (debouncerA.rose())
    { // if input A changed from low to high, it was CW if B is high too
        EncVariation = (debouncerB.read()) ? 1 : -1;
    }
    else if (debouncerA.fell())
    { // if input A changed from high to low, it was CW if B is low too
        EncVariation = (debouncerB.read()) ? -1 : 1;
    }
    else if (debouncerB.rose())
    { // if input B changed from low to high, it was CCW if A is high too
        EncVariation = (debouncerA.read()) ? -1 : 1;
    }
    else if (debouncerB.fell())
    { // if input B changed from high to low, it was CCW if B is low too
        EncVariation = (debouncerA.read()) ? 1 : -1;
    }
//
  if (EncVariation != 0) {

        encoder0Pos = encoder0Pos + EncVariation;

        int degs = (encoder0Pos * 6) % 360 ;

        if(degs&lt;0){ degs = 360 + degs; }

        Serial.println (degs);
   }
}
</code></pre>

<p>For <strong>three</strong> inputs/ticks this outputs like:</p>

<p>6</p>

<p>12 </p>

<p>18</p>

<p>24</p>

<p>30</p>

<p>36</p>

<p>But I only need the second ones like:</p>

<p>12</p>

<p>24</p>

<p>36</p>

<p>How can I do that?
(I need it to send the relevant data do a PC.)</p>

<p>I spend so long time on it couldnt find any solution.</p>
 10394: <p><em>IF</em> and only IF you want exactly what you have asked for which is alternate lines not to be output then this is a very crude and quick solution.</p>

<p>Outside of <code>loop()</code> add this declaration:</p>

<pre><code>bool skipNextLine = true;  // true skips the odd lines, false skips even lines
</code></pre>

<p>And change the end of your code like this:</p>

<pre><code>  if (EncVariation != 0) {
    encoder0Pos = encoder0Pos + EncVariation;
    int degrees = (encoder0Pos * 6) % 360 ;
    if(degrees&lt;0){ deg = 360 + degs; }
    if (!skipNextLine)
    {  // This will skip alternate lines
        Serial.println (deg);
        skipNextLine = true;
    }
    else
    {
        skipNextLine = false;
    }
  }
</code></pre>
