So the Jist of this code for the sake of understanding. We have a costume club who's regions are defined into clans, and each member has their own official member number.
There's a keypad hooked up to the transmitting arduino. When they enter a number and hit the pound sign, I'm trying to send that user's clan, number, and the command they entered.
I know all my code and hardware is correct because I'm sending the member number as an int and I'm receiving it correctly. but I can't seem to figure out how to send a string.
The serial result on the receiver is:
GOT DATA
1147
So obviously it's working, just having some issue with the CLAN string char conversion or something maybe?
anyway I've been at this all weekend and I'm stumped. Any help / assistance you guys can provide would be greatly appreciated! thanks!
Transmitting code:
#include <Keypad.h>
#include <VirtualWire.h>
#include <EasyTransferVirtualWire.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
char CLAN[] = "BKMG";
int OM = 1147;
char Array[20];
//define the cymbols on the buttons of the keypads
String command = "";
char hexaKeys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {9, 11, 10, 12}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7, 8}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
EasyTransferVirtualWire ET;
struct commandPulse
{
char *clan;
int memberNumber;
char *command;
};
commandPulse pulse;
void setup(){
ET.begin(details(pulse));
Serial.begin(9600);
vw_set_tx_pin(4);
vw_set_ptt_inverted(true);
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
pinMode(13, OUTPUT);
randomSeed(analogRead(0));
}
void sendPulse() {
pulse.clan = CLAN;
pulse.memberNumber = OM;
Serial.println(pulse.clan);
ET.sendData();
// pulse.clan = "";
command = "";
}
void loop(){
char customKey = customKeypad.getKey();
// if (customKey){
// Serial.println(customKey);
// }
if (customKey) {
if (customKey == '#') {
sendPulse();
} else {
command = command + customKey;
Serial.println("Pulse is");
Serial.println(command);
}
}
}
receiving code:
#include <VirtualWire.h>
#include <EasyTransferVirtualWire.h>
EasyTransferVirtualWire ET;
struct commandPulse
{
char *clan;
int memberNumber;
char *command;
};
commandPulse message;
//byte message[90]; // a buffer to store the incoming messages
//byte messageLength = 90; // the size of the message
void setup()
{
ET.begin(details(message));
Serial.begin(9600);
Serial.println("Device is ready");
vw_set_ptt_inverted(true); // Required for DR3100
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_set_tx_pin(11);
vw_rx_start(); // Start the receiver
pinMode(13, OUTPUT);
randomSeed(analogRead(0));
}
void loop()
{
// commandPulse message;
if (ET.receiveData()) {
Serial.println("GOT DATA");
Serial.println(message.clan);
Serial.println(message.memberNumber);
Serial.println(message.command);
}
/*
if (vw_get_message((uint8_t *)&message, (uint8_t *)sizeof(message))) {
{
Serial.print("pulse recieved: ");
Serial.println((uint8_t)sizeof(message));
Serial.println(sizeof(message));
Serial.println(message.clan);
Serial.println(message.memberNumber);
Serial.println(message.command);
// int command = processResponse((char*)message, 1); //Byte Array Response and Pin Code.
}
}
*/
}