Potentiometers

Dependencies:   mbed

main.cpp

Committer:
eencae
Date:
2017-02-28
Revision:
1:d957f119593e
Parent:
0:74d086537907

File content as of revision 1:d957f119593e:

/* ELEC1620 Application Board Example

Potentiometers

(c) Dr Craig A. Evans, University of Leeds, Feb 2017

*/

#include "mbed.h"

AnalogIn pot0(p20);
AnalogIn pot1(p19);
AnalogIn pot2(p17);

int main() {
    
    while(1) {
        
        float pot0_val = pot0.read();  // returns a float in the range 0.0 to 1.0
        //float pot0_val = pot0;       // short-hand 
        
        float pot0_voltage = pot0_val*3.3f;  // multiply by 3.3 to get the voltage
                
        printf("Pot 0 val = %.2f (%.2f V)\n",pot0_val,pot0_voltage);
        
        wait(0.2);
        
    }
}