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

thats correct led 1 stop working stay fix in lower level and led 2 doesn’t turn on.

The problem is that I’m trying to learn C but all the manuals that I found was using diferent syntax.

with 1 led the program runs perfect.

VIDEO OF 1 LED

This is with tiny13 it’s the only physical avr that I have at the moment.

k, this line of code is wrong for qualifying sleep mode:

if (real_mode_idx && real_mode_idx2 == 0){

I think you want this:

if ((real_mode_idx == 0) && (real_mode_idx2 == 0 ) ){

And again - I think your main loop is wrong(?) You probably want to check the change of modes for each switch independently?

Thanks for the correction and yes, I want each switch independently. This is for a headlamp with a flood led and a throw led for caving.

I need to adjust the mode of each led independently .

now it fixed in pastebin code.

I’ll simulate in proteus.

well, still not working. In simulator when I burn 1Led code it works perfect too.

But when burn 2 Led code.

pushing PB3 then the PB1 get fixed in 0,9v (85/255) and doesn’t respond anymore I need to reset.

Wait - what is that "return 0" doing in the main while loop? That's not good being there. Looks like the first mode change would cause the light to get stuck permanently on in that mode... Hhmm. Check it out.

My code at the end of main looks like this:

} // mode change detected
} // while

return 0; // Standard Return Code

If you comment the close curly braces like above, it helps tracing down the indents.

Was that the issue? Any updates?

Ok, Tom E I don't understand why the return 0 it's not needed. This is the end of my code you seems to tell me that I have a lot of }} just before the return 0 sentence?

_delay_ms(1);// Need this here, maybe instructions for PWM output not getting executed before shutdown?

// Go to sleep

sleep_until_switch_press();

}

}

}

} return 0; // Standard Return Code }

Sorry but wouldn’t it just be easier to have two independent 13A drivers. That way you could have FET + 1 driver for either or both and have ramping firmware for floody, for example, and steps for throw or anything. Would be much simpler.

Yes thats the easy way but I don`t have so much space on pcb for duplicate the 13a and the resistor divisor for the battery level…

On these green pcb of 2 image on #6 post it’s need to fit the pads of 2 leds, the pads of vcc imput duplicated the power cord it’s a 4 x 0.76mm copper wire. Two tact switches two fet and tiny85 a lot of components for this surface….

You can share the bat+ input and the LVP between the two saving space

Jaimelito wrote:

Please explain that timming problem.

Thanks

At the time I posted that, you had made multiple posts with no replies. I was just trying to prevent you from being discouraged by the lack of replies by explaining that a lot of FW stuff seemed to be going on and that there are not many active programmers around.

Hhmm, just looked at your original from pastebin.com, and the return statement does look placed correctly -- must have been messed up when I re-formatted? Dunno what happened. Ok, should not be an issue then.

I was thinking the same thing - to use 2 drivers. It's an option if you have the space. I believe the battery can be shared.

I assume you took care of the 3 things that need to be updatedc/hanged for 13A --> 85? CPU speed is one, 2nd gets a compile error, and 3rd is a change for bit positins in a reg- forgot details. Need to look at this in the eve, at home.

When I said four pads for battery it's because I wanna use that conectors

"This one for lamp": http://www.tme.eu/es/Document/bbc83bc170be4d1ba1b2f8591889e6e0/DOC-5339-20090116-153746.pdf

"This for the battery": http://www.tme.eu/es/Document/5214192ebc72b71d1203bac76dc8198a/DOC-13633-20090217-111344.pdf

I wanna use all four wires two for positive and two for negative to increase the section. This is the reason for the four battery pads.

[quote=ImA4Wheelr] Jaimelito wrote: Please explain that timming problem.

Thanks

At the time I posted that, you had made multiple posts with no replies. I was just trying to prevent you from being discouraged by the lack of replies by explaining that a lot of FW stuff seemed to be going on and that there are not many active programmers around. [/quote]

Don't worry about that I know that it's not a programmer forum but you are the only forum that has been concerned something for which I am very grateful.
I have a few things against me.
One can be, not knowing programming in C.
Two is, my language is not English and for me is complicated technical expressions comprehension.
But I see that, I do not have against people in this forum who tries to help.

"PCB": http://img.photobucket.com/albums/v174/JaiMeLiTo/pcb%20tamantildeo.png