'BLUE' was not declared in this scope

Hi,
This is a OLED example code compiling well and runs good before I changed a line: oled.setTextColor(BLUE); instead of oled.setTextColor(WHITE); why?
what color definded in SSD1306?
does it has a background color setting?
Thanks
Adam

/*
 * Created by ArduinoGetStarted.com
 *
 * This example code is in the public domain
 *
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-oled
 */

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width,  in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// declare an SSD1306 display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(9600);

  // initialize OLED display with address 0x3C for 128x64
  if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    while (true);
  }

  delay(2000);         // wait for initializing
  oled.clearDisplay(); // clear display

  oled.setTextSize(1);          // text size
 // oled.setTextColor(WHITE);     // text color
  oled.setTextColor(BLUE);     // text color
  oled.setCursor(0, 10);        // position to display
  oled.println("Hello World!"); // text to display
  oled.display();               // show on OLED
}

void loop() {
}

ERROR:

Arduino: 1.8.3 (Windows 7), Board: "Arduino Nano, ATmega328"

C:\Users\HUA.DELLV-PC\Documents\Arduino\sketch_jul30d\sketch_jul30d.ino: In function 'void setup()':

sketch_jul30d:33: error: 'BLUE' was not declared in this scope

   oled.setTextColor(BLUE);     // text color

                     ^

exit status 1
'BLUE' was not declared in this scope

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

You've got the source; why not look?

1 Like

Thanks.
I checked the 'Adafruit_SSD1306_H_', seems it only defined 'WHITE' & 'BLACK'?
why?

Can I add other colors there?

My OLED did shown yellow and blue without any definition some times.

Because it's a monochrome device?

1 Like

My device? can show 'white'/blue/yellow some time.

And is yellow just white, with a yellow filter?

1 Like

You probably have an oled with a yellow band at the top or a blue one . They are not colour , just two colours - as far as your software is concerned one is “ black” the other “ white”

If you have true colour display , look for the driver chip and google it for a different library

1 Like

Thanks.

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