参考
注意、いろいろ
- 過去ログを見よ!!!
- なんどか「シリアルモニター」を開き直す(windows系)
- なぜか連続でシリアル出力するとかけるで、ウエート
- 3.1.2
目的
無線でラジコンサーボ SG90を制御する(予定)
結果
ESP-ROM:esp32c6-20220919
.........
[0]<500>
[1]<510>
[2]<521>
[3]<531>
[4]<542>
[5]<552>
[6]<563>
[7]<573>
[8]<584>
[9]<594>
[10]<605>
[11]<616>
[12]<626>
[13]<637>
[14]<647>
[15]<658>
[16]<668>
[17]<679>
[18]<689>
[19]<700>
[20]<711>
[21]<721>
[22]<732>
[23]<742>
[24]<753>
[25]<763>
[26]<774>
[27]<784>
[28]<795>
[29]<806>
[30]<816>
[31]<827>
[32]<837>
[33]<848>
[34]<858>
[35]<869>
[36]<879>
[37]<890>
[38]<901>
[39]<911>
[40]<922>
[41]<932>
[42]<943>
[43]<953>
[44]<964>
[45]<974>
[46]<985>
[47]<996>
[48]<1006>
[49]<1017>
[50]<1027>
[51]<1038>
[52]<1048>
[53]<1059>
[54]<1069>
[55]<1080>
[56]<1091>
[57]<1101>
[58]<1112>
[59]<1122>
[60]<1133>
[61]<1143>
[62]<1154>
[63]<1164>
[64]<1175>
[65]<1186>
[66]<1196>
[67]<1207>
[68]<1217>
[69]<1228>
[70]<1238>
[71]<1249>
[72]<1259>
[73]<1270>
[74]<1281>
[75]<1291>
[76]<1302>
[77]<1312>
[78]<1323>
[79]<1333>
[80]<1344>
[81]<1354>
[82]<1365>
[83]<1376>
[84]<1386>
[85]<1397>
[86]<1407>
[87]<1418>
[88]<1428>
[89]<1439>
[90]<1449>
[91]<1460>
[92]<1471>
[93]<1481>
[94]<1492>
[95]<1502>
[96]<1513>
[97]<1523>
[98]<1534>
[99]<1544>
[100]<1555>
[101]<1566>
[102]<1576>
[103]<1587>
[104]<1597>
[105]<1608>
[106]<1618>
[107]<1629>
[108]<1639>
[109]<1650>
[110]<1661>
[111]<1671>
[112]<1682>
[113]<1692>
[114]<1703>
[115]<1713>
[116]<1724>
[117]<1734>
[118]<1745>
[119]<1756>
[120]<1766>
[121]<1777>
[122]<1787>
[123]<1798>
[124]<1808>
[125]<1819>
[126]<1829>
[127]<1840>
[128]<1851>
[129]<1861>
[130]<1872>
[131]<1882>
[132]<1893>
[133]<1903>
[134]<1914>
[135]<1924>
[136]<1935>
[137]<1945>
[138]<1956>
[139]<1967>
[140]<1977>
[141]<1988>
[142]<1998>
[143]<2009>
[144]<2019>
[145]<2030>
[146]<2040>
[147]<2051>
[148]<2062>
[149]<2072>
[150]<2083>
[151]<2093>
[152]<2104>
[153]<2114>
[154]<2125>
[155]<2135>
[156]<2146>
[157]<2157>
[158]<2167>
[159]<2178>
[160]<2188>
[161]<2199>
[162]<2209>
[163]<2220>
[164]<2230>
[165]<2241>
[166]<2252>
[167]<2262>
[168]<2273>
[169]<2283>
[170]<2294>
[171]<2304>
[172]<2315>
[173]<2325>
[174]<2336>
[175]<2347>
[176]<2357>
[177]<2368>
[178]<2378>
[179]<2389>
[180]<2399>
プログラム
//servo_sg90_test1_M5NanoC6_1
//インクルド
#include <Arduino.h>
//定義
//V_0が0度の時の初期値で単位は、nS(ナノ秒)
//V_180が180度の時の初期値で単位は、nS(ナノ秒)
#define V_0 500
#define V_180 2400
#define HH ((V_180-V_0)*1024)/180
#define SO(AA) (V_0+(((AA)*(HH))>>10))
#define M_SO(AA) (SO(180-(AA)))
void setup() {
// put your setup code here, to run once:
//シリアルの初期化 //debug(1)
Serial.begin(9600);
Serial.println();
//シリアルの待ちが0.5*9
for (int i = 0; i < 9; i++) {
Serial.print('.'); delay(500); //接続待ち
} //for
Serial.println();
delay(500);
int a;
for (int i = 0; i < (180 + 1); i++) {
a = SO(i); //正転
//a = M_SO(i); //逆転
//a = SO(180-i);
printf("[%d]<%d>\n", i, a);delay(1);
}//for
}//setup
void loop() {
// put your main code here, to run repeatedly:
delay(300); //0.3秒待つ
}//loop