Automatic on-off control of 12V LED headlight (Arduino?) - Page 1
Forum section: electronics / beginners

author: Mile Tzali
author_rank: Newbie
timestamp: December 28, 2020, 02:00:59 pm
content: First things first, I'm a very big noob in this field, and to make matters worse, my high school vocation was in electronics, but I've spent all my time and energy evading classesI regret it very much today. All the things in basic electronics sound familiar to me, but I have no real knowledge of it. I picked up some info in highschool, but not enough, so it's worst possible scenario of "sort of knowing" but not really knowing, stuck in the middle of nowhere.With that out of the way, I finished my first soldering work in my life, I took apart my bike's gauge cluster, removed the oem SMD leds and soldered new 3528's in. My mistake was that I bought some super bright ones (2000mcd rating) so now I have an idea how to sort that problem out, but in the meantime I figured I'd do something else. The idea is simple, but my knowledge is sparse. If someone can help me on this and give me breadcrumbs to follow, I'd appreciate it. I'm n Discord in all sorts of groups trying to get some bits of info how to complete this idea, if you know a discord that I'd should know about, let me knowNow on to the topic, this is the idea;- bike has a H7 LED headlight bulb for high beam- there's a switch on the bike that enables manual flash of the high beam - you press the button, high beam is on, you let it go, high beam is off- the idea is to use that switch to trigger automatic flash sequence on that high beam bulb; press the switch and the headlight flashes on and off for a couple of timesWhere do I start?

author: DrG
author_rank: Super Contributor
timestamp: December 28, 2020, 02:36:27 pm
content: Quote from: Mile Tzali on December 28, 2020, 02:00:59 pmYou could start by sorting out the problem with the LEDs before moving on to another project. You have not given much information but you can start with some reading likehttps://www.waveformlighting.com/pcb-designs/led-strip-light-schematic-and-voltage-informationBy your own admission, you need to make up the "course work" that you skipped.

author: nuclearcat
author_rank: Unknown
timestamp: December 28, 2020, 03:20:30 pm
content: Quote from: Mile Tzali on December 28, 2020, 02:00:59 pmMotorbike or bicycle? I am assuming first.Its pretty trivial circuit, the only what matters if your circuit will be powered from battery. If it is only from engine, then arduino-alike board with proper mosfet will do the job, but if battery - you need to keep in mind it should not drain battery when engine is off.

author: tpowell1830
author_rank: Frequent Contributor
timestamp: December 28, 2020, 03:29:09 pm
content: Quote from: DrG on December 28, 2020, 02:36:27 pmI agree with DrG, you at least need to know the basics, and you obviously do not have them. Soldering is a skill, so good for you that you were able to work your LEDs, but electronic basic knowledge is another thing.I suggest that you start with "Getting Started in Electronics" by Forrest Mims and work your way up from there.Good luck and good studies.

author: Mile Tzali
author_rank: Newbie
timestamp: December 28, 2020, 03:45:13 pm
content: Quote from: DrG on December 28, 2020, 02:36:27 pmAgreed, I'm fully aware of gaps in my knowledge but sometimes I feel going head on solving these tasks is my best bet to learn. I never had a soldering iron in my hand before, I bought one and went to sort the gauge cluster SMD leds and it worked, so perhaps now I feel too eager to tackle the next thing, which is perhaps too ambitious at this point. But, I'm aware that given my knowledge, there's no shortcuts on this, but I'm eager to make up for time with shortcuts like this, can't help itI'm trying to find a similar project here and re-create the circuit on everycircuit.com or Eagle Free, where I can see visually what happens, where does current stop or make a turn, I think this kind of visual approach would aid me in my learning or make up on my lost high school curriculumQuote from: nuclearcat on December 28, 2020, 03:20:30 pmMotorbike yes, 12V DC battery, stator, rectifier, standard stuff. The headlight switch on the handlebars has the "Passing" switch button, you use it to flash the high beam bulb manually, my idea is to use that button to initiate a flashing sequence. Perhaps there's a way to do it other than Arduino, so that I don't have to worry about powering Arduino?I asked a senior electrician about this problem, he advised me to look into IC 4060, he thought I knew my electronic basics

author: Ian.M
author_rank: Super Contributor
timestamp: December 28, 2020, 03:55:09 pm
content: You are right to wory about powering an Arduino as its on-board regulator is unlikely to stand up to the voltage spikes and transients that are inevitable in an automotive environment. It would be rather unfortunate if your circuit failed and killed the lights while riding at night on a twisty mountain road! Probably the best option there is to make sure your control circuit is fed from a switched 12V feed so you don't have to worry about battery drain when off, and use a bare ATmega328P chip rather than an Arduino (you can still use the Arduino IDE, and program it using an Arduino running the ArduinoISP sketch), fed by a regulator designed to survive automative use.

author: DrG
author_rank: Super Contributor
timestamp: December 28, 2020, 04:07:15 pm
content: Quote from: Mile Tzali on December 28, 2020, 03:45:13 pmOK, I hear you and I applaud your enthusiasm to go further, faster (running before walking?). But, hear me out....You went out of your way to explain that you avoided study at school - ok, not being punitive and good that you admit that.You replaced some SMT LEDs and you used super brights and that is some kind of a problem. Now, you want to move on to a more complicated project."My mistake was that I bought some super bright ones (2000mcd rating) so now I have an idea how to sort that problem out, but in the meantime ..."I don't know because the details are missing, but I am thinking that you need to change the resistor(s), and thus, the current driving the LEDs - it may be just that simple. Figuring that out gives you a project win and some knowledge that you can carry forward andinto the next project. Moreover, you can get plenty of help figuring it out.Ignoring why the LEDs are too bright now that you changed them is not just a function of using super bright LEDs. Can you tell us why they are too bright now? That is my point.

