voy a probar primero con un arduino emisor y otro receptor
arduino emisor:
#include <VirtualWire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 10, 5, 4, 3, 2);
int boton = 6;
int eb = 0;;
int tx = 12;
void setup()
{
lcd.begin(16, 2);
vw_set_ptt_inverted(true);
vw_setup(7000);
pinMode(boton, INPUT);
vw_set_tx_pin(12);
vw_rx_start();
}
void loop()
{
//************** si recives un mensaje************
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
if (buf[0]==50) // chequeamos si el primer caracter que nos llega es de un arduino o de otro 49 para el 1 o 50 para el 2
{
lcd.clear();
lcd.setCursor(0,0);
for (int i = 1; i < buflen; i++) //Mostramos el mensaje desde el segundo caracter
{
lcd.print((char)bufi entre corchetes); // quita tambien los ***
}
}
}
//************** para enviar el mensaje*************
eb = digitalRead(boton);
if ( eb == HIGH) //Condicion para ver si esta activado el boton
{
const char *msg = "1mensaje enviado"; //cambia el 1 por un 2 para indentificar quien envia el mensaje
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
}
}
arduino receptor:
#include <VirtualWire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 10, 5, 4, 3, 2);
int boton = 6;
int eb = 0;;
int rx = 12;
void setup()
{
lcd.begin(16, 2);
vw_set_ptt_inverted(true); // Required for RX Link Module
vw_setup(7000); // Bits per sec
pinMode(boton, INPUT);
vw_set_rx_pin(12);
vw_rx_start();
Serial.println("Iniciando");
}
void loop()
{
//************** si recives un mensaje************
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
lcd.clear();
lcd.setCursor(0,0);
for (int i = 0; i < buflen; i++) //Mostramos el mensaje desde el segundo caracter
{
lcd.print((char)bufi entre corchetes); // quita tambien los ***
}
}
//************** para enviar el mensaje*************
eb = digitalRead(boton);
if ( eb == HIGH) //Condicion para ver si esta activado el boton
{
const char *msg = "1mensaje enviado"; //cambia el 1 por un 2 para indentificar quien envia el mensaje
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
}
}
asi tengo los dos arduinos montados solo uno con un tx y otro con rx. Le meto el skecth pero no sale nada en los lcd. He probado lo que me pusiste y si sale Prueba Rx/Tx". hay algo que no va bien pero no consigo dar con ello