Saturday, April 23, 2011

PWM, new code, getting there

      I changed the LED output from digitalWrite to analogWrite and used a PWM pin on the Arduino (3 pin options for this, 9,10,11 of digital pins)
      I did this in anticipation of adding steps to the RGB color response: rather than the jacket changing rapidly from blue to orange, the color should transition as the strength of the signal increases. In theory, this will prevent rapid switches and make the response feel more natural (supernatural :P ). Some delays will help as back-up.
...

      Ok, all is well in that regard. I have two photocell-LED systems as input right now (ultimately there will be 3) and the code is semi-functional. Semi, in that the values fluctuate too often. Same problem as last time, which I temporarily solved with a little delay. The delay was a band-aid, but is not really a good enough solution, and here's why: while the brightness (soon to be color) flickers less rapidly, it gives the impression of being very random. What I have now is not reliable enough to be generally dim when there is little meter response, generally brighter when there is some meter response, and generally bright with full meter response.

      Now it's something like this:
PMW output when meter is not detecting anything (val from 0 - 255): 0, 50, 0, 0, 0, 50, 0, 255, 0, 0, 0, 100, 0

      So statistically the ratio is still on my side but like I said before, rapid fluctuations and flashes of full brightness confuse the wearer. Basically I need to slow the whole thing down. Less response is more believable with the paranormal, no?

      My plan is to add a STATE value, which I've used in simple pushbutton tutorials. This way I can presumably call for a change (dim to bright) not from a SINGLE input value, but in reference to a group of multiple value inputs..

No comments:

Post a Comment