Go Down

Topic: LCD with VirtualWire doesn't work properly (Read 724 times) previous topic - next topic

gnusso

Hi all,
this is the scenario:

" I try to use LCD with VirtualWire Library but without success. I didn't have back issues from the compiler but the LCD stop to work when I add VirtualWire part. "

What I've try to is:

- Change inside VirtualWire the Default Tx,RX, PPT Pin --> But Without success

Code: [Select]

// Set the digital IO pin to be for transmit data
   vw_set_tx_pin(uint8_t pin);
   vw_set_rx_pin(uint8_t pin);
   vw_set_ptt_pin(uint8_t pin);


The Display is configured like into the example below reported:

Code: [Select]

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}


Can I try to change PIN for LCD ? or are particular Pin ?

Have you already encountered this kind of issues ?

Thanks in advance for the help,
gnux

gardner

The code you have given does not mention VirtualWire at all.  Please give the code you are actually using.

What do you have wired up that you are using Virtual Wire?  Is it a radio?  Have you confirmed that the VirtualWire part does or does not work independently of the LCD?

gnusso

So, virtual wire it's working when try to emulate the LCD in Serial ... when I enable the LCD the LCD doesn't work ... so If comment the VIRTUAL WIRE part the LCD start to work ... so you can take a simple example for example something like this because is a general issues ...

Code: [Select]

#include <VirtualWire.h>
#include <LiquidCrystal.h>
#include "M2tk.h"
#include "utility/m2ghlc.h"

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

uint8_t uiKeySelectPin = 10;
uint8_t uiKeyNextPin = 9;

uint8_t select_color = 0;
uint8_t select_priority = 0;

void setup()
{
   
    vw_setup(1200);
    m2_SetLiquidCrystal(&lcd, 16, 4);
    m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
    m2.setPin(M2_KEY_NEXT, uiKeyNextPin);
}


void fn_ok(m2_el_fnarg_p fnarg) {
  /* accept selection */
}

void fn_cancel(m2_el_fnarg_p fnarg) {
  /* discard selection */
}

const char *fn_idx_to_color(uint8_t idx)
{
  if ( idx == 0 )
    return "red";
  else if (idx == 1 )
    return "green";
  return "blue";
}

const char *fn_idx_to_priority(uint8_t idx)
{
  switch(idx)
  {
    case 0: return "lowest";
    case 1: return "low";
    case 2: return "medium";
    case 3: return "high";
    case 4: return "highest";
  }
  return "";
}


M2_LABEL(el_label1, NULL, "Color:");
M2_COMBO(el_combo1, NULL, &select_color, 3, fn_idx_to_color);

M2_LABEL(el_label2, NULL, "Prio.: ");
M2_COMBO(el_combo2, "v1", &select_priority, 5, fn_idx_to_priority);

M2_BUTTON(el_cancel, NULL, "cancel", fn_cancel);
M2_BUTTON(el_ok, NULL, " ok ", fn_ok);

M2_LIST(list) = {
    &el_label1, &el_combo1,
    &el_label2, &el_combo2, 
    &el_cancel, &el_ok
};
M2_GRIDLIST(list_element, "c2",list);
M2tk m2(&list_element, m2_es_arduino, m2_eh_2bs, m2_gh_lc);


void loop() {
    const char *msg = "hello";
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    digitalWrite(13, false);
    m2.checkKey();
    m2.checkKey();
    if ( m2.handleKey() )
    m2.draw();
    m2.checkKey();
}


then looking the library by default VirtualWire use rx 11 pin tx 12 pin then I've change the pin but still to have the issues ...

please let me know if you need more information,

Best regards,
Gnux

gardner

Your code does not tell VirtualWire which pins to use..

If you read the docs at http://download.milesburton.com/Arduino/VirtualWire/VirtualWire.pdf

Quote

4.1 vw_set_tx_pin
extern void vw_set_tx_pin(uint8_t pin);
Set the digital IO pin to use for transmit data. Defaults to 12.
4.2 vw_set_rx_pin
extern void vw_set_rx_pin(uint8_t pin);
Set the digital IO pin to use for receive data. Defaults to 11.


The default pins (11, 12) collide with the ones you've picked for your LCD.
Use the above APIs to set the pins you will actually use.

gnusso

Yes si using the default pin ... So can i use each pin for display ?

Thx
Gnux

PaulS

I guess that what I don't understand is why you want to use the LCD on the default VW pins and move the VW class to other pins. Why not just move the LCD to something other than the VW pins?

gnusso

I've tried but specifying other PIN for virtual Wire doesn't works ... then specifying other pin for LCD it's working... my question is all pin can be used for LCD ?

Thanks
gnux

PaulS

Quote
my question is all pin can be used for LCD ?

Any unused pin, yes.

gnusso


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy