Skip to main content
Edit after comment
Source Link
Code Gorilla
  • 5.7k
  • 1
  • 17
  • 31

I think you are asking

if (value > 5)
{
  StatementOne;
  statementTwo;
}

But I think you might want to write a function, which would look like this

void doThing(int button, int led)
{
  if (digitalRead(button))
     digitalWrite(led);
}

[Edit after reading your comment] So you need to store the state of the system as a variable in the code.

bool state = false;
if (button1 && !state)
{
  state = true;
  // Your on code.
} 
if (button2 && state)
{
  state = false; 
  // Your off code
}

You need to add your existing code for turning your LCD and LED on and off where the comments are.
The state variable holds the on or off state of your LCD and LED. You can of course split it even further so your LCD and LED come on separately of each other.

Does that help? If so don't forget to mark it as answered.

I think you are asking

if (value > 5)
{
  StatementOne;
  statementTwo;
}

But I think you might want to write a function, which would look like this

void doThing(int button, int led)
{
  if (digitalRead(button))
     digitalWrite(led);
}

I think you are asking

if (value > 5)
{
  StatementOne;
  statementTwo;
}

But I think you might want to write a function, which would look like this

void doThing(int button, int led)
{
  if (digitalRead(button))
     digitalWrite(led);
}

[Edit after reading your comment] So you need to store the state of the system as a variable in the code.

bool state = false;
if (button1 && !state)
{
  state = true;
  // Your on code.
} 
if (button2 && state)
{
  state = false; 
  // Your off code
}

You need to add your existing code for turning your LCD and LED on and off where the comments are.
The state variable holds the on or off state of your LCD and LED. You can of course split it even further so your LCD and LED come on separately of each other.

Does that help? If so don't forget to mark it as answered.

Source Link
Code Gorilla
  • 5.7k
  • 1
  • 17
  • 31

I think you are asking

if (value > 5)
{
  StatementOne;
  statementTwo;
}

But I think you might want to write a function, which would look like this

void doThing(int button, int led)
{
  if (digitalRead(button))
     digitalWrite(led);
}