Please help!!
I have built a proto to measure voltage with an arduino and a 16X2 alphanumeric LCD, it works great!! Only I would like to know if its possible to replace the current alphanumeric LCD with the Color Smart GPU and display the same results. If it is possible could you please provide a short sample code that would replace my current code below.
Thank You!!
// include the library code:
#include <LiquidCrystal.h>
#include <PID_v1.h>
#define aref_voltage 1.72
#define PPO inputReading1*aref_voltage/1024
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, 5,7,2, REVERSE);
// initialize the lcd with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
/****************************************************************
*initiate pins for each led
*****************************************************************/
const int red1 =22;
const int blue1 =28;
const int green1 =26;
/****************************************************************/
/****************************************************************
*initiate pins for sensor inputs 1, 2, 3
*****************************************************************/
const int sensor1 = A0; // the analog pin the 02 Sensor Vout pin is connected to
int inputReading1; //declare a variable
const int sensor2 = A1; // the analog pin the 02 Sensor Vout pin is connected to
int inputReading2; // declare a variable
const int sensor3 = A2; // the analog pin the 02 sensor Vout pin is connected to
int inputReading3; // declare a variable
/*****************************************************************/
void setup ()
{
Input = analogRead(PPO);
Setpoint = 520;
myPID.SetMode(AUTOMATIC);
analogReference(EXTERNAL); // set external analog Ref for PPO output
/*****************************************************************
*set output assignments for led pins
******************************************************************/
pinMode( red1, OUTPUT);
pinMode( green1, OUTPUT);
pinMode( blue1, OUTPUT);
/****************************************************************/
/***************************************************************
*set up the LCD's number of columns and rows:
****************************************************************/
lcd.begin(20, 4);
lcd.setCursor(0, 0);//where to start cursor
lcd.print("PINA SYSYTEMS ");//print message
lcd.print("SOFTWARE VERSION 1.0");//print message
delay(2000);
lcd.clear();
lcd.setCursor(0, 0); // set the cursor to column 0, line 0
lcd.print("PP1"); // Print a message to the LCD.
lcd.setCursor(6, 0); // set the cursor to column 6, line 0
lcd.print("PP2"); // Print a message to the LCD
lcd.setCursor(12, 0); // set the cursor to column 12, line 0
lcd.print("PP3"); // Print a message to the LCD.
/*************************************************************/
}
void loop ()
{
/*************************************************************
- turn the output pin on/off based on pid output
**************************************************************/
Input = analogRead(PPO);
myPID.Compute();
analogWrite(7,Output);
/*************************************************************/
if (PPO >= 1.10 && PPO <= 1.40) color(255, 0, 0);
if (PPO < 1.10 && PPO >= 0.80) color(0, 255, 0);
lcd.setCursor(0, 1); //sets the cursor to column 0, line 1
//getting the voltage reading from the 02 sensor
inputReading1 = analogRead(sensor1);
// converting that reading to voltage
float voltage1 = inputReading1 * aref_voltage;
voltage1 /= 1024.0;
//print actual voltage to lcd
lcd.print(voltage1, 2);
delay(200);
lcd.setCursor(6, 1); //sets the cursor to column 6, line 1
//getting the voltage reading from the temperature sensor
inputReading2 = analogRead(sensor2);
// converting that reading to voltage
float voltage2 = inputReading2 * aref_voltage;
voltage2 /= 1024.0;
//print actual voltage to lcd
lcd.print(voltage2, 2);
delay(200);
lcd.setCursor(12, 1); //sets the cursor to column 12, line 2
//getting the voltage reading from the temperature sensor
inputReading3 = analogRead(sensor3);
// converting that reading to voltage
float voltage3 = inputReading3 * aref_voltage;
voltage3 /= 1024.0;
//print actual voltage to lcd
lcd.print(voltage3, 2);
delay(200);
}
void color (unsigned char red, unsigned char green, unsigned char blue)
{
analogWrite(red1, 255-red);
analogWrite(blue1, 255-blue);
analogWrite(green1, 255-green);
}