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
Diff: main.cpp
- Revision:
- 0:a6df9b39f120
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 15 16:03:37 2015 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+
+
+DigitalOut Vcc(PA_0);
+AnalogIn aInn(PA_1);
+DigitalOut Gnd(PA_4);
+
+
+int main()
+{
+ Vcc = 1;
+ Gnd = 0;
+
+ float maxVoltage,minVoltage,voltagePrv;
+
+ maxVoltage = minVoltage = aInn.read()*3.3f;
+
+ while(1)
+ {
+ float voltage;
+ for(int i = 0; i < 1000; i++)
+ {
+ voltage += aInn.read()*3.3f;
+ }
+
+ voltage = voltage/1000;
+ if(voltage < voltagePrv - 0.3f || voltage > voltagePrv + 0.3f)
+ {
+ voltagePrv = voltage;
+ if(voltage < minVoltage) minVoltage = voltage;
+ if(voltage > maxVoltage)maxVoltage = voltage;
+
+ printf("VoltIn: %.3f Max: %.3f Min: %.3f Diff: %.3f\r\n", voltage, maxVoltage, minVoltage, maxVoltage-minVoltage);
+ }
+ // printf("Voltage:\t%.3f \r\n", voltage);
+ wait_ms(135);
+ }
+
+
+}