inplermenting strobe function


hello in making led flashlight arduino pro mini inside contole led on mosfet.
i have pwm working 5 steps , resetting love have strobe function
but have no idea how

this code
code: [select]

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 want press button after led on full power (255) instead of going 0 going strobe , wen press 1 more time turns off
if can me greateful

code: [select]
  if (volt1 = 9)ledlevel = 0;
after assign value 9 volt1, test true. want == in there, not =.

code: [select]
  if (ledlevel > 255) ledlevel = 0;
well, that's why led strobing. if cap ledlevel @ 255, rather setting 0, strobing stop.


Arduino Forum > Using Arduino > Programming Questions > inplermenting strobe function


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code