ADC & DAC Analog
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 00003 00004 DigitalOut Vcc(PA_0); 00005 AnalogIn aInn(PA_1); 00006 DigitalOut Gnd(PA_4); 00007 00008 00009 int main() 00010 { 00011 Vcc = 1; 00012 Gnd = 0; 00013 00014 float maxVoltage,minVoltage,voltage; 00015 00016 maxVoltage = aInn.read()*3.3f; 00017 minVoltage = aInn.read()*3.3f; 00018 00019 while(1) 00020 { 00021 voltage = aInn.read()*3.3f; 00022 00023 if(voltage < minVoltage) minVoltage = voltage; 00024 if(voltage > maxVoltage) maxVoltage = voltage; 00025 00026 printf("VoltIn: %.3f Max: %.3f Min: %.3f Diff: %.3f\r\n", voltage, maxVoltage, minVoltage, maxVoltage-minVoltage); 00027 00028 // printf("Voltage:\t%.3f \r\n", voltage); 00029 wait_ms(135); 00030 } 00031 00032 00033 }
Generated on Tue Jul 19 2022 01:52:59 by
1.7.2