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.
Dependencies: I2cLCD USBDevice mbed
main.cpp
00001 // lpclcd AnalogIn test program 00002 // 2013/11/4 00003 00004 #include "mbed.h" 00005 #include "I2cLCD.h" 00006 #include "USBSerial.h" 00007 00008 //Virtual serial port over USB 00009 USBSerial serial; 00010 // I2C LCD pin assignment 00011 I2cLCD lcd(p28, p27, p29); //sda scl reset 00012 00013 // AnalogIn note: 00014 // val = name; 00015 // returns 0(0V) thru 1(3.3V)(float) 00016 // val = name.read_u16(); 00017 // returns 0(0V)~65535(0xffff, 3.3V)(12bits precision) 00018 AnalogIn ad0(P0_11); 00019 AnalogIn ad1(P0_12); 00020 AnalogIn ad2(P0_13); 00021 AnalogIn ad3(P0_14); 00022 AnalogIn ad5(P0_16); 00023 AnalogIn ad6(P0_22); 00024 00025 DigitalOut myled(P1_6); 00026 DigitalOut backlight(P1_3); 00027 DigitalIn usersw(P0_1); 00028 00029 uint8_t line[128]; 00030 long cn; 00031 00032 int main() { 00033 00034 backlight = 0; 00035 lcd.cls(); 00036 lcd.printf("lpclcd AnalogIn"); 00037 lcd.locate(0,1); 00038 lcd.printf("LPC11U24"); 00039 00040 cn = 0; 00041 while(1) { 00042 if (usersw == 1) { 00043 lcd.locate(0,1); 00044 lcd.printf("A0:%4d A1:%4d",(int)(ad0*1023),(int)(ad1*1023)); 00045 } else { 00046 lcd.locate(0,1); 00047 lcd.printf("A2:%4d A3:%4d",(int)(ad2*1023),(int)(ad3*1023)); 00048 }; 00049 serial.printf("AD0: %4d\r\n",(int)(ad0*1023)); 00050 serial.printf("AD1: %4d\r\n",(int)(ad1*1023)); 00051 serial.printf("AD2: %4d\r\n",(int)(ad2*1023)); 00052 serial.printf("AD3: %4d\r\n",(int)(ad3*1023)); 00053 serial.printf("AD5: %4d\r\n",(int)(ad5*1023)); 00054 serial.printf("AD6: %4d\r\n",(int)(ad6*1023)); 00055 serial.printf("----------------\r\n"); 00056 // 00057 wait(0.2); 00058 myled = (cn&1); 00059 cn++; 00060 } 00061 }
Generated on Sat Jul 16 2022 23:38:47 by
1.7.2