- Mon Nov 03, 2008 10:48 am
#58289
Hey guys,
A year or two ago when the OLED module came out I started playing around with it. I managed to get it to work via SPI on a PIC18F4550. Since then I was busy and didn't have much time to play with it. Recently I found some spare time so I've decided to get it connected to my Arduino.
I managed to get SPI to work on the Arduino, but I'm having trouble getting Parallel to work. I based my code mostly off of the OLED_example.c that sparkfun provides, however I've had no luck.
I triple checked my pins and everything is correct. My SPI code works perfectly fine, but when I try doing parallel the screen just stays black. I tried both 6800 and 8800 parallel by changing the BS1 and BS2 jumpers around (6800 is BS1 ground, BS2 to vcc and 8800 is both to vcc). I try my code with both as I don't know which SparkFun used for their example.
I am powering the OLED by an external 3v battery (2x AA, as the arduino's 3.3v outputs 4.0v for me which is out of the OLED spec).
Do I need to do anything with the "EN" pin? I have the original v01 board but the schematic on the SF website is v22 so I don't know whats what.
Below is the Arduino code. Ignore the colors as I use them to determine which wire is where. I originally used D0-7 and manually set them, but I moved everything over to Arduino's 0-7 pins which is connected to PORTD. I'm setting PORTD directly now instead of manually setting all the bits. I'll change to to a for loop + array after I get it working. Sorry for the messy code. I'll clean it up and make it pretty after it works.
-robodude666
A year or two ago when the OLED module came out I started playing around with it. I managed to get it to work via SPI on a PIC18F4550. Since then I was busy and didn't have much time to play with it. Recently I found some spare time so I've decided to get it connected to my Arduino.
I managed to get SPI to work on the Arduino, but I'm having trouble getting Parallel to work. I based my code mostly off of the OLED_example.c that sparkfun provides, however I've had no luck.
I triple checked my pins and everything is correct. My SPI code works perfectly fine, but when I try doing parallel the screen just stays black. I tried both 6800 and 8800 parallel by changing the BS1 and BS2 jumpers around (6800 is BS1 ground, BS2 to vcc and 8800 is both to vcc). I try my code with both as I don't know which SparkFun used for their example.
I am powering the OLED by an external 3v battery (2x AA, as the arduino's 3.3v outputs 4.0v for me which is out of the OLED spec).
Do I need to do anything with the "EN" pin? I have the original v01 board but the schematic on the SF website is v22 so I don't know whats what.
Below is the Arduino code. Ignore the colors as I use them to determine which wire is where. I originally used D0-7 and manually set them, but I moved everything over to Arduino's 0-7 pins which is connected to PORTD. I'm setting PORTD directly now instead of manually setting all the bits. I'll change to to a for loop + array after I get it working. Sorry for the messy code. I'll clean it up and make it pretty after it works.
Code: Select all
Any help would be appreciated, thanks!// zomg pins
int RES = 8; //blue
int RW = 1; //green ANALOG
int RD = 9; //yellow
int CS = 0; //blue ANALOG
int DC = 10;//red
// Data pin defines
// NOTE: replace with array later
int D0 = 0; // blue
int D1 = 1; // green
int D2 = 2; // yellow
int D3 = 3; // red
int D4 = 4; // blue
int D5 = 5; // green
int D6 = 6; // yellow
int D7 = 7; // red
/* Sparkfun based code */
//init
void sparkFun_init();
//reset
void Reset_SSD1339();
// write command or data
void write_c(byte out_command);
void write_d(byte out_data);
//Based on SparkFun functions for testing purposes
void write_c(byte out_command)
{
digitalWrite(DC, LOW);
analogWrite(CS, LOW);
analogWrite(RW, LOW);
PORTD = out_command;
delayMicroseconds(120);
analogWrite(RW, HIGH);
analogWrite(CS, HIGH);
digitalWrite(DC, HIGH);
}
void write_d(byte out_data)
{
digitalWrite(DC, HIGH);
analogWrite(CS, LOW);
analogWrite(RW, LOW);
PORTD = out_data;
delayMicroseconds(120);
analogWrite(RW, HIGH);
analogWrite(CS, HIGH);
digitalWrite(DC, HIGH);
}
void Reset_SSD1339()
{
digitalWrite(RES, LOW);
delay(100);
digitalWrite(RES, HIGH);
}
void sparkFun_init(){
digitalWrite(RD, HIGH);
digitalWrite(DC, LOW);
analogWrite(RW, LOW);
analogWrite(CS, LOW);
Reset_SSD1339();
write_c(0xa0); // Set Re-map / Color Depth
write_d(0x34);//0xb4); // 262K 8bit R->G->B <-- 0b0011.0100
write_c(0xa1); // Set display start line
write_d(0x00); // 00h start
write_c(0xA6); // Normal display
write_c(0xad); // Set Master Configuration
write_d(0x8e); // DC-DC off & external VcomH voltage & external pre-charge voltage
write_c(0xb0); // Power saving mode
write_d(0x05);
write_c(0xb1); // Set pre & dis_charge
write_d(0x11); // pre=1h dis=1h
write_c(0xb3); // clock & frequency
write_d(0xf0); // clock=Divser+1 frequency=fh
write_c(0xbb); // Set pre-charge voltage of color A B C
write_d(0x1c); // color A
write_d(0x1c); // color B
write_d(0x1c); // color C
write_c(0xbe); // Set VcomH
write_d(0x1f); //
write_c(0xc1); // Set contrast current for A B C
write_d(0xaa); // Color A
write_d(0xb4); // Color B
write_d(0xc8); // Color C
write_c(0xc7); // Set master contrast
write_d(0x0f); // no change
write_c(0xca); // Duty
write_d(0x7f); // 127+1
write_c(0xaf); // Display on
}
void setup(){
int i, x, y;
pinMode(DC, OUTPUT);
pinMode(CS, OUTPUT);
pinMode(RES, OUTPUT);
pinMode(RW, OUTPUT);
pinMode(RD, OUTPUT);
//replace with array
pinMode(D0, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D4, OUTPUT);
pinMode(D5, OUTPUT);
pinMode(D6, OUTPUT);
pinMode(D7, OUTPUT);
PORTD = 0x00;
sparkFun_init();
delay(120);
write_c(0x8e); // clear window command
write_d(0);
write_d(0);
write_d(130);
write_d(130);
delay(100);
write_c(0x92); // fill enable command
write_d(0x01);
delay(10);
randomSeed(analogRead(5));
// draw 100 random dots
for(i = 0; i < 100; i++)
{
x = random(0, 129);
y = random(0, 129);
write_c(0x83);
write_d(x);
write_d(y);
write_d(x+1);
write_d(y+1);
write_d(128);
write_d(128);
}
}
void loop(){
//not looping
}
-robodude666
Hi ther- Ohh, shiny.