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.
main.cpp
- Committer:
- YMP
- Date:
- 2019-09-20
- Revision:
- 1:bab46c2f0263
- Parent:
- 0:9d2545148cbf
- Child:
- 2:fdd8a3074d79
File content as of revision 1:bab46c2f0263:
//------------------------------------------------------------------- //QEIライブラリ使用 //------------------------------------------------------------------- //mbed用ライブラリ #include "mbed.h" //エンコーダ用ライブラリ #include "QEI.h" //変数宣言 //1回転でのパルス数 #define ROTATE_PER_REVOLUTIONS 360 //エンコーダのチャンネルAとBの初期状態を決める QEI wheel(P1_0, P1_1, NC, ROTATE_PER_REVOLUTIONS, QEI::X4_ENCODING); //メイン関数 int main() { //作業用変数 long delt_ms = 1; wait_ms(delt_ms); while(1) { //エンコーダ値格納用変数 static double y; //エンコーダの値(生)の取得 y=(double)wheel.getPulses(); //エンコーダの値を角度に変換 y=y*360/(ROTATE_PER_REVOLUTIONS); //エンコーダ値(角度)の表示(TeraTerm) printf("%f\r\n",y); //待機時間(1ミリ秒) wait(delt_ms); } }