[SOLVED] LCD keypad blinking while VirtualWire is sending. why?

Hello everyone,
I have a project going on with lcd keypad shield (here) and a pair of RF transmitter and receiver, everything assembled on the same arduino
Library used are virtualwire and LCDcrystal

Everything goes fine since the system has to send the message: the LCD blinks during the transmitting phase. I look around and I saw some conflicts going on between the two libraries that somebody solved changing the pin assignment.
But here is the thing: the LCD shield has fixed pin (8, 9, 4, 5, 6, 7) for its functionalities while the other are free to be used. Now if Virtualwire has something to do with these pins during transmitting ( I don’t know), how can I bypass that? If THIS is the problem…

here is the code

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


//#define transmit_en_pin 3
#define rxPin 2 
#define trxPin 3

int n_call = 2;  // numero unità del sistema

/* OTHER CODE HERE*/

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);           // select the pins used on the LCD panel

/* OTHER CODE HERE*/
	
void setup(){
	Serial.begin(9600);
	
	// SETTAGGI DI TRASMISSIONE
	vw_set_tx_pin(trxPin);        //configurazione pin trasmissione
	vw_set_rx_pin(rxPin );    // impostazione pin di riccezione
	//vw_set_ptt_pin(transmit_en_pin);  // settaggio pin enable-transmission
	vw_set_ptt_inverted(true);      // settaggio polarità PUSH-TO-TALK
	vw_setup(2000);
	
	Serial.println("-- START --");
	
	lcd.begin(16, 2);               // start the library
}


void loop(){
	uint8_t buf[VW_MAX_MESSAGE_LEN];
	uint8_t buflen = VW_MAX_MESSAGE_LEN;

/* OTHER CODE HERE*/

		
		// costituzione messaggio di invio 
		int num;
		char call[2];
		num = random(1,n_call+1);
		String str;
		str=String(num);
		str.toCharArray(call,2);
		
		// HERE THE BLINKING OCCURS
		for(int i=0; i<5; i++){
			vw_send((uint8_t *)call, 2); 
			vw_wait_tx();           
			delay(10);
		}
		
/* OTHER CODE HERE*/

}

any suggestion?

any suggestion?

It is usually good to post the whole code, even as an attachment if it is too big to fit between code tags.

Your display is using in addition pin 10 according to the link you supplied:

Pins 4, 5, 6, 7, 8, 9 and 10 are used to interface with the LCD

Is pin 10 used in any of the code that does not appear here ?
What RF devices are you using ?

hello 6v6gt, thank you for your reply.
I meant to get things easier symplifying the code. Of course no problem sharing.

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


//#define transmit_en_pin 3
#define rxPin 2 
#define trxPin 3

int n_call = 2;  // numero unità del sistema

/* OTHER CODE HERE*/

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);           // select the pins used on the LCD panel

/* OTHER CODE HERE*/
 
void setup(){
 Serial.begin(9600);
 
 // SETTAGGI DI TRASMISSIONE
 vw_set_tx_pin(trxPin);        //configurazione pin trasmissione
 vw_set_rx_pin(rxPin );    // impostazione pin di riccezione
 //vw_set_ptt_pin(transmit_en_pin);  // settaggio pin enable-transmission
 vw_set_ptt_inverted(true);      // settaggio polarità PUSH-TO-TALK
 vw_setup(2000);
 
 Serial.println("-- START --");
 
 lcd.begin(16, 2);               // start the library
}


void loop(){
 uint8_t buf[VW_MAX_MESSAGE_LEN];
 uint8_t buflen = VW_MAX_MESSAGE_LEN;

/* OTHER CODE HERE*/

 
 // costituzione messaggio di invio 
 int num;
 char call[2];
 num = random(1,n_call+1);
 String str;
 str=String(num);
 str.toCharArray(call,2);
 
 // HERE THE BLINKING OCCURS
 for(int i=0; i<5; i++){
 vw_send((uint8_t *)call, 2); 
 vw_wait_tx();           
 delay(10);
 }
 
/* OTHER CODE HERE*/

}

By default Virtualwire uses pin 10 as transmit_en_pin. Knowing that I tried choosing pin 3 for the purposes (as you can see commented at the beginning), but nothing changes.

Nothing else is set by me on pin 10.

If you don't want pin 10 to be used by virtual wire, haven't you got to set it explicitly to another pin, otherwise the library code will interfere with it e.g. change its function to an input pin which it monitors?:

vw_set_ptt_pin(transmit_en_pin)

Configure the transmit enable pin, or "push to talk". Default is pin 10.

source

eg

vw_set_ptt_pin(A3)

