Matrix Orbital LK204, trying to get started

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
Avinitlarge
LCD?
Posts: 6
Joined: Tue Jun 10, 2014 7:56 am

Matrix Orbital LK204, trying to get started

Post by Avinitlarge »

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 try and get my sketch working with the Matrix Orbital display. I have tried for a few hours to get it working but due to my noobness, I failed. 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.

Could someone give me some pointer please? Sorry for the noobness

This is my original sketch

Code: Select all

// 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

Tino
Matrix Orbital
Matrix Orbital
Posts: 158
Joined: Wed May 22, 2013 9:04 am
Location: Matrix Orbital

Re: Matrix Orbital LK204, trying to get started

Post by Tino »

Hi Avinitlarge,

In your sketch you are using the "LiquidCrystal" Library. This Library is for Parallel displays which your LK204 is not. We have an Arduino example on our support site which uses I2C with the Arduino which could help give you an idea on how to get your code running here:
http://www.matrixorbital.ca/appnotes/ArduinoDemo/

In our demo we used the "Wire" library for I2C.

Also there are some examples on Arduino's sight for the "SoftwareSerial" library here:
http://arduino.cc/en/Reference/Libraries

Keep in mind that the Arduino uses TTL so you will need to set your display to TTL protocol unless you are using I2C.

I hope this helps.
If you have any other questions or concerns please feel free to ask.
Thank you
Martino
Martino DeLeon
Matrix Orbital
Technical Support Representative

Post Reply