Don't work nothing code or circuit is wrong

I am trying a circuit. When I pressed button 1 turn on led 1 and when I pressed button 2 turn on led 2. But I don't get no result.

/* Relays */

#define PUMP_PIN D6 //PUMP (Red LED)
#define LAMP_PIN D7 //LAMP (Green LED)
boolean pumpStatus = 0;
boolean lampStatus = 0;

/* Buttons */

#define PUMP_ON_BUTTON D9 //push-button PUMP (Red)
#define LAMP_ON_BUTTON D10 //push-button LAMP (Green)

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(10);
  Serial.println("ArduFarmBot 2");
  Serial.println(".... Starting Setup");
  Serial.println("  ");


  pinMode(PUMP_PIN, OUTPUT);
  pinMode(LAMP_PIN, OUTPUT);
  pinMode(PUMP_ON_BUTTON, INPUT_PULLUP);
  pinMode(LAMP_ON_BUTTON, INPUT_PULLUP);

  digitalWrite(PUMP_PIN, LOW);
  digitalWrite(LAMP_PIN, LOW);

}

void loop() {
  // put your main code here, to run repeatedly:

}

/****************************************************************
* Read local commands (Pump and Lamp buttons are normally "HIGH"):
****************************************************************/

void readLocalCmd()
{
  boolean digiValue = debounce(PUMP_ON_BUTTON);
  Serial.println(digiValue);
  if(!digiValue)
  {
    pumpStatus = !pumpStatus;
    aplyCmd();
  }
  digiValue = debounce(LAMP_ON_BUTTON);
  if(!digiValue)
  {
    lampStatus = !lampStatus;
    aplyCmd();
  }
}

/***************************************************
* Receive Commands and act on actuators
****************************************************/

void aplyCmd()
{
  if(pumpStatus == 1)
  {
    digitalWrite(PUMP_PIN, HIGH);
    
  }
  else
  {
    digitalWrite(PUMP_PIN, LOW);
  }

  if(lampStatus == 1)
  {
    digitalWrite(LAMP_PIN, HIGH);
  }
  else
  {
    digitalWrite(LAMP_PIN, LOW);
  }
}


/***************************************************
* Debouncing a key
****************************************************/
boolean debounce(int pin)
{
  boolean state;
  boolean previousState;
  const int debounceDelay = 30;
  
  previousState = digitalRead(pin);
  for(int counter=0; counter< debounceDelay; counter++)
  {
    delay(1);
    state = digitalRead(pin);
    if(state != previousState)
    {
      counter = 0;
      previousState = state;
    } 
  }
  return state;
}

void loop() {
  // put your main code here, to run repeatedly:

}

Right there.

Image from Original Post so we don't have to download it. See this Simple Image Guide

...R

Hi

Your main problem is that there is nothing in your loop() function.

The way an Arduino sketch works is that it executes setup() once after power-up/reset and then continuously executes loop() until power-down/reset.

Try changing this:-

void loop() {
  // put your main code here, to run repeatedly:

}

To this:-

void loop() {
  readLocalCmd();

}

Which should get you going.

Ian

mangulo:
I am trying a circuit. When I pressed button 1 turn on led 1 and when I pressed button 2 turn on led 2. But I don't get no result.

You have no code in your loop() function.

You must call your other functions from loop()

Have a look at Planning and Implementing a Program

...R

But I don't get no result.

If you don't get "no result", then you should tell us the result that you do get.