Hoping someone can help with a school project. If you're feeding power to a 3v led light can you monitor if the light is getting power? I could use a little bit of code. My daughter and I want to make a counter every time the light is turned on and for how long?
What LED are you monitoring ?
Show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.
The same 3v might be able to be monitored by an Arduino, you might need a transistor Opto Isolator or an LDR.
Is the led turned on and off by hand? If so, an LDR will be quite fast enough for the job, even if connected to an Arduino analog pin.
Ok, I added a schematic of the switched 3V LED light adafruit with a heat sink. I was hoping to add 2 wires 2 the sides of the light.
the switch is a manual
Does the LED have a series resistor (what is the value) ?
Is your light (LED) power supply 3v exactly ?
What is the light power supply, battery, AC/DC . . . ?
What is S1 ? (push button switch)
Power - x2 - 3v coin batteries (stacked)
S1 Switch - Momentary
*Light may have a variance power requirement around +/- 3v (not sure) 1 Watt Cool White LED - Heatsink Mounted : ID 518 : $3.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Goal - count the number of times of switch activation and duration
*"The best way to drive these LEDs is constant current, @ 350 mA, but you can get away with under-driving for compactness. At about 3V, the LED draws ~200 mA, so connect two Alkaline batteries up directly with no resistor for a basic bright lamp. You can also try driving it directly with a 3.3V power supply, that will probably work OK as well (although its not ideal) "
Suggest you connect the LED to a 2N2222 transistor as seen in the image below.
Use 4 AA batteries in a battery holder for your power LED supply.
The switch is read by the Arduino UNO.
When the switch closes, you can start a TIMER in software, increment a counter and turn ON the LED by way of Arduino pin #3.
When the switch is pressed a second time, the TIMER is stopped, the LED is turned OFF . . . . .
Ask if you have any questions.
That can be made into two projects. First, the light.
How flexible is the assignment? You can use a photoresistor on an analog port to detect the LED is on, or you can just monitor the power to the LED with a digital port. Or, as someone suggested, put the switch on the Arduino and let the Arduino control the light. Once you decide which way you want to count the light activations, then work on counting and timing it.
this looks like 6v supply, or am I misunderstanding? the instruction says 2 alkaline batteries, they are 1.5v
I think we might be doing some over-engineering here.
My reading of the OP's post is that the only requirement is to record when the LED is turned on and for how long. There is no implication that the LED itself is under the control of the Arduino.
I think we should assume just what the OP asked: monitor the power feed to the LED and record "when and for how long". Who or what operates S1 is not part of our consideration.
An even more rigorous solution would be to monitor the light output from the LED, thus being able to detect a blown LED. Probably outside the scope of this exercise, though.
So, my approach would be to common the Arduino ground to the LED -ve supply, and monitor the LED +ve supply with a digital input port. Agreed?
We need to ascertain what the OP means by "when" the LED is switched on. Does this mean the time of day (in which case an RTC would be sensible)? And "how long" - measured in seconds, milliseconds, minutes?
Correct, as per their drawing.
Just suggesting, since they are wanting to do timing and counting, why not use the UNO for everything.
The Switch still controls the LED but do it in software.
Addition of a common transistor can better control current regulation rather than relying on the internal resistance of the battery.
Software can do the timing and counting based on switch operation rather than looking at the light or voltage from the LED.
Of course there are 100s of ways of doing this.
Yes there are quite a few things left out of the request.
Assumption could be timing is short (ms maybe) ; reaction timing ?
And ... you are not going to power a 1 W LED from 3V coin batteries!
Thanks for everyone's help. We were hoping the Arduino and the Switched Light could be to separate units. (what we're using it for is below)
Correct, The LED itself is NOT under the control of the Arduino. I only have access to the -/+ of the LED to measure the current that is activated once the switch is down. (momentary) .
The larger coin batteries do power that LED (or even a cell phone Vibration in testing)
WE will use an RTC shield (linked) that has clock power with and SD card and code it to collect data if it' pressed and for how long.
FYI The application is a dog door that we want to measure dog passage activity with time stamps. It has a built-in light and switch and when a dog passes thru we want to use a soldered +/- port that you could plug in the Arduino data collector and monitor the DC "current" activity. But the Arduino can be removed and the door will function without it. Very similar to a Volt Meter. This way we can attach it to another dog door and figure out what door is used more in an experiment.
Adalogger FeatherWing - RTC + SD Add-on For All Feather Boards