Nobuki HIRAMINE
/
cds
Measuring the brightness.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 TextLCD g_lcd(p24, p26, p27, p28, p29, p30); // RS, E, DB4, DB5, DB6, DB7 00005 AnalogIn g_analogin(p15); 00006 00007 int main() { 00008 wait(0.001); 00009 g_lcd.cls(); wait(0.001); 00010 g_lcd.locate(0, 0); 00011 00012 while(1) { 00013 double dV = g_analogin * 3.3; 00014 00015 double dR = 0.0; 00016 if( 0.005 < (3.3 - dV) ) 00017 { 00018 dR = 10 * 1000 * dV / (3.3 - dV); 00019 } 00020 00021 g_lcd.cls(); wait(0.001); 00022 g_lcd.locate(0, 0); 00023 g_lcd.printf( "%5.2lf[V]", dV ); 00024 g_lcd.locate(0, 1); 00025 if( 0.0 == dR ) 00026 { 00027 g_lcd.printf( "Infinity[ohm]" ); 00028 } 00029 else 00030 { 00031 g_lcd.printf( "%8.2lf[ohm]", dR ); 00032 } 00033 00034 wait(1.0); 00035 } 00036 }
Generated on Tue Jul 19 2022 00:31:11 by 1.7.2