Drittoppgaven
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:cd965f803ca2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 08 16:20:51 2015 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" + +DigitalOut Vcc(PA_0); +AnalogIn aInn(PA_1); +DigitalOut Gnd(PA_4); + +int main() +{ + Vcc=1; + Gnd=0; + int i; + float voltage, maxVoltage, minVoltage, avgV, sum; + + maxVoltage = minVoltage=aInn.read()*3.3f; + while(1) + { + + for(i=0;i<1000;i++) + { + voltage=aInn.read()*3.3f; + } + sum=(sum+voltage)/1000; + + if(voltage<maxVoltage) + maxVoltage=voltage; + + if(voltage>minVoltage) + minVoltage=voltage; + + printf("AvgV: %.3f Curent: %.3f Min: %.3f Max: %.3f Max-Min: %.3f\r\n",sum, voltage, maxVoltage, minVoltage, maxVoltage-minVoltage); + wait_ms(500); + } +}