Error message: error compiling for board Arduino UNOcannot compile for UNO

I want to learn 3.5" color TFT so I found this code at https://create.arduino.cc/projecthub/electropeak/ultimate-beginner-s-guide-to-run-tft-lcd-displays-by-arduino-081006
I have libraries loaded but get this message.



#include "Adafruit_GFX.h"
#include "MCUFRIEND_kbv.h"
MCUFRIEND_kbv tft;
#include "Volume.h"
#define BLACK   0x0000
int a = 0,b = 4000,c = 1000,d = 3000;
int s=2000;
int j, j2;
int i, i2;
int White;
void setup()
{
 Serial.begin(9600);
 uint16_t ID = tft.readID();
 tft.begin(ID);
 tft.invertDisplay(true);
 tft.setRotation(1);
}
void loop(void)
{
 tft.invertDisplay(true);
 tft.fillScreen(BLACK);
 tft.drawRGBBitmap(0, 0, test, 480, 320);
 White = tft.color565(255, 255, 255);
 while(1){
 if (a < s) {
     j = 14 * (sin(PI * a / 2000));
     i = 14 * (cos(PI * a / 2000));
     j2 = 1 * (sin(PI * a / 2000));
     i2 = 1 * (cos(PI * a / 2000));
     tft.drawLine(i2 + 62, j2 + 240, i + 62, j + 240, White);
     j = 14 * (sin(PI * (a-300) / 2000));
     i = 14 * (cos(PI * (a-300) / 2000));
     j2 = 1 * (sin(PI * (a-300) / 2000));
     i2 = 1 * (cos(PI * (a-300) / 2000));
     tft.drawLine(i2 + 62, j2 + 240, i + 62, j + 240, 0x0000);
     tft.fillRect(50, 285, 30, 30, 0x0000);
     tft.setTextSize(2);
     tft.setTextColor(0xffff);
     tft.setCursor(50, 285);
     tft.print(a / 40); tft.print("%");
     a++;
 }
 if (b < s) {
     j = 14 * (sin(PI * b / 2000));
     i = 14 * (cos(PI * b / 2000));
     j2 = 1 * (sin(PI * b / 2000));
     i2 = 1 * (cos(PI * b / 2000));
     tft.drawLine(i2 + 180, j2 + 240, i + 180, j + 240, White);
     j = 14 * (sin(PI * (b-300) / 2000));
     i = 14 * (cos(PI * (b-300) / 2000));
     j2 = 1 * (sin(PI * (b-300) / 2000));
     i2 = 1 * (cos(PI * (b-300) / 2000));
     tft.drawLine(i2 + 180, j2 + 240, i + 180, j + 240, 0x0000);
     tft.fillRect(168, 285, 30, 30, 0x0000);
     tft.setTextSize(2);
     tft.setTextColor(0xffff);
     tft.setCursor(168, 285);
     tft.print(b / 40); tft.print("%");
     b++;}
   if (c < s) {
     j = 14 * (sin(PI * c / 2000));
     i = 14 * (cos(PI * c / 2000));
     j2 = 1 * (sin(PI * c / 2000));
     i2 = 1 * (cos(PI * c / 2000));
     tft.drawLine(i2 + 297, j2 + 240, i + 297, j + 240, White);
     j = 14 * (sin(PI * (c-300) / 2000));
     i = 14 * (cos(PI * (c-300) / 2000));
     j2 = 1 * (sin(PI * (c-300) / 2000));
     i2 = 1 * (cos(PI * (c-300) / 2000));
     tft.drawLine(i2 + 297, j2 + 240, i + 297, j + 240, 0x0000);
     tft.fillRect(286, 285, 30, 30, 0x0000);
     tft.setTextSize(2);
     tft.setTextColor(0xffff);
     tft.setCursor(286, 285);
     tft.print(c / 40); tft.print("%");
     c++;}
   if (d < s) { j = 14 * (sin(PI * d / 2000)); i = 14 * (cos(PI * d / 2000)); j2 = 1 * (sin(PI * d / 2000)); i2 = 1 * (cos(PI * d / 2000)); tft.drawLine(i2 + 414, j2 + 240, i + 414, j + 240, White); j = 14 * (sin(PI * (d-300) / 2000)); i = 14 * (cos(PI * (d-300) / 2000)); j2 = 1 * (sin(PI * (d-300) / 2000)); i2 = 1 * (cos(PI * (d-300) / 2000)); tft.drawLine(i2 + 414, j2 + 240, i + 414, j + 240, 0x0000); tft.fillRect(402, 285, 30, 30, 0x0000); tft.setTextSize(2); tft.setTextColor(0xffff); tft.setCursor(402, 285); tft.print(d / 40); tft.print("%"); d++;} if (a > s) {
     j = 14 * (sin(PI * a / 2000));
     i = 14 * (cos(PI * a / 2000));
     j2 = 1 * (sin(PI * a / 2000));
     i2 = 1 * (cos(PI * a / 2000));
     tft.drawLine(i2 + 62, j2 + 240, i + 62, j + 240, White);
     j = 14 * (sin(PI * (a+300) / 2000));
     i = 14 * (cos(PI * (a+300) / 2000));
     j2 = 1 * (sin(PI * (a+300) / 2000));
     i2 = 1 * (cos(PI * (a+300) / 2000));
     tft.drawLine(i2 + 62, j2 + 240, i + 62, j + 240, 0x0000);
     tft.fillRect(50, 285, 30, 30, 0x0000);
     tft.setTextSize(2);
     tft.setTextColor(0xffff);
     tft.setCursor(50, 285);
     tft.print(a / 40); tft.print("%");
     a--;}
 if (b > s) {
     j = 14 * (sin(PI * b / 2000));
     i = 14 * (cos(PI * b / 2000));
     j2 = 1 * (sin(PI * b / 2000));
     i2 = 1 * (cos(PI * b / 2000));
     tft.drawLine(i2 + 180, j2 + 240, i + 180, j + 240, White);
     j = 14 * (sin(PI * (b+300) / 2000));
     i = 14 * (cos(PI * (b+300) / 2000));
     j2 = 1 * (sin(PI * (b+300) / 2000));
     i2 = 1 * (cos(PI * (b+300) / 2000));
     tft.drawLine(i2 + 180, j2 + 240, i + 180, j + 240, 0x0000);
     tft.fillRect(168, 285, 30, 30, 0x0000);
     tft.setTextSize(2);
     tft.setTextColor(0xffff);
     tft.setCursor(168, 285);
     tft.print(b / 40); tft.print("%");
     b--;}
   if (c > s) {
     j = 14 * (sin(PI * c / 2000));
     i = 14 * (cos(PI * c / 2000));
     j2 = 1 * (sin(PI * c / 2000));
     i2 = 1 * (cos(PI * c / 2000));
     tft.drawLine(i2 + 297, j2 + 240, i + 297, j + 240, White);
     j = 14 * (sin(PI * (c+300) / 2000));
     i = 14 * (cos(PI * (c+300) / 2000));
     j2 = 1 * (sin(PI * (c+300) / 2000));
     i2 = 1 * (cos(PI * (c+300) / 2000));
     tft.drawLine(i2 + 297, j2 + 240, i + 297, j + 240, 0x0000);
     tft.fillRect(286, 285, 30, 30, 0x0000);
     tft.setTextSize(2);
     tft.setTextColor(0xffff);
     tft.setCursor(286, 285);
     tft.print(c / 40); tft.print("%");
     c--;}
   if (d > s) {
     j = 14 * (sin(PI * d / 2000));
     i = 14 * (cos(PI * d / 2000));
     j2 = 1 * (sin(PI * d / 2000));
     i2 = 1 * (cos(PI * d / 2000));
     tft.drawLine(i2 + 414, j2 + 240, i + 414, j + 240, White);
     j = 14 * (sin(PI * (d+300) / 2000));
     i = 14 * (cos(PI * (d+300) / 2000));
     j2 = 1 * (sin(PI * (d+300) / 2000));
     i2 = 1 * (cos(PI * (d+300) / 2000));
     tft.drawLine(i2 + 414, j2 + 240, i + 414, j + 240, 0x0000);
     tft.fillRect(402, 285, 30, 30, 0x0000);
     tft.setTextSize(2);
     tft.setTextColor(0xffff);
     tft.setCursor(402, 285);
     tft.print(d / 40); tft.print("%");
     d--;}
   }  
}

