Check and configure your keypad readings - Placidus

If your escornabot doesn't work right away after you've uploaded the code and connected the keypad, you should check the values that the Arduino is reading. As you've seen, the keypad consists of a bunch of resistors and buttons connected to the Arduino. Depending on the button you press, more or less resistors will get in the way of the current, and the analog pin will read a different voltage. We are going to connect the keypad to the Arduino, as shown on the [mounting guide], and we are going to upload the example code that you can find on the Arduino IDE, named "AnalogReadSerial". There is a very good example on how to use it on the Arduino documentation.

Analog Read Serial

Once you've got the example uploaded to your Arduino, you just have to check and write down the values that appear on the screen when you press each button of the keypad. Then open escornabot's code and look for the folllowing lines in the Configuration.h tab:

// input values for each key pressed
#define BS_ANALOG_VALUE_UP 575
#define BS_ANALOG_VALUE_RIGHT 721
#define BS_ANALOG_VALUE_DOWN 287
#define BS_ANALOG_VALUE_LEFT 431
#define BS_ANALOG_VALUE_GO 143
#define BS_ANALOG_VALUE_RESET 870    

Those are the values that come set by default, so, if they are different to the values you have previously written down, you must change them. For example, if you read 167 when pressing "GO" button, you must put that number instead of "143".

Now, your escornabot should follow your orders right away!

Advanced Users: Two wire Keypad.

There is a way to use a two wire keypad. This takes advantage of the INPUT_PULLUP command of the Arduino language, and it's implemented on the beta branch of the code. If you want to go this way, this are the steps you should take:

Check that you have connected the keypad analog pin to A4 or change the following line:

// Button set pin setup (analog input)
#define BS_ANALOG_PIN A4    

Open Arduino IDE, copy & paste this sketch and write down your readings (Instead of using Arduino's own example):

 #define KEYBOARD_PIN A4  
    #define KEYBOARD_WIRES 2 // change to 3 in old buttonsets with 3 wires

    void setup() {
      pinMode(KEYBOARD_PIN, KEYBOARD_WIRES == 2 ? INPUT_PULLUP : INPUT);
      Serial.begin(9600);
    }

    void loop() {
      Serial.println(analogRead(KEYBOARD_PIN));
      delay(200);
    }

Change the button values as shown before.