Annikken Andee and arduino

Hello,

I'm currently programming for a school project.
The aim of my part is to count the hen which are inside the hen house.

I'm using arduino uno and an Annikken Andee.

Everything is working for the basic lines i wrotted but now i'd like to allow the user chosing the number of hens he own.

I decided to use a Keyboard_IN to do it from the android device.
Problem is, the button never stop loading and the while loop never stop.

If someone ca help me it would be really nice :slight_smile: (Sorry if i wrote some mistakes i'm french.)

Here the code:

const int A = 4;
const int B = 5;
int cptA;
int cptB;
int x;
int nb_base = 0;
int verif = 0;
#include <SPI.h>
#include <Andee.h>

AndeeHelper objectA;
AndeeHelper displaybox;
AndeeHelper textInputButton;

void setup() {
  Serial.begin(9600);
  Andee.begin();  // debut communication anniken et Arduino
  Andee.clear();  // effacer l'ecran
  setInitialData();
}

void setInitialData()
{
  objectA.setId(2);  
  objectA.setType(DATA_OUT);  
  objectA.setLocation(2, 2, FULL); 
  objectA.setTitle("nombre de poules dans à l'interieur");
  objectA.setData(x);
  objectA.setUnit("poules");

  displaybox.setId(0);
  displaybox.setType(DATA_OUT);
  displaybox.setLocation(0,1,FULL);
  displaybox.setTitle("Nombre de poules total");

  textInputButton.setId(1);
  textInputButton.setType(KEYBOARD_IN); // Sets object as a text input button
  textInputButton.setLocation(1,0,FULL);
  textInputButton.setTitle("Entrez votre nombre de poules");
  textInputButton.setKeyboardType(ALPHA_NUMERIC); 
  configuration();
}

void configuration()
{
while(verif == 0) { // tant qu'un A n'est pas reçu 
  
 objectA.update();
 displaybox.update(); // Always remember to update so that new content will be displayed
 textInputButton.update(); 
 
       if( textInputButton.isPressed() )
  {
    memset(nb_base, 0x00, 32); // Empty the contents of the string before receiving user input
    textInputButton.ack(); // Acknowledge button press or else phone will be left waiting
    textInputButton.getKeyboardMessage(nb_base); // Display keyboard and store input into userInput
    displaybox.setData(nb_base); // Display user input on the display box
    verif = 0;
  }
   }

}

void loop() {
cptA = digitalRead(A);
cptB = digitalRead(B); 


 
if (cptA==HIGH && cptB==LOW) {

  while (!(cptA==HIGH && cptB==HIGH)) {
    cptA = digitalRead(A);
    cptB = digitalRead(B);
  } 
  while (!(cptA==LOW && cptB==HIGH)) {
    cptA = digitalRead(A);
    cptB = digitalRead(B);
  }
  while (!(cptA==LOW && cptB==LOW)) {
    cptA = digitalRead(A);
    cptB = digitalRead(B);
  }
  
  if (cptA==LOW && cptB==LOW)
    x=x+1;
    Serial.println(x);
  }

if (cptA==LOW && cptB==HIGH)  {

    while (!(cptA==HIGH && cptB==HIGH)) {
      cptA = digitalRead(A);
      cptB = digitalRead(B);
      
    }
  while (!(cptA==HIGH && cptB==LOW)) {
    cptA = digitalRead(A);
    cptB = digitalRead(B);
  }
  
  while (!(cptA==LOW && cptB==LOW)) {
    cptA = digitalRead(A);
    cptB = digitalRead(B);
    }
  if (cptA==LOW && cptB==LOW)
  x=x-1;
  Serial.println(x);
  }
  
 objectA.setData(x);
 Serial.print(x);
 objectA.update();
 displaybox.update(); // Always remember to update so that new content will be displayed
 textInputButton.update(); 
  
  delay(500); 
  }

Oh i found a mistake
verif = 0; should be verif = 1;