author: Mile Tzali
author_rank: Newbie
timestamp: December 28, 2020, 04:26:27 pm
content: The leds are soldered on the circuit board where the instrument LCDs are, for the backlight. I measured the voltage of the original ones, 2.1V, which is what a regular orange SMD led uses, at least according to a table I found online. My goal was to change the orangey instrument backlight with white, just makes it look bit nicer. My mistake was buying the leds with highest luminosity rating, 2000mcd at 6000K color temp. I found another set, 6000K color but 1000mcd luminosity, I'll go with those. These 2000mcd are just too bright, it's hard to convey with a photograph but when I look at the cluster, especially knowing how the original orange leds looked, these 2000mcd are just over the top bright. I think putting lower rating mcd leds will sort that out.Quote from: Ian.M on December 28, 2020, 03:55:09 pmIt's a project bike so not much time on the road, but yeah I don't want to make something crappy and go through dismantling the entire front end just to reach the headlight and fix my contraptionThe ATmega chip you suggested, is it some sort of advanced counter like the 4060? I might be wrong, but does PIC controller fall into category of potential solutions?I'm trying to come up with a circuit using 74HC93 in Tinkercad to see how these things work, this is the lack of knowledge coming to haunt me, I want to get to the bottom of everything which is simply not possible nor optimal, but whatever, it's a long winterhttps://www.tinkercad.com/things/ls0MIMfJf24-magnificent-rottis/editel?sharecode=eZ_ESjlG3ms-PWULStty1ybo4lFruC3vIKgbflMaCbA

author: Ian.M
author_rank: Super Contributor
timestamp: December 28, 2020, 04:43:30 pm
content: The ATmega328P is the core MCU on Arduino Uno, Nano and Pro Micro boards. Once programmed with an Arduino compatible bootloader, it acts just like an Arduino from a software point of view. Various PICs could also be used for a MCU based solution, but unless you already have a MPLAB X supported PIC programmer and experience with the XC8 toolchain, I wouldn't bother.Replacing red/orange instrument cluster lighting with bright white may not have been a good idea, as the colour and intensity may have been chosen to help preserve your night vision. You should probably mod the driver circuit to reduce the LED current significantly and if there's a dimmer control, you may also need to mod it to get an acceptable brightness range.

author: Mile Tzali
author_rank: Newbie
timestamp: December 28, 2020, 05:19:32 pm
content: It's a project bike so not many night rides, it's mostly my testbench for curiosityHow would the 328P get powered in this scenario, I presume it would need some protection from bike's oscillating power delivery?

author: Ian.M
author_rank: Super Contributor
timestamp: December 28, 2020, 07:00:52 pm
content: At most, the MCU will only need a few tens of mA, so a relatively simple circuit with a linear regulator with a high enough input voltage rating is practical. However the transients go much higher than any reasonable regulator can handle so you'll need a unidirectional TVS diode (so it clamps negative transients close to 0V) that you are 100% certain will clamp under the max regulator input voltage but will never continuously pass current at the vehicles's max electrical system voltage. A 17V one is probably a reasonable choice for a 30V max input regulator, but check the datasheets. A 35V or higher max input regulator gives you more margin so you can use a higher TVS diode voltage. Then you need a heavy duty wirewound resistor in the feed to keep the surge current down to something the TVS diode can handle during spikes and if a battery terminal comes loose while a low battery is charging (or you switch off the headlight with a bad battery) and the alternator output voltage looses regulation and surges, or if the vehicle regulator goes bad. You then need to fuse the feed appropriately to reduce the risk of the resistor and TVS diode cooking if the vehicle regulator fails with the alternator delivering a continuous overvoltage. You don't have to provide 100% protection, you just need to ensure that your circuit isn't the first critical system on the vehicle to fail!Note that this dumb brute-force shunt protection approach rapidly becomes impractical if your gadget requires significant current as the min. resistor wattage (5x its nominal wattage for a 1 second pulse) and TVS diode size to handle a load dump surge while delivering even a few hundred mA gets pretty ridiculous. At higher load currents, the only practical method is to use a smart protection circuit that disconnects the input during long-duration surges.

author: Zero999
author_rank: Super Contributor
timestamp: December 28, 2020, 07:10:11 pm
content: Quote from: Mile Tzali on December 28, 2020, 04:26:27 pmThis is not surprising. Orange is the second least efficient (in terms of radiant power out, vs electrical power in) LED colour, after yellow. White is a much more efficient LED colour and will give much more light, given the same power, than a wimpy orange LED. To achieve a comparable brightness with the orange LEDs, you'll need to dial back the current by at least a factor of 10.

author: Mile Tzali
author_rank: Newbie
timestamp: December 29, 2020, 12:23:38 pm
content: I already thought about that possibility and I think I solved it - just need parts to arrive. So my upgrade on this "led backlight" project will be a small 3535 addressable (sk6812 mini) strip running across where these white leds are now. I'll desolder those and I'll have the addressable leds in the back, on the 5v wifi controller (step down converter is on the way as well), so I'll be able to dim the backlight exactly to my liking, and even change the color when I feel like it.As far as this on-off headlight control idea is concerned, I'm aware it's a tall order, I was thinking would it be possible to make a similar device in Tinkercad or similar app? Just so I can understand it visually, I think it would help.Any of you know any good discord where I can bother people with these questions?

author: themadhippy
author_rank: Super Contributor
timestamp: December 29, 2020, 12:40:55 pm
content: my ole skool solution would be a 555 driving a 4017, common the even outputs together with diodes for however many flashes you want and use that to run a transistor relay driver