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: mbed SDFileSystem
Analog_In.cpp
00001 00002 #ifdef COMPILE_Analog_In 00003 00004 AnalogIn analog_value(A0); 00005 00006 DigitalOut led(LED1); 00007 00008 int main() 00009 { 00010 float meas_r; 00011 float meas_v; 00012 00013 printf("\nAnalogIn example\n"); 00014 00015 while(1) { 00016 00017 meas_r = analog_value.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) 00018 meas_v = meas_r * 3300; // Converts value in the 0V-3.3V range 00019 00020 // Display values 00021 printf("measure = %f = %.0f mV\n", meas_r, meas_v); 00022 00023 // LED is ON is the value is below 1V 00024 if (meas_v < 1000) { 00025 led = 1; // LED ON 00026 } else { 00027 led = 0; // LED OFF 00028 } 00029 00030 wait(1.0); // 1 second 00031 } 00032 } 00033 00034 00035 #endif
Generated on Fri Jul 15 2022 04:49:55 by
1.7.2