Hi All!
Just started with the arduino ![]()
Having some major problems with the variables->flickering.
Arduino UNO
MAX6675 Thermocouple
1.8 SPI TFT
In the proces of building a cargauge with:
EGT,AFR and boost read out.
This is my code so far based on the basic example:
"THE" question haw can i remove the flickering in the variables?
/*
Arduino TFT text example
This example demonstrates how to draw text on the
TFT with an Arduino. The Arduino reads the value
of an analog sensor attached to pin A0, and writes
the value to the LCD screen, updating every
quarter second.
This example code is in the public domain
Created 15 April 2013 by Scott Fitzgerald
http://arduino.cc/en/Tutorial/TFTDisplayText
*/
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
#include "max6675.h"
// pin definition for the max6675
int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst 8
// pin definition for the Leonardo
// #define cs 7
// #define dc 0
// #define rst 1
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
// char array to print to the screen
char sensorPrintout[4];
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("EGT :\n ", 0, 0);
// ste the font size very large for the loop
TFTscreen.setTextSize(3);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("AFR :\n ", 0, 50);
// ste the font size very large for the loop
TFTscreen.setTextSize(3);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Boost :\n ", 0, 100);
// ste the font size very large for the loop
TFTscreen.setTextSize(3);
//activate MAX7735
Serial.begin(19200);
// use Arduino pins
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
Serial.println("MAX6675 test");
// wait for MAX chip to stabilize
delay(500);
}
void loop() {
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
delay(10);
// Read the value of the sensor EGT
String sensorVal = String(thermocouple.readCelsius());
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255, 255, 255);
// print the sensor value
TFTscreen.text(sensorPrintout, 80, 0);
// wait for a moment
delay(100);
// erase the text you just wrote
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 80, 0);
// Read the value of the sensor on AFR
String sensorVal2 = String(analogRead(A0));
// convert the reading to a char array
sensorVal2.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255, 255, 255);
// print the sensor value
TFTscreen.text(sensorPrintout, 80, 50);
// wait for a moment
delay(100);
// erase the text you just wrote
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 80, 50);
}