user55866: I recently made a project where output is coming from the differential between data reading and reference value. It works on my Proteus simulation but there is no PWM output on my real world device.
Here is my code listing
for (z = 0; z <= output2; z++)
  if (output2 >= 30) {
   toggle == HIGH; 
   en = !en;
  }
if (en == true) {
  OCR1A = map(z, 0, 255, 0, ICR1); ;
  OCR1B = 0;
} else {
  OCR1A=0; 
  OCR1B = map(z, 0, 255, 0, ICR1);
}
if (output2 < 30) {
  en = !en;
  analogWrite(9, 0);
  analogWrite(10, 0);
}


user25690: I’m not sure what you’re trying to accomplish, but you’re writing a constant 0 to the analog output.

if (output2 < 30) {
  en = !en;
  analogWrite(9, 0);
  analogWrite(10, 0);
}


To quote the analogWrite() doc

Syntax
analogWrite(pin, value)
Parameters
pin: the pin to write to. Allowed data types: int.
value: the duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int

If you want to see an output, you have to write a value between 0 and 255.

55866: <p>I recently made a project where output is coming from the differential between data reading and reference value. It works on my Proteus simulation but there is no PWM output on my real world device.</p>

<p>Here is my code listing</p>

<pre><code>for (z = 0; z &lt;= output2; z++)
  if (output2 &gt;= 30) {
   toggle == HIGH; 
   en = !en;
  }
if (en == true) {
  OCR1A = map(z, 0, 255, 0, ICR1); ;
  OCR1B = 0;
} else {
  OCR1A=0; 
  OCR1B = map(z, 0, 255, 0, ICR1);
}
if (output2 &lt; 30) {
  en = !en;
  analogWrite(9, 0);
  analogWrite(10, 0);
}
</code></pre>
 25690: <p>I’m not sure what you’re trying to accomplish, but you’re writing a constant <code>0</code> to the analog output.</p>
<blockquote>
<pre><code>if (output2 &lt; 30) {
  en = !en;
  analogWrite(9, 0);
  analogWrite(10, 0);
}
</code></pre>
</blockquote>
<p>To quote the <a href="https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/" rel="nofollow noreferrer">analogWrite() doc</a></p>
<blockquote>
<p>Syntax</p>
<p>analogWrite(pin, value)</p>
<p>Parameters</p>
<p>pin: the pin to write to. Allowed data types: int.</p>
<p>value: the duty cycle: between 0 (always off) and 255 (always on). Allowed data types: int</p>
</blockquote>
<p>If you want to see an output, you have to write a value between 0 and 255.</p>