The sketch which you posted compiles, runs and exhibits the fault? The "/* OTHER CODE HERE*/" comments do not then indicate you have removed code for posting in this thread.

Hi, How are you powering the project?

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :)

@6v6gt yuo were right, some assignment to the vw_set_ptt_pin where missing, now it works.
Besides, I re-posted the wrong code

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


#define transmit_en_pin 3
#define rxPin 2 
#define trxPin 3

int n_call = 2;  // numero unità del sistema

#define btnRIGHT  0 // valore restituito dal tasto dopo lettura: per condizioni IF
#define btnUP     1 // valore restituito dal tasto dopo lettura: per condizioni IF
#define btnDOWN   2 // valore restituito dal tasto dopo lettura: per condizioni IF
#define btnLEFT   3 // valore restituito dal tasto dopo lettura: per condizioni IF
#define btnSELECT 4 // valore restituito dal tasto dopo lettura: per condizioni IF
#define btnNONE   5 // valore restituito dal tasto dopo lettura: per condizioni IF
int keyLR[]    = {btnNONE,btnNONE};
int keyUD[]    = {btnNONE,btnNONE};
int keyStartT  = btnNONE;
int keyStopT   = btnNONE;
int keySave    = btnNONE;
int keySaveSave= btnNONE;
int keyRestart = btnNONE;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);           // select the pins used on the LCD panel

int comMode = 1;//inizializzazione stato trasmissione/ricezione

unsigned long rxT0;
unsigned long txT0;

// dati analisi
int count = 0;
unsigned long dt = 0; // sigolo tempo di reazione
int t_recording[200] = {0}; //vettore per la registrazione dei tempi di reazione inizializzato tutto a 0. Massimo 200 operazioni


  
void setup(){
 Serial.begin(9600);
 
 // SETTAGGI DI TRASMISSIONE
 vw_set_tx_pin(trxPin);        //configurazione pin trasmissione
 vw_set_rx_pin(rxPin );    // impostazione pin di riccezione
 vw_set_ptt_pin(transmit_en_pin);  // settaggio pin enable-transmission
 vw_set_ptt_inverted(true);      // settaggio polarità PUSH-TO-TALK
 vw_setup(2000);
 
 Serial.println("-- START --");
 
 lcd.begin(16, 2);               // start the library
}

void loop(){
 uint8_t buf[VW_MAX_MESSAGE_LEN];
 uint8_t buflen = VW_MAX_MESSAGE_LEN;
 
 if(txT0 > rxT0){  // dal secondo loop
 dt = txT0-rxT0; // calcolo dei delta T
 t_recording[count-1] = dt; // salvataggio nel vettore di registrazione dati
 } 
 
 if(comMode == 1){
 vw_rx_stop();
 
 rxT0 = millis(); 
 count++;
 
 // costituzione messaggio di invio 
 int num;
 char call[2];
 num = random(1,n_call+1); // chiamata random
 // trasformazione in char attraverso stringa
 String str;
 str=String(num);
 str.toCharArray(call,2);
 
 //TRASMISSIONE
 for(int i=0; i<5; i++){
 vw_send((uint8_t *)call, 2); // invio del messaggio di lunghezza 2 (necessario per char singoli)
 vw_wait_tx();       // attesa conclusione invio    
 delay(10);
 }
 
 if(vw_tx_active() == false) {  
 
 Serial.println("invio");
 Serial.print("Sent: ");Serial.println(num);
 
 comMode = 0; 
 }
 
 } else if (comMode==0){
 vw_rx_start();
 if (vw_get_message(buf,&buflen)) {  // Non - blocking per lettura ricezione
 comMode=2;
 }
 
 } else if (comMode==2){
 vw_rx_stop();
 if ( int(char(buf[0]) == 48)){ // è in ASCII
 txT0 = millis();
 
 Serial.println("rice");
 Serial.print("Got:  ");Serial.println(char(buf[0]));      
 
 delay(200); // delay prima della successiva chiamata
 comMode = 1;  
 }
 }
}



int read_LCD_buttons(){               // read the buttons
 if (analogRead(0) > 1000) return btnNONE; 
 
 // soglie dei valori delle resistenze per lettura tasti e confronto con lettura su A0
 if (analogRead(0) < 50)   return btnRIGHT;  
 if (analogRead(0) < 195)  return btnUP; 
 if (analogRead(0) < 380)  return btnDOWN; 
 if (analogRead(0) < 555)  return btnLEFT; 
 if (analogRead(0) < 790)  return btnSELECT;  
 
 return btnNONE;                // when all others fail, return this.
}

@TomGeorge the system is powered with these batteries
batteries