Chris Styles
/
EA_potentiometer
An example program showing how to use the Potentiometer on the Embedded Artists baseboard
main.cpp@0:43de45cb558c, 2010-03-02 (annotated)
- Committer:
- chris
- Date:
- Tue Mar 02 07:06:53 2010 +0000
- Revision:
- 0:43de45cb558c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chris | 0:43de45cb558c | 1 | #include "mbed.h" |
chris | 0:43de45cb558c | 2 | |
chris | 0:43de45cb558c | 3 | // Potentionmeter is on mbed p15 |
chris | 0:43de45cb558c | 4 | // Ensure J27 is fitted |
chris | 0:43de45cb558c | 5 | |
chris | 0:43de45cb558c | 6 | AnalogIn pot (p15); |
chris | 0:43de45cb558c | 7 | |
chris | 0:43de45cb558c | 8 | Serial pc (USBTX,USBRX); |
chris | 0:43de45cb558c | 9 | |
chris | 0:43de45cb558c | 10 | int main() { |
chris | 0:43de45cb558c | 11 | while(1) { |
chris | 0:43de45cb558c | 12 | float ain = pot; |
chris | 0:43de45cb558c | 13 | pc.printf("Analog pot voltage = %.2fv\n",ain*3.3); |
chris | 0:43de45cb558c | 14 | wait(0.2); |
chris | 0:43de45cb558c | 15 | } |
chris | 0:43de45cb558c | 16 | } |