TKU016CT-A100 Arduino Sample Code Guide

4×4 Keypad Arduino Example Programs

These example programs use the libraries included with the Arduino 1.6.7 IDE to send commands to the keypad module.
The demo performed by these sketches emulate interactive keys that activate the embedded buzzer when pressed.

Wiring Example

Circuit Diagram: UART & 4×4 Key-matrix
TKU016CT-A100 Connection diagram for UART Arduino Sample Code
Circuit Diagram: SPI
TKU016CT-A100 Connection diagram for SPI Arduino Sample Code
Circuit Diagram: I2C
TKU016CT-A100 Connection diagram for I2C Arduino Sample Code

Using either an Arduino UNO or Arduino PRO:

  • The only difference between the Arduino PRO and Arduino UNO wiring is the need for level shifting.
  • The Arduino UNO uses 5V communication signals when connected via USB, so a level shifter is needed. (Example Sparkfun BOB-12009)
  • The Arduino PRO is programmed with a TTL-232R-3V3 with the power (RED) wire cut. An external 3.3V power supply is required as well.
  • A level shifter is not required for the Arduino PRO.

Sample Code (Arduino Sketches) for Arduino 1.6.7 IDE

  • Copy the following sample code and upload it to your Arduino

Right-click in the code area to copy all of the source code to your clipboard.


/*
 * Establish a UART connection between an Arduino UNO/PRO and a Noritake 4x4 Keypad.
 * This example has example code for UART and key matrix scanning.
 * These difference code blocks are labeled in the loop() function.
 * This example uses the SoftwareSerial library from Arduino.
 * 
 * Wiring Reference:
 * RX: pin 10
 * TX: pin 11
 * 
 * KS0: pin 7
 * KS1: pin 6
 * KS2: pin 5
 * KS3: pin 4
 * 
 * KD0: pin 9
 * KD1: pin 8
 * KD2: pin 3
 * KD3: pin 2
 * 
 * Switching between UART and keyscan mode:
 * This example code starts in UART mode.
 * To use keyscan mode:
 * - Comment out the section labeled "UART Touch Algorithm"
 * - Comment out "touchSwitchReadSetting(0x02);"
 * - Uncomment "keyScan();"
 * - Make sure the keyscan select and data signals are connected as seen in the wiring reference file "UART_KeyScan - Schematic.pdf"
 *
 * The only difference between the Arduino PRO and Arduino UNO wiring is the need for level shifting and power requirements.
 * The Arduino UNO uses 5V communication signals when connected via USB, so a level shifter is needed (https://www.sparkfun.com/products/12009)
 * The Arduino PRO is programmed with a TTL-232R-3V3 with the power (RED) wire cut. An external 3.3V power supply is required as well.
 * A level shifter is not required for the Arduino PRO.
 *
 * ======== DISCLAIMER ========
 * YOU MUST AGREE TO THIS TERMS AND CONDITIONS. THIS SOFTWARE IS
 * PROVIDED BY NORITAKE CO., INC "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR SORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * =============================
 */
 

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX
int valid = 0;
int keyValid = 0;
int touchValid = 0;
byte switchVal;
byte touchVal = 0;

int countData = 0;
int count = 0;
byte prevSW = 0;

//Keyscan ports
int KS0 = 7;
int KS1 = 6;
int KS2 = 5;
int KS3 = 4;
int KD0 = 9;
int KD1 = 8;
int KD2 = 3;
int KD3 = 2;

void setup() {

  //Set up keyscan select pins
  pinMode(KS0, OUTPUT);
  pinMode(KS1, OUTPUT);
  pinMode(KS2, OUTPUT);
  pinMode(KS3, OUTPUT);

  //Set up keyscan data pins
  pinMode(KD0, INPUT);
  pinMode(KD1, INPUT);
  pinMode(KD2, INPUT);
  pinMode(KD3, INPUT);

  mySerial.begin(38400); // set the data rate for the SoftwareSerial port
  
  allLEDsON();
  
  basicBuzzer();

  touchSwitchReadSetting(0x02); //Set the read setting to automatic transmit mode 2
}

