Firmware for -Attiny85- to control 2 led with momentary buttons independently

Hi every one!!

Well i’ve decide to post my work until now.

I’ve make some modifications to various firmwares, trying to get this:

When off:
short push ->turn on light
long push -> turn on 255
extra long push -> locked or unlocked

When on:

short push -> cycle between modes (excluding off)
long push -> off

i’m trying to understand the code but there aren’t likeness between codes that i’v got.

However, i couldn’t duplicate imputs and outputs, the lock neither.

MY CODE

Have a look through the group buy section. There is one ongoing where they are modifying the code. Will post link later if you don’t find it. May be worth speaking to them

i’ve been looking for post in Group buy section but I haven’t found anything about any code. Only a flashlight with two leds for hicking.this
If you don’t mind, Could you give me the link?

I am pretty sure it is

Bigsy should be able to help you. A member of that group is modifying the code

Speak with this member,Toykeeper, they may be able to help you with information.

Toykeeper is a big help, but you may be better off just posting in this thread. It is the go-to place for firmware questions and answers.

I personally have used a very similar firmware (based on STAR) but it does not have the lockout feature.

This is my scheme and the housing of the headlamp



This is that i have

Where are you getting the housing fabricated?

In a local milling lathe company.

Ahh ok. I am also designing a headlight and will be designing the casing for it. It’s a slightly different type of light though: Build: Dual XP-L headlight project.

I can’t help you much with your code, I did all that differently. Your code uses E-switch activated interrupts, I don’t. I run the watchdog interrupt at highest speed and do all E-switch checking in the main() routine. Besides the E-switch my light also has a mechanical switch with an off time capacitor, so I have a lot of functionality on that.

This is my try of duplicate but can’t build solution. https://github.com/jaimelito/Firmwares/blob/2-leds/Jaimelito.c

I’ve solved the problem of can’t build but doesn’t work only get fix low mode and anymore…

It’s nearly full the tiny13a (99.6%) therefore I change for a tiny85.

Can anybody help me.

Well, my attiny85 it’s down. But I’m useing Proteus for the simulation-test of code.

Anybody can help me? I’m stuck in this like two months :weary:

hello, anybody here???

I’m stuck in firmware development :_(

I think timing is why you are not getting FW responses. We have less than a handful of capable programmers right now and they all seem to be deep into developing their own FW's for the Attiny85. They all have normal jobs and limited hobby time to do that. Just seems to be a lot going on right now on that front.

Hang in there and keep plugging away. Sounds like an interesting project.

Please explain that timming problem.

Thanks

I could maybe help, but need more details:

  • what is the goal for hardware. You say 2 LEDs, and momentary buttons, like plural - what does this mean? Do you want two separate PWM output channels and 2 electronic buttons?
  • I'm not sure what you mean by "locked" or "unlocked". Please explain. There's lots of ways that can be interpreted.

1st thing is you say it's for an 85 but you have the F_CPU set to 4.8 Mhz? I only got 8 Mhz working on a 85. 4.8 is the speed for a 13A, not an 85.

Also you are not providing fuse settings -- please provide what you are using. I have no clue what Proteus is - sounds like a simulator. I only have experience working directly with 85's. Not sure if I can help you out much if you are not using the real thing.

I'm looking at the code while typing this post....

I do see you have the 2 PWM's configured - good, and the 2 switch's configures on pin's 2 and 3 of the CPU - think that is good too. You setup the next/prev in duplicate, which indicates you want 1 button controlling 1 LED, and the other button controlling the other LED - I understand better what you are trying to do... Still look'n/reviewing....

Update:

Looks like there's some confusing things goin on:

  • indentation is confusing - difficult to follow. used a "beautify" tool to clean it up so I could review it
  • FULL_MODE ?? checked for but never set?
  • what is goin on with strobe mode? It's implying you think it's mode_idx set to 4, but in your 'modes' table, mode_idx of 4 is hi (255 value) ??
  • also, looks like you only check the 2nd button mode changes if the 1st button mode change occurred. Not sure if that's what you want? Doesn't sound right.

hope some of this helps.. Might be missing something, but run out of time - probably for rest of day.

I think it is better to explain how I want it works.

My intention is control each led independiently.

There are 4 modes 2,32,125,255.

From OFF.

  1. Short press turn on in first mode
  1. Long press turn on in 255 mode.

From ON.

  1. Short press change to next mode ascending.
    cycling beetwen modes without pass for 0.
  1. Long press turn led off

I get this working with 1 led and 1 momentary but when I try to duplicate the code for useing 2 led and 2 momentary it doesn´t work.

I can’t test with real attiny85 because I have a bad fuse config with the only one I have. I’m using Proteus(simulation electronics program) until get some new Tiny85

k - when u say doesn't work, LED #1 stops working or just LED #2 doesn't work? By doesn't work, give me all the specific details...

It's always best to take baby steps first, small incremental changes, specially when we can't single step debug. Sounds like you did that to some extent.

Still dunno how you want the 2nd switch to work. Looks lts tied to the 1st switch the way you wrote the code. The code you wrote doesn't independently handle the 2nd switch. Check your braces in the main loop. You are only checking for a mode change for LED #2 when and only when a mode change occurs with LED #1.