Skip to content

Instantly share code, notes, and snippets.

@Tamakichi
Created February 24, 2019 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tamakichi/c719920610eb0a81a698dc9bc4668e23 to your computer and use it in GitHub Desktop.
Save Tamakichi/c719920610eb0a81a698dc9bc4668e23 to your computer and use it in GitHub Desktop.
豊四季タイニーBASIC for STM32 サーボ―モータの制御サンプルプログラム
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