2014/08/12

3x4 Keypad Radio Frequency remote control

  To send digits to radio frequency receiver, a 3x4 keypad and a transmitter is a good combination. To use the keypad, the connection between keypad and pins has to be clarified. For my keypad, the connections are:

Keypad.1: Pin1 + Pin5
Keypad.2: Pin1 + Pin6
Keypad.3: Pin1 + Pin7
Keypad.4: Pin2 + Pin5
Keypad.5: Pin2 + Pin6
Keypad.6: Pin2 + Pin7
Keypad.7: Pin3 + Pin5
Keypad.8: Pin3 + Pin6
Keypad.9: Pin3 + Pin7
Keypad.*: Pin4 + Pin5
Keypad.0: Pin4 + Pin6
Keypad.#: Pin4 + Pin7

I just want to send 3 digits range from 000 to 999 to receiver running the sketch posted on May. 11, 2014. The result is showed on the following photo.

Connections

1. Transmitter.Vcc -> Arduino.5V
2. Transmitter.Gnd -> Arduino.Gnd
3. Transmitter.Data -> Arduino.D12
4. Keypad.Pin1 (ROW0) -> Arduino.D5
5. Keypad.Pin2 (ROW1) -> Arduino.D4
6. Keypad.Pin3 (ROW2) -> Arduino.D3
7. Keypad.Pin4 (ROW3) -> Arduino.D2
8. Keypad.Pin5 (COL0) -> Arduino.D8
9. Keypad.Pin6 (COL1) -> Arduino.D7
10. Keypad.Pin7 (COL2) -> Arduino.D6



Photo



Updated Sketch

// Modified by Befun Hung on Oct. 28, 2014   
// Blink led after sending message to notice user 5 times 
#include <Keypad.h>
#include <VirtualWire.h>

#define maxLength 3
const byte ROWS = 4; // four rows
const byte COLS = 3; // three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {5, 4, 3, 2};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {8, 7, 6};    // connect to the column pinouts of the keypad
char keyins[maxLength+1] = "";
int i=0, j=0, sendTimes=5;
int led=13;

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  Serial.begin(9600);
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  Serial.println("Ready!");
  pinMode(led, OUTPUT);
}
  
void loop() {
    char key = keypad.getKey();
    if (key) {
      Serial.print(key);
      keyins[i] = key;
      i++;
      if (i == maxLength) {
        for (j=0;j<sendTimes;j++) {
          Serial.println();
          send(keyins);
          digitalWrite(led, HIGH);
          delay(20);
          digitalWrite(led, LOW);
          delay(20);
        }
        i = 0;
      } 
    }
}

void send(char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}

Sketch

#include <Keypad.h>
#include <VirtualWire.h>

#define maxLength 3
const byte ROWS = 4; // four rows
const byte COLS = 3; // three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {5, 4, 3, 2};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {8, 7, 6};    // connect to the column pinouts of the keypad
char keyins[maxLength+1] = "";
int i=0;

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  Serial.begin(9600);
  // Initialize the IO and ISR
  vw_setup(2000); // Bits per sec
  Serial.println("Ready!");
}
  
void loop() {
    char key = keypad.getKey();
    if (key) {
      Serial.print(key);
      keyins[i] = key;
      i++;
      if (i == maxLength) {
        Serial.println();
        send(keyins);
        i = 0;
      }
    }
}

void send(char *message)
{
  vw_send((uint8_t *)message, strlen(message));
  vw_wait_tx(); // Wait until the whole message is gone
}

2014/08/09

Schematic and Photo Of Arduino PCF8574 I2C LCD Keypad Shield

  My PCF8574 I2C LCD Keypad Shield has been completed. The benefit of I2C LCD Keypad Shield over LCD Keypad Shield is that it free up 6 digital I/O used by LCD Keypad Shield for other use.
  The schematic used is version 1.1 other than the version 1.0 posted on Feb. 28, 2014. The difference between version 1.1 and version 1.0 is that the version 1.1 has a 4-pins I2C connector as shown on the bottom-left corner of the shield on the photo to act a either a shield or a breakout. When the shield serves as a breakout, the 5-way button cannot function. The sketch runs is same as the one posted on Feb. 28, 2014.

  When the shield is stacked directly upon the Arduino Uno, it should be noticed avoiding the pins of PCF8574 touching the shield of USB type B connector of Arduino. A insulated stick is a simple way. It is recommend to use Arduino boards with mini or micro USB connector such as Leonardo or stack on any other shield.


Schematic
Photo