1

Topic: push button and timer

I want to set 8 buttons up that allow me to set up a timer for each one. Once pushed on the others are ignored until the timer reaches zero. Then I want the button to revert back to the "off" color or its original state on the phone. I can successfully use the on off switch to control the LED but I have to manually turn it off on the phone. Suggestions??

2

Re: push button and timer

uint8_t button_1;             // =1 if switch ON and =0 if OFF -RemoteXY

const int LED_1_PIN = 5;

unsigned long ledTimer = 0;
unsigned int ledTimeOn = 5000;  //Time on for LED

void setup()
{
  pinMode(LED_1_PIN, OUTPUT);
}

void loop()
{
  if (ledTimer == 0)
  {
    // Add more buttons below, could be done in an array for simplifying
    if (RemoteXY.button_1 == 1)
    {
      ledTimer = millis();
      digitalWrite(LED_1_PIN, HIGH);
    }
  }
  if (ledTimer > 0)
  {
    if (millis() - ledTimer >= ledTimeOn)
    {
      // Add more buttons below, could be done in an array for simplifying
      if (RemoteXY.button_1 == 1)
      {
        ledTimer = 0;
        digitalWrite(LED_1_PIN, LOW);
        RemoteXY.button_1 = 0;
      }
    }
  }
}

3

Re: push button and timer

Thank You for your help... I'll be working on it this week!!!