void loop() {
  
  //Start UART Touch Algorithm
  if(mySerial.available()){
    byte data = mySerial.read();
    delayMicroseconds(300);
    //Check for a valid touch value and store it
    if(valid == 1 && keyValid == 1 && touchValid == 0){
      touchValid = 1;
      touchVal = data;
    }
    //Check for a valid key value and store it
    else if(valid == 1 && keyValid == 0 && data <= 16 && data >= 0){
      keyValid = 1;
      switchVal = data;
    }
    //Check for the touch header byte
    else if(data == 0x11 && valid == 0){
      valid = 1;
    }
    //Turn LED OFF if a switch is being pressed
    if(touchVal == 0x01 && touchValid == 0x01){
      LED_control_OFF(switchVal);
      basicBuzzer();
    }
    //Turn LED ON if a switch is released
    else if(touchVal == 0 && touchValid == 0x01){
      LED_control_ON(switchVal);
    }
    //Reset flags when a touch packet has been read
    if(touchValid == 1){
      valid = 0;
      keyValid = 0;
      touchValid = 0;
    }
  }
  
  //End UART Touch Algorithm

  //Function used for keyscan mode
  //keyScan();

}

/*
 * Turns all LEDs ON.
 * 
 * @return none
 */
void allLEDsON(){
  mySerial.write(0x1f);
  mySerial.write(0x4b);
  mySerial.write(0x20);
  mySerial.write(0xf0);
  mySerial.write(0x02);
  mySerial.write(0xff);
  mySerial.write(0xff);
}

/*
 * Turns a specific LED ON.
 * 
 * @param  LED  The desired LED to turn ON.
 * @return none
 */
void LED_control_ON(byte LED){
  mySerial.write(0x1f);
  mySerial.write(0x4b);
  mySerial.write(0x21);
  mySerial.write(LED);
  mySerial.write(0xf0);
}

/*
 * Turns a specific LED OFF.
 * 
 * @param LED  The desired LED to turn OFF.
 * @return none
 */
void LED_control_OFF(byte LED){
  mySerial.write(0x1f);
  mySerial.write(0x4b);
  mySerial.write(0x21);
  mySerial.write(LED);
  mySerial.write((byte)0x00);
}

/*
 * Makes the default buzzer noise.
 * 
 * @return none
 */
void basicBuzzer(){
  mySerial.write(0x1f);
  mySerial.write(0x4b);
  mySerial.write(0x30);
  mySerial.write(0x03);
}

/*
 * Makes a buzzer noise based on input parameter.
 * 
 * Pitch values can be found in the keypad's datasheet.
 * 
 * @return none
 */
void buzzerPitch(byte pitch){
  mySerial.write(0x1f);
  mySerial.write(0x4b);
  mySerial.write(0x31);
  mySerial.write(0x02);
  mySerial.write(pitch);
  mySerial.write(0x07);
  mySerial.write(0x40);
  mySerial.write(0x07);
}

/*
 * Set the desired touch switch setting.
 * 
 * byte = 0x00: Manual transmit mode (Send only in response to read command)
 * byte = 0x01: Automatic transmit mode 1 (All touch switch status)
 * byte = 0x02: Automatic transmit mode 2 (Individual touch switch status)
 * default: byte = 0x00 or memory SW setting
 * 
 * @return none
 */
void touchSwitchReadSetting(byte mode){
  mySerial.write(0x1f);
  mySerial.write(0x4b);
  mySerial.write(0x18);
  mySerial.write(mode);
}

/*
 * Produce a keyscan signal and change the display based on key scan results.
 * 
 * @return none
 */
