PDA

View Full Version : light to frequency convert code question



science_geek
01-11-2009, 01:41 PM
i am using the frequency to light converter from parallax, i am using the code from obex, and i have the output variable sent to a small display from 4d systems, one thing that i would like to do is to do a pwm so that when the sensor reads a certain intensity, it would adjust the pwm for a small high output led, one problem with this though, the higher the intensity the higher the frequency, if i were to bring the frequency down to a reasonable level (say between 0 and 256 like used in the pwm tutorials) it would still be "backwards", how can i invert the variable so that a lower light intensity would result in a lower pwm frequency.

Paul Baker
01-11-2009, 04:10 PM
You invert the value by subtracting the measured value fromĚthe maximum value.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)