title: How can I print a digitalRead using wiringPi in a C programm
body: <p>I am trying to run a program for reading an encoder in a motor. The PWM is running correctly but I would like to read the input from the encoder. I am using <code>digitalRead</code> and I already tried with <code>printf(digitalRead(21))</code> but it does not really work. How can I visualize it? I attach my program in C:</p>
  <pre><code>#include &lt;wiringPi.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdint.h&gt;
  
  #define MFOR_MOTOR 25
  #define MBACK_MOTOR 24 
  #define PWM_MOTOR 1
  #define ENCODER_A 21
  #define ENCODER_B 22
  
  int main(void) {
  
      if (wiringPiSetup() == -1)
          exit(1);
  
      int pwm_user;
      wiringPiSetup();
      pinMode(MFOR_MOTOR, OUTPUT);
      pinMode(MBACK_MOTOR, OUTPUT);
      pinMode(PWM_MOTOR, PWM_OUTPUT);
      pinMode(ENCODER_A, INPUT);
      pinMode(ENCODER_B, INPUT);
  
      printf(&quot;Raspberry Pi wiringPi Motor PWM program\n&quot;) ;
      printf(&quot;PWM from motor: &quot;);
      scanf(&quot;%d&quot;, &amp;pwm_user); 
      pwmWrite(PWM_MOTOR, pwm_user);
      digitalWrite(MFOR_MOTOR, HIGH);
  
      while (1) {
          digitalRead(ENCODER_A);
      }
  
      digitalWrite(MFOR_MOTOR, LOW);
      return 0;  
  }
  </code></pre>