void keyScan(){
  byte column1 = columnScan(KS0);
  byte column2 = columnScan(KS1);
  byte column3 = columnScan(KS2);
  byte column4 = columnScan(KS3);
  //Check if a key in column 1 is pressed
  if(~column1 < 0xff){
    if(~column1 & 0x01){
      //SW1 is pressed
      Serial.println("SW1");
      LED_control_OFF((byte)0x00);
    } else if((~column1 & 0x01) == 0x00){
      LED_control_ON((byte)0x00);
    }
    if(~column1 & 0x02){
      //SW2 is pressed
      Serial.println("SW2");
      LED_control_OFF(0x01);
    } else if((~column1 & 0x02) == 0x00){
      LED_control_ON(0x01);
    }
    if(~column1 & 0x04){
      //SW3 is pressed
      Serial.println("SW3");
      LED_control_OFF(0x02);
    } else if((~column1 & 0x04) == 0x00){
      LED_control_ON(0x02);
    }
    if(~column1 & 0x08){
      //SW4 is pressed
      Serial.println("SW4");
      LED_control_OFF(0x03);
    } else if((~column1 & 0x08) == 0x00){
      LED_control_ON(0x03);
    }
  }
  //Check if a key in column 2 is pressed
  if(~column2 < 0xff){
    if(~column2 & 0x01){
      //SW5 is pressed
      Serial.println("SW5");
      LED_control_OFF(0x04);
    } else if((~column2 & 0x01) == 0x00){
      LED_control_ON(0x04);
    }
    if(~column2 & 0x02){
      //SW6 is pressed
      Serial.println("SW6");
      LED_control_OFF(0x05);
    } else if((~column2 & 0x02) == 0x00){
      LED_control_ON(0x05);
    }
    if(~column2 & 0x04){
      //SW7 is pressed
      Serial.println("SW7");
      LED_control_OFF(0x06);
    } else if((~column2 & 0x04) == 0x00){
      LED_control_ON(0x06);
    }
    if(~column2 & 0x08){
      //SW8 is pressed
      Serial.println("SW8");
      LED_control_OFF(0x07);
    } else if((~column2 & 0x08) == 0x00){
      LED_control_ON(0x07);
    }
  }
  //Check if a key in column 3 is pressed
  if(~column3 < 0xff){
    if(~column3 & 0x01){
      //SW9 is pressed
      Serial.println("SW9");
      LED_control_OFF(0x08);
    } else if((~column3 & 0x01) == 0x00){
      LED_control_ON(0x08);
    }
    if(~column3 & 0x02){
      //SW10 is pressed
      Serial.println("SW10");
      LED_control_OFF(0x09);
    } else if((~column3 & 0x02) == 0x00){
      LED_control_ON(0x09);
    }
    if(~column3 & 0x04){
      //SW11 is pressed
      Serial.println("SW11");
      LED_control_OFF(0x0a);
    } else if((~column3 & 0x04) == 0x00){
      LED_control_ON(0x0a);
    }
    if(~column3 & 0x08){
      //SW12 is pressed
      Serial.println("SW12");
      LED_control_OFF(0x0b);
    } else if((~column3 & 0x08) == 0x00){
      LED_control_ON(0x0b);
    }
  }
  //Check if a key in column 4 is pressed
  if(~column4 < 0xff){
    if(~column4 & 0x01){
      //SW13 is pressed
      Serial.println("SW13");
      LED_control_OFF(0x0c);
    } else if((~column4 & 0x01) == 0x00){
      LED_control_ON(0x0c);
    }
    if(~column4 & 0x02){
      //SW14 is pressed
      Serial.println("SW14");
      LED_control_OFF(0x0d);
    } else if((~column4 & 0x02) == 0x00){
      LED_control_ON(0x0d);
    }
    if(~column4 & 0x04){
      //SW15 is pressed
      Serial.println("SW15");
      LED_control_OFF(0x0e);
    } else if((~column4 & 0x04) == 0x00){
      LED_control_ON(0x0e);
    }
    if(~column4 & 0x08){
      //SW16 is pressed
      Serial.println("SW16");
      LED_control_OFF(0x0f);
    } else if((~column4 & 0x08) == 0x00){
      LED_control_ON(0x0f);
    }
  }
}

