-
Dependencies: mbed
main.cpp
- Committer:
- tunagonen
- Date:
- 2017-05-23
- Revision:
- 0:350c4c9c0047
File content as of revision 0:350c4c9c0047:
#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 } }