# Help! "Error compiling for board" msg

**URL:** <https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594>\
**Category:** General Guidance\
**Created:** [November 27, 2021, 10:02am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594 "2021-11-27T10:02:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 27, 2021, 10:02am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/1 "2021-11-27T10:02:21Z")

</div>

Hello. I have a sketch I'm trying to load up to my D1 mini clone, It is quite long, made up of several different bits of other codes. When I try to compile, I am getting

exit status 1  
Error compiling for board LOLIN(WEMOS) D1 mini (clone).

My code is as follows:

```cpp
#include <Wire.h> 
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFiMulti.h> // FOR WIFI SIGNAL
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Adafruit_NeoPixel.h>

// ************DEFINIR AQUI LOS SSID DE CADA DISPOSITIVO***********
#ifndef APSSID
#define APSSID "Rpwn1"
#define APPSK "batalla2"
#endif

LiquidCrystal_I2C lcd(0x27, 16, 2);
//char* GAME_TIME="Tiempo de Juego:";
//char* BOMB_TIME="Tiempo Deton.:";
//char* ARM_TIME="Tiempo de Armado:";
//char* ZERO_SECS="00 segundos";
//char* ENABLE_SOUND="Activar Sonido?";
//char* YES_OR_NOT="A: SI B: No";
//char* GAME_TIME_TOP="TIEMPO DE JUEGO";
//char* GAME_OVER = "FIN DEL JUEGO! ";
const int RSSI_MAX =-50;// define maximum strength of signal in dBm
const int RSSI_MIN =-100;// define minimum strength of signal in dBm
int pointDistance = 0;
ESP8266WiFiMulti wifiMulti;

//const uint32_t connectTimeoutMs = 10000;

/* Set these to your desired credentials. */
const char *ssid = APSSID;
const char *password = APPSK;
const byte ROWS = 1; //four rows
const byte COLS = 2; //four columns
char keys[ROWS][COLS] = {
  {'c', 'd'}
  };
byte rowPins[ROWS] = {15}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {13, 12}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

    // variable for reading the pushbutton status

//TIME INTS
int GAMEHOURS = 0;
int GAMEMINUTES = 45;
int BOMBMINUTES = 4;
int ACTIVATESECONDS = 3;

boolean endGame = false;
boolean refresh = true; //1 refresh one time...
boolean sdStatus = false; //search and destroy game enable used in config
boolean saStatus = false; //same but SAbotaghe
boolean doStatus = false; //for DEmolition
boolean start = true;
boolean defusing;
boolean cancelando;

// SOUND TONES
boolean soundEnable = true;
int tonepin = 2; // Pin 2 for the sound
int alarmTone1 = 700;
int alarmTone2 = 2600;
int activeTone = 1330;
int errorTone = 100;

unsigned long iTime;
unsigned long timeCalcVar;
unsigned long redTime;
unsigned long blueTime;
unsigned long iZoneTime;//initial time for zone
byte team=0; // 0 = neutral, 1 = blue team, 2 = red team
#define PIN 14
#define NUM_LEDS 20

//LED strip
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup(){
  lcd.begin();
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  pinMode(tonepin, OUTPUT);
  Serial.begin(9600);
  lcd.setCursor(1,0);
  tone(tonepin,2400,300);
  lcd.print(" *****LOBOS******");// you can add your team name or someting cool
  lcd.setCursor(2,1);
  lcd.print(" ***DEL NORTE****");// you can add your team name or someting cool

WiFi.softAP(ssid, password);
  
  // CONFIGURE THE BARS OF PROGRESS BAR
  byte bar1[8] = {
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
  };
  byte bar2[8] = {
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
  };
  byte bar3[8] = {
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
  };
  byte bar4[8] = {
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
  };
  byte bar5[8] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
  };
  byte up[8] = {
    B00000,
    B00100,
    B01110,
    B11111,
    B11111,
    B00000,
    B00000,
  };

  byte down[8] = {
    B00000,
    B00000,
    B11111,
    B11111,
    B01110,
    B00100,
    B00000,
  };
  lcd.createChar(0,bar1);
  lcd.createChar(1,bar2);
  lcd.createChar(2,bar3);
  lcd.createChar(3,bar4);
  lcd.createChar(4,bar5);
  lcd.createChar(5,up);
  lcd.createChar(6,down);
}

void loop(){

  domination();
  
 }
void keypadEvent(KeypadEvent key){
  switch (keypad.getState()){
    case RELEASED:
      switch (key){
         case 'd': defusing=false;
         break;
         case 'c': cancelando=false;
         break;
      }
    break;
    case HOLD:
      switch (key){
        case 'd': defusing= true;
        break;
        case 'c': cancelando=true;
        break;
      }
    break;
  }
}
//##################MENUS###############################

void domination(){

  //SETUP INITIAL TIME 
  int minutos = GAMEMINUTES-1;
  boolean showGameTime=true;
  unsigned long a;
  unsigned long iTime=millis(); // initialTime in millisec 
  unsigned long aTime;
 
  team=0;
  iZoneTime=0;
  aTime=0;
  redTime=0;
  blueTime=0;

  int largoTono = 50;
  // 0 = neutral, 1 = blue team, 2 = red team
  a=millis();
  //Starting Game Code
  while(1) // this is the important code, is a little messy but works good.
  {
    if(endGame){
      gameOver();
    }
    
    keypad.getKey();
    aTime=millis()- iTime;
    //Code for led blinking
    timeCalcVar=(millis()- iTime)%1000;
    if(timeCalcVar >= 0 && timeCalcVar <= 40)
    {
      if(team==1)RunningLights(0,0,0xff, 50); //CALL TO LIGHT STRIP bkue
      if(team==2)RunningLights(0xff,0,0, 50); //CALL TO LIGHT STRIP red
    }
    if(timeCalcVar >= 50 && timeCalcVar <= 100)
    {    
      if(team==1)RunningLights(0,0,0, 50); //turn light strip off (All black)
      if(team==2)RunningLights(0,0,0, 50);  
    }
    // Sound!!! same as Destroy 
    if(timeCalcVar >= 0 && timeCalcVar <= 40 && soundEnable)tone(tonepin,activeTone,largoTono);

    if(timeCalcVar >= 245 && timeCalcVar <= 255 && minutos-aTime/60000<2 && soundEnable)tone(tonepin,activeTone,largoTono);
    if(timeCalcVar >= 495 && timeCalcVar <= 510 && minutos-aTime/60000<4 && soundEnable)tone(tonepin,activeTone,largoTono);
    if(timeCalcVar >= 745 && timeCalcVar <= 760 && minutos-aTime/60000<2 && soundEnable)tone(tonepin,activeTone,largoTono);
    //Help to count 3 secs
    if(a+2000<millis()){
      a=millis();   
      showGameTime=!showGameTime;
      cls();
    }

    if(showGameTime){ //THE SECOND IS /2
      lcd.setCursor(0,0);
      lcd.print("TIEMPO DE JUEGO");
      lcd.setCursor(3,1);
      printTime(minutos, aTime);
    }
    else if (!showGameTime){

      lcd.setCursor(2,0);
      if(team == 0)lcd.print("ZONA NEUTRAL");
      if(team == 1)lcd.print(" ZONA AZUL");
      if(team == 2)lcd.print(" ZONA ROJA");

      if(team>0){
        lcd.setCursor(3,1);
        printTimeDom(millis()-iZoneTime,true);
      }
    }

    //###########################CHECKINGS##################

    //Check If Game End
    if(minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0)
    {
      gameOver();
    }

    //Check If IS neutral
    while((defusing || cancelando) && team > 0)
    {
      cls();
      if(team>0)lcd.print("NEUTRALIZANDO...");
      lcd.setCursor(0,1);
      unsigned int percent=0;
      unsigned long xTime=millis(); //start disabling time
      while(defusing || cancelando)
      {
        //check if game time runs out during the disabling
        aTime= millis()- iTime;
        if((minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0) || minutos-aTime/60000>4000000000){ 
          endGame = true;
        }
        
        keypad.getKey();
        timeCalcVar = (millis()- xTime)%1000;

        if( timeCalcVar >= 0 && timeCalcVar <= 20)
        {
          if(soundEnable)tone(tonepin,alarmTone1,200);
        }
        if(timeCalcVar >= 480 && timeCalcVar <= 500)
        {
          if(soundEnable)tone(tonepin,alarmTone2,200);
          RunningLights(0,0,0, 50);
        }

        unsigned long seconds= millis() - xTime;
        percent = (seconds)/(ACTIVATESECONDS*10);
        drawBar(percent);

        if(percent >= 100)
        {
          delay(1000);

          if(team==1){ 
            blueTime+=millis()-iZoneTime;
            iZoneTime=0; 

          }
          if(team==2){ 
            redTime+=millis()-iZoneTime;
            iZoneTime=0; 
          }
          team=0;
          break;
        }
      }
      cls();
    }

    //Capturing red

    while(defusing && team == 0 )
    {
      cls();
      if(team==0)lcd.print("CAPTURANDO ZONA");
      lcd.setCursor(0,1);
      unsigned int percent=0;
      unsigned long xTime=millis(); //start disabling time
      while(defusing)
      {
        keypad.getKey();
        //check if game time runs out during the disabling
        aTime= millis()- iTime;
        if((minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0) || minutos-aTime/60000>4000000000){ 
          endGame = true;
        }
        timeCalcVar = (millis()- xTime)%1000;

        if( timeCalcVar >= 0 && timeCalcVar <= 20)
        {
          RunningLights(0xff,0,0, 50);  
          if(soundEnable)tone(tonepin,alarmTone1,200);
        }
        if(timeCalcVar >= 480 && timeCalcVar <= 500)
        {
          if(soundEnable)tone(tonepin,alarmTone2,200);
          RunningLights(0,0,0, 50);
        }

        unsigned long seconds= millis() - xTime;
        percent = (seconds)/(ACTIVATESECONDS*10);
        drawBar(percent);

        if(percent >= 100)
        {
          RunningLights(0,0,0, 50);
          team=2;
          iZoneTime=millis();
          delay(1000);
          break;
        }
      }
      cls();
      RunningLights(0,0,0, 50);
    }

    //getting to blue zone
    while(cancelando && team == 0 )
    {
      cls();
      if(team==0)lcd.print("CAPTURANDO ZONA");
      lcd.setCursor(0,1);
      unsigned int percent=0;
      unsigned long xTime=millis(); //start disabling time
      while(cancelando)
      {
        keypad.getKey();
        //check if game time runs out during the disabling
        aTime= millis()- iTime;
        if((minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0) || minutos-aTime/60000>4000000000){ 
          endGame = true;
        }
        timeCalcVar = (millis()- xTime)%1000;

        if( timeCalcVar >= 0 && timeCalcVar <= 20)
        {
          RunningLights(0,0,0xff, 50);   
          if(soundEnable)tone(tonepin,alarmTone1,200);
        }
        if(timeCalcVar >= 480 && timeCalcVar <= 500)
        {
          if(soundEnable)tone(tonepin,alarmTone2,200);
          RunningLights(0,0,0, 50);
        }

        unsigned long seconds= millis() - xTime;
        percent = (seconds)/(ACTIVATESECONDS*10);
        drawBar(percent);

        if(percent >= 100)
        {
          RunningLights(0,0,0, 50);
          team=1;
          iZoneTime=millis();
          delay(1000);
          break;
        }
      }
      cls();
      RunningLights(0,0,0, 50);  
    }
  }
}

void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
  int Position=0;
 
  for(int j=0; j<NUM_LEDS*2; j++)
  {
      Position++; // = 0; //Position + Rate;
      for(int i=0; i<NUM_LEDS; i++) {
        setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
                   ((sin(i+Position) * 127 + 128)/255)*green,
                   ((sin(i+Position) * 127 + 128)/255)*blue);
      }
     
      showStrip();
      delay(70);
  }
}

void showStrip() {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strip.show();
 #endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strip.setPixelColor(Pixel, strip.Color(red, green, blue));
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;
 #endif
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}  

void gameOver(){

  if(team==1)blueTime+=millis()-iZoneTime;
  if(team==2)redTime+=millis()-iZoneTime;
  RunningLights(0,0,0, 50);
  while(!defusing){
    keypad.getKey();
    if(defusing){
      keypad.getKey();
      break;
    }
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("TIEMPO ACABADO!");
    lcd.setCursor(1,1);

    if(blueTime>redTime){
      //blueteam wins
      lcd.print("AZULES GANAN");
      RunningLights(0,0,0xff, 50); //CALL TO LIGHT STRIP FUNCTION
    }
    else{
      //redteam wins 
      lcd.print(" ROJOS GANAN");
      RunningLights(0xff,0,0, 50); //CALL TO LIGHT STRIP FUNCTION
    }
    delay(2000);
    keypad.getKey();
    if(defusing){
      keypad.getKey();
      break;
    }
    cls();
    lcd.print("Tiempo Rojo:");
    lcd.setCursor(5,1);
    printTimeDom(redTime,false);
    delay(3000);
    keypad.getKey();
    if(defusing){
      keypad.getKey();
      break;
    }
    cls();
    lcd.print("Tiempo Azul:");
    lcd.setCursor(5,1);
    printTimeDom(blueTime,false);
    delay(2000);
    keypad.getKey();
    if(defusing){
      keypad.getKey();
      break;
    }
  }
}
     //###########################CHECKINGS##################

void drawBar(byte porcent){
  //TODO: Optimize this code 
  int box=(8*porcent)/10;
  lcd.setCursor(0,1);
  while(box>=5){
    if(box>=5)
    {
      lcd.write(4);
      box-=5;
    }
  }
    switch(box){
    case 0:
      break;
    case 1:
      lcd.write((uint8_t)0);
      break;
    case 2:
      lcd.write(1);
      break;
    case 3:
      lcd.write(2);
      break;
    case 4:
      lcd.write(3);
      break;
    }
}
void cls(){
  lcd.clear();
  lcd.setCursor(0,0);
}
void printTime(unsigned long minutos, unsigned long aTiempo){

  timeCalcVar=minutos-aTiempo/60000;
  //Hours
  
  if(timeCalcVar/60==0 && refresh){
      lcd.clear();
      refresh=false;
      //delay(100);
      lcd.setCursor(3,1);
      Serial.println("!!!!");
  }
   
  if(timeCalcVar/60>=1){
    
    if(timeCalcVar/60<10)
  {
    lcd.setCursor(2,1);
    lcd.print("0");
    lcd.print(timeCalcVar/60);
  }
  else
  {
    lcd.print(timeCalcVar/60);
  }
  
  lcd.print(":");
  
  }
  //minutes
  if(timeCalcVar%60<10)
  {
    lcd.print("0");
    lcd.print(timeCalcVar%60);
  }
  else
  {
    lcd.print(timeCalcVar%60);
  }
  lcd.print(":");
  //seconds
  timeCalcVar=aTiempo/1000;
  if(59-(timeCalcVar%60)<10)
  {
    lcd.print("0");
    lcd.print(59-(timeCalcVar%60));
  }
  else
  {
    lcd.print(59-(timeCalcVar%60));
  }
  lcd.print(":");
  lcd.print(999-(millis()%1000));
}

void printTimeDom(unsigned long aTiempo, boolean showMillis){
  //minutes
  if((aTiempo/60000)<10)
  {
    lcd.print("0");
    lcd.print(aTiempo/60000);
  }
  else
  {
    lcd.print(aTiempo/60000);
  }
  lcd.print(":");
  //seconds
  if(((aTiempo/1000)%60)<10)
  {
    lcd.print("0");
    lcd.print((aTiempo/1000)%60);
  }
  else
  {
    lcd.print((aTiempo/1000)%60);
  }
  if(showMillis){
    lcd.print(":");
    lcd.print(999-millis()%1000);
  }
}

void startGameCount(){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Listo");
  lcd.setCursor(0,1);
  lcd.print("Presione 1 Boton");
  keypad.waitForKey();//if you press a button game start

  cls();
  lcd.setCursor(1,0);
  lcd.print("Iniciando Juego");
  for(int i = 5; i > 0 ; i--){ // START COUNT GAME INIT
    lcd.setCursor(5,1);
    tone(tonepin,2000,100);
    lcd.print(" EN ");
    lcd.print(i);
    delay(1000);
  }
  cls();
  domination();
}

void checkArrows(byte i,byte maxx ){

  if(i==0){
    lcd.setCursor(15,1);
    lcd.write(6); 
  }
  if(i==maxx){  
    lcd.setCursor(15,0);
    lcd.write(5);
  }
  if(i>0 && i<maxx){
    lcd.setCursor(15,1);
    lcd.write(6);
    lcd.setCursor(15,0);
    lcd.write(5);  
  }
}

int dBmtoPercentage(int dBm)
{
  int quality;
    if(dBm <= RSSI_MIN)
    {
        quality = 0;
    }
    else if(dBm >= RSSI_MAX)
    {  
        quality = 100;
    }
    else
    {
        quality = 2 * (dBm + 100);
   }

     return quality;
}//dBmtoPercentage

```

Any help would be much appreciated.

---

<div class="post-metadata">

**Author:** ![anon73444976](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon73444976](https://forum.arduino.cc/u/anon73444976)\
**Post date:** [November 27, 2021, 10:08am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/2 "2021-11-27T10:08:52Z")

</div>

> [@capetito](#):
>
> When I try to compile, I am getting
> 
> exit status 1  
> Error compiling for board LOLIN(WEMOS) D1 mini (clone).

You probably get a whole lot more  
Post it  
All of it

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 27, 2021, 10:26am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/3 "2021-11-27T10:26:16Z")

</div>

this is the error message i get.

```cpp
Compiling sketch...
"C:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" -I "C:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/signing.py" --mode header --publickey "C:\\Users\\Us\\AppData\\Local\\Temp\\arduino_modified_sketch_962261/public.key" --out "C:\\Users\\Us\\AppData\\Local\\Temp\\arduino_build_870283/core/Updater_Signing.h"
"C:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++" -D __ets__ -DICACHE_FLASH -U __STRICT_ANSI__ -D_GNU_SOURCE "-IC:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/include" "-IC:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/lwip2/include" "-IC:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\Us\\AppData\\Local\\Temp\\arduino_build_870283/core" -c -Wall -Wextra -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10816 -DARDUINO_ESP8266_WEMOS_D1MINI -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_WEMOS_D1MINI\"" -DFLASHMODE_DOUT -DESP8266 "-IC:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\cores\\esp8266" "-IC:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\variants\\d1_mini" "-IC:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\libraries\\Wire" "-IC:\\Users\\Us\\Documents\\Arduino\\libraries\\Keypad\\src" "-IC:\\Users\\Us\\Documents\\Arduino\\libraries\\Arduino-LiquidCrystal-I2C-library-master" "-IC:\\Users\\Us\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\libraries\\ESP8266WiFi\\src" "-IC:\\Users\\Us\\Documents\\Arduino\\libraries\\Adafruit_NeoPixel" "C:\\Users\\Us\\AppData\\Local\\Temp\\arduino_build_870283\\sketch\\flag_dominable_encoder.ino.cpp" -o "C:\\Users\\Us\\AppData\\Local\\Temp\\arduino_build_870283\\sketch\\flag_dominable_encoder.ino.cpp.o"
In file included from C:\Users\Us\AppData\Local\Temp\arduino_build_870283\sketch\flag_dominable_encoder.ino.cpp:1:
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/Arduino.h:44:14: error: expected identifier before numeric constant
   44 | #define HIGH 0x1
      | ^~~
C:\Users\Us\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
   56 | #define CLOSED HIGH
      | ^~~~
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/wl_definitions.h:74:3: note: in expansion of macro 'CLOSED'
   74 | CLOSED = 0,
      | ^ ~~~~~
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/Arduino.h:44:14: error: expected '}' before numeric constant
   44 | #define HIGH 0x1
      | ^~~
C:\Users\Us\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
   56 | #define CLOSED HIGH
      | ^~~~
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/wl_definitions.h:74:3: note: in expansion of macro 'CLOSED'
   74 | CLOSED = 0,
      | ^ ~~~~~
In file included from C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src/ESP8266WiFi.h:28,
                 from C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src/ESP8266WiFiMulti.h:30,
                 from C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:4:
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/wl_definitions.h:73:19: note: to match this '{'
   73 | enum wl_tcp_state {
      | ^
In file included from C:\Users\Us\AppData\Local\Temp\arduino_build_870283\sketch\flag_dominable_encoder.ino.cpp:1:
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/Arduino.h:44:14: error: expected unqualified-id before numeric constant
   44 | #define HIGH 0x1
      | ^~~
C:\Users\Us\Documents\Arduino\libraries\Keypad\src/Keypad.h:56:16: note: in expansion of macro 'HIGH'
   56 | #define CLOSED HIGH
      | ^~~~
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/wl_definitions.h:74:3: note: in expansion of macro 'CLOSED'
   74 | CLOSED = 0,
      | ^ ~~~~~
In file included from C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src/ESP8266WiFiMulti.h:30,
                 from C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:4:
C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\src/ESP8266WiFi.h:29:1: error: expected declaration before '}' token
   29 | }
      | ^
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino: In function 'void keypadEvent(KeypadEvent)':
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:180:10: warning: enumeration value 'IDLE' not handled in switch [-Wswitch]
  180 | switch (keypad.getState()){
      | ^
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:180:10: warning: enumeration value 'PRESSED' not handled in switch [-Wswitch]
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino: In function 'void domination()':
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:230:20: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
  230 | if(timeCalcVar >= 0 && timeCalcVar <= 40)
      | ~~~~~~~~~~~~^~~~
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:241:20: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
  241 | if(timeCalcVar >= 0 && timeCalcVar <= 40 && soundEnable)tone(tonepin,activeTone,largoTono);
      | ~~~~~~~~~~~~^~~~
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:299:25: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
  299 | if( timeCalcVar >= 0 && timeCalcVar <= 20)
      | ~~~~~~~~~~~~^~~~
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:352:25: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
  352 | if( timeCalcVar >= 0 && timeCalcVar <= 20)
      | ~~~~~~~~~~~~^~~~
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:398:25: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
  398 | if( timeCalcVar >= 0 && timeCalcVar <= 20)
      | ~~~~~~~~~~~~^~~~
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino: In function 'void RunningLights(byte, byte, byte, int)':
C:\Users\Us\AppData\Local\Temp\arduino_modified_sketch_962261\flag_dominable_encoder.ino:428:57: warning: unused parameter 'WaveDelay' [-Wunused-parameter]
  428 | void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
      | ~~~~^~~~~~~~~
Using library Wire at version 1.0 in folder: C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\Wire 
Using library Keypad at version 3.1.1 in folder: C:\Users\Us\Documents\Arduino\libraries\Keypad 
Using library Arduino-LiquidCrystal-I2C-library-master in folder: C:\Users\Us\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master (legacy)
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\Us\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi 
Using library Adafruit_NeoPixel at version 1.10.0 in folder: C:\Users\Us\Documents\Arduino\libraries\Adafruit_NeoPixel 
exit status 1
Error compiling for board LOLIN(WEMOS) D1 mini (clone).

```

---

<div class="post-metadata">

**Author:** ![anon73444976](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon73444976](https://forum.arduino.cc/u/anon73444976)\
**Post date:** [November 27, 2021, 10:31am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/4 "2021-11-27T10:31:37Z")

</div>

If you've only got two keys, lose the keypad library.

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 27, 2021, 10:37am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/5 "2021-11-27T10:37:51Z")

</div>

I tried but couldnt get it to work. Where and how would I place that code?

---

<div class="post-metadata">

**Author:** ![anon73444976](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon73444976](https://forum.arduino.cc/u/anon73444976)\
**Post date:** [November 27, 2021, 10:50am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/6 "2021-11-27T10:50:11Z")

</div>

At a very quick glance, you just need to replace the code in keyEvent to read the I/O pins and set the defusing and cancelando variables

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [November 27, 2021, 11:41am UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/7 "2021-11-27T11:41:37Z")

</div>

Change the order of the #included statements so that Keypad.h is AFTER ESP8266WiFiMulti.h, apparently this is a case where the libraries have a conflicting DEFINE. There is a similar problem with the WiFiEsp library [https://forum.arduino.cc/t/wifiesp-and-keypad-library-conflict/582357](https://forum.arduino.cc/t/wifiesp-and-keypad-library-conflict/582357)

```cpp
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFiMulti.h> // FOR WIFI SIGNAL
#include <Keypad.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Adafruit_NeoPixel.h>

```

---

<div class="post-metadata">

**Author:** ![ruilviana](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ruilviana/32/722429_2.png) [@ruilviana](https://forum.arduino.cc/u/ruilviana)\
**Post date:** [November 27, 2021, 1:55pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/8 "2021-11-27T13:55:55Z")

</div>

Hi  
This error is being caused by some incompatibility between Keypad.h libraries and ESP Wifi libraries, like this ESP8266WiFiMulti.h and ESP8266WiFi.h.  
For checking just test the sketch below. It gives compilation error.

Because of my little knowledge I don't know the exact reason for the mistake. and how to solve it.

RV mineirin

```cpp
#include <Keypad.h>
#include <ESP8266WiFiMulti.h> // FOR WIFI SIGNAL

void setup(){
}

void loop(){
}

```

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 27, 2021, 2:20pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/9 "2021-11-27T14:20:49Z")

</div>

Thanks for the info.

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 27, 2021, 2:22pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/10 "2021-11-27T14:22:15Z")

</div>

Could you help me with that code? I'm not very adept with the programming part of these projects. Where and what would I need to include/remove?

---

<div class="post-metadata">

**Author:** ![ruilviana](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ruilviana/32/722429_2.png) [@ruilviana](https://forum.arduino.cc/u/ruilviana)\
**Post date:** [November 27, 2021, 2:23pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/11 "2021-11-27T14:23:51Z")

</div>

other people has this problem too.

> [@Error when including \<Keypad.h\> and \<ESP8266WiFi.h\>](https://forum.arduino.cc/t/error-when-including-keypad-h-and-esp8266wifi-h/655221):
>
> I got an error when I am trying to include: #include \<Keypad.h\> #include \<ESP8266WiFi.h\> When I add both of them to a program, the compiler gets the following error. I tried to edit the keypad library by commenting the \<Arduino.h\> inclusion because maybe the redeclaration makes the trouble but it isn't. Do you know why am I getting this error? Thanks [edit] I am not using a regular Arduino, I am using Wemos D1 R1 [edit] Here is the compiler error: In file included from sketch\V2.ino.cpp:…

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 23, 2021, 2:45pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/12 "2021-11-23T14:45:39Z")

</div>

Hello all.  
I'm trying to modify a skecth to use in an Airsoft game device. I got the source code from the web, it's been used an copied over many times before. I myself have used it to make an entire device with different game types according to video guides and tutorials.  
I now want to modify this code to use different hardware and code. Specifically, I want to use only one of the game modes and change the input device from a 4x4 keypad to 2 simple push buttons.  
So far I have the game mode part almost done, but I haven't been able to change the input method from the key pad to the push buttons.

The original sketch uses the keypad library, which has the keypad.getKey function that monitors for key presses. How can I achieve that with the 2 seperate push buttons? I need each button to do a different function.

Here is the code I have so far:

```cpp
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f,16,2);

//leds

const int REDLEDS = 15; //pin D8
const int GREENLED = 13; //pin D7

//TIME INTS
int GAMEHOURS = 4;
int GAMEMINUTES = 30;
int BOMBMINUTES = 5;
int ACTIVATESECONDS = 8;

boolean endGame = false;

boolean doStatus = false; //for DEmolition
boolean start = true;
boolean defusing;
boolean cancelando;

// SOUND TONES
boolean soundEnable = true;
int tonepin = 12; // Pin D6 for the buzzer
int alarmTone1 = 700;
int alarmTone2 = 2600;
int activeTone = 1330;
int errorTone = 100;

unsigned long iTime;
unsigned long timeCalcVar;
unsigned long redTime;
unsigned long greenTime;
unsigned long iZoneTime;//initial time for zone
byte team=0; // 0 = neutral, 1 = green team, 2 = red team

void setup(){
  lcd.begin(16, 2);
  Serial.begin(9600);
  lcd.setCursor(3,0);
  tone(tonepin,2400,30);
  lcd.print("LOBOS DEL");// you can add your team name or someting cool
  lcd.setCursor(4,1);
  lcd.print("NORTE");// you can add your team name or someting cool

  //PinModes
  pinMode(GREENLED, OUTPUT);     
  pinMode(REDLED, OUTPUT); 
// pinMode(RELAYPIN, OUTPUT);  
  // CONFIGURE THE BARS OF PROGRESS BAR
  byte bar1[8] = {
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
  };
  byte bar2[8] = {
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
  };
  byte bar3[8] = {
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
  };
  byte bar4[8] = {
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
  };
  byte bar5[8] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
  };
  byte up[8] = {
    B00000,
    B00100,
    B01110,
    B11111,
    B11111,
    B00000,
    B00000,
  };

  byte down[8] = {
    B00000,
    B00000,
    B11111,
    B11111,
    B01110,
    B00100,
    B00000,
  };
  lcd.createChar(0,bar1);
  lcd.createChar(1,bar2);
  lcd.createChar(2,bar3);
  lcd.createChar(3,bar4);
  lcd.createChar(4,bar5);
  lcd.createChar(5,up);
  lcd.createChar(6,down);
}

void loop(){

  //SETUP INITIAL TIME 
  int minutos = GAMEMINUTES-1;
  boolean showGameTime=true;
  unsigned long a;
  unsigned long iTime=millis(); // initialTime in millisec 
  unsigned long aTime;
 
  team=0;
  iZoneTime=0;
  aTime=0;
  redTime=0;
  greenTime=0;

  int largoTono = 50;
  // 0 = neutral, 1 = green team, 2 = red team
  a=millis();
  //Starting Game Code
  while(1) // this is the important code, is a little messy but works good.
  {
    if(endGame){
      gameOver();
    }
    
    keypad.getKey();
    aTime=millis()- iTime;
    
    //Code for led blinking
    timeCalcVar=(millis()- iTime)%1000;
    if(timeCalcVar >= 0 && timeCalcVar <= 40)
    {
      if(team==1)digitalWrite(GREENLED, HIGH);  
      if(team==2)digitalWrite(REDLED, HIGH);  
    }
    if(timeCalcVar >= 50 && timeCalcVar <= 100)
    {    
      if(team==1)digitalWrite(GREENLED, LOW);  
      if(team==2)digitalWrite(REDLED, LOW);
    }
    // Sound!!! same as Destroy 
    if(timeCalcVar >= 0 && timeCalcVar <= 40 && soundEnable)tone(tonepin,activeTone,largoTono);

    if(timeCalcVar >= 245 && timeCalcVar <= 255 && minutos-aTime/60000<2 && soundEnable)tone(tonepin,activeTone,largoTono);
    if(timeCalcVar >= 495 && timeCalcVar <= 510 && minutos-aTime/60000<4 && soundEnable)tone(tonepin,activeTone,largoTono);
    if(timeCalcVar >= 745 && timeCalcVar <= 760 && minutos-aTime/60000<2 && soundEnable)tone(tonepin,activeTone,largoTono);
    //Help to count 3 secs
    if(a+2000<millis()){
      a=millis();   
      showGameTime=!showGameTime;
      cls();
    }
    //THE NEXT TO METHODS SHOW "GAME TIME" AND "CONTROLED ZONE TIME" IT SHOWS 2 AND 2 SEC EACH

    if(showGameTime){ //THE SECOND IS /2
      lcd.setCursor(3,0);
      lcd.print("GAME TIME");
      lcd.setCursor(3,1);
      printTime(minutos, aTime);
    }
    else if (!showGameTime){

      lcd.setCursor(2,0);
      if(team == 0)lcd.print("NEUTRAL ZONE");
      if(team == 1)lcd.print(" GREEN ZONE");
      if(team == 2)lcd.print(" RED ZONE");

      if(team>0){
        lcd.setCursor(3,1);
        printTimeDom(millis()-iZoneTime,true);
      }
    }

    //###########################CHECKINGS##################

    //Check If Game End
    if(minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0)
    {
      gameOver();
    }

    //Check If IS neutral
    while((defusing || cancelando) && team > 0)
    {
      cls();
      if(team>0)lcd.print("NEUTRALIZING...");
      lcd.setCursor(0,1);
      unsigned int percent=0;
      unsigned long xTime=millis(); //start disabling time
      while(defusing || cancelando)
      {
        //check if game time runs out during the disabling
        aTime= millis()- iTime;
        if((minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0) || minutos-aTime/60000>4000000000){ 
          endGame = true;
        }
        
        keypad.getKey();
        timeCalcVar = (millis()- xTime)%1000;

        if( timeCalcVar >= 0 && timeCalcVar <= 20)
        {
          if(soundEnable)tone(tonepin,alarmTone1,200);
        }
        if(timeCalcVar >= 480 && timeCalcVar <= 500)
        {
          if(soundEnable)tone(tonepin,alarmTone2,200);
          digitalWrite(REDLED, LOW);
        }

        unsigned long seconds= millis() - xTime;
        percent = (seconds)/(ACTIVATESECONDS*10);
        drawBar(percent);

        if(percent >= 100)
        {
          delay(1000);

          if(team==1){ 
            greenTime+=millis()-iZoneTime;
            iZoneTime=0; 

          }
          if(team==2){ 
            redTime+=millis()-iZoneTime;
            iZoneTime=0; 
          }
          team=0;
          break;
        }
      }
      cls();
    }

    //Capturing red

    while(defusing && team == 0 )
    {
      cls();
      if(team==0)lcd.print(" CAPTURING ZONE");
      lcd.setCursor(0,1);
      unsigned int percent=0;
      unsigned long xTime=millis(); //start disabling time
      while(defusing)
      {
        keypad.getKey();
        //check if game time runs out during the disabling
        aTime= millis()- iTime;
        if((minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0) || minutos-aTime/60000>4000000000){ 
          endGame = true;
        }
        timeCalcVar = (millis()- xTime)%1000;

        if( timeCalcVar >= 0 && timeCalcVar <= 20)
        {
          digitalWrite(REDLED, HIGH);  
          if(soundEnable)tone(tonepin,alarmTone1,200);
        }
        if(timeCalcVar >= 480 && timeCalcVar <= 500)
        {
          if(soundEnable)tone(tonepin,alarmTone2,200);
          digitalWrite(REDLED, LOW);
        }

        unsigned long seconds= millis() - xTime;
        percent = (seconds)/(ACTIVATESECONDS*10);
        drawBar(percent);

        if(percent >= 100)
        {
          digitalWrite(GREENLED, LOW);
          team=2;
          iZoneTime=millis();
          delay(1000);
          break;
        }
      }
      cls();
      digitalWrite(REDLED, LOW);
    }

    //getting to green zone
    while(cancelando && team == 0 )
    {
      cls();
      if(team==0)lcd.print("CAPTURANDO ZONA");
      lcd.setCursor(0,1);
      unsigned int percent=0;
      unsigned long xTime=millis(); //start disabling time
      while(cancelando)
      {
        keypad.getKey();
        //check if game time runs out during the disabling
        aTime= millis()- iTime;
        if((minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0) || minutos-aTime/60000>4000000000){ 
          endGame = true;
        }
        timeCalcVar = (millis()- xTime)%1000;

        if( timeCalcVar >= 0 && timeCalcVar <= 20)
        {
          digitalWrite(GREENLED, HIGH);  
          if(soundEnable)tone(tonepin,alarmTone1,200);
        }
        if(timeCalcVar >= 480 && timeCalcVar <= 500)
        {
          if(soundEnable)tone(tonepin,alarmTone2,200);
          digitalWrite(GREENLED, LOW);
        }

        unsigned long seconds= millis() - xTime;
        percent = (seconds)/(ACTIVATESECONDS*10);
        drawBar(percent);

        if(percent >= 100)
        {
          digitalWrite(GREENLED, LOW);
          team=1;
          iZoneTime=millis();
          delay(1000);
          break;
        }
      }
      cls();
      digitalWrite(GREENLED, LOW);  
    }
  }
}

void gameOver(){

  if(team==1)greenTime+=millis()-iZoneTime;
  if(team==2)redTime+=millis()-iZoneTime;
  digitalWrite(GREENLED, LOW);
  digitalWrite(REDLED, LOW);
  while(!defusing){
    keypad.getKey();
    if(defusing){
      keypad.getKey();
      break;
    }
    lcd.clear();
    lcd.setCursor(3,0);
    lcd.print("TIME OVER!");
    lcd.setCursor(0,1);

    //check who team win the base
    if(greenTime>redTime){
      //greenteam wins
      lcd.print(" GREEN TEAM WINS");
      digitalWrite(GREENLED, HIGH);
    }
    else{
      //redteam wins 
      lcd.print(" RED TEAM WINS");
      digitalWrite(REDLED, HIGH);
    }
    delay(3000);
    keypad.getKey();
    if(defusing){
      keypad.getKey();
      break;
    }
    cls();
    lcd.print("Red Time:");
    lcd.setCursor(5,1);
    printTimeDom(redTime,false);
    delay(3000);
    keypad.getKey();
    if(defusing){
      
      break;
    }
    cls();
    lcd.print("Green Time:");
    lcd.setCursor(5,1);
    printTimeDom(greenTime,false);
    delay(3000);
    keypad.getKey();
    if(defusing){
      keypad.getKey();
      break;
    }
  }

```

Sorry if the code is long and messy. It is what I originally found online and have just modified a bit as best I can.

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [November 23, 2021, 3:32pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/13 "2021-11-23T15:32:43Z")

</div>

> [@capetito](#):
>
> ` keypad.getKey();`

Replace this by a call to your own button check procedure. See Debounce example in the IDE.

---

<div class="post-metadata">

**Author:** ![johnwasser](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/johnwasser/32/214270_2.png) [@johnwasser](https://forum.arduino.cc/u/johnwasser)\
**Post date:** [November 24, 2021, 2:15pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/14 "2021-11-24T14:15:45Z")

</div>

The original code uses a "keypadEvent()" function that gets called when you call keypad.getKey() and a button has changed state. You can replace the keypad.getKey() with something like:

```cpp
defusing = digitalRead(DefuseButtonPin) == LOW;
cancelando = digitalRead(CancelandoButtonPin) == LOW;

```

Since keypad.getKey() is called in several places you should put those two lines in a function and call the function. That way you can add more buttons without editing the code in many different places.

```cpp
void keypadEvent(KeypadEvent key)
{
  switch (keypad.getState())
  {
    case RELEASED:
      switch (key)
      {
        case 'd': defusing = false;
          break;
        case 'c': cancelando = false;
          break;
      }
      break;
    case HOLD:
      switch (key)
      {
        case 'd': defusing = true;
          break;
        case 'c': cancelando = true;
          break;
      }
      break;
  }
}
```

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 24, 2021, 7:21pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/15 "2021-11-24T19:21:48Z")

</div>

> [@johnwasser](#):
>
> The original code uses a "keypadEvent()" function that gets called when you call keypad.getKey() and a button has changed state. You can replace the keypad.getKey() with something like:
> 
> ```arduino
> defusing = digitalRead(DefuseButtonPin) == LOW;
> cancelando = digitalRead(CancelandoButtonPin) == LOW;
> 
> ```

Ok, interesting. Would this work eventhough the buttons could both work as Diffusebutton or CancelandoButton? Because each button can carry out both functions at any time.

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [November 24, 2021, 7:30pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/16 "2021-11-24T19:30:55Z")

</div>

> [@capetito](#):
>
> Because each button can carry out both functions at any time.

That's impossible. Buttons do not carry out functions, that's the code which reads the button state and does something.

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 24, 2021, 7:41pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/17 "2021-11-24T19:41:33Z")

</div>

> [@DrDiettrich](#):
>
> That's impossible. Buttons do not carry out functions, that's the code which reads the button state and does something.

Each of the two buttons on the device can work as a diffuse button or as a cancel button. How would I set up the code for that use?

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [November 24, 2021, 7:45pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/18 "2021-11-24T19:45:07Z")

</div>

> [@capetito](#):
>
> Each of the two buttons on the device can work as a diffuse button or as a cancel button.

Why then do you need 2 buttons at all?

> [@capetito](#):
>
> How would I set up the code for that use?

Specify under which conditions a button shall work as a diffuse or cancel button. Then implement that condition.

---

<div class="post-metadata">

**Author:** ![capetito](https://avatars.discourse-cdn.com/v4/letter/c/e47c2d/32.png) [@capetito](https://forum.arduino.cc/u/capetito)\
**Post date:** [November 24, 2021, 8:08pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/19 "2021-11-24T20:08:18Z")

</div>

> [@DrDiettrich](#):
>
> Why then do you need 2 buttons at all?

I have a device that has a timer and two buttons, one for each of two teams different teams. One Team1 presses Team1Button, it starts the clock counting for them. If Team2 presses the Team2Button,it cancels the timer for Team1 and then starts the Team2 timer. If Team1 susequently presses the Team1Button, it will stop the Team2 timer and start the Team1 timer once more right were it stopped last time. So each of the two buttons can be a diffuser and a cancel button depending on when it is pressed.  
Hope that helps to clarify the context for the program.

---

<div class="post-metadata">

**Author:** ![DrDiettrich](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/drdiettrich/32/219048_2.png) [@DrDiettrich](https://forum.arduino.cc/u/DrDiettrich)\
**Post date:** [November 24, 2021, 8:59pm UTC](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594/20 "2021-11-24T20:59:09Z")

</div>

Then construct the corresponding state machine.

[Next page](https://forum.arduino.cc/t/help-error-compiling-for-board-msg/929594.md?page=2)
