Hello, I'm new to arduino + electronics. I am trying to send a simple open/close message with my transmitter to my receiver. However, I'm having trouble getting this to work for some reason, I've followed multiple tutorials and tried all kinds of things, I'm unsure what it is that I'm doing incorrectly.
The transmitter and receiver each sit on their own arduino nano.
Transmitter is connected as following:
VCC => 5V
Data => D12
GND => GND
Receiver is connected as following:
VCC => 5V
Data => D12
GND => GND
This is the code for the transmitter
//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.H>
char *controller;
void setup() {
pinMode(13, OUTPUT);
vw_set_ptt_inverted(true); //
vw_set_tx_pin(12);
vw_setup(4000);// speed of data transfer Kbps
}
void loop() {
controller = "1" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, 1);
delay(2000);
controller = "0" ;
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(13, 0);
delay(2000);
}
This is the code for the receiver
//simple Tx on pin D12
//Written By : Mohannad Rawashdeh
// 3:00pm , 13/6/2013
//http://www.genotronex.com/
//..................................
#include <VirtualWire.h>
void setup()
{
vw_set_ptt_inverted(true); // Required for DR3100
vw_set_rx_pin(12);
vw_setup(4000); // Bits per sec
pinMode(13, OUTPUT);
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
if (buf[0] == '1') {
digitalWrite(13, 1);
}
if (buf[0] == '0') {
digitalWrite(13, 0);
}
}
}
This is not the only code I've tried, I'm utilizing the (old) VirtualWire library from this tutorial. Is anyone able to assist me in figuring out what's going wrong here?