Reading and processing a PWM on AtTiny45 I have this question and I can't find answers!

I wanted to use an AtTiny45V (due to low voltage requirements, it will run at 1.8 volts) to read a PWM from an Arduino, and then process this information.

Explained better:

let's say, I hook up one pin of the AtTiny to an Arduino pin (named connection), and in the IDE I write: 

AnalogWrite(connection,X)


I want the AtTiny to write high on a port based on the X value.

Example:

X = 20 writes high on AtTiny PB5

X = 25 writes high on AtTiny PB5 and PB3

etc...

So, basically I want to read the duty cycle from the Arduino PWM and let the AtTiny do something based on duty cycle value.

Is this possible?

Thanks
You don't need to read the duty cycle, just the time that the PWM signal is high. First wait for the input pin to go high, then start a timer, wait for the signal to go low again, and finally read the timer value. If other tasks need to be performed concurrently then use pin change interrupt to detect the high and low transitions. 

If the ATtiny is running Arduino software then the solution is even easier - just use the pulseIn() function. 

This technique works for all PWM values except 0 and 255. With these values the pin stays low or high permanently, so there are no transitions to time. The easiest way around this is to simply avoid transmitting 0 or 255.

Alternatively you could pass the PWM signal through an RC filter to produce a 'DC' voltage, then read it with the ADC. However this will slow the response time down, and the signal will produce intermediate values as it goes from one voltage to another. To get good resolution the RC filter would need to have a long time constant, and you might have to average several readings to get a stable value.