firt
Dependencies: mbed hallsensor_software_decoder
main.cpp
00001 #include "mbed.h" 00002 00003 AnalogIn analog_value(A0); 00004 00005 DigitalOut led(LED1); 00006 00007 int main() { 00008 float meas; 00009 00010 printf("\nAnalogIn example\n"); 00011 00012 while(1) { 00013 meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) 00014 meas = meas * 3300; // Change the value to be in the 0 to 3300 range 00015 printf("measure = %.0f mV\n", meas); 00016 if (meas > 2000) { // If the value is greater than 2V then switch the LED on 00017 led = 1; 00018 } 00019 else { 00020 led = 0; 00021 } 00022 wait(0.2); // 200 ms 00023 } 00024 }
Generated on Sat Jul 30 2022 19:17:59 by 1.7.2