Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - daryllwin

Pages: [1]
1
OLEDs / Having trouble with the NHD-0420DZW-AB5
« on: October 01, 2014, 10:41:54 PM »
Hi All

I'm having quite a bit of trouble with the display mentioned in the title and getting it to work with an Arduino UNO.

I've connected the display in serial mode, and my code is as shown below. I've also redid the jumpers behind as described in the datasheet.

Code: [Select]
/*
 Circuit:
 CS: pin 10
 MOSI: pin 11
 MISO: pin 12
 SCK: pin 13
 */

// the sensor communicates using SPI, so include the library:
#include <SPI.h>

const byte COMMAND = 0b11111100;     // read command
const byte DATA = 0b00000010;   // write command
const byte ON = 0b0000001111;  //turn display on

const int chipSelectPin = 10;

void setup() {
  Serial.begin(9600);
  SPI.begin();
  pinMode(chipSelectPin, OUTPUT);
  delay(100);
  digitalWrite(chipSelectPin, LOW);
  delay(100);
  SPI.transfer(0b0000111000);
  delay(100);
  SPI.transfer(0b0000001000);
  delay(100);
  SPI.transfer(0b0000000001);
  delay(100);
  SPI.transfer(0b0000000110);
  delay(100);
  SPI.transfer(0b0000000010);
  delay(100);
  SPI.transfer(0b0000001111);
  digitalWrite(chipSelectPin, HIGH);
  delay(100);
}

void loop() {
  digitalWrite(chipSelectPin, LOW);
  delay(100);
  SPI.transfer(0b1000011111);
  delay(1000);
  digitalWrite(chipSelectPin, HIGH);
}

Most of the time, the display shows gibberish. There are occasions (1 out of 5 roughly) where the display initializes properly, and a blinking cursor is shown at the first character.

However, even when it initializes correctly, the cursor never moves, which I'm guessing means that the display isn't receiving any data from the Arduino.

This kind of baffles me because it must have received the initialization commands for it to show the blinking cursor right?

Pages: [1]