I have a very simple sketch to light up two LEDs based on message received by the RX module.
The TX module sends one of four commands
rr
0r
yy
0y
Very simplistic and based on project 47 of Arduino Workshop.
I then decided to add a LCD to the go with the RX module.
The minute I add LiquidCrystal lcd (4,5,6,7,8,9); to my rx sketch, the LEDs no longer work.
If I comment it out, then the sketch works and the LEDs turn on and off based on the four commands.
I am wondering is there a conflict with the two libraries?
#include <LiquidCrystal.h>
#include <VirtualWire.h>
uint8_t myBuffer[VW_MAX_MESSAGE_LEN];
uint8_t bufferLen = VW_MAX_MESSAGE_LEN;
const int NUM_ROWS = 2;
const int NUM_CHARACTERS = 16;
int x;
int y;
LiquidCrystal lcd(4,5,6,7,8,9); //pins for RS, E, DB4, DB5, DB6, DB7
boolean isOff;
void setup()
{
//set up the 433 MHz module
vw_set_rx_pin(12); //
vw_setup(2000); //bits per second
vw_rx_start(); //start the receiver PLL running
//set up LCD display
//lcd.begin(NUM_CHARACTERS, NUM_ROWS);
//lcd.clear();
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
Serial.begin(9600);
Serial.println("setup");
}
void loop()
{
if (vw_get_message(myBuffer, &bufferLen))
{
isOff = false;
switch (myBuffer[0])
{
case 'r':
digitalWrite(2, HIGH);
break;
case '0':
isOff = true;
break;
case 'y':
digitalWrite(3, HIGH);
break;
}
if (isOff == true)
{
if (myBuffer[1] == 'r') digitalWrite(2, LOW);
if (myBuffer[1] == 'y') digitalWrite(3, LOW);
}
}
}
EDIT:
In another, there is mention of conflict with VirtualWire's pin 10, 11
http://forum.arduino.cc/index.php?topic=176504.0
But I am not using pins 10 and 11 for the LiquidCrystal
EDIT #2:
Per a post by Crossroads in the above thread, VirtualWire takes over pin 9 and 10 not 10 and 11 as I wrote earlier.
So, I changed to LiquidCrystal lcd(4,5,6,7,8,12);
and used pin 11 for rx vw_set_rx_pin(11);
EDIT #3:
Also needed to set vw_set_tx_pin(13); because the default TX pin if not specified defaults to 12.