![](/media/cache/group/plengoer.png.50x50_q85.png)
ポテンショメータの変換
Fork of USBSerial_HelloWorld by
main.cpp
- Committer:
- mitsuhiroYabu
- Date:
- 2017-05-22
- Revision:
- 10:35941a39f02d
- Parent:
- 9:d88699a0905a
File content as of revision 10:35941a39f02d:
#include "mbed.h" #include "USBSerial.h" //Virtual serial port over USB //USBSerial serial; DigitalOut myled(LED1); AnalogIn potentiometer(p15); float pot_val = 0.5; float result = 0.5; Serial pc(USBTX, USBRX); #define MAX 0.28 #define MIN 0.62 int main(void) { while(1) { myled = 1; pot_val = potentiometer.read(); result = (pot_val-MIN)/(MAX-MIN); pc.printf("pot_val=%2.2f conversion=%2.2f angle=%3.2f[deg] \r\n",pot_val,result,result*360); //serial.printf("I am a virtual serial port\r\n"); wait_ms(50); myled = 0; wait_ms(50); } }