Craig Evans
/
1620_App_Board_Joystick
Joystick example
Fork of 1620_App_Board_Pots by
main.cpp
- Committer:
- eencae
- Date:
- 2017-02-24
- Revision:
- 0:74d086537907
- Child:
- 1:d957f119593e
File content as of revision 0:74d086537907:
/* 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 int pot0_int_val = pot0.read_u16(); // can also get int in range 0 to 65,535 printf("Pot 0 val = %.2f [%i] (%.2f V)\n",pot0_val,pot0_int_val,pot0_voltage); wait(0.2); } }