pwm output to analoginput

iam using 2 arduino boards for my project, can i give PWM output of from my first arduino board to the analog read input of the second board, and read the output from PWM pin of second board ?. will my output of second board will be as same as my input of my first arduino board pwm input?

vinothkrishnan:
iam using 2 arduino boards for my project, can i give PWM output of from my first arduino board to the analog read input of the second board, and read the output from PWM pin of second board ?. will my output of second board will be as same as my input of my first arduino board pwm input?

your ppm output using analogWrite() is a square wave function with a varying duty cycle.

your analogRead() function is looking for a voltage from 0-5V

they are not compatible.

You should look at an interrupt driven timer to measure the PWM output from one device to the (digital) input of the other.

Sure you can. It won't be as accurate as you might need but... If you put a capacitor (I would suggest an electrolytic - make sure the polarity is right) across the line coming from the PWM pin and the ground pin (both arduinos should be connected at the ground pins) then the capacitor "softens out" the square wave. A big enough cap (and it doesn't need to be super big) will allow this wavy signal to approach an average of the duty cycle at any particular moment.

Now if you are expecting meaningful millisecond changes to show up at the analog-in on the second arduino, that's not going to happen, but if you just need to see an approximate level of how intense the signal is from the pwm this will do the trick.

You will never see a full 1023 signal coming in to the analog pin though. You more likely to get values from nearly 0 to 800.

Remember to put a dropping resistor on the analog-in pin and tie to ground (a 10k 1/4 watt will do the trick) so that there is no delay in the voltage dropping as the PWM duty cycle drops.

The other option is a Digital to Analog converter - this would be more accurate - these are cheap but you might not have one at hand, whereas caps are a dime a dozen.

1 Like

And as luck would have it there were just two articles posted on just this topic:

vinothkrishnan:
iam using 2 arduino boards for my project, can i give PWM output of from my first arduino board to the analog read input of the second board, and read the output from PWM pin of second board ?. will my output of second board will be as same as my input of my first arduino board pwm input?

Why not send the number (for analogWrite()) to the second board and let the second board do the actual analogWrite().

For example if you want analogWrite(123); send "123" to the second board with Serial.print(123) or equivalent.

...R

no robin , i interfaced arduino with labview ,when i send a PWM signal from 1 board to analog pin of other board , it does not give me the same output , it jest gives 0 and 5 volt continously, i want to read my output as 1 volt to 5 volt linearly.

This is becoming an XY problem.

It seems that you have a PC (with Labview) and two Arduinos. Please tell us what you are trying to achieve and maybe we can give some useful advice.

...R

Hi,
Can you please post a copy of your concept, in CAD or a picture of a hand drawn circuit in jpg, png?
To show us how you want to connect your project.

Thanks.. Tom.. :slight_smile:

You will have to low pass filter the PWM to a DC level to read it with analogRead, if you try to read a pulse string with analogRead you will only see 1023 when the pulse is HIGH or 0 when the pulse is LOW.

Hi,

What is your electronics, programming, arduino, hardware experience?
Is this a school/college/university project?

Something like this sounds like a educational experiment to demonstrate analog to PWM to analog to PWM in first Arduino then using analog input of a second to take the signal and output a PWM.

If it isn’t a school project, what is the application?
If you just want to have one Arduino communicate with another, there are better and more accurate ways.

Tom… :slight_smile: