How To Build a Flashlight With Perfect Modes (picture heavy)

Thank you! I think these are correct, the best price I’ve found are for this pack (without buying a lot of them) http://www.ebay.com/itm/250936543547

anyone knows a trick to desolder using a single welder?

Use a flat/spade tip, heat all 4 legs on one side and use a pair of tweezers to GENTLY lever under the chip and lift that side off the pads then go to the other side.

Be VERY gentle or you will lift traces.

That error usually means that you have a bad / intermittent connection. Try cleaning with an old toothbrush and some isopropyl alcohol and try again.

Thanks for the tips! After some modifications and testing …… I’ve made ​​a breakthrough!

1) Is the original configuration of the leads. (I think that was the problem because it was not able to correctly program the ATTINY13)
2) As it could be a connection problem, after cleaning the ATtiny13, I decided to solder the ends of the wires with some solder. (sorry for the quality of the pictures, not very well appreciated)
3) The next step was to try and desolder the ATTINY13 directly on clip. (I did not get any good results, got the same errors with the two previous ATTINY13)
4) After investigating many forum posts, find similar errors …. etc I find this post and after reviewing the positions of my cables, I made a change after change …. I did a couple of tests and AVRdude …. GOT IT!


I quickly put a few drops of tin in the driver to make contact with the pill, I now know that the flashlight was going to turn on!

Low mode! I put the .hex and .eep file of “programmable” folder, Now to see if I can understand how to program!
The next step for me is to learn to modify any firmware driver (I wanted to try luxdrv among others)

many thanks to all, I’m very happy today!

Hello friends,

I have bought everything I need to reprogram my Nanjg105c.
I am planning to add a hall effect to the circuit, and connect the output of the hall to the Attiny’s ADC.

Do you have any idea how do I read the values of the ADC?
and another questions, is the possible to use the Attiny in order to “completely block” any current to the led?
I mean is that possible to reprogram the driver to be turned off while ADC on low, and turn on while ADC on high [for example].

THANKS in advance!! :slight_smile:

You could use the STAR off time memory firmware as a code example. It reads ADC for the off time capacitor.
STAR Firmware by JonnyC

Thanks for the fast answer!!
Sounds interesting, I’ll read a little more about this Firmware and how to edit it. H)
When I will succeed i’ll post here my results.

Not sure if I completely understand your question.
With nanjg 105c drivers power goes to the LED through the amc7135 chips. The LED is only on when the amc7135 is activated (high signal for LED full on or pwm signal for variable brightness LED modes). The attiny can turn off the LED but a 0 (zero) value pwm doesn’t seem to turn it off. You need to disable the pin entirely or pull it low.

The STAR firmware for momentary switches might serve as an example.

In the STAR firmware the attiny goes to sleep when “off”, attiny draws very little power asleep. An interrupt is needed to wake it up. Not sure if ADC can trigger an interrupt with attiny13.

Helios-, Thanks for your help!

Yep it should “”similar”” to my project.

My light will be in “always on” mode, as it won’t have any physical switch(clicky or etc.) - Just an NANJG star, LED, and an 18650 Battery (nothing else).

The only way to turn it on will be to put a magnet near the HallEffect, that will be connected to the ADC.
When ADC goes on high [ A magnet is near the HallEffect], I want the light to be on constant TURBO-HIGH mode.
When ADC goes on low [ no magnet near the HallEffect], I want the light to be off.

I will have to read the code deeper, in order to understand how to implement my idea, with this code.

When attiny is in “sleep-mode”, will it draw current from the battery?

In sleep mode the attiny does draw a tiny bit of current. There are different levels of sleep. Not sure how small the current draw is in the STAR sleep.
With flashlights, the current the driver draws when “off” / asleep is often called “parasitic drain” so you might see that term on BLF.

You could also just use a magnetic switch in place of the e-switch the momentary-switch firmware uses. That would allow you to activate it with a magnet and use the regular sleep mode since the switch would provide an interrupt. You also wouldn’t even have to change any code unless you wanted to change which modes the light has.

I have this type of magnetic switch in an ancient “Forever Flashlight”; simply get a magnet near it and the switch closes. Pull the magnet away and the switch opens. It was the solution they used to make the light waterproof; magnet on the outside of the dry area, switch on the inside.

@Helios- thanks ! :slight_smile:

@ToyKeeper
I think that you mean using a reed switch, correct me if i’m wrong.
It will be a problem, because if I connect the switch between the battery and the driver, the high current will blow it.
After a small research I did I understood that those switches are built to be in low current environment, that’s why I should use the ADC to control the ON/OFF of the driver.

I just couldn’t understand something, I see that those firmwares have TURBO MODE and HIGH MODE, what is the difference? TURBO is 100% and HIGH is less?

I will have more time this weekend, I hope that I will be able to connect and flash everything :slight_smile:

The emitter power does not go through the switch. The switch is simply used as a sensor, and the main power follows a completely different route. Don’t try to connect an electronic switch between the battery and driver.

If you were using a non-electronic switch like a traditional reverse clicky, then yes. The emitter current would need to go through the switch. But not for an electronic switch.

What does the signal coming out of the HALL sensor look like? Is a a single “blip” when activated, a constant (or PWM) output or variable or what?

The output of the Hall effect is “Linear voltage output” which goes high/low and depends on magnets proximity.
Taken from the DATASHEET [ LINK: Safety and Productivity Solutions | Honeywell ]

I hope the ATtinys’ pins will be able to sense those outputs.

ToyKeeper was saying a magnetic reed switch could work as a simple replacement for the momentary tactile switch used in the STAR momentary firmware. If attiny13 can’t do ADC interrupts then a linear voltage output hall effect sensor won’t be able to wake the attiny from sleep. In that case a reed switch could be used instead.

Oh…… Only now I got it.
Sorry for my ignorance.

I thought that the switch in STARs’ firmware is a regular switch.

Now that I read a little more about it, I saw that you should connect the “e-switch” to GND and STAR4.
Now it makes sense, and changes the picture to me.

Do you know to what pin on the ATtiny this STAR4 goes on the NANJG board?
That way, I think, that I will be able to change the values it reads from the this STAR4 , and change it in according to the hall effect.

:nerd_face:

I have this little diagram at the top of my firmware so I don't forget...

/*
 * NANJG 105C Diagram
 *           ---
 *         -|   |- VCC
 *  Star 4 -|   |- Voltage ADC
 *  Star 3 -|   |- PWM
 *     GND -|   |- Star 2
 *           ---

Pin 3 HOWEVER the MCU isnt reading a voltage from the switch, the momentary switch is simply providing a path to ground when pressed.

The STAR momentary code definitely wont work and I’m not even sure code could be written to work, I dont know enough about the attiny13A to know if it can read a positive voltage input there or not.

You could possible use some other sort of magnetic switch that would provide a path to ground to work with STAR-MOM but not a hall sensor, its all wrong for what STAR uses for the input.

Hi all and thanks for the replies!

About the hall effect, i think that is possible to provide a path from the ground to pin3 with it.
I have seen some diagrams of hall effects and I think that its’ output is negative (as ground)
For example this diagram: https://www.kjmagnetics.com/images/blog/wiring_hall2a1.png

What do you think, should it work that way?