Go Down

Topic: Showing images on an Oled.... but am I doing wrong? (Read 493 times) previous topic - next topic

dranosh

Hi guys, jsut a quick question because I can find out how to...


I am trying to includein the loop the image that this code uses at initialize... any ideas why it doesn'twork?

It should loop betwenn showing the image and a dot,right?


Code: [Select]
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2



#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{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, 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,
0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x07, 0xFF, 0xFF, 0xFE, 0x00, 0x0F, 0xFF, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xC0, 0x0F, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xE0, 0x1F, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x3F, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x01, 0xFE, 0x00, 0x00, 0x07, 0xF8, 0x3F, 0x1F, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x7F, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x7E, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0xFC, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07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00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
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, 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
};

#define SSD1306_LCDHEIGHT 64

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

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

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(2000);

  // Clear the buffer.
  display.clearDisplay();

  // draw a single pixel
  display.drawPixel(100, 10, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();
  delay(2000);
  display.clearDisplay();

  display.drawPixel(10, 10, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();
  delay(2000);
  display.clearDisplay();

  


}


void loop() {

   // draw a single pixel
  display.drawPixel(100, 10, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();
  delay(2000);
  display.clearDisplay();

  display.drawBitmap(30,16, logo16_glcd_bmp, 16,16,1);
  display.display();
   delay(2000);
  display.clearDisplay();

  display.drawPixel(10, 10, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();
  delay(2000);
  display.clearDisplay();
  
}

artisticforge

#1
Dec 03, 2017, 01:04 pm Last Edit: Dec 03, 2017, 01:51 pm by artisticforge Reason: adding further questions
Hi guys, jsut a quick question because I can find out how to...


I am trying to includein the loop the image that this code uses at initialize... any ideas why it doesn'twork?

It should loop betwenn showing the image and a dot,right?



What is it doing?

Which operating system are you using? Linux, MacOSX or Windows?
Which version of the Arduino IDE are you using?
Which Arduino board are you using?
Which OLED display are you using?
How are you powering the display?

Can you post a photograph of the circuit so that we may see what you have wired up?


dranosh


I am using Windows 7
I am using the latest Arduino version, recently downloaded, and an Arduino Uno
The OLED is from Ebay (similar to this one:https://www.ebay.com/p/0-96-I2c-IIC-Serial-128x64-128-64-Blue-OLED-LCD-LED-Display-Module-Communicate/18008063887?iid=272893039041)
Powering using USB from computer.

The circuit is just the wiring from the arduino to the display.

It works good, I mean, when using the demo from Adafruit, it shows perfectly everything. My problem is at the time I try to make my own code.

Code: [Select]
/*********************************************************************

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

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2



#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH  16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{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, 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,
0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x07, 0xFF, 0xFF, 0xFE, 0x00, 0x0F, 0xFF, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0x3F, 0xFF, 0xFF, 0xFF, 0xC0, 0x0F, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xE0, 0x1F, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x3F, 0xFF, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x01, 0xFE, 0x00, 0x00, 0x07, 0xF8, 0x3F, 0x1F, 0x07, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x7F, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x7E, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0xFC, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x07, 0xE0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x07, 0xE0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x07, 0xE0, 0x20,
0x01, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x1F, 0x07, 0xC0, 0x00, 0x00, 0x07, 0xE0, 0x20,
0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x20,
0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x20,
0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x1F, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x20,
0x01, 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x1F, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x20,
0x01, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x1F, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0x07, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x1F, 0x00, 0x7F, 0xFF, 0xFF, 0xFE, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
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, 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
};

#define SSD1306_LCDHEIGHT 64

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

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

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  // init done
 
  // Show image buffer on the display hardware.

  display.display();
  delay(2000);

  // Clear the buffer.
  display.clearDisplay();

  // draw a single pixel
  display.drawPixel(100, 10, WHITE);

  display.display();
  delay(2000);
  display.clearDisplay();

  display.drawPixel(10, 10, WHITE);

  delay(2000);
  display.clearDisplay();

 


}


void loop() {

   // draw a single pixel
  display.drawPixel(100, 10, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  display.drawBitmap(30,16, logo16_glcd_bmp, 16,16,1);
  display.display();
   delay(2000);
  display.clearDisplay();

  display.drawPixel(10, 10, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();
 
}



Here it shows the image at the init, but not at the loop :(

wzaggle

  display.drawBitmap(0,0, logo16_glcd_bmp, 128,64,WHITE);


artisticforge

I am using Windows 7
I am using the latest Arduino version, recently downloaded, and an Arduino Uno
The OLED is from Ebay (similar to this one:https://www.ebay.com/p/0-96-I2c-IIC-Serial-128x64-128-64-Blue-OLED-LCD-LED-Display-Module-Communicate/18008063887?iid=272893039041)
Powering using USB from computer.

The circuit is just the wiring from the arduino to the display.

It works good, I mean, when using the demo from Adafruit, it shows perfectly everything. My problem is at the time I try to make my own code.


Here it shows the image at the init, but not at the loop :(
two comments:
buying electronic devices off ebay is strictly a gamble. you have no idea what you are buying.
these displays can draw more amperes than you think they can. These displays should not be powered from
the USB connection. They really need their own power supply.

The other person, answered your question.

david_prentice

I had not spotted the message from wzaggle.   I tried the code for myself on an SPI OLED.
And came to the same conclusion.  i.e. your logo bitmap was far too big for a 16x16.

Regarding comments about power supply etc.
OLEDs take very little current.   Your Laptop USB will be fine.   An unpowered Hub will be fine.

Things like electric motors,  backlights on 7 inch TFT screens  take a lot of current.
You can buy a little gizmo from Ebay to read the USB current.   Put in your USB socket.

Yes,  there are 16x2 LCDs that appear on Ebay without series resistors for the backlight.
The backlight looks too bright.   Your gizmo will tell you how much current.

David.

dranosh

display.drawBitmap(0,0, logo16_glcd_bmp, 128,64,WHITE);


Thats it, now it is working.
Still I have some problems with the size but works...

dranosh

Ok so now I have a new problem.

I want to include a button to change from an image to a dot. This is my code

Code: [Select]

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

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

//#define NUMFLAKES 10
//#define XPOS 0
//#define YPOS 1
//#define DELTAY 2



//#define LOGO16_GLCD_HEIGHT 32
//#define LOGO16_GLCD_WIDTH  32
static const unsigned char PROGMEM logo16_glcd_bmp[] = {
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, 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,
0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00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 0xFF, 0xFF, 0xFF, 0xE0, 0x00, 0x1F, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x20,
0x01, 0x00, 0x1F, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x1F, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x20,
0x01, 0x00, 0x07, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x1F, 0x00, 0x7F, 0xFF, 0xFF, 0xFE, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
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, 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
};


#define SSD1306_LCDHEIGHT 64

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif


const int LED =13;
const int BOTON = 2;
int val = 0; //val se emplea para almacenar el estado del boton
int state = 0; // 0 LED apagado, mientras que 1 encendido
int old_val = 0; // almacena el antiguo valor de val

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

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(2000);

  // Clear the buffer.
  display.clearDisplay();

pinMode(LED,OUTPUT); // establecer que el pin digital es una señal de salida
 pinMode(BOTON,INPUT); // y BOTON como señal de entrada

}


void loop() {


  val= digitalRead(BOTON); // lee el estado del Boton
if ((val == HIGH) && (old_val == LOW)){
state=1-state;
delay(10);
}
old_val = val; // valor del antiguo estado
if (state==1){
 digitalWrite(LED, HIGH); // enciende el LED
 // draw a single pixel
 display.clearDisplay();
 display.drawPixel(0,0, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
 display.display();
  //delay(2000);
  
}
else{
 digitalWrite(LED,LOW); // apagar el LED
display.clearDisplay();
   display.drawBitmap(0,-15, logo16_glcd_bmp, 128,64,WHITE);
  display.display();
   //delay(2000);
  
}

    
}


Sorry about the spanish words in the code.

The point is that is not working, the button itself is working, as I have included a Led to turn it on or off and the led is working nicely.

Is there anything that I am missing?

MAS3

Quote from: dranosh
The point is that is not working, ...
¿ What does that mean ?
Your display isn't cleared ?
The pixel isn't displayed (and are you sure of that) ?
What if you put the pixel on an other position, like
Code: [Select]
display.drawPixel(5,5, WHITE); (there's a  reason for asking this) ?
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Go Up