Show Posts
Pages: [1]
1  Using Arduino / LEDs and Multiplexing / Re: How to set a few programms to ONE BUTTON. LED POLICE FLASHER on: January 07, 2013, 02:42:26 pm
NOWW WITH CODEEE!!!!!!

You can find everything you need to make one on my BLOG here:

http://electronicandcomputerone.blogspot.com/
2  Using Arduino / LEDs and Multiplexing / Re: How to set a few programms to ONE BUTTON. LED POLICE FLASHER on: December 03, 2012, 06:37:04 am
Yeah, Thank you so much!
3  Using Arduino / LEDs and Multiplexing / Re: How to set a few programms to ONE BUTTON. LED POLICE FLASHER on: September 19, 2012, 10:23:36 am
Hi, thanks you so much!!! I finished with this police flasher!!
You can watch this on YT :       







Berni
4  Using Arduino / LEDs and Multiplexing / Re: How to set a few programms to ONE BUTTON. LED POLICE FLASHER on: July 30, 2012, 11:59:27 am
With this "but only the first time" I mean when i turn on arduino and first program running, and when i want to change program from 1 to 2 it works fine, other i need to hold button down for some time to change or i need to press a few times on it.
This is part of sketch! i didn't write all programs because it will be very long.
Code:
const int patternCount = 15;
int LED1=4;
int LED2=5;
int LED3=6;
int LED4=7;
int LED5=8;
int LED6=9;
int LED7=10;
int LED8=11;
int LED9=12;
int LED10=3;
int buttonPin=2;
static unsigned long lastButtonTime = 0;
void setup()
{

  pinMode((LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8,LED9,LED10),OUTPUT);  // set each LED to pins
  pinMode(buttonPin,INPUT);
 
}


void loop()
    {
    static int pattern = 1; 
//  If the button is down and the last time it went down was more than 1/10th second ago.
   if (digitalRead(buttonPin) && (millis() - lastButtonTime) > 100)
   
        {
        lastButtonTime = millis();
       
        pattern = (pattern + 1) % patternCount;
       
        }
   
    switch (pattern)
        {
 
     
    case 1:
   digitalWrite(LED1,HIGH); 
   digitalWrite(LED2,HIGH); 
   digitalWrite(LED3,HIGH);
   digitalWrite(LED4,HIGH);
   digitalWrite(LED5,HIGH);
   delay(50);
   digitalWrite(LED1,LOW); 
   digitalWrite(LED2,LOW); 
   digitalWrite(LED3,LOW);
   digitalWrite(LED4,LOW);
   digitalWrite(LED5,LOW);
   delay(50);

case 2: (program) break;
case 3: (program) break;
case 4: (program) break;
case 5: (program) break;
case 6: (program) break;
case 7: (program) break;
case 8: (program) break;
case 9: (program) break;
case 10: (program) break;
case 11: (program) break;
5  Using Arduino / LEDs and Multiplexing / Re: How to set a few programms to ONE BUTTON. LED POLICE FLASHER on: July 30, 2012, 04:57:31 am
Code:
    static unsigned long lastButtonTime = 0;

    //  If the button is down and the last time it went down was more than 1/10th second ago.
    if (digitalRead(buttonPin) && (millis() - lastButtonTime) > 100)
        {
        lastButtonTime = millis();
        pattern = (pattern + 1) % patternCount;
        }


Yeah it works! Thnaks!
 but only first time! I don't know why.  I was changing the time when it went down and i setting like this :

  if (digitalRead(buttonPin) && (millis() - lastButtonTime) > 10) and  nothing happens. it's the same like before.

Maybe I can put it in every case so when i press button he does this, and maybe it will work fine if that is possible? 

What do you think about it?
6  Using Arduino / LEDs and Multiplexing / Re: How to set a few programms to ONE BUTTON. LED POLICE FLASHER on: July 29, 2012, 03:56:35 pm
Maybe there are some function like counting presses or something else with i can set all that programs

That's correct!  Each time you detect the button press you switch to the next pattern.  If you are already at the last pattern you switch back to the first pattern.  Like this:

Code:
const int patternCount = 5;

void loop()
    {
    static int pattern = 0;

    if (digitalRead(buttonPin))
        {
        pattern = (pattern + 1) % patternCount;
        }

    switch (pattern)
        {
    case 0:  doPattern0(); break;
    case 1:  doPattern1(); break;
    case 2:  doPattern2(); break;
    case 3:  doPattern3(); break;
    case 4:  doPattern4(); break;
        }
    }
       

YEAHHH!!  It works really nice!!
THANKS!!!  smiley
but
there is another problem and that is bounce. I write several code with debounce and nothnig doesn't work! really i don't know how to fix it!
if you know, please write!
thanks! smiley
7  Using Arduino / LEDs and Multiplexing / How to set a few programms to ONE BUTTON. LED POLICE FLASHER on: July 29, 2012, 11:52:46 am
So, can anyone tell me how to set a few programs to one button, I work on some LED police flasher and i have a many programs that loops throught program and that become boring, so i think that will be better to put one button inside circuit and set all this programs to him if that is possible???  maybe there are some function like counting presses or something else with i can set all that programs but i don't know which is!    smiley
SO IF ANYONE KNOWS!!! PLEASE HELPP

by: Berni
Pages: [1]