Hi
using the </> tags show the error msgs.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

When I try to compile I get an error:

In function 'void loop()':
sketch_dec21b:23:28: error: 'test' was not declared in this scope
tft.drawRGBBitmap(0, 0, test, 480, 320);

So it seems that there is no bitmap byte array with the name of "test" for the function to display.

Displaying Monochrome Images

static const uint8_t name[] PROGMEM = 
{    //Add image code here.
}
tft.drawBitmap(x, y, name, sx, sy, 0x0000); 

First you should convert your image to hex code. Download the software from the following link. if you don’t want to change the settings of the software, you must invert the color of the image and make the image horizontally mirrored and rotate it 90 degrees counterclockwise. Now add it to the software and convert it. Open the exported file and copy the hex code to Arduino IDE. x and y are locations of the image. sx and sy are sizes of image. you can change the color of the image in the last input.

Hi, yes I know about the image sort of but this is the message I get

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"





















In file included from C:\Users\Tom Bauer\Documents\Arduino\libraries\Adafruit_GFX_Library-1.10.12\Adafruit_GrayOLED.cpp:20:0:

C:\Users\Tom Bauer\Documents\Arduino\libraries\Adafruit_GFX_Library-1.10.12\Adafruit_GrayOLED.h:30:10: fatal error: Adafruit_I2CDevice.h: No such file or directory

 #include <Adafruit_I2CDevice.h>

          ^~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

exit status 1

Error compiling for board Arduino Uno.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

You , obviously need to install the "Adafruit I2C " library :relaxed:

not so obviously since If using an earlier version of the Arduino IDE (pre-1.8.10), locate and install Adafruit_BusIO (newer versions handle this prerequisite automatically). I am using 1.8.13
so I am confused by this.

Hi,

C:\Users\Tom Bauer\Documents\Arduino\libraries\Adafruit_GFX_Library-1.10.12\Adafruit_GrayOLED.h:30:10: fatal error: Adafruit_I2CDevice.h: No such file or directory

I don't think it matters what version you have, you still have to load the library to the IDE.
Its not automatic.

Got to library manager and search for Adafruit_BusIO and load or update it.

I just did, compiled and now it doesn't like, "test".

 tft.drawRGBBitmap(0, 0, test, 480, 320);
Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"

C:\Arduino Projects\sketch_dec23a\sketch_dec23a.ino: In function 'void loop()':

sketch_dec23a:23:26: error: 'test' was not declared in this scope

  tft.drawRGBBitmap(0, 0, test, 480, 320);

                          ^~~~

C:\Arduino Projects\sketch_dec23a\sketch_dec23a.ino:23:26: note: suggested alternative: 'tft'

  tft.drawRGBBitmap(0, 0, test, 480, 320);

                          ^~~~

                          tft

exit status 1

'test' was not declared in this scope

Tom... :grinning: :+1: :coffee: :australia:

Yes, I get the same now and know what to do from here, a least for a while!
Thanks all

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.