Looking for mistakes in my code for arduino as a flashlight controller

Hey!,
I would like to make my sketch running, but I have some problems with it. It’s a controller for flashlight based on atmega328p. After hooking power supply to Uno, digital pin 7 goes high (which would be later connected to enable pin of dc/dc driving power Leds). Pin 6 spreads pwm (dimming function) with variable duty cycle according to how many times button is pressed (it switches throught 3 modes with different duty cycle). To turn the flashlight off the button should be pressed for 2,5 s, which it does. The problem is that after turning off, it doesn’t want to turn on, when the button is pressed (interrupt comes in). When I press the button, pins 6 and 7 go high just for very short time and go low again. I would like it to power on when i pressthe button. Code also implements battery voltage measuring and other features but they are not the case. Button is connecting pin to supply voltage and pulldown resistor is added.

LowPower.h (3.13 KB)

dolampki.ino (6.4 KB)

This would seem to be the perfect time to begin debugging your program by using Serial.print() to display values being tested in your code. Then you can determine if the values are what you believe them to be.

Paul

Read the article at the top of the Forum about how to use the Forum. Include your code the way it instructs you to do so there. Include ALL the code.

Interrupt? Without reading your code, I imagine you are thinking it is like a reset.

Interrupts are intended for minimum interruption. They are not resets. Your code must explicitly reset everything you need reset.