Hi all,
I recently bought this transmitter/receiver http://www.ebay.com/itm/331344982006 .
Up to now no success to see this working (just to flash the led) although I was able to work with the simple case of this guy here http://www.icstation.com/product_info.php?ref=25&products_id=1402&affiliate_banner_id=1 (in this case I just reproduce the example to send a string; no led flashing)
Since the first has 6 pins (transmitter) I tried initially to use only one data PIN
13 --> 11 for arduino
12
11
10
9V --> external battery
GND --> GND
#include <VirtualWire.h>
void setup()
{
Serial.begin (9600); // Sets the baud rate to 9600 bps
vw_setup(2000);
vw_set_tx_pin(13);
pinMode(12, INPUT); // I just give instantly with a wire some current from the battery
digitalWrite(12, HIGH);
}
void loop()
{
char *msg2;
if(digitalRead(12) == LOW)//if the button is pressed
{
Serial.println("it works");
char *msg2 = "1";//send 1 to the receiver
vw_send((uint8_t *)msg2, strlen(msg2));//send the byte to the receiver
vw_wait_tx(); // Wait until the whole message is gone
}
}
For the receiver the PINS are as follows with second column the arduino PINS
GND --> GND
10
11
12
13 --> 12
17
VCC --> 5V arduino
GND
A led is also connected with PIN7 arduino and GND
#include <VirtualWire.h>
int led = 7;
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
vw_setup(2000);
vw_set_rx_pin(12); //Rx Data pin to Digital Pin 12
vw_rx_start(); // Start the receiver PLL running
pinMode(led, OUTPUT);
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i]);//print received command
if(buf[i] == '1') //if button 1 is pressed....
{
digitalWrite(led,HIGH);
Serial.println(" = forward");
}
}
Serial.println("");
}
}
Is there something wrong that I am doing? Could be that the virtualWire library might not work with other transmitters? Any help would be highly welcome