Game Operation Arduino and Hall Sensors Errors

Ok here is what the idea is:

I have a board cut out like a man under is some Hall Sensors "OH3144 3144OH A3144E A3144 " I have a wand with a magnet on the end When you place the wand in on the cut out Man the Arduino send the sensor number to a 2nd Arduino by ZigBee for a read out of the spot.

The receiver works great but the Hall Sensors are giving me miss reads.

I am using "INPUT_PULLUP" not a resister connected to the hall sensor. I have tried moving hall sensors to different Mega pins with same unpredictable behavior of hall sensors. I have used different mega boards and Hall sensors with no difference.

here is the code:

int hallPin2 = 48;//49 Rt side top of head "t0"
int hallPin3 = 47;//47 Center top of Head "t1"
int hallPin4 = 46;//46 LT side top of head  "t2"
int hallPin5 = 44;//44 Rt side face "t3"
int hallPin6 = 42;//42 center face "nose" "t4"
int hallPin7 = 40;//40 Lt side of face "t5"
int hallPin8 = 38;//38 Rt Check "t6"
int hallPin81 = 37;//37 Mouth "t28"
int hallPin9 = 36;//36 Lt Check "t7"
int hallPin10 = 52;//52 Rt Elbow "t8"
int hallPin11 = 50; //50 Rt bicp "t9"
int hallPin12 = 3; //3 Lt hand "t10"
int hallPin13 = 5;//5;// Lt elbow "t11" 
int hallPin14 = 7; //7 Lt bicp "t12"
int hallPin15 = 34;//34 Rt shdr "t13"
int hallPin16 = 32;//32 Center shdr/Thot "t14"
int hallPin17 = 33;//33 Lt shdr "t15"
int hallPin18 = 9; // 9 Rt chest "t16"
int hallPin19 = 11; //11 Heart "17"
int hallPin20 = 10; // 10 Lt chest "t18"      
int hallPin21 = 15;// 15 Rt stom "19"
int hallPin22 = 16;//16 Center stom "t20"
int hallPin23 = 21;//21 Lt stom "t21"
int hallPin24 = 23;//23 Rt Hip "t22"
int hallPin25 = 26;//25 Gourn "t23"
int hallPin26 = 27;//27 Lt Hip "t24"
int hallPin27 = 29;//29 Rt foot "t25"
int hallPin28 = 30;//30 Rt Thgh "t26"
int hallPin29 = 31;//31 Lt Thgh "t27
int hallPin30 = 28;//28 Lt Foot "t29

int delayNow = 6000; 

void setup()
{
  pinMode(hallPin2, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin3, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin4, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin5, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin6, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin7, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin8, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin81, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin9, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin10, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin11, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin12, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin13, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin14, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin15, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin16, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin17, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin18, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin19, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin20, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin21, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin22, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin23, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin24, INPUT_PULLUP); // Right Hip
  delay(100);
  pinMode(hallPin25, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin26, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin27, INPUT_PULLUP); // Right Foot
  delay(100);
  pinMode(hallPin28, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin29, INPUT_PULLUP);
  delay(100);
  pinMode(hallPin30, INPUT_PULLUP);
  delay(1000);

  delay(1000);
  
  Serial1.begin(9600);
  Serial.begin(9600);

  Serial.println("Ready");
  
}

