How to connect pins of oLed 2x16 newHaven


#1

I have a NHD-0216K1Z-FSB-FBW-L Character Liquid Crystal Display Module.

OLed page

I am trying to connect it using this pinout table:
With table 4.Interface Pin Function I tried connecting it as is…relying on the digital pins on the duo diagram:

Connecting digital pins as numbered respectively, according to this code:

 Demonstrates the use a 2x16 OLED display.
 The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. 
 
 This sketch prints to the OLED and shows the time since last reset
 
  The circuit:
 * OLED RS pin to digital pin 12
 * OLED Enable pin to digital pin 11
 * OLED D4 pin to digital pin 5
 * OLED D5 pin to digital pin 4
 * OLED D6 pin to digital pin 3
 * OLED D7 pin to digital pin 2
 * OLED R/W pin to ground

Or with this other version - which I haven’t tried yet…

Does anyone have an idea how to go about it??
What are the equivalent pins to the pins required in the code? or any other way…
Thanx


#2

Hi @jadeye, The pins you used to connect to the display module have no problem. Just make sure that you have followed the instructions of the display module to make it work.


#3

@guohui, thank you for your reply.

Here is the full code:

/*
 Demonstrates the use a 2x16 OLED display.
 The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. 
 
 This sketch prints to the OLED and shows the time since last reset
 
  The circuit:
 * OLED RS pin to digital pin 12
 * OLED Enable pin to digital pin 11
 * OLED D4 pin to digital pin 5
 * OLED D5 pin to digital pin 4
 * OLED D6 pin to digital pin 3
 * OLED D7 pin to digital pin 2
 * OLED R/W pin to ground

 */

// include the library code:
#include <LiquidCrystal.h>
#include <Time.h>  
#include <Wire.h>  

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  setTime(15,36,30,14,5,2013);
  lcd.begin(16, 2);
  delay(100);               // wait for 1/10 second
}

void printDigits(int digits){
  // utility function for digital clock display: prints preceding colon and leading 0
  lcd.print(":");
  if(digits < 10)
    lcd.print('0');
  lcd.print(digits);
}

void printDay(){
  int day;
  day = weekday();
  if(day == 1){lcd.print("Sun, ");}
  if(day == 2){lcd.print("Mon, ");}
  if(day == 3){lcd.print("Tue, ");}
  if(day == 4){lcd.print("Wed, ");}
  if(day == 5){lcd.print("Thu, ");}
  if(day == 6){lcd.print("Fri, ");}
  if(day == 7){lcd.print("Sat, ");}
}

void printMonth(){
  int mon;
  mon = month();
  if(mon == 1){lcd.print("Jan ");}
  if(mon == 2){lcd.print("Feb ");}
  if(mon == 3){lcd.print("Mar ");}
  if(mon == 4){lcd.print("Apr ");}
  if(mon == 5){lcd.print("May ");}
  if(mon == 6){lcd.print("Jun ");}
  if(mon == 7){lcd.print("Jul ");}
  if(mon == 8){lcd.print("Aug ");}
  if(mon == 9){lcd.print("Sep ");}
  if(mon == 10){lcd.print("Oct ");}
  if(mon == 11){lcd.print("Nov ");}
  if(mon == 12){lcd.print("Dec ");}
}

void digitalClockDisplay(){
  // digital clock display of the time
  lcd.setCursor(2, 0);
  delay(10);               // wait for 1/10 second
  lcd.print(hourFormat12());
  printDigits(minute());
  printDigits(second());
  lcd.print(" ");
  if(isAM()){lcd.print("am");}
  else{lcd.print("pm");}
  
  lcd.setCursor(0, 1);
  printDay();
  printMonth();
  lcd.print(day());
  lcd.print(" ");
  lcd.print(year()); 
}

void loop() {
  digitalClockDisplay();  
  delay(1000);
}

I am using an exterior 5V for the OLed display,
But nothing is working…

A tutorial showing what I am trying to achieve with an arduino board can be found here


#4

Have you connected the GND of Duo with the GND of the exterior power source?


#5

