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:e0f62f153426
- Child:
- 1:315a39beca2d
diff -r 000000000000 -r e0f62f153426 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Oct 31 05:21:28 2015 +0000 @@ -0,0 +1,90 @@ +#include "mbed.h" + +Serial pc(D8, D2); + +DigitalOut ss1a(D15); +DigitalOut ss1b(D14); +DigitalOut ss1c(D13); +DigitalOut ss1d(D12); + +DigitalOut ss2a(D11); +DigitalOut ss2b(D10); +DigitalOut ss2c(D9); +DigitalOut ss2d(D7); + +AnalogIn analog_value(A1); + +int main() +{ + int ascidata1,realdata1,ascidata2,realdata2; + uint8_t data; + int meas; + float meas1; + int state_show=0; + + while(1) + { + if(state_show == 0) + { + pc.printf("\nMenu\n"); + pc.printf("1.Input 0-99\n"); + pc.printf("2.VR output\n"); + state_show = 1; + } + + + if(pc.readable()) + { + data = pc.getc(); + + pc.printf("Mode select complete \n\n"); + state_show=2; + } + + + if(state_show ==2) + { + + if(data=='1') + { + pc.printf("Number input : "); + ascidata1 =pc.getc(); + ascidata2 =pc.getc(); + realdata1=ascidata1-48; + realdata2=ascidata2-48; + + if(realdata1==0){ss1d=0;ss1c=0;ss1b=0;ss1a=0;} + if(realdata1==1){ss1d=0;ss1c=0;ss1b=0;ss1a=1;} + if(realdata1==2){ss1d=0;ss1c=0;ss1b=1;ss1a=0;} + if(realdata1==3){ss1d=0;ss1c=0;ss1b=1;ss1a=1;} + if(realdata1==4){ss1d=0;ss1c=1;ss1b=0;ss1a=0;} + if(realdata1==5){ss1d=0;ss1c=1;ss1b=0;ss1a=1;} + if(realdata1==6){ss1d=0;ss1c=1;ss1b=1;ss1a=0;} + if(realdata1==7){ss1d=0;ss1c=1;ss1b=1;ss1a=1;} + if(realdata1==8){ss1d=1;ss1c=0;ss1b=0;ss1a=0;} + if(realdata1==9){ss1d=1;ss1c=0;ss1b=0;ss1a=1;} + + if(realdata2==0){ss2d=0;ss2c=0;ss2b=0;ss2a=0;} + if(realdata2==1){ss2d=0;ss2c=0;ss2b=0;ss2a=1;} + if(realdata2==2){ss2d=0;ss2c=0;ss2b=1;ss2a=0;} + if(realdata2==3){ss2d=0;ss2c=0;ss2b=1;ss2a=1;} + if(realdata2==4){ss2d=0;ss2c=1;ss2b=0;ss2a=0;} + if(realdata2==5){ss2d=0;ss2c=1;ss2b=0;ss2a=1;} + if(realdata2==6){ss2d=0;ss2c=1;ss2b=1;ss2a=0;} + if(realdata2==7){ss2d=0;ss2c=1;ss2b=1;ss2a=1;} + if(realdata2==8){ss2d=1;ss2c=0;ss2b=0;ss2a=0;} + if(realdata2==9){ss2d=1;ss2c=0;ss2b=0;ss2a=1;} + state_show = 0; + } + } + + if(data=='2') + { + meas = analog_value.read(); + meas1 = meas*3.3; + pc.printf("%f volt",meas1); + } + + } +} +