0508_Assignment2
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:259c510de120
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 29 09:49:28 2015 +0000 @@ -0,0 +1,40 @@ +// Assignment 2 +// 29/10/2015 +#include "mbed.h" + +Serial BT(D8,D2); //tx rx +BusOut S1(D3,D4,D5,D6),S2(D9,D10,D11,D12); +DigitalOut point(D13); +AnalogIn Vin(A5); +Timer timeout; + +int main() +{ + + point=1; + float v; + uint8_t a[2],counter; + S1=0; + S2=0; + while(true) + { + timeout.reset(); + timeout.start(); + counter = 0; + while ((counter < 2) && (timeout.read() < 1)) + { + if (BT.readable()) + { + a[counter] = BT.getc(); + if(counter) + S2=a[counter]-48; + else + S1=a[counter]-48; + counter++; + //BT.printf("%c",a[counter-1]); + } + } + v=Vin.read()*3.3; + BT.printf("VR = %f\n",v); + } +} \ No newline at end of file