Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 I2C disp(PB_7, PB_6); 00004 00005 const int addr = 0x3E; 00006 00007 Serial pc(USBTX, USBRX, 9600); 00008 00009 uint8_t startup[10] = { 00010 0x38, 00011 0x39, 00012 0x14, 00013 0x70, 00014 0x54, 00015 0x77,//contrast 00016 0x6C, 00017 0x38, 00018 0x0F, 00019 0x01 00020 }; 00021 00022 uint8_t message[16] = { 00023 0xB1, 00024 0xB2, 00025 0xB3, 00026 0xB4, 00027 0xB5, 00028 0xB6, 00029 0xB7, 00030 0xB8, 00031 0xB9, 00032 0xBA, 00033 0xBB, 00034 0xBC, 00035 0xBD, 00036 0xBE, 00037 0xBF, 00038 0xC0 00039 }; 00040 00041 00042 DigitalOut LED(LED1); 00043 DigitalIn pa5(PA_5); 00044 DigitalIn pa6(PA_6); 00045 00046 void commandWrite(uint8_t command) 00047 { 00048 char package[2]; 00049 package[0] = 0x80; 00050 package[1] = (char)command; 00051 disp.write(addr << 1, (char *)package, 2); 00052 } 00053 00054 void dataWrite(uint8_t data) 00055 { 00056 char package[2]; 00057 package[0] = 0xC0; 00058 package[1] = (char)data; 00059 disp.write(addr << 1, (char *)package, 2); 00060 } 00061 00062 int main() 00063 { 00064 LED = 0; 00065 disp.frequency(100000); 00066 for(int i = 0; i < sizeof(startup); i++) { 00067 commandWrite(*(startup + i)); 00068 } 00069 wait_ms(10); 00070 for(int i = 0; i < sizeof(message); i++) { 00071 dataWrite(*(message + i)); 00072 if(i == 7) commandWrite(0xC0); 00073 } 00074 00075 }
Generated on Fri Sep 16 2022 05:48:59 by
1.7.2