Drittoppgaven
Dependencies: mbed
Revision 0:cd965f803ca2, committed 2015-10-08
- Comitter:
- Voldread
- Date:
- Thu Oct 08 16:20:51 2015 +0000
- Commit message:
- Drittoppgaven
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /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); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Oct 08 16:20:51 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file