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: task2.cpp
- Revision:
- 1:0359809ceda5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/task2.cpp Tue Aug 06 05:31:49 2019 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" + +AnalogIn ain(p20); +BusOut dout(LED1,LED2,LED3,LED4); +Serial pc(USBTX, USBRX); +int main() { + + while (ain) { + if(ain < 0.2f) + { + + dout=0b0000; + printf("Potentiometer value %f\n\r",ain.read()); + wait(1); + } + else if(0.4f>ain>0.2f) + { + dout=0b1000; + printf("Potentiometer value %f\n\r",ain.read()); + wait(1); + } + else if(0.6f>ain>0.4f) + { + + dout=0b1100; + printf("Potentiometer value %f\n\r",ain.read()); + wait(1); + } + else if(0.8f>ain>0.6f) + { + dout=0b1110; + printf("Potentiometer value %f\n\r",ain.read()); + wait(1); + } + else if(ain>0.8f) + { + + dout=0b1111; + printf("Potentiometer value %f\n\r",ain.read()); + wait(1); + } + + } +}