hello, i am trying to make a RF remote to switch on 8 relays, how i intend to do it is to send characters to the receiver and use strcmp to convert it to an action. firstly is this a good method? secondly i cant get strcmp to display its value, need help. the sketch is as bellow.
transmitter
/*
SimpleSend
This sketch transmits a short text message using the VirtualWire library
connect the Transmitter data pin to Arduino pin 12
*/
const int buttonPin = 2;
int buttonState = 0;
#include <VirtualWire.h>
void setup()
{
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
pinMode(buttonPin, INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
send("1");
delay(100);
}
}
void send (char *message)
{
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}
Receiver
/*
SimpleReceive
This sketch displays text strings received using VirtualWire
Connect the Receiver data pin to Arduino pin 11
*/
#include <VirtualWire.h>
byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages
byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message
void setup()
{
Serial.begin(9600);
Serial.println("Device is ready");
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver
}
void loop()
{
if (vw_get_message(message, &messageLength)) // Non-blocking
{
Serial.print("Received: ");
for (int i = 0; i < messageLength; i++)
{
Serial.print("{");
Serial.write(message[i]);
Serial.print("}");
Serial.print("The result of strcmp is : ");
Serial.println((strcmp(message[i])));
}
Serial.println();
}
}
so basically, when receiver receiver "1" it will turn on relay 1, etc.... is this a good method? can anyone recommend a better method? and lastly, whats wrong with the strcmp? it gives an error while compiling saying
RF_Receiver.ino: In function 'void loop()':
RF_Receiver:28: error: invalid conversion from 'byte' to 'const char*'
c:/program files/arduino/hardware/tools/avr/lib/gcc/../../avr/include/string.h:124: error: too few arguments to function 'int strcmp(const char*, const char*)'
RF_Receiver:28: error: at this point in file
Help is much appreciated!! thanks