HI
I am a COMPLETE noob with Arduino. I have managed to write a sketch using a std LCD screen, Now Im trying I2C using a Matrix Orbital LK204. I have loaded up an example and it worked fine so I thought I would give it a try my self with a simple sketch, which I seem to have done wrong. The last time I did any programming was about 25 years ago on a ZX Spectrum, I know a little bit of PHP and HTML, thats about it.
Sorry for the noobness
#include <Wire.h>
#include <stdlib.h>
#define LCD (0x28)
void setup()
{
  Wire.begin();
  Wire.beginTransmission(LCD);
 // Print a message to the LCD.
  Wire.write("Hello, world!");
}
void loop()
{
}
Sorry, wrong sketch, this is the right one. I didn't explain my problem either. DOH!!
It will write Hello, world! but still leaves the Matrix orbital logo on the screen. If I press the reset button, it will write Hello, world! straight after the 1st one. How do I get the screen to clear?
#include <Wire.h>
#include <stdlib.h>
#define LCD (0x28)
void setup()
{
  Wire.begin();
  Wire.beginTransmission(LCD);
 // Print a message to the LCD.
  Wire.write("Hello, world!");
  Wire.endTransmission();
}
void loop()
{
}
I managed to sort that problem, now on to the next. I wrote a sketch for a parallel LCD display and it worked fine. I now want to modify it to work with the LK204. I have been at if for hours and its a no go Can anyone help me please?
This is the original sketch that uses the parallel display
// Avinitlarge's Boost & AFR Gauge Project
// Reads boost from MPX4250AP on Analog 0 and AFR on Analog 7.
// Converts vacuum readings to inHg.
// Displays peak boost
// include libraries
#include <LiquidCrystal.h>
float rawval = 0; // Setup raw sensor value
float kpaval = 0; // Setup kPa value
float boost = 0; // Setup boost value
float rawvala = 0; // Setup raw afr sensor value
float afrval = 0; // Setup afr value
float afr = 0; // Setup value for afr value
float vac = 0; // Setup vacuum value
float peak = 0; // Setup peak value
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // set LCD interface pins
void setup() // Start setup
 {
   // set up the LCD's number of columns and rows:
 lcd.begin(20, 4);
 lcd.setCursor(4,0); //set cursor to top left corner
 lcd.print("Volvo V70 R"); //print the text to the lcd
Â
 lcd.setCursor(3,2); //set cursor to top left corner
 lcd.print("Custom tune by"); //print the text to the lcd
 lcd.setCursor(5,3); //set cursor to top left corner
 lcd.print("Avinitlarge"); //print the text to the lcd
 {
  delay(2000); //change the delay to change how fast the boot up screen changes
 }
lcd.begin(20, 4); // set the LCD's columns and rows
Â
// Setup static characters on the lcd
lcd.setCursor(4,0);
lcd.print("Volvo V70 R");
lcd.setCursor(2,2);
lcd.print("Boost:");
lcd.setCursor(3,3);
lcd.print("Peak:");
lcd.setCursor(14,3);
lcd.print("psi");
lcd.setCursor(4,1);
lcd.print("AFR:");
} // End setup
void loop() // Start loop
{
Â
//AFR Gauge start
 // some base calculations to get afr
rawvala = analogRead(7); // Read lambda sensor raw value on analog port 1
afrval = (rawvala*(19.40-10)/(1023-0) +10); // Calculate afr value from raw value for debugging
afr = (rawvala*(19.40-10)/(1023-0) +10); // Calculate afr from raw value ***(calculations need proving)***
 lcd.setCursor(9,1);
 lcd.print(afr,1); // Prints the afr figure
//AFR Gauge endÂ
Â
//Boost gauge start
// some base calculations to get pressures
rawval = analogRead(0); // Read MAP sensor raw value on analog port 0
kpaval = (rawval*(0.005)/(0.022)+20); // Calculate kpa value from raw value for debugging
boost = ((rawval*(0.005)/(0.022)+20)*(0.145)-14.5); // Calculate psi from raw value ***(calculations need proving)***
if (boost >= 0) // Set condition for bargraph to show above zero (negative numbers cause LCD crash)
 {
 lcd.setCursor(9,2);
 lcd.print(boost,1); // Prints the boost figure
 lcd.setCursor(14,2);
 lcd.print("psi "); // Prints 'psi' with a space after it to clear the 'g' off 'inHg'
 }
if (boost < 0)
 {
 lcd.setCursor(9,2);
 lcd.print(vac,1); // Prints the vacuum figure
 vac = boost*-2.036025; // Used 'minus' 2.036025 so that the figure printed wont have a minus symbol in front of it
 lcd.setCursor(14,2);
 lcd.print("inHg"); // Changes the units to 'inHg' on the lcd
Â
 }
if (boost > peak) // If current boost is higher than peak, store new value
 {
 peak = boost ; // Store new peak value in peak memory
 }
lcd.setCursor(9,3);
lcd.print(peak,1); // Prints the peak value
} //end loop