Yes…the oLed lights up lightly but nothing is displaying…the exterior power source does nothing…the Potentiometer - 10k (Ohm, Linear) changes nothing when you change it…
I moved the (all) data wires down one notch figuring maybe pin 2 is actually D1. Also tried the following settings:
LiquidCrystal lcd(D12, D11, D5, D4, D3, D2);
OR
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

Checked potentiometer fo resistance and its ok…tried shortening the middle leg with voltage…nothing… :disappointed: :frowning2:


#6

I just saw a couple of youtubes on the issue and I need to ask if you know:
My external power supply is:

Input: 110-240V - 50/60Hz 0.1A
Output: 5V (DC) 1000mA

The specs for this oLed say supply voltage is: min 4.7v to max 5.5v
And for backlight current it says: min 10mA to max 18mA
datasheet
Could it be burnt??


#7

LiquidCrystal library works with redbear duo? what IDE are you using?


#8

@jadeye Try wrapping the LCD operation functions with SINGLE_THREADED_BLOCK().


#9

arduino 1.6.8, looks like it does/ might…


#10

@guohui nothing…

Here’s my code:

#include <LiquidCrystal.h>
#include <Time.h>  
#include <Wire.h>  

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  setTime(15,36,30,14,5,2013);
  lcd.begin(16, 2);
  delay(100);               // wait for 1/10 second
}

void printDigits(int digits){
  SINGLE_THREADED_BLOCK() {
    // utility function for digital clock display: prints preceding colon and leading 0
    lcd.print(":");
    if(digits < 10)
      lcd.print('0');
    lcd.print(digits);
  }
}

void printDay(){
  SINGLE_THREADED_BLOCK() {
    int day;
    day = weekday();
    if(day == 1){lcd.print("Sun, ");}
    if(day == 2){lcd.print("Mon, ");}
    if(day == 3){lcd.print("Tue, ");}
    if(day == 4){lcd.print("Wed, ");}
    if(day == 5){lcd.print("Thu, ");}
    if(day == 6){lcd.print("Fri, ");}
    if(day == 7){lcd.print("Sat, ");}
  }
}

void printMonth(){
  SINGLE_THREADED_BLOCK() {
    int mon;
    mon = month();
    if(mon == 1){lcd.print("Jan ");}
    if(mon == 2){lcd.print("Feb ");}
    if(mon == 3){lcd.print("Mar ");}
    if(mon == 4){lcd.print("Apr ");}
    if(mon == 5){lcd.print("May ");}
    if(mon == 6){lcd.print("Jun ");}
    if(mon == 7){lcd.print("Jul ");}
    if(mon == 8){lcd.print("Aug ");}
    if(mon == 9){lcd.print("Sep ");}
    if(mon == 10){lcd.print("Oct ");}
    if(mon == 11){lcd.print("Nov ");}
    if(mon == 12){lcd.print("Dec ");}
  }
}

void digitalClockDisplay(){
  SINGLE_THREADED_BLOCK() {
    // digital clock display of the time
    lcd.setCursor(2, 0);
    delay(10);               // wait for 1/10 second
    lcd.print(hourFormat12());
    printDigits(minute());
    printDigits(second());
    lcd.print(" ");
    if(isAM()){lcd.print("am");}
    else{lcd.print("pm");}
    
    lcd.setCursor(0, 1);
    printDay();
    printMonth();
    lcd.print(day());
    lcd.print(" ");
    lcd.print(year()); 
  }
}

void loop() {
  digitalClockDisplay();  
  delay(1000);
}
  • the Lcd does not change when I connect the 5V nor does it change when I play with the potentiometer…

#11

Also wrap the functions in setup(). Anyway, I have no LCD in hand and it’s hard to produce your issue. You would probably check the LCD methods if they are compatible with Duo APIs.


#12

hii @jadeye,

I would suggest you to use i2c Serial interface board for the display with external 5v power supply … may be you may not be getting sufficient current through the pins…


#13

Hi,
SINGLE_THREADED_BLOCK() is undefined on my arduino 1.8.3
Need to add somthing ?


#14

It should have been included in this header file: https://github.com/redbear/STM32-Arduino/blob/master/arduino/cores/RedBear_Duo/firmware/wiring/inc/spark_wiring_thread.h

Just make sure you have installed the latest board package correctly. ^^

Cheers!