I am trying to use VirtualWire with RF modules and ATtiny85.
My ATtiny85 is working fine. I can run the "blink" example with no trouble.
I also tested the TX and RX modules with two arduinos and it all works OK.
But after uploading the sketch of transmitter to the ATtiny85, nothing happens. The TX does not send anything to the receiver, and the test led keeps turned ON everytime.
I've tried with VirtualWire 1.14 and arduino 1.0.5 (i also tried with arduino 1.0.3, 1.0, 0022)
I've read that VirtualWire 1.14 supports ATtiny85 so I can't understand what's happening.
The RF modules i'm using:
Just one additional comment: if I comment the vw_* commands in the sketch, the led works normally (it goes ON and then OFF after a second).
And here is the code:
For the TX (running in ATtiny85):
#include <VirtualWire.h>
const int led_pin = 0;
const int tx_pin = 1;
void setup()
{
vw_setup(2000);
vw_set_ptt_inverted(true);
vw_set_tx_pin(tx_pin);
pinMode(led_pin, OUTPUT);
}
void loop()
{
char msg[7] = {'h','e','l','l','o',' ','#'};
digitalWrite(led_pin, HIGH);
delay(1000);
vw_send((uint8_t *)msg, 7);
vw_wait_tx();
digitalWrite(led_pin, LOW);
delay(1000);
}
For the RX (running in Arduino UNO)
#include <VirtualWire.h>
const int led_pin = 0;
const int rx_pin = 11;
void setup()
{
Serial.begin(9600);
Serial.println("setup");
vw_set_rx_pin(rx_pin);
vw_set_ptt_inverted(true);
vw_setup(2000);
vw_rx_start();
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
digitalWrite(led_pin, HIGH);
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i], HEX);
Serial.print(" ");
}
Serial.println("");
digitalWrite(led_pin, LOW);
}
}
Thanks in advance for your help.