How to get a pwm pin value that is in pinMode OUTPUT?
How to get a digital OUTPUT PIN value:
#define pin 3
void setup()
{
pinMode(pin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
delay(1000);
digitalWrite(pin, HIGH);
Serial.println(bitRead(PORTD,pin));
delay(1000);
digitalWrite(pin, LOW);
Serial.println(bitRead(PORTD,pin));
}
For testing reasons, I want to get PWM output pin value.
Incorrect sketch:
#define pin 3
void setup()
{
pinMode(pin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
delay(1000);
analogWrite(pin, 100);
Serial.println(pulseIn(pin, HIGH)); // value of the PWM output pin
}
This sketch was created for example only. I don't know PWM value because PWM value will be generating dynamically. Could you explain how to get a PWM output pin value, please?