/*
 * Helper function for keyscan().
 * Sends a keyscan signal to the module.
 * 
 * @return scanData The byte representing the keyscan result for a column.
 */
byte columnScan(int column){
  digitalWrite(column, LOW);
  byte scanData = readKD();
  digitalWrite(column, HIGH);
  return scanData;
}

/*
 * Helper function for columnScan.
 * Reads in the four output values from the module and masks them into one byte.
 * 
 * @return result The combined value for the given column scan.
 */
byte readKD(){
  byte KD0_in = digitalRead(KD0);
  byte KD1_in = digitalRead(KD1);
  byte KD2_in = digitalRead(KD2);
  byte KD3_in = digitalRead(KD3);
  
  byte result = ((KD3_in << 3) | (KD2_in << 2) | (KD1_in << 1) | KD0_in);
  return result;
}
                

Right-click in the code area to copy all of the source code to your clipboard.


/*
 * Establish an SPI connection between an Arduino UNO/PRO and a Noritake 4x4 Keypad.
 * This example uses the included SPI library from Arduino.
 * 
 * Connection reference (relative to 4x4 keypad)
 * RESET: pin 5
 * CSB: pin 7
 * MOSI: pin 11
 * MISO: pin 12
 * SCK: pin 13
 * 
 * ======== DISCLAIMER ========
 * YOU MUST AGREE TO THIS TERMS AND CONDITIONS. THIS SOFTWARE IS
 * PROVIDED BY NORITAKE CO., INC "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR SORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * =============================
 */  
 
#include <SPI.h>

const int RESET = 5;
const int CS = 7;
const int BUFFERMAX = 63;
byte touchResults[BUFFERMAX];
byte data;
byte pos = 0;
byte empty;

void setup() {
  //Join SPI bus   
  SPI.begin();
  SPI.setDataMode(SPI_MODE3);
  pinMode(RESET, OUTPUT);
  digitalWrite(RESET, HIGH);
  pinMode(CS, OUTPUT);

  //Reset keypad  
  digitalWrite(RESET, LOW);
  delay(1);
  digitalWrite(RESET, HIGH);
  delay(100);

  defaultBuzzer(); //Play buzzer after reset  

  allLEDsON();

  touchSwitchReadSetting(0x02); //Set the read setting to automatic transmit mode 2  
}

void loop() {
  int valid = 0;
  
  digitalWrite(CS, LOW);

  //Get status byte  
  SPI.transfer(0x58);
  delayMicroseconds(20); // Force 20us delay  
  byte maskedResult;
  byte statusResult = SPI.transfer(0x00);
  delayMicroseconds(20); // Force 20us delay  

  //Verify that the incoming data is valid  
  if((statusResult & 0x40) == 0){
    maskedResult = statusResult & 0x3f;
  }
  digitalWrite(CS, HIGH);
  //End status byte read  
  
  //Get touch data  
  digitalWrite(CS, LOW);
  SPI.transfer(0x54);
  delayMicroseconds(20); // Force 20us delay  

  for(int i = 0; i <= maskedResult + 1; i++){
    //Read data  
    data = SPI.transfer(0x00);
    delayMicroseconds(20); // Force 20us delay  
    if(valid){
      touchResults[i] = data;
    }
    if(data == 0x11 && valid == 0){
      i = 0;
      touchResults[i] = data;
      valid = 1;
    }
    empty = 0;
  }
  valid = 0;
  digitalWrite(CS, HIGH);
  //End touch data read   

  //Parse touch data and manipulate buzzer and LEDs   
  while(!empty){
    if(touchResults[pos] == 0x11 && touchResults[pos + 2] == 0x01){
      defaultBuzzer();
      LED_control_OFF(touchResults[pos + 1]);

    }

    if(touchResults[pos] == 0x11 && touchResults[pos + 2] == 0x00){
      LED_control_ON(touchResults[pos + 1]);
    }

    if(touchResults[pos + 3] == 0x11){
      pos += 3;
      empty = 0;
    } else {
      empty = 1;
    }
  }

  //Reset variables  
  pos = 0;
  touchResults[0] = 0;
  touchResults[1] = 0;
  touchResults[2] = 0;
  statusResult = 0;
  maskedResult = 0;
}

