Good morning folks,
I've been working on a project to display the output voltage of a analog sensor to an O'LED display and so far I've been able to write code to accomplish this, how ever their seems to be a small issue that I would like to over come if possible. When I start the processor the screen displays the voltage in the correct decimal format, but the output flashes repeatedly on the screen every second in order to update the current analog sensor voltage, is there a way to manipulate the code to update the sensor voltage without flashing?
Thank you Guys!!
#include <SMARTGPU.h>//include the SMARTGPU library!
#define MULTIPLIER 100
#define aref_voltage 3.0
SMARTGPU lcd;//create our object called LCD
//****************************O2 SENSOR INPUTS****************************
const int sensor1 = A0; // the analog pin the 02 Sensor Vout pin is connected to
int sensorValue1; //declare a variable
const int sensor2 = A1; // the analog pin the 02 Sensor Vout pin is connected to
int sensorValue2; // declare a variable
const int sensor3 = A2; // the analog pin the 02 sensor Vout pin is connected to
int sensorValue3; // declare a variable
void Display(){
sensorValue1 = analogRead(sensor1);
float VoltageSensor1 = sensorValue1*aref_voltage;
VoltageSensor1 /= 1024.0;
long lWhole1 = 0;
unsigned long ulPart1 = 0;
lWhole1=(long)((float)VoltageSensor1);// whole part of the number to the left of the decimal point
ulPart1=(long)((float)VoltageSensor1*MULTIPLIER)-lWhole1*MULTIPLIER;// fractional part to the right of the decimal point
char PPO1[1]= "";
sprintf(PPO1, "%li.%02li", lWhole1,ulPart1);
lcd.string(9,70,100,50,GREEN,FONT7,TRANS,PPO1);
sensorValue2 = analogRead(sensor2);
float VoltageSensor2 = sensorValue2*aref_voltage;
VoltageSensor2 /= 1024.0;
long lWhole2 = 0;
unsigned long ulPart2 = 0;
lWhole2=(long)((float)VoltageSensor2);// whole part of the number to the left of the decimal point
ulPart2=(long)((float)VoltageSensor2*MULTIPLIER)-lWhole2*MULTIPLIER;// fractional part to the right of the decimal point
char PPO2[2]= "";
sprintf(PPO2, "%li.%02li", lWhole2,ulPart2);
lcd.string(123,70,255,65,GREEN,FONT7,TRANS,PPO2);
sensorValue3 = analogRead(sensor3);
float VoltageSensor3 = sensorValue3*aref_voltage;
VoltageSensor3 /= 1024.0;
long lWhole3 = 0;
unsigned long ulPart3 = 0;
lWhole3=(long)((float)VoltageSensor3);// whole part of the number to the left of the decimal point
ulPart3=(long)((float)VoltageSensor3*MULTIPLIER)-lWhole3*MULTIPLIER;// fractional part to the right of the decimal point
char PPO3[3]= "";
sprintf(PPO3, "%li.%02li", lWhole3,ulPart3);
lcd.string(238,70,320,65,GREEN,FONT7,TRANS,PPO3);
}
void setup(){
lcd.init(); //configure serial and pinout on arduino for SMARTGPU
lcd.start(); //initialize SMARTGPU processor
analogReference(EXTERNAL); // set external analog Ref for PPO output
}
void loop(){
lcd.imageSD(0,0,"main7");
Display();
}