Hi,
The code I am testing shown error: 'GREEN' was not declared in this scope.
My question is the 'WHITE' was not declared either, why that can pass compile.
The 'GREEN' section between two line of Asterisks is new added .
Thanks
Adam
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SSD1306_LCDHEIGHT 64 //// https://forum.arduino.cc/t/ssd1306-says-height-incorrect/351277
//// #error ("Height incorrect, please fix Adafruit_SSD1306.h!");
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
const unsigned char audi_logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0xff, 0xe0, 0x07, 0xff, 0xc0, 0x0f, 0xff, 0xc0, 0x1f, 0xff, 0x80, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0xfc, 0x7f, 0xff, 0xf8, 0x7f, 0xff, 0xf0, 0xff, 0xff, 0xe0, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xf8, 0x00, 0x00,
0x00, 0x01, 0xfe, 0x00, 0x7f, 0xfc, 0x00, 0xff, 0xfc, 0x01, 0xff, 0xf8, 0x01, 0xfe, 0x00, 0x00,
0x00, 0x03, 0xf0, 0x00, 0x1f, 0xf0, 0x00, 0x1f, 0xe0, 0x00, 0x3f, 0xe0, 0x00, 0x7f, 0x00, 0x00,
0x00, 0x07, 0xe0, 0x00, 0x0f, 0xe0, 0x00, 0x1f, 0xc0, 0x00, 0x1f, 0xc0, 0x00, 0x1f, 0x80, 0x00,
0x00, 0x0f, 0xc0, 0x00, 0x1f, 0xf0, 0x00, 0x1f, 0xe0, 0x00, 0x3f, 0xe0, 0x00, 0x0f, 0xc0, 0x00,
0x00, 0x1f, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x3f, 0xf0, 0x00, 0x7f, 0xe0, 0x00, 0x03, 0xe0, 0x00,
0x00, 0x3e, 0x00, 0x00, 0x3e, 0x78, 0x00, 0x7c, 0xf8, 0x00, 0xf9, 0xf0, 0x00, 0x03, 0xe0, 0x00,
0x00, 0x3e, 0x00, 0x00, 0x7c, 0x7c, 0x00, 0x78, 0xf8, 0x00, 0xf8, 0xf0, 0x00, 0x01, 0xf0, 0x00,
0x00, 0x3c, 0x00, 0x00, 0x78, 0x3c, 0x00, 0xf8, 0x78, 0x00, 0xf0, 0xf8, 0x00, 0x00, 0xf0, 0x00,
0x00, 0x7c, 0x00, 0x00, 0x78, 0x3c, 0x00, 0xf0, 0x7c, 0x01, 0xf0, 0x78, 0x00, 0x00, 0xf0, 0x00,
0x00, 0x7c, 0x00, 0x00, 0x78, 0x3e, 0x00, 0xf0, 0x7c, 0x01, 0xe0, 0x78, 0x00, 0x00, 0xf0, 0x00,
0x00, 0x78, 0x00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0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0xfc, 0x7f, 0xff, 0xf8, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xf0, 0x00, 0x00,
0x00, 0x00, 0x0f, 0xff, 0xf0, 0x1f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x00, 0x01, 0xfe, 0x00, 0x01, 0xfc, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x3f, 0x01, 0xf8, 0x3f, 0xff, 0x83, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xf7, 0xe0, 0x3f, 0x01, 0xf8, 0x7f, 0xff, 0xe3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x07, 0xe3, 0xf0, 0x3f, 0x01, 0xf9, 0xfe, 0x1f, 0xe3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0f, 0xc3, 0xf8, 0x3f, 0x01, 0xfb, 0xf8, 0x07, 0xf3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0x81, 0xfc, 0x3f, 0x01, 0xfb, 0xf0, 0x03, 0xf3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1f, 0x80, 0xfe, 0x3f, 0x01, 0xfb, 0xf0, 0x01, 0xf3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x7f, 0xff, 0xfe, 0x3f, 0x01, 0xfb, 0xf0, 0x03, 0xf3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3f, 0x83, 0xf1, 0xf8, 0x07, 0xf3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x9f, 0xcf, 0xf1, 0xff, 0x3f, 0xe3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xf8, 0x00, 0x1f, 0xcf, 0xff, 0xe0, 0x7f, 0xff, 0xc3, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xf8, 0x00, 0x0f, 0xe7, 0xff, 0xc0, 0x3f, 0xff, 0x03, 0xf0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
int sensorValue = 0;
int voltage = 0;
const int analogInPin = A0;
//display.invertDisplay(true); // invert the colours of led display
//display.invertDisplay(false);
//display.drawPixel(10, 10, WHITE);//to highlight a particular pixel
void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize I2C addr to 0x3C ( for 128x64 Display )
display.clearDisplay(); // clear the display before starting the program to avoid adafruit splashscreen ( *we can also skip it by modifing header file )
// drawBitmap(x-axis position, y-axis position, bitmap data, bitmap width, bitmap height, color)
}
void loop()
{
display.clearDisplay();
display.drawBitmap(0, 0, audi_logo, 128, 64, WHITE);
display.display();
delay(1000);
//****************************************************************
display.clearDisplay();
display.drawBitmap(0, 0, audi_logo, 128, 64, GREEN);
display.display();
delay(1000);
//******************************************************************
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("VIRAL");
display.setCursor(1, 20);
display.println("SCIENCE");
display.display();
delay(1000);
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(GREEN);
display.setCursor(1, 0);
display.println("SUBSCRIBE");
display.display();
delay(1000);
}
error:
Arduino: 1.8.13 (Windows 7), Board: "ESP32 Dev Module, Enabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
E:\ENGINEERING\DIY\ESP32 CAM\PROJECTS\004_Arduino OLED Bitmap Graphics Display\Arduino_OLED_Bitmap_M2\Arduino_OLED_Bitmap_M2.ino: In function 'void loop()':
Arduino_OLED_Bitmap_M2:124:48: error: 'GREEN' was not declared in this scope
display.drawBitmap(0, 0, audi_logo, 128, 64, GREEN);
^
exit status 1
'GREEN' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.