Sample code for code for C8051F380 micro controller
I am using C8051F380 microcontroller I have NHD-0216KZW-AB5 display, and I want to use SPI to communicate with this please provide me a sample code.
-
Hi,
Unfortunately, we do not have any sample code available for the C8051F380 microcontroller. However, we do have sample code for the Arduino Uno that you can use as a reference for your code development. Please note that this shared code can also be used for the NHD-0216KZW-AB5, as it shares the same timing values, command table, and initialization sequence.
0 -
Is the code the same for NHD-0216CW-AB3
is this NHD-0216CW-AB3 display compatible with the C8051F380 microcontroller please let me know and share the SPI code for this NHD-0216CW-AB3.
0 -
Hi,
The code for the NHD-0216KZW-AB5 differs from that of the NHD-0216CW-AB3 due to variations in pin connections, timing characteristics, and commands. Please refer the sample code written for the NHD-0216CW-AB3 display on the Arduino Mega. However, we have not yet tested these displays with the C8051F380 microcontroller to ensure compatibility.
0 -
Is there any method to verify whether this NHD-0216CW-AB3 Display is compatible with the C8051F380 microcontroller or not? Please replay to me on an urgent basis.
0 -
//Arduino Code example for Newhaven OLED display NHD-0420DZW model for serial communication.
/*/Program for writing to NHD-0420DZW series display./This code is written for the Arduino Uno (Microchip ATmega328P) using Serial Interface.//Newhaven Display invests time and resources providing this open source code,/Please support Newhaven Display by purchasing products from Newhaven Display!
* Copyright (c) 2020 Alee Shah - Newhaven Display International, Inc.** This code is provided as an example only and without any warranty by Newhaven Display.* Newhaven Display accepts no responsibility for any issues resulting from its use.* The developer on the final application incorporating any parts of this* sample code is responsible for ensuring its safe and correct operation* and for any consequences resulting from its use.* See the GNU General Public License for more details.***/
/***************************************************** PINOUT: Arduino Uno -> Character OLED *****************************************************/
#define CS 11#define SDI 12#define SCL 13
/***************************************************** Text Strings *****************************************************/
char const text1[] = (" Newhaven Display ");char const text2[] = (" International ");char const text3[] = (" CHARACTER TEST ");char const text4[] = (" Serial Interface ");char const text5[] = ("ABCDEFGHIJKLMOPQRSTU");char const text6[] = ("VWXYZabcdefghijklmno");char const text7[] = ("pqrstuvwxyz123456789");char const text8[] = (" <(' ')> || <(' ')> ");
/***************************************************** Function Commands *****************************************************/
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// Command Function://-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// 10-bit Instruction Transmission//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void command(char i){unsigned int m;digitalWrite(CS, LOW); // CS = 0;digitalWrite(SDI, LOW); // RS = 0;digitalWrite(SCL, LOW);digitalWrite(SCL, HIGH); // Clock RS Pin indigitalWrite(SCL, LOW);delay(1);digitalWrite(SDI, LOW); // RW = 0;digitalWrite(SCL, LOW);digitalWrite(SCL, HIGH); // Clock RW Pin indigitalWrite(SCL, LOW);for(m=0;m<8;m++){ // Clock in DB0 - DB7if((i&0x80)==0x80)digitalWrite(SDI, HIGH);elsedigitalWrite(SDI, LOW);while(0);i=(i<<1);digitalWrite(SCL, LOW);while(0);digitalWrite(SCL, HIGH);while(0);digitalWrite(SCL, LOW);}digitalWrite(CS, HIGH); // CS = 1;}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// Start_Data_Transmission Function://-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// Set CS pin LOW to begin transmission; Set RS & RW bits//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void start_data_transmission(){digitalWrite(CS, LOW); // CS = 0;delay(1);digitalWrite(SDI, HIGH); // RS = 1;digitalWrite(SCL, LOW);digitalWrite(SCL, HIGH); // Clock RS Pin indigitalWrite(SCL, LOW);delay(1);digitalWrite(SDI, LOW); // RW = 0;digitalWrite(SCL, LOW);digitalWrite(SCL, HIGH); // Clock RW Pin indigitalWrite(SCL, LOW);}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// Data Function://-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// Send 8-bit Transmission; Can be continuous transmission//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void data(char i){unsigned int m;for(m=0;m<8;m++){ // Clock in DB0 - DB7if((i&0x80)==0x80)digitalWrite(SDI, HIGH);elsedigitalWrite(SDI, LOW);while(0);i=(i<<1);digitalWrite(SCL, LOW);while(0);digitalWrite(SCL, HIGH);while(0);digitalWrite(SCL, LOW);}}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// End_Data_Transmission Function://-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=// Set CS pin HIGH to end transmission.//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void end_data_transmission(){digitalWrite(CS, HIGH); // CS = 1;delay(1);}
/***************************************************** Display Functions *****************************************************/
void clear_screen(){ // clear displaycommand(0x01);}
void ret_home(){ // Return to home positioncommand(0x02);}
void disp1(){ // DISPLAY TEXTclear_screen();ret_home(); // First Linestart_data_transmission();for( int i=0;i<20;i++){data(text1[i]);}end_data_transmission();/******************************************/command(0xc0); // Second Linestart_data_transmission();for (int i=0;i<20;i++){data(text2[i]);}end_data_transmission();/******************************************/command(0x94); // Third Linestart_data_transmission();for( int i=0;i<20;i++){data(text3[i]);}end_data_transmission();/******************************************/command(0xD4); // Fourth Linestart_data_transmission();for (int i=0;i<20;i++){data(text4[i]);}end_data_transmission();}
void disp2(){ // DISPLAY TEXTclear_screen();ret_home(); // First Linestart_data_transmission();for( int i=0;i<20;i++){data(text5[i]);}end_data_transmission();/******************************************/command(0xc0); // Second Linestart_data_transmission();for (int i=0;i<20;i++){data(text6[i]);}end_data_transmission();/******************************************/command(0x94); // Third Linestart_data_transmission();for( int i=0;i<20;i++){data(text7[i]);}end_data_transmission();/******************************************/command(0xD4); // Fourth Linestart_data_transmission();for (int i=0;i<20;i++){data(text8[i]);}end_data_transmission();}
/***************************************************** Initialization Routine *****************************************************/
void init1(){delay(300);
command(0x28); //Function setdelay(2);command(0x08); //Display OFFdelay(2);command(0x01); //Clear Displaydelay(2);command(0x06); //Entry Mode setdelay(2);command(0x02); //Return Homedelay(2);command(0x0C); //Display ONdelay(2);}
/****************************************************** Setup Function, to run once ******************************************************/
void setup() {DDRB = 0xFF; // Enable pins on PORT B as outputsinit1();delay(100);}
/****************************************************** Loop Function, to run repeatedly ******************************************************/
void loop() {disp1();delay(2500);disp2();delay(2500);}This Code fully works with the NHD-0216KZW-AB5 display with Arduino Uno Please give a sample code for NHD-0216CW-AB3 with Arduino Uno( We don't have Arduino mega).0 -
This Code fully works with the NHD-0216KZW-AB5 display with Arduino Uno Please give a sample code for NHD-0216CW-AB3 with Arduino Uno( We don't have Arduino mega).
0 -
Hi,
Unfortunately, we do not currently have a sample code specifically available for the Arduino Uno. However, you can still utilize our available sample code and adapt it for use with the Arduino Uno by adjusting the pin configurations.
0 -
ok we got the display one can you tall me how show sensor value to the display any sample code.
0 -
Hi,
Unfortunately, we do not have any sample code available for specific applications. Typically, we provide sample codes to our users to help them set up the display. However, they will need to implement the code to fit their specific application. If you are interested, you can search for a sample code online that demonstrates how to display sensor values.
0
Please sign in to leave a comment.
Comments
9 comments