python , 使用 arduino ide 的 python [2021/8/22]


我要寫1支小程式, 一個文字檔, 給 串口通訊 載入的 .ini 檔。
可以用 DevC++, C++, C#,VB, python ....
可是, 近日電腦系裝重裝, 一些程式編譯器, 還未安裝。
Excel VBA 是可以使用。

本來, 想用python 寫, 但必須裝 Anaconda
先用 arduino ide 寫, 給 LGT8F328 這片ARDUINO 板子跑, 用 Serial.print() 把字串, 回傳給電腦, 
已寫好, 完成工作。

突然, 想到 arduino ide  , 燒錄時, 會呼叫 pyhton , 那就直接寫 python , 交給 arduino ide 自帶的 python 執行, 免去安裝 Anaconda ....


arduino ide 燒錄 esp8266 WeMos D1/R1 , 有燒錄指令, 是用python 寫的。

C:\Arduino\portable\packages\esp8266\tools\python3\3.7.2-post1/python3 -I C:\Arduino\portable\packages\esp8266\hardware\esp8266\3.0.2/tools/upload.py --chip esp8266 --port COM3 --baud 115200 --before default_reset --after hard_reset write_flash 0x0 
C:\Users\owner\AppData\Local\Temp\arduino_build_720343/D1_Blink.ino.bin 

python 工具, 就是 C:\Arduino\portable\packages\esp8266\tools\python3\3.7.2-post1/python3 

我寫1支 mk_item.py 可以給它執行 

以下為 mk_item.py 

 ''' C:\Arduino\portable\packages\esp8266\tools\python3\3.7.2-post1/python3 E:\wsh\wsh_now\fb外包\MorrisLu\20210702_塗花手臂\python\mk_item.py ''' 

item=1 
print ("[Section1]") 
for i in range(0,5): 
        s="Item"+str(item)+"=M"+str(i)+" 000" 
        print (s) 
        item=item+1 s="Item"+str(item)+"=" 
        print (s) 
        item=item+1 

for i in range(0,5): 
        s="Item"+str(item)+"=M"+str(i)+" 100" 
        print (s) 
        item=item+1 

s="Item"+str(item)+"=" 
print (s) 
item=item+1 

for i in range(0,5): 
        s="Item"+str(item)+"=M"+str(i)+" 255" 
        print (s) 
        item=item+1 

s="Item"+str(item)+"=>STP<" 
print (s) 
item=item+1



留言

這個網誌中的熱門文章

無效的努力

股市-華頓S&P黃豆(00693U) 操作法