I'm using the LiquidCrystal library with my 4x20 LCD. I think I've got it set up right.. everything works.
When I use setCursor(1,0); it goes to line two like expected, but when I'm inputting data from anything, when it needs to goto the next line, it skips line 2, goes to line 3, then to line 2, then finally line 4. I'm sure it has something to do with my code, I did a search but wasn't really sure what to search for, so sorry if it's already been answered! And I didn't see any functions for it on the Arduino tutorials, so I'm a bit lost! (no surprise :D)
Here's my code, it's using VirtualWire to receive data and post it to the LCD, just two words at the moment for testing.
Right now, the code is set to start on line two, so when it starts displaying, line two first fills up, then line 4, then line 1, then line 3.
Any pointers in cleaning up code would be appreciated as well:D
// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
#include <VirtualWire.h>
#include <LiquidCrystal.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
// In this case, the minimum: RS,R/W,EN,D4,D5, D6, D7
LiquidCrystal lcd(6, 7, 8, 9, 10, 11, 12);
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
lcd.begin(20, 4); // begins LCD, 20 columns, 4 rows(lines)
delay(20);
lcd.clear();
delay(20);
lcd.print("ready to begin");
// Initialise the IO and ISR
vw_set_rx_pin(2); // sets receiver to 2 to clear pin for LCD
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
lcd.setCursor(0,1);
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i]);
Serial.print(" ");
lcd.print(buf[i]);
}
Serial.println("");
lcd.print(" ");
digitalWrite(13, false);
}
}