niall behan
/
lab_question3
lab question 3
Diff: main.cpp
- Revision:
- 0:52c0110393c4
diff -r 000000000000 -r 52c0110393c4 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 21 12:00:33 2019 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" + +PwmOut red(p23); +PwmOut green(p24); +AnalogIn pot1(p19); +AnalogIn pot2(p20); +Serial pc(USBTX,USBRX); + +float a,b; + + int main() + { + while(1) + { + a=pot1*100; //the value requires to be multiplied by 100 + red=pot1; + + b=pot2*100; //in order to get the percentage + green=pot2; + + pc.printf("Pot 1 position is: %3f\n\r",a); + wait(2); + + pc.printf("Pot 2 position is: %3f\n\r",b); + wait(2); + } + } + \ No newline at end of file