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.
main.cpp
- Committer:
- Carzavec
- Date:
- 2013-12-03
- Revision:
- 0:7166ed837948
File content as of revision 0:7166ed837948:
#include "mbed.h"
Serial pc(USBTX, USBRX); //enable serial port which links to USB
AnalogIn Ain(p19);
BusOut Bar1(p14,p13,p12,p11,p10,p9,p8,p7,p6,p5);
float ADCdata;
float x1=2.2;
float x2=2.8;
float y1=22.0;
float y2=28.0;
float data2;
int BarConvert(char BarValue) { // function 'BarConvert'
switch (BarValue) { //p14,p13,p12,p11,p10,p9,p8,p7,p6,p5
case 20 : return 0x0000;
case 21 : return 0x0001;
case 22 : return 0x0003;
case 23 : return 0x0007;
case 24 : return 0x000F;
case 25 : return 0x001F;
case 26 : return 0x003F;
case 27 : return 0x007F;
case 28 : return 0x00FF;
case 29 : return 0x01FF;
case 30 : return 0x03FF;
default : return 0x03FF;
}
}
int main() {
while(1){
ADCdata=Ain*3.3;
data2=((y2-y1)/(x2-x1))*(ADCdata-x1)+y1;
//data2 = ADCdata ;
pc.printf("%f \n\r",data2);
wait(0.5);
Bar1=BarConvert(data2);
wait_ms(100);
}
}