I have built a small unit consisting of 3 variable resistors and a ST7735 display connected to a nano.
The programme accepts the input from three analog pins and shows the three colours as circles then mixes them together to show the result of all three.
I have a small problem, the number beside the colour circle is in Hexadecimal but the letter is in lower case, is it possible to convert it to make it show in upper case?
/*
Arduino TFT text example for ST7735
LED - n/c
SCL - D13
SDA - D11
DC - D9
Reset - D8
CS - D10
GND - GND
VCC - 5v
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. (no need for the analog sensor).
see examples/TFT/arduino/TFTDisplayText for original
*/
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst 8
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
// char array to print to the screen
char numblue[4];//to print number on screen
char numgreen[4];
char numred[4];
void setup() {
Serial.begin(9600);
// 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);
}
void loop() {
TFTscreen.stroke(0,0,0);// erase the text you just wrote
TFTscreen.text(numblue,23,2);//text,left edge, down 70
TFTscreen.stroke(0,0,0);// erase the text you just wrote
TFTscreen.text(numgreen,23,26);//text,left edge, down 70
TFTscreen.stroke(0,0,0);// erase the text you just wrote
TFTscreen.text(numred,23,50);//text,left edge, down 70
int blue = analogRead(A0);// Read the value of the sensor on A0
//convert it so it can be read as a number on screen
blue = map(blue, 0, 1023, 0, 254);
String sensorblue = String(blue,HEX);//to print number on screen
sensorblue.toCharArray(numblue, 4);//to print number on screen
int green = analogRead(A1);// Read the value of the sensor on A1
//convert it so it can be read as a number on screen
green = map(green, 0, 1023, 0, 254);
String sensorgreen = String(green,HEX);//to print number on screen
sensorgreen.toCharArray(numgreen, 4);//to print number on screen
int red = analogRead(A2);// Read the value of the sensor on A2
//convert it so it can be read as a number on screen
red = map(red, 0, 1023, 0, 254);
String sensorred = String(red,HEX);//to print number on screen
sensorred.toCharArray(numred, 4);//to print number on screen
TFTscreen.stroke(255,0,0);//blue letters/numbers
TFTscreen.setTextSize(2);
TFTscreen.text(numblue,23,2);//print text,left edge, down 2
TFTscreen.stroke(0,255,0);//green letters/numbers
TFTscreen.setTextSize(2);
TFTscreen.text(numgreen,23,26);//print text,left edge, down 26
TFTscreen.stroke(0,0,255);//red letters/numbers
TFTscreen.setTextSize(2);
TFTscreen.text(numred,23,50);//print text,left edge, down 50
delay(500);
TFTscreen.stroke(blue,0,0);//blue colour for circle
TFTscreen.fill(blue,0,0);//fill circle with blue
TFTscreen.circle(10,10,10);//print circle
delay(10);
TFTscreen.stroke(0,green,0);//green colour for circle
TFTscreen.fill(0,green,0);//fill circle with green
TFTscreen.circle(10,33,10);//print circle
delay(10);
TFTscreen.stroke(0, 0,red);//red colour for circle
TFTscreen.fill(0,0,red);//fill circle with red
TFTscreen.circle(10,57,10);//print circle
delay(10);
TFTscreen.stroke(blue,green,red);//just blue altering for box
TFTscreen.fill(blue,green,red);//just changing blue
TFTscreen.rect(10,70,30,21);//build rectangle
TFTscreen.circle(10,80,10);//put circle on one end
TFTscreen.circle(40,80,10);//put circle on other end
}