Alright Jim, thank you, i am really grateful for you help , i will try and update you later on the progress
Very good
I made two mistakes in the formula. Try this code:
void setup()
{
Serial.begin(9600);
pinMode(8, INPUT);
}
void loop()
{
unsigned long pulse_width;
float average, dutycycle;
pulse_width = pulseIn(8, HIGH, 100000UL);
if (pulse_width > 16)
{
Serial.print("Pulse width = ");
Serial.println(pulse_width);
dutycycle = pulse_width*490.0/10000.0;
average = 5.0*dutycycle/100.0;
Serial.print("Average = ");
Serial.println(average, 3);
}
}
Hey jim, i tried the code but it doesnt show anything on the serial monitor, i connected Mega D3 to nano D8 and gnd to gnd
You can't read the PWM output with analog input because it's pulsating ON an OFF at near 1000 times per second, the analog input will read either 5V or 0V and all you see are meaningless flying numbers. Do you have a 10k resistor and 0.47 to 2.2 uF capacitor?
Hi,
No i dont have the extra components
Hi Tom,
Alright i'll try your schematic, Thanks Tom
Yep, thanks for the pitcher picture.
I made a mistake in the code
I corrected it, see updated code post #24
It will only print out a number if the duty cycle is between 1% and 99.5%
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.