RF Transmitter and LCD Compatabilty Programming Problem

I am trying to send various messages from one Arduino to another. I have set up one with four buttons, an LCD and a an RF transmitter. I'm using the Virtual Wire library. When an individual button is pressed, I want a corresponding message to appear on the LCD and the transmitter to transmit that message. I can get the messages to display on the LCD but when I add the code for the transmitter, the messages don't display (they are still sent via RF). By systematically commenting out code I have narrowed the problem down to this line :

vw_setup(2000);

This sets bits per second for transmitting. When this line is commented out, the LCD displays the messages. When not commented out, the messages don't appear on the LCD. I'm using a 16x2 LCD.

Anyone know how I can get around this? Any suggestions would be greatly appreciated.

All that tells us is that vw and your LCd aren't happy with each other. You'll find the next step in the sticky at the top of the forum.

Mark

Thanks for getting back to me Mark. What is a "sticky" (I'm pretty new to this) ?

Here's the offending part of the code

#include <VirtualWire.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int button1Pin = 7;
const int button2Pin = 8;
const int button3Pin = 9;
const int button4Pin = 10;
const int ledPin = 13;

int button1State = 0;
int button2State = 0;
int button3State = 0;
int button4State = 0;

void setup() {
lcd.begin(16, 2);
lcd.print("Ready..");
lcd.setCursor(0, 1);
Serial.begin(9600); // Debugging only
Serial.println("setup");

vw_set_tx_pin(6);
vw_set_ptt_inverted(true);
vw_setup(2000);
vw_tx_start();

pinMode(ledPin, OUTPUT);
pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);
pinMode(button4Pin, INPUT);
}

The stickys are the two posts that are all ways at the top of the forum.

Which LCD ,which RF Tx/Rx pair Provide links to both. How have you got things wired up.

And allways post all your code!, never just the bit you think is the problem.

Mark

This is wrong, the pin should not be above the setup.

vw_set_tx_pin(6);
vw_set_ptt_inverted(true);
vw_setup(2000);
vw_tx_start();

Try this.

vw_setup(2000); 
vw_set_tx_pin(6);
vw_tx_start(); // This may also not be needed, but try it with and without it.

Hi

Have tried putting the pin below the setup but still nothing is displayed on the LCD. Only when I comment out the line

vw_setup(2000);

do the messages display. Also when I have this line in, the LED (pin 13) that I have to blink when I press a button stays on.

There is no problem sending and receiving the messages (obviously with vw_setup(2000); not commented out).

Have you looked at the vw library? There are a number of default pins. You probably need to assign new values to all of them, even if you don't use them, or not use them for your LCD.

Have you tried setting up vw before the LCD?

Hi Paul

Thanks for your comments.

I have tried setting up vw before the LCD but that didn;t help. I've also swapped pin 3 and pin 6, as pin 3 was being used by the LCD (that pin is usually used for vw tx). I altered the sketch to reflect the changes but to no avail. I'll try and have a look at the vw library, though that will be new ground for me.

Thanks again

Rob