void loop()
{
  if(digitalRead(hallPin2) == LOW){ /// we see a mag
    Serial.println("Rt side top of head t0 D49");
    Serial1.print(2);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin3) == LOW){ /// we see a mag
    Serial.println("Center top of Head t1 D47");
    Serial1.print(3);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin4) == LOW){ /// we see a mag
    Serial.println("LT side top of head  t2 D46");
    Serial1.print(4);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin5) == LOW){ /// we see a mag
    Serial.println("Rt side face t3 D44");
    Serial1.print(5);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin6) == LOW){ /// we see a mag
    Serial.println("nose t4 D42");
    Serial1.print(6);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin7) == LOW){ /// we see a mag
    Serial.println("Lt side of face t5 D40");
    Serial1.print(7);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin8) == LOW){ /// we see a mag
    Serial.println("Right Check t6 D38");
    Serial1.print(8);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
    if(digitalRead(hallPin81) == LOW){ /// we see a mag
    Serial.println("Mouth t28 D37");// can change this latter
    Serial1.print('u');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin9) == LOW){ /// we see a mag
    Serial.println("Lt Check t7 D36");
    Serial1.print(9);
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin10) == LOW){ /// we see a mag
    Serial.println("Rt Elbow t8 D52");
    Serial1.print('a');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin11) == LOW){ /// we see a mag
    Serial.println("Rt bicp t9 D50");
    Serial1.print('b');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin12) == LOW){ /// we see a mag
    Serial.println("Lt hand t10 D3");
    Serial1.print('c');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin13) == LOW){ /// we see a mag
    Serial.println("Lt elbow t11 D5");
    Serial1.print('d');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin14) == LOW){ /// we see a mag
    Serial.println("Lt bicp t12 D7");
    Serial1.print('e');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin15) == LOW){ /// we see a mag
    Serial.println("Rt shdr t13 D34");
    Serial1.print('f');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin16) == LOW){ /// we see a mag
    Serial.println("Center shdr/Thot t14 D32");
    Serial1.print('g');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin17) == LOW){ /// we see a mag
    Serial.println("Lt shdr t15 D33");
    Serial1.print('h');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin18) == LOW){ /// we see a mag
    Serial.println("Rt chest t16 D9");
    Serial1.print('i');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin19) == LOW){ /// we see a mag
    Serial.println("Heart 17 D11");
    Serial1.print('j');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin20) == LOW){ /// we see a mag
    Serial.println("Lt chest t18 D15");
    Serial1.print('k');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin21) == LOW){ /// we see a mag
    Serial.println("Rt stom 19 D16");
    Serial1.print('l');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }
  if(digitalRead(hallPin22) == LOW){ /// we see a mag
    Serial.println("Center stom t20 D17");
    Serial1.print('m');
    delay(delayNow ); // A small delay to pause before we check the next sensor
  }

}

Everything works a first then I get Hall sensor miss reading and the miss reading is unpredictable!

If I turn it off then back on it is a different Hall sensor misread! then it will work for a day then not again!

Can someone look at my code and see if I am doing something wrong? Thanks

Can someone look at my code and see if I am doing something wrong?

Before anyone looks at code you need to check that your circuit is right. What checks have you made to verify that. And by checks I mean what software have you run to verify it. Please post this code and a schematic.

int delayNow = 6000;

    delay(delayNow ); // A small delay to pause before we check the next sensor

Six seconds blindness after a single sensor is read as triggered?

If all of them trigger, how long would a single read through all take?

Drop all those delays, you seem to insert them senselessly around every second line.

I would put the hall-pins in a byte array and all the string constants in PROGMEM.

const char hp2Text[] PROGMEM = "Rt side top of head t0 D49";
const char hp3Text[] PROGMEM = "Center top of Head t1 D47";
const char hp4Text[] PROGMEM = "LT side top of head  t2 D46";
const char hp5Text[] PROGMEM = "Rt side face t3 D44";
const char hp6Text[] PROGMEM = "nose t4 D42";
const char hp7Text[] PROGMEM = "Lt side of face t5 D40";
const char hp8Text[] PROGMEM = "Right Check t6 D38";
const char hp81Text[] PROGMEM = "Mouth t28 D37";
const char hp9Text[] PROGMEM = "Lt Check t7 D36";
const char hp10Text[] PROGMEM = "Rt Elbow t8 D52";
const char hp11Text[] PROGMEM = "Rt bicp t9 D50";
const char hp12Text[] PROGMEM = "Lt hand t10 D3";
const char hp13Text[] PROGMEM = "Lt elbow t11 D5";
const char hp14Text[] PROGMEM = "Lt bicp t12 D7";
const char hp15Text[] PROGMEM = "Rt shdr t13 D34";
const char hp16Text[] PROGMEM = "Center shdr/Thot t14 D32";
const char hp17Text[] PROGMEM = "Lt shdr t15 D33";
const char hp18Text[] PROGMEM = "Rt chest t16 D9";
const char hp19Text[] PROGMEM = "Heart 17 D11";
const char hp20Text[] PROGMEM = "Lt chest t18 D15";
const char hp21Text[] PROGMEM = "Rt stom 19 D16";
const char hp22Text[] PROGMEM = "Center stom t20 D17";
const char hp23Text[] PROGMEM = "Lt stom t21";
const char hp24Text[] PROGMEM = "Rt Hip t22";
const char hp25Text[] PROGMEM = "Gourn t23";
const char hp26Text[] PROGMEM = "Lt Hip t24";
const char hp27Text[] PROGMEM = "Rt foot t25";
const char hp28Text[] PROGMEM = "Rt Thgh t26";
const char hp29Text[] PROGMEM = "Lt Thgh t27";
const char hp30Text[] PROGMEM = "Lt Foot t29";

