hello...
i try make program the transmit device used keypad then through the RF module to Receive device then LCD will display keypad value. need advise this program..
*trasmiter
#include <LiquidCrystal.h>
#include <Keypad.h>
#include <VirtualWire.h>
LiquidCrystal lcd(3, 4, 5, 6, 8, 11);
const int led_pin = 13;
const int transmit_pin = 7;
const byte ROWS = 4;
const byte COLS = 4;
char key[100];
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {A0, A1, A2, A3};
byte colPins[COLS] = {A4, A5, 0,1};
Keypad myKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
// Initialise the IO and ISR
delay(500);
vw_set_tx_pin(transmit_pin);
vw_set_ptt_inverted(true);
vw_setup(2000); // Bits per sec
lcd.begin(16,2);
lcd.print("number ID");
delay(500);
lcd.clear();
}
void loop(){
char key = myKeypad.getKey();
if (key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||key=='8'||key=='9'||key=='0'||key=='A'||key=='B'||key=='C'||key=='D'||key=='*'||key=='#')
{
lcd.print(key);
}
if (key=='*')
{
lcd.clear();
}
if (key=='#')
{
char msg[100] = {key};
vw_send ((uint8_t* )msg, 1);
vw_wait_tx();
}
}
*********** receiver***********
#include <LiquidCrystal.h>
#include <VirtualWire.h>
LiquidCrystal lcd(3, 4, 5, 6, 8, 11);
const int led_pin = 13;
const int receive_pin = 1;
int i;
void setup()
{
delay(1000);
vw_set_rx_pin (receive_pin);
vw_set_ptt_inverted (true);
vw_setup (2000); //speed communication bps
vw_rx_start();
}
void loop()
{
uint8_t msg[VW_MAX_MESSAGE_LEN];
uint8_t msglen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(msg,&msglen)) // verify if any data is received
{
for (i=0; i<msglen; i++)
{
lcd.print(msg*);*
-
}*
-
}*
}