November 25, 2024, 09:12:07 AM

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.


Photoresistor led dimmer

Started by imagineerdan, June 28, 2013, 08:10:40 PM

Previous topic - Next topic

imagineerdan

Is it possible to hook a photoresistor to te prop1 or 2 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 prop board also reference a pot to determine the sensitivity of the above?

How would this be wired up to either prop board and what would the code look like? I would preferably like to use the prop-1 as then my project enclosure can be smaller. Thanks soo much I have been wrestling with this for a while!!

JonnyMac

No, I don't think you can do this. The problem is that you need pwm to be running all the time but that is never the case with the Prop-1. When your code goes to read the sensor the output you are attempting to control must be full on or full off. Since the Prop-1 is not very fast, this would likely end up pulsing the output.
Jon McPhalen
EFX-TEK Hollywood Office

bsnut

Jon makes a good point, that the Prop-1 or the Prop-2 would have trouble since they don't process their code fast a enough. But, the HC-8 (Propeller powered board) can handle this project without any problems since it is able to process its code alot faster than Prop-1 (Basic Stamp 1) or the Prop-2 (Basic Stamp 2) and the advantage is it has 8 cogs (processors on one chip) to do true PWM for LED dimming in one of its cogs and use the other to read the photoresistor value.

If you don't want to go to the HC-8, than I can provide you some code but, the LED will be simply being turned off and on real fast and will not be true PWM.
William Stefan
The Basic Stamp Nut

imagineerdan

Thank you both! Lets go with the HC8 then. What would the code look like as well as how would it be hooked up? Thanks soo much!!

JonnyMac

There are no open inputs on the HC-8+ but you can add an ADC chip (analog to digital) that would let you connect to the option port. You can read this chip (2, 4, or 8 pots) and do as you please.

Understand that the HC-8+ is far more powerful than the Prop-1 -- though the Propeller processor and BASIC Stamp 1 processor have a common ancestry and came from the same creative mind (Chip Gracey, who owns Parallax). This will actually be a multi-file project, not just a few lines of code as we're used to with the Prop-1. That said, the object files (adc and dimmer) are easily re-usable, in fact, they're designed to be. No copy-and-paste; you tell you main program you want to use them and they're included in.

If you want to go with the HC-8+, close this thread and re-post your question (for the HC-8+) in the "Hacking the HC-8+" thead; I'll start working on schematics and code.
Jon McPhalen
EFX-TEK Hollywood Office