hello in making a led flashlight with arduino pro mini inside to contole the led on a mosfet.
i now have pwm working with 5 steps and resetting but i would love to have a strobe function
but i have no idea how to do this
this is my code
int switchPin = 8;
int ledPin = 11;
boolean lastButton = LOW;
boolean currentButton = LOW;
int ledLevel = 0;
int Voltin1 = A0;
float Volt1;
void setup()
{
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
}
boolean debounce(boolean last)
{
boolean current = digitalRead(switchPin);
if (last != current)
{
delay(5);
current = digitalRead(switchPin);
}
return current;
}
void loop()
{
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{
ledLevel = ledLevel + 51;
}
lastButton = currentButton;
if (Volt1 = 9)ledLevel = 0;
if (ledLevel > 255) ledLevel = 0;
analogWrite(ledPin, ledLevel);
Volt1 = analogRead(Voltin1);
Volt1 = Volt1 / 24;
}
i just want to press the button after the led is on full power (255) instead of it going back to 0 its going to strobe and wen i press it one more time it turns off
if someone can help me with that i will be greateful