Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
test_potentiometer.cpp@0:040a825abcfa, 2021-04-30 (annotated)
- Committer:
- Y_OKA
- Date:
- Fri Apr 30 05:19:04 2021 +0000
- Revision:
- 0:040a825abcfa
To Kobayashi-kun
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Y_OKA | 0:040a825abcfa | 1 | |
| Y_OKA | 0:040a825abcfa | 2 | #include "mbed.h" | 
| Y_OKA | 0:040a825abcfa | 3 | |
| Y_OKA | 0:040a825abcfa | 4 | AnalogIn potensio1(PA_0); // A0 Potentiometer 1 | 
| Y_OKA | 0:040a825abcfa | 5 | |
| Y_OKA | 0:040a825abcfa | 6 | float outValue; | 
| Y_OKA | 0:040a825abcfa | 7 | |
| Y_OKA | 0:040a825abcfa | 8 | Serial pc(USBTX, USBRX); // tx, rx tera terminal等を使用してPCにA0ピンのセンサアナログ値を表示させる | 
| Y_OKA | 0:040a825abcfa | 9 | |
| Y_OKA | 0:040a825abcfa | 10 | void motorReverse(void); | 
| Y_OKA | 0:040a825abcfa | 11 | |
| Y_OKA | 0:040a825abcfa | 12 | int main() { | 
| Y_OKA | 0:040a825abcfa | 13 | |
| Y_OKA | 0:040a825abcfa | 14 | while(1) { | 
| Y_OKA | 0:040a825abcfa | 15 | double pot = potensio1.read(); //0-1(0V~3.3V) | 
| Y_OKA | 0:040a825abcfa | 16 | outValue = pot; | 
| Y_OKA | 0:040a825abcfa | 17 | pc.printf("%f, %f\r\n", pot, outValue); //PCに表示(確認用) | 
| Y_OKA | 0:040a825abcfa | 18 | |
| Y_OKA | 0:040a825abcfa | 19 | |
| Y_OKA | 0:040a825abcfa | 20 | } | 
| Y_OKA | 0:040a825abcfa | 21 | } |