/*
 * Turn all of the LEDs ON on the keypad.
 * 
 * @return none
 */  
void allLEDsON(){
  digitalWrite(CS, LOW);

  SPI.transfer(0x44);
  SPI.transfer(0x1f);
  SPI.transfer(0x4b);
  SPI.transfer(0x20);
  SPI.transfer(0xf0);
  SPI.transfer(0x02);
  SPI.transfer(0xff);
  SPI.transfer(0xff);

  digitalWrite(CS, HIGH);
}

/*
 * Plays the default buzzer sound on the keypad.
 * 
 * @return none
 */  
void defaultBuzzer(){
  digitalWrite(CS, LOW);

  SPI.transfer(0x44);
  SPI.transfer(0x1f);
  SPI.transfer(0x4b);
  SPI.transfer(0x30);
  SPI.transfer(0x03);

  digitalWrite(CS, HIGH);
}

/*
 * Turn an individal LED ON.
 * 
 * @param  LED  The LED to turn ON.
 * @return none
 */  
void LED_control_ON(byte LED){
  digitalWrite(CS, LOW);

  SPI.transfer(0x44);
  SPI.transfer(0x1f);
  SPI.transfer(0x4b);
  SPI.transfer(0x21);
  SPI.transfer(LED);
  SPI.transfer(0xf0);

  digitalWrite(CS, HIGH);
}

/*
 * Turn an individual LED OFF.
 * 
 * @param LED  The LED to turn OFF.
 */  
void LED_control_OFF(byte LED){
  digitalWrite(CS, LOW);

  SPI.transfer(0x44);
  SPI.transfer(0x1f);
  SPI.transfer(0x4b);
  SPI.transfer(0x21);
  SPI.transfer(LED);
  SPI.transfer(0x00);

  digitalWrite(CS, HIGH);
}

/*
 * Set the touch switch read mode.
 * 
 * mode = 0x00: Manual transmit mode (Send only in response to a read command)
 * mode = 0x01: Automatic transmit mode 1 (All touch-switch status)
 * mode = 0x02: Automatic transmit mode 2 (Individual touch-switch status)
 * 
 * @param  mode  The desired touch switch read mode.
 * @return none
 */  
void touchSwitchReadSetting(byte mode){
  digitalWrite(CS, LOW);

  SPI.transfer(0x44);
  SPI.transfer(0x1f);
  SPI.transfer(0x4b);
  SPI.transfer(0x18);
  SPI.transfer(mode);
  
  digitalWrite(CS, HIGH);
}
                

Right-click in the code area to copy all of the source code to your clipboard.


/*
 * Establish an I2C connection between an Ardunio UNO/PRO and a Noritake 4x4 Keypad.
 * This example uses the included Wire library from Arduino.
 * 
 * Arduino wiring reference:
 * SDA = A4
 * SCL = A5
 * 
 * ======== DISCLAIMER ========
 * YOU MUST AGREE TO THIS TERMS AND CONDITIONS. THIS SOFTWARE IS
 * PROVIDED BY NORITAKE CO., INC "AS IS" AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR SORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * =============================
 */  

#include <Wire.h>

byte pos = 0;
byte empty;
const int BUFFERMAX = 63;
byte address = 0x00;

void setup() {
  Wire.begin(); //Join I2C bus   
  defaultBuzzer(); //Play a buzzer sound to signify program start.  
  allLEDsON();
  
  touchSwitchReadSetting(0x02); //Set the read setting to automatic transmit mode 2  
}

