College Project

Hi, I was wondering if anyone can help me? I am currently part of a team taking part in the EESW project at Gower College Swansea, I have been programming an arduino uno to read and display the current temperature of the room it's in. It is connected to a thermistor and a 10k resistor.

So this is where I need help, I want to display said value on to the tft screen by arduino, I am aware it is currently no longer supported but this is all we've had access to in the college. I have managed to created the code for the arduino to read and display the temperature in Celsius like I wanted but I don't know how to get it to display to the tft screen, please help this is urgent.

Here is my code to view the temperature, it display in the onboard serial monitor inside the arduino software:

// char array to print temp
char printout[4];
// the setup routine runs once when you press reset:

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(115200);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 95.0);
// print out the value you read:
Serial.println(voltage);
}

I want to display said value on to the tft screen

Which TFT screen?

Have you got any supporting libraries?

www.arduino.cc/en/Main/GTFT - That is the web link to the TFT screen we are using, and I'm not sure what you mean by supporting libraries?

Library - it's on about the third line in

Yes, I do have this.

So what's the problem?
Doesn't the library include example code?

I need the results of the original code I posted to display on said screen, I'm not sure how to code it to do that. I'm very new to code I have only learnt bare basics before now and that was in visual basic.

If you're very lucky, after a bit of initialisation, setting font size and cursor positioning, it may be as simple as replacing Serial.println(voltage); with tft.print(voltage);

(Sorry, I don't have this device - you'll need to look at the example code - hopefully there's a "Hello world" which is within spitting distance of what you want)

It says tft was not declared in this scope? Sorry, like I said I'm very new to this.

Post the code that produced the error. It sounds like the library is not #included properly.

#include <TFT.h> // Hardware-specific library
#include <SPI.h>

#define CS 10
#define DC 9
#define RESET 8

TFT myScreen = TFT(CS, DC, RESET);

// char array to print temp
char printout[4];
// the setup routine runs once when you press reset:

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(115200);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 95.0);
// print out the value you read:
tft.println(voltage);
}

Try myScreen.println(voltage);but I note that you have not set the output position or font as advised in post #7

I’m not sure how to do that? All of this is why I’m here for help.

Look down the left-hand side here

And here's a worked example.

Okay so now I've just been given a compiling error?

ryanwilkinswilliams:
Okay so now I've just been given a compiling error?

Oh.
That's sad.

(I can offer sympathy, or more concrete advice. At the moment, it's just sympathy. Your move)

What does that mean?

I can help you, if you allow me to.

Posting "it doesn't work" or "I get a compilation error" or something equally vacuous doesn't help anyone.

This is the code I currently have:

#include <TFT.h> // Hardware-specific library
#define cs 10
#define dc 9
#define rst 8

TFT TFTscreen = TFT(cs, dc, rst);

// char array to print temp
char printout[4];
// the setup routine runs once when you press reset:

void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(115200);
TFTscreen.begin();

TFTscreen.background(0, 0, 0);

TFTscreen.stroke(255,255,255);
TFTscreen.setTextSize(2);
TFTscreen.text("Sensor Value : ",0,0);
TFTscreen.setTextSize(5);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 95.0);
// print out the value you read:
tft.println(voltage);
}

And I'm expected to take the trouble to copy that out and paste it into an IDE, just to discover the same compilation error you get, am I?

What's my motivation?