Hello,

I am having a difficult time understanding how to get the attached code to accept more digits than 1. The IF statements work like I would like except I cannot enter a number like 12, it will just do number 1. I believe I have to assign it to an array and then reference that array but I am missing the necessary knowledge to make this work. Any help that you can provide that would be greatly appreciated. I am using this keypad on my iPhone: http://viccarre.mx/ishield/documentation.html#using and the single digits work. It looks like “i” is what is sent when I hit the “Enter” button. How can I modify this code to accept digits from 1-4 in length and have the Enter button indicate that I am done entering that number and to perform the corresponding IF statement?

Thank you

Chad

#include <Adafruit_NeoPixel.h>

#include <SPI.h>

#include <boards.h>

#include <RBL_nRF8001.h>

#include “iShield.h”

#define PIN 10

byte byteRead;

iShield myiShield;

int cont = 0;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(200, PIN, NEO_GRB + NEO_KHZ800);

//Grid Conversion

int a1 = 0;

int a2 = 1;

int a3 = 2;

int a4 = 3;

int a5 = 4;

int a6 = 5;

int a7 = 6;

int a8 = 7;

int a9 = 8;

int a10 = 9;

int a11 = 10;

int a12 = 11;

int a13 = 12;

int a14 = 13;

int a15 = 14;

int a16 = 15;

int a17 = 16;

int a18 = 17;

int b18 = 18;

int b17 = 19;

int b16 = 20;

int b15 = 21;

int b14 = 22;

int b13 = 23;

int b12 = 24;

int b11 = 25;

int b10 = 26;

int b9 = 27;

int b8 = 28;

int b7 = 29;

int b6 = 30;

int b5 = 31;

int b4 = 32;

int b3 = 33;

int b2 = 34;

int b1 = 35;

int c1 = 36;

int c2 = 37;

int c3 = 38;

int c4 = 39;

int c5 = 40;

int c6 = 41;

int c7 = 42;

int c8 = 43;

int c9 = 44;

int c10 = 45;

int c11 = 46;

int c12 = 47;

int c13 = 48;

int c14 = 49;

int c15 = 50;

int c16 = 51;

int c17 = 52;

int c18 = 53;

int d18 = 54;

int d17 = 55;

int d16 = 56;

int d15 = 57;

int d14 = 58;

int d13 = 59;

int d12 = 60;

int d11 = 61;

int d10 = 62;

int d9 = 63;

int d8 = 64;

int d7 = 65;

int d6 = 66;

int d5 = 67;

int d4 = 68;

int d3 = 69;

int d2 = 70;

int d1 = 71;

int e1 = 72;

int e2 = 73;

int e3 = 74;

int e4 = 75;

int e5 = 76;

int e6 = 77;

int e7 = 78;

int e8 = 79;

int e9 = 80;

int e10 = 81;

int e11 = 82;

int e12 = 83;

int e13 = 84;

int e14 = 85;

int e15 = 86;

int e16 = 87;

int e17 = 88;

int e18 = 89;

int f18 = 90;

int f17 = 91;

int f16 = 92;

int f15 = 93;

int f14 = 94;

int f13 = 95;

int f12 = 96;

int f11 = 97;

int f10 = 98;

int f9 = 99;

int f8 = 100;

int f7 = 101;

int f6 = 102;

int f5 = 103;

int f4 = 104;

int f3 = 105;

int f2 = 106;

int f1 = 107;

int g1 = 108;

int g2 = 109;

int g3 = 110;

int g4 = 111;

int g5 = 112;

int g6 = 113;

int g7 = 114;

int g8 = 115;

int g9 = 116;

int g10 = 117;

int g11 = 118;

int g12 = 119;

int g13 = 120;

int g14 = 121;

int g15 = 122;

int g16 = 123;

int g17 = 124;

int g18 = 125;

int h18 = 126;

int h17 = 127;

int h16 = 128;

int h15 = 129;

int h14 = 130;

int h13 = 131;

int h12 = 132;

int h11 = 133;

int h10 = 134;

int h9 = 135;

int h8 = 136;

int h7 = 137;

int h6 = 138;

int h5 = 139;

int h4 = 140;

int h3 = 141;

int h2 = 142;

int h1 = 143;

int i1 = 144;

int i2 = 145;

int i3 = 146;

int i4 = 147;

int i5 = 148;

int i6 = 149;

int i7 = 150;

int i8 = 151;

int i9 = 152;

int i10 = 153;

int i11 = 154;

int i12 = 155;

int i13 = 156;

int i14 = 157;

int i15 = 158;

int i16 = 159;

int i17 = 160;

int i18 = 161;

int j18 = 162;

int j17 = 163;

int j16 = 164;

int j15 = 165;

int j14 = 166;

int j13 = 167;

int j12 = 168;

int j11 = 169;

int j10 = 170;

int j9 = 171;

int j8 = 172;

int j7 = 173;

int j6 = 174;

int j5 = 175;

int j4 = 176;

int j3 = 177;

int j2 = 178;

//int j1 = 179;

int k1 = 180;

int k2 = 181;

int k3 = 182;

int k4 = 183;

int k5 = 184;

int k6 = 185;

int k7 = 186;

int k8 = 187;

int k9 = 188;

int k10 = 189;

int k11 = 190;

int k12 = 191;

int k13 = 192;

int k14 = 193;

int k15 = 194;

int k16 = 195;

int k17 = 196;

int k18 = 197;

char currentProblem;

void setup() {

ble_set_name(“Chad”);

ble_begin();

strip.begin();

strip.show();

Serial.begin(9600);

}

void loop() {

myiShield.getInbox();

currentProblem = myiShield.getKeypadData();

int prob = int(currentProblem);

if (currentProblem == ‘1’){

colorWipe(strip.Color(0, 0, 0), 200);

strip.setPixelColor(f18, 0xFF0000); //Green - Finish

strip.setPixelColor(h18, 0xFF0000); //Green - Finish

strip.setPixelColor(f15, 0x00FF00); //Red

strip.setPixelColor(g14, 0x00FF00); //Red

strip.setPixelColor(f12, 0x00FF00); //Red

strip.setPixelColor(j11, 0x00FF00); //Red

strip.setPixelColor(j7, 0x00FF00); //Red

strip.setPixelColor(f4, 0x0000FF); //Blue - Start

strip.show();

}

if (currentProblem == ‘2’){

colorWipe(strip.Color(0, 0, 0), 200);

strip.setPixelColor(h18, 0xFF0000); //Green - Finish

strip.setPixelColor(g14, 0x00FF00); //Red

strip.setPixelColor(f12, 0x00FF00); //Red

strip.setPixelColor(f4, 0x0000FF); //Blue - Start

strip.show();

}

}

void colorWipe(uint32_t c, uint8_t wait) {

int i;

for (i = 0; i < strip.numPixels(); i++) strip.setPixelColor(i, 0);

strip.show();

delay(wait);

}

KeypadTestwithProblemSingleDigit.ino (4.1 KB)