void loop() {
  int valid = 0;
  byte touchResults[BUFFERMAX]; //Array to store incoming touch data.  
  Wire.requestFrom(address, BUFFERMAX);
  
  //Check if data is ready to be transmitted.  
  while(Wire.available()){
    byte data = Wire.read(); //Read data from the transmit buffer.  
    
    //Check if a header byte has been received.  
    if(valid){ 
      touchResults[pos] = data; //Save incoming data  
      pos++; //Increment position  
    }
    //Check if a header byte is received.   
    if(data == 0x11 && valid == 0){
      pos = 0; //Reset the array position  
      touchResults[pos] = data; //Save the header byte to the first array position  
      valid = 1; //Enable valid flag  
      pos++; //Increment position  
    }
    empty = 0; //Reset the array empty flag.  
  }
  pos = 0; //Reset position  
  
  while(!empty){
    //Check if a switch has been touched  
    if(touchResults[pos] == 0x11 && touchResults[pos + 2] == 0x01){ 
      defaultBuzzer();
      LED_control_OFF(touchResults[pos + 1]);
    }
    //Check if a switch has been released  
    if(touchResults[pos] == 0x11 && touchResults[pos + 2] == 0x00){ 
      LED_control_ON(touchResults[pos + 1]);
    }
    //Check if another set of touch data is present  
    if(touchResults[pos + 3] == 0x11){ 
      pos += 3;
      empty = 0; //Ensure that the empty flag is clear  
    } else {
      empty = 1; //Put the empty flag high  
    }
  }
  pos = 0; //Reset position  
  //Reset the results array  
  for(int i = 0; i <= 20; i++){ 
    touchResults[i] = 0x00; 
  }
}

/*
 * Turn all of the LEDs ON on the keypad.
 * 
 * @return none
 */  
void allLEDsON(){
  Wire.beginTransmission(address);  // transmit to keypad  
  Wire.write(0x1f);              // sends one byte  
  Wire.write(0x4b);              // sends one byte  
  Wire.write(0x20);              // sends one byte  
  Wire.write(0xf0);              // sends one byte  
  Wire.write(0x02);              // sends one byte  
  Wire.write(0xff);              // sends one byte  
  Wire.write(0xff);              // sends one byte  
  Wire.endTransmission();        // stop transmitting  
}

/*
 * Turn an individal LED ON.
 * 
 * @param  LED  The LED to turn ON.
 * @return none
 */  
void LED_control_ON(byte LED){
  Wire.beginTransmission(address);
  Wire.write(0x1f);
  Wire.write(0x4b);
  Wire.write(0x21);
  Wire.write(LED);
  Wire.write(0xf0);
  Wire.endTransmission();
}

/*
 * Turn an individual LED OFF.
 * 
 * @param LED  The LED to turn OFF.
 */  
void LED_control_OFF(byte LED){
  Wire.beginTransmission(address);
  Wire.write(0x1f);
  Wire.write(0x4b);
  Wire.write(0x21);
  Wire.write(LED);
  Wire.write(0x00);
  Wire.endTransmission();
}

/*
 * Plays the default buzzer sound on the keypad.
 * 
 * @return none
 */  
void defaultBuzzer(){
  Wire.beginTransmission(address);
  Wire.write(0x1f);
  Wire.write(0x4b);
  Wire.write(0x30);
  Wire.write(0x03);
  Wire.endTransmission();
}

/*
 * Set the touch switch read mode.
 * 
 * mode = 0x00: Manual transmit mode (Send only in response to a read command)
 * mode = 0x01: Automatic transmit mode 1 (All touch-switch status)
 * mode = 0x02: Automatic transmit mode 2 (Individual touch-switch status)
 * 
 * @param  mode  The desired touch switch read mode.
 * @return none
 */  
void touchSwitchReadSetting(byte mode){
  Wire.beginTransmission(address);
  Wire.write(0x1f);
  Wire.write(0x4b);
  Wire.write(0x18);
  Wire.write(mode);
  Wire.endTransmission();
}