Hi, I'm new to arduino, I need you to help me with a program by a push-button and 2 LEDs do the following.
when you press the button equal to or less than 5 times turns on the led 1, after 6 to 10 turn only led 2 and 11, is then reset, I think I have an idea, but need help from experienced people like you
You need to first detect button pressed and increment a counter (plus a delay for
software debounce). (you can find lots of examples all over this site for that)
int counter = 0 ;
void loop ()
{
 if ( // here go the button change detection and debouncing - an exercise for you
 {
  counter ++ ;
Next to force the counter to be modulo 10:
  counter %= 10 ;
Then you can use the value of the counter to update the LED pin:
  digitalWrite (LED1_pin, counter < 5) ;
  digitalWrite (LED2_pin, counter >= 5) ;
 }
Note that modular arithmetic counts from zero, so I test for 0..4 and 5..9,
one off from what you describe.
and how can i reset the program??
or it´s automatic
mnuelv:
and how can i reset the program??
or it´s automatic
use modulo 11 instead of 10 and
digitalWrite (LED1_pin, (counter < 6) && (counter >0)) ;
digitalWrite (LED2_pin, counter >= 6) ;
if (counter == 0){
digitalWrite (LED1_pin, LOW) ;
digitalWrite (LED2_pin, LOW) ;
}
}