OLED IIc 12864 arduino cannot get it to work

Hi,

Staring blind to my pc trying to implement the oled display using u8g library.
tried many thing but doing something wrong and cannot find out what.
Blank at the moment don;t know what to do anymore.
Hope someone can help me out.

I like to display a string ' AGL' and the value 'AGL+counter" on my oled screen.

Help would appreciated, thanks

here is my code:

// ******************************************** OLED Display ********************************************

#include "U8glib.h"
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK);                     // Display which does not send ACK

// ********************************************** BME280 ************************************************

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define Sealevel_HPA (1013.25)                                    // Set sealevel 

Adafruit_BME280 bme; // I2C
unsigned long delayTime;

// ******************************************* FLAPS Sensor ********************************************

int AGL = 0;                                                      // Set initial heigth
int sensorPin = A0;                                               // select the input pin for the flaps potentiometer
int sensorValue = 0;                                              // variable to store the value coming from the sensor
int tol = 15;                                                     // set tolerance flaps slider

// ****************************************** Rotary Encoder *******************************************

#define inputCLK 8                                                // Set input pin CLK
#define inputDT 9                                                 // Set input pin DT
int pinwaarde = 0;
int var = 0; //tijdelijk
int mode = 0;
int counter = 0;                                                  // Initial encoder count
float currentStateCLK;                                            // Initial CLK state
float previousStateCLK;                                           // Previous CLK state
String encdir = "";

// ****************************************** General Setup ********************************************




void setup() {

  // Rotary encoder setup
  pinMode (inputCLK, INPUT);                                      // Set encoder pins as inputs
  pinMode (inputDT, INPUT);
  int gearPin = 5;
  int buzzerPin = 6;
  pinMode (7, INPUT);                                             // Set input pin encoder switch
  pinMode (buzzerPin, OUTPUT);                                    // Buzzer pin
  pinMode (gearPin, INPUT);                                       // Gear down switch



  Serial.begin(9600);                                             // start serial port
  unsigned status;
  status = bme.begin();
}


void loop() {
  mode = 0;


  // read the value from the flaps-sensor:
  //sensorValue = analogRead(sensorPin);  // read serial value

  if      (sensorValue > 100 - tol && sensorValue < 150 + tol)  {
    Serial.println("flaps 1  ");
  }
  else if (sensorValue > 200 - tol && sensorValue < 250 + tol)  {
    Serial.println("flaps 2  ");
  }
  else if (sensorValue > 300 - tol && sensorValue < 350 + tol)  {
    Serial.println("flaps 3  ");
  }
  else if (sensorValue > 400 - tol && sensorValue < 450 + tol)  {
    Serial.println("flaps 4  ");
  }
  else if (sensorValue > 500 - tol && sensorValue < 550 + tol)  {
    Serial.println("flaps L1 ");
  }
  else if (sensorValue > 600 - tol && sensorValue < 650 + tol)  {
    Serial.println("flaps L2 ");
  }
  else Serial.print("----  ");



  pinwaarde = digitalRead(7);
  if (pinwaarde == LOW) {
    subroutine();
  };

  // Print QNH
  Serial.print("QNH = ");
  Serial.print(int(bme.readPressure() / 100.0F));
  Serial.print(" hPa ");

  // Print AGL
  AGL = (bme.readAltitude(Sealevel_HPA));
  Serial.print("AGL = ");
  Serial.print (AGL + counter);
  Serial.println(" m");

  if  (AGL + counter < 150) {                                     // Set Landing gear warning altitude and determine of gear is down
    digitalWrite(6, HIGH);
  }
  
  else if (AGL + counter >= 150) {
    digitalWrite(6, LOW);
  }


  delay(1000);                                                    // wait for xxx ms
}

void subroutine() {                                               // Set AGL & QNH
  var = 0;
  while (var < 1) {

    pinwaarde = digitalRead(7);                                   // Read pinvalue ecncoder switch
    if (pinwaarde == LOW)
    {
      mode++;
      delay(1000);
      if (mode == 3)                                              // Long press value encoder switch for break out of loop
        break;                                                    // Return to main
    }

    currentStateCLK = digitalRead(inputCLK); inputCLK;            // Read the current state of inputCLK
    if (currentStateCLK != previousStateCLK) {
      if (digitalRead(inputDT) != currentStateCLK) {
        counter --;
        encdir = "CCW";
      } else {
        // Encoder is rotating clockwise
        counter ++;
        encdir = "CW";
      }


      AGL = (bme.readAltitude(Sealevel_HPA));
      Serial.print("AGL = ");
      Serial.print (AGL + counter);                               // Print AGL modified
      Serial.println(" m");

      previousStateCLK = currentStateCLK;                         // Update previousStateCLK with the current state

    }
  }
}

I have the same problem and have asked a similar question in another thread.

If you have a very simple application, then I have had success with this derivative of the Adafruit library.

Problem is that it uses a lot of memory which means if you have a larger project, you will run into stability issues. It will prove your display is working ok though.

S.

It's not a adafruit display it's a IIc ..

Won't run on adafruit librarries, at least I tried and wont work

Unless you know the trick

thanks

Post a link to the actual display that you have bought. e.g. Ebay sale

Or post photos of pcb. (also front view if there are printed names for the terminals)

Duplicate thread! Also in the section "International/Dutch" :o

Is that a problem? Maybe my English friends now the solution.

david_prentice:
Post a link to the actual display that you have bought. e.g. Ebay sale

Or post photos of pcb. (also front view if there are printed names for the terminals)

This one:

Got it going now, forgot a } and a loop to much