November 25, 2024, 02:32:32 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Live ambient light photocell input to led dimming

Started by imagineerdan, June 30, 2013, 01:02:26 PM

Previous topic - Next topic

imagineerdan

Is it possible to hook a photoresistor to the hc8 which when exposed to bright light makes one of the darlington Channels output for a 12v led to glow bright, then when the photocell gets a little less light the led is proportionally dimmer etc etc? Can the hc8 board also reference a pot to determine the sensitivity of the above?

How would this be wired up and what would the code look like? Thanks soo much I have been wrestling with this for a while!!

JonnyMac

Just so I can manage your expectations, this is not a whip-it-up-in-a-minute project.  It's not difficult, but it is a little involved.

First things first: there are no open pins on the HC-8+ that you can connect photocells or pots; you'll need to use an ADC circuit to read them. The attached schematic (just updated yesterday) is for a little accessory we're going to build for HC-8+ hackers. It consists of a 4-channel ADC and the connections. The part numbers on the schematic are for surface mount parts -- you can get them in through-hole for prototyping.

Your mission: build the board. Then I'll show you how to read the ADC channels using your HC-8+. After that, all the pieces are in place and we can write your application (I already have dimmer code for the HC-8+; we use it in the standard code for the board).

Just a note on the schematic: X1 is a female connection that mates with the 8-pin option header. The pin with a 0 above it is 5v; the pin with a 7 above it is ground (Vss).
Jon McPhalen
EFX-TEK Hollywood Office

imagineerdan

That's totally ok and am willing to work through this one, it will be good to get some propeller experience anyway thanks again !

JonnyMac

The Propeller is a blast. Once you get accustomed to the multi-core approach, it's not a lot of fun dealing with single-core controllers for anything but trivial projects. I have written dozens of objects -- probably more than 100,000 lines of code for the Propeller.

As I indicated, I already have code that does dimming, I have code for the MCP3204, and that's just scratching the surface. For example, one of the code modules we use in the production HC-8+ is a fader manager. It lets me control up to eight simultaneous fades at one time. And as it's running in its own processor, it's set and forget. The fade manager works in coordination with the dimmer module.

If I want to fade a channel from off to one in one second I can do it with a single line of code:

  fm.fade(0, 0, 255, 1000)

That's it; channel 0 will now start fading from full off to full on and will be done in one second. Want to do a cross-fade? Easy peasy:

  fm.fade(0, 0, 255, 1000)
  fm.fade(1, 255, 0, 1000)


Again, the Propeller is a lot of fun. Eight processors. Lots of speed. Easy to re-use code. It's fun!
Jon McPhalen
EFX-TEK Hollywood Office