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 //********************** 00002 // UV index meter for mbed with ML8511 00003 // 00004 // UV index 00005 // Extreme 11+ 00006 // Very High 8-10 00007 // High 6-7 00008 // Moderate 3-5 00009 // Low 0-2 00010 // 00011 // LPC1768 flash=512KB, ADC=12bits 00012 // LPC11U35 flash=64KB, ADC=10bits 00013 // Nucleo ADC=12bits 00014 // 00015 // (C)Copyright 2014 All rights reserved by Y.Onodera 00016 // http://einstlab.web.fc2.com 00017 //********************** 00018 #include "mbed.h" 00019 #include "AQM0802.h" 00020 00021 //#pragma O0 00022 //#pragma O1 00023 //#pragma O2 // default 00024 //#pragma O3 00025 //#pragma Otime 00026 //#pragma Ospace 00027 00028 00029 #if defined(TARGET_LPC1768) 00030 I2C i2c(p28,p27); 00031 AnalogIn ain(p15); 00032 #endif 00033 // for TG-LPC11U35-501 00034 #if defined(TARGET_LPC11U35_501) 00035 I2C i2c(P0_5,P0_4); 00036 AnalogIn ain(P0_11); 00037 #endif 00038 // for Nucleo 00039 #if defined(TARGET_NUCLEO_F401RE) 00040 I2C i2c(D14,D15); 00041 AnalogIn ain(PA_0); 00042 #endif 00043 00044 AQM0802 lcd(i2c); 00045 00046 int main() { 00047 00048 char msg[10]; 00049 float UV; 00050 00051 sprintf(msg, "UV index"); 00052 lcd.locate(0,0); 00053 lcd.print(msg); 00054 00055 while(1) { 00056 00057 // UV index 00058 // 1V=0 00059 // 2V=10 00060 UV = (ain.read()*3.3-1.0)/(2.0-1.0)*10.0; 00061 00062 sprintf(msg,"%4.1f",UV); 00063 lcd.locate(0,1); 00064 lcd.print(msg); 00065 wait(1); 00066 } 00067 00068 } 00069
Generated on Wed Jul 13 2022 09:10:09 by
1.7.2