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.
Diff: main.cpp
- Revision:
- 0:6909d61c61ff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jan 23 17:17:48 2019 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+
+AnalogIn pot(PTB0);
+Serial pc(USBTX, USBRX);
+
+int main()
+{
+ float x,m;
+ float v[]={1,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1,0.0};
+ float LR;
+ int i;
+ float l[]={0,4,16,28,191,330,600,1111,2000,2607,10000};
+
+
+ while(1)
+ {
+ x=pot.read();
+
+ for(i=0;i<11;i++)
+ {
+ if(x<=v[i] && x>v[i+1])
+ {
+ m=(v[i]-v[i+1])/(l[i]-l[i+1]);
+ LR=l[i]-((v[i]+x)/m);
+ pc.printf("%f\n\r",LR);
+ wait(0.5);
+ }
+
+
+
+ }
+ }
+}