Created
February 24, 2019 08:36
-
-
Save Tamakichi/c719920610eb0a81a698dc9bc4668e23 to your computer and use it in GitHub Desktop.
豊四季タイニーBASIC for STM32 サーボ―モータの制御サンプルプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 'サーボ―モータの制御 | |
20 'TOWER PRO SG90を使ったデモ | |
30 'PWM 50Hz 0.5ms:-90°~ 2.4ms:+90° | |
40 '配線 VCC(赤) => 5V | |
50 'GND(茶) => GND | |
60 'PWM(橙) => PA8 | |
70 ' | |
80 GPIO PA8,PWM:'PWM(5Vトレラントピン) | |
90 INPUT "角度(-90 ~ 90):",D | |
100 IF (D<-90) OR (D>90) ?"正しい数値を入力して下さい":GOTO 90 | |
110 P=MAP(D,-90,90,102,491):'-90~90を102~491に対応 | |
120 POUT PA8,P,50 | |
130 GOTO 90 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment