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 #include "mbed.h" 00002 00003 AnalogIn analog_value(A0); 00004 00005 DigitalOut led(LED1); 00006 00007 int main() 00008 { 00009 float meas_r; 00010 float meas_v; 00011 00012 printf("\nAnalogIn example\n"); 00013 00014 while(1) { 00015 meas_r = analog_value.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range) 00016 meas_v = meas_r * 5000; // Converts value in the 0V-5V range 00017 // Display values 00018 printf("measure = %f = %.0f mV\n", meas_r, meas_v); 00019 00020 // LED is ON is the value is below 1V 00021 if (meas_v < 1000) { 00022 led = 1; // LED ON 00023 } else { 00024 led = 0; // LED OFF 00025 } 00026 00027 wait(1.0); // 1 second 00028 } 00029 }
Generated on Thu Jul 14 2022 21:34:33 by
1.7.2