sample program for lpc1114 with the Library TRP105F_Spline. Use this with the program DistanceSensor_BaseUnit which is for mbed lpc1768
Dependencies: TRP105F_Spline mbed
main.cpp
00001 #include "mbed.h" 00002 #include "CODE_SELECTIVE.h" 00003 #include "TRP105F_Spline.h" 00004 00005 DigitalOut myled(LED1); 00006 DigitalIn unisig(dp13); 00007 TRP105FS sensor(5, dp4); 00008 Serial com_lpc1768(dp16, dp15); 00009 00010 int main() 00011 { 00012 char c; 00013 unsigned short x; 00014 00015 while(1) { 00016 c = com_lpc1768.getc(); 00017 00018 if(c == 0) { 00019 c = com_lpc1768.getc(); 00020 switch(c) { 00021 case 'c': 00022 for(int i = 0; i < 5; i++) { 00023 while( unisig){;} 00024 while(!unisig){;} 00025 sensor.setSample(i * 255 / 4, sensor.getVoltage()); 00026 com_lpc1768.putc(i + 1); 00027 } 00028 sensor.calibrate(); 00029 sensor.saveSetting_intoSerial(&com_lpc1768); 00030 break; 00031 case 'l': 00032 sensor.loadSetting_fromSerial(&com_lpc1768); 00033 break; 00034 } 00035 00036 while(1) { 00037 myled = 1; 00038 c = com_lpc1768.getc(); 00039 if(c == 0x11) { 00040 c = com_lpc1768.getc(); 00041 for(int i = 0; i < c; i++) 00042 com_lpc1768.putc(com_lpc1768.getc()); 00043 }// 00044 00045 else if (c == 0x12) { 00046 myled = 0; 00047 x = sensor.getDistance(); 00048 com_lpc1768.putc((x>>8)&0xFF); 00049 com_lpc1768.putc((x )&0xFF); 00050 } 00051 00052 } 00053 00054 } 00055 } 00056 }
Generated on Wed Jul 20 2022 02:38:57 by 1.7.2