const char* const messages[] PROGMEM = {
  hp2Text, hp3Text, hp4Text, hp5Text, hp6Text, hp7Text, hp8Text, hp81Text,
  hp9Text, hp10Text, hp11Text, hp12Text, hp13Text, hp14Text, hp15Text, hp16Text,
  hp17Text, hp18Text, hp19Text, hp20Text, hp21Text, hp22Text, hp23Text, hp24Text,
  hp25Text, hp26Text, hp27Text, hp28Text, hp29Text, hp30Text,
};

const byte hallPins[] PROGMEM = {
  48, 47, 46, 44, 42, 40, 38, 37,
  36, 52, 50, 3, 5, 7, 34, 32,
  33, 9, 11, 10, 15, 16, 21, 23,
  26, 27, 29, 30, 31, 28,
};

const byte btForward[] PROGMEM = {
  2, 3, 4, 5, 6, 7, 8, 'u',
  9, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
  'h', 'i', 'j', 'k', 'l', 'm', 'o', 'p',
  'q', 'r', 's', 't', 'u', 'v',
};

void setup() {
  for (byte i = 0; i < sizeof(hallPins); i++) {
    pinMode(pgm_read_byte(&hallPins[i]), INPUT_PULLUP);
  }
  Serial1.begin(9600);
  Serial.begin(250000);
  dumpArrays();
  Serial.println(F("Ready"));
}

void loop() {
  for (byte i = 0; i < sizeof(hallPins); i++) {
    if (!digitalRead(pgm_read_byte(&hallPins[i]))) {
      Serial.println((__FlashStringHelper*)pgm_read_word(&messages[i]));
      Serial1.write(pgm_read_byte(&btForward[i]));
    }
  }
}

void dumpArrays() {
  for (byte i = 0; i < sizeof(hallPins); i++) {
    Serial.print(F("index "));
    if (i < 10) {
      Serial.write('0');
    }
    Serial.print(i);
    Serial.print(F(" pin "));
    byte pin = pgm_read_byte(&hallPins[i]);
    if (pin < 10) {
      Serial.write('0');
    }
    Serial.print(pin);
    byte btChar = pgm_read_byte(&btForward[i]);
    Serial.write(' ');
    if (btChar < ' ') {
      Serial.write(' ');
      Serial.print(btChar);
      Serial.write(' ');
    } else {
      Serial.write('\'');
      Serial.write(btChar);
      Serial.write('\'');
    }
    Serial.print(F(" \""));
    Serial.print((__FlashStringHelper*)pgm_read_word(&messages[i]));
    Serial.println(F("\""));
  }
}
index 00 pin 48  2  "Rt side top of head t0 D49"
index 01 pin 47  3  "Center top of Head t1 D47"
index 02 pin 46  4  "LT side top of head  t2 D46"
index 03 pin 44  5  "Rt side face t3 D44"
index 04 pin 42  6  "nose t4 D42"
index 05 pin 40  7  "Lt side of face t5 D40"
index 06 pin 38  8  "Right Check t6 D38"
index 07 pin 37 'u' "Mouth t28 D37"
index 08 pin 36  9  "Lt Check t7 D36"
index 09 pin 52 'a' "Rt Elbow t8 D52"
index 10 pin 50 'b' "Rt bicp t9 D50"
index 11 pin 03 'c' "Lt hand t10 D3"
index 12 pin 05 'd' "Lt elbow t11 D5"
index 13 pin 07 'e' "Lt bicp t12 D7"
index 14 pin 34 'f' "Rt shdr t13 D34"
index 15 pin 32 'g' "Center shdr/Thot t14 D32"
index 16 pin 33 'h' "Lt shdr t15 D33"
index 17 pin 09 'i' "Rt chest t16 D9"
index 18 pin 11 'j' "Heart 17 D11"
index 19 pin 10 'k' "Lt chest t18 D15"
index 20 pin 15 'l' "Rt stom 19 D16"
index 21 pin 16 'm' "Center stom t20 D17"
index 22 pin 21 'o' "Lt stom t21"
index 23 pin 23 'p' "Rt Hip t22"
index 24 pin 26 'q' "Gourn t23"
index 25 pin 27 'r' "Lt Hip t24"
index 26 pin 29 's' "Rt foot t25"
index 27 pin 30 't' "Rt Thgh t26"
index 28 pin 31 'u' "Lt Thgh t27"
index 29 pin 28 'v' "Lt Foot t29"
Ready