-
Dependencies: mbed
Revision 0:350c4c9c0047, committed 2017-05-23
- Comitter:
- tunagonen
- Date:
- Tue May 23 13:31:17 2017 +0000
- Commit message:
- potentiometer check;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 350c4c9c0047 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 23 13:31:17 2017 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" +Serial pc(USBTX, USBRX); // to connect to pc +float resistor; // defining the variable resistor +AnalogIn mypotentiometer(A2); // getting anolog reading from the potentiometer +DigitalOut plus(PTE20) ; //output for 3.3 V +DigitalOut ground(PTE22) ; //output for the ground + + +int main() +{ + while(1) { + plus = 1 ; // voltage in is 3.3 V + ground = 0 ; // ground is 0 V + resistor = (mypotentiometer); // reading from the potentiometer + if (resistor > 0.999 ) { //in order to get an exact array from 0 to 1 + resistor = 1 ; + } + wait(0.5); + pc.printf("%f \r\n", resistor); //to print into terminal + } +} + + \ No newline at end of file
diff -r 000000000000 -r 350c4c9c0047 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue May 23 13:31:17 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6 \ No newline at end of file