Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 4579|回復: 0
打印 上一主題 下一主題

用 Python 寫 Arduino sketches

[複製鏈接]
跳轉到指定樓層
1#
發表於 2013-2-1 11:26:17 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
本帖最後由 pizg 於 2013-2-1 16:35 編輯

我最近發現也可以使用 Python 程式語言搭配眾多的 Python IDE 來控制 Arduino,
熟悉 Python 的人都知道它的好處,
這兒有簡介可以瞧瞧 https://ep2013.europython.eu/media/conference/slides/python-e-arduino-una-storia-di-serpenti-e-re.pdf
其中 eMail Notifier 是一個不錯的例子 http://www.robofun.net/forum/viewthread.php?tid=7930&extra=page%3D1
其它的我就不多說了.

Python 和 Arduino 它們之間也是透過 Firmata 方式連繫的,
所以 Arduino 端必須要先 upload 「Standard Firmata」這支程式,
下列是一個能讓 pin 13 燈閃亮的範例.

相關資料:
Python http://www.python.org/
pyFirmata https://bitbucket.org/fab/pyfirmata/src/96116e877527?at=default

程式碼:

  1. #Blink.py
  2. import pyfirmata

  3. PIN = 13 # Pin 13 is used
  4. DELAY = 1 # A 1 seconds delay
  5. PORT = '\\.\COM3'
  6. board = pyfirmata.Arduino(PORT)

  7. while True:
  8.     board.digital[PIN].write(1) # Set the LED pin to 1 (HIGH)
  9.     board.pass_time(DELAY)
  10.     board.digital[PIN].write(0) # Set the LED pin to 0 (LOW)
  11.     board.pass_time(DELAY)
複製代碼


ps. 1.剛剛才發現對岸已有人用 Python 寫了一個 Arduino IDE, 真是牛人啊,
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=2465
2.這個也是洋人用 Python 寫的Arduino IDE http://gnome.eu.org/index.php/Gnoduino#Source_Code
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-9-28 07:26 , Processed in 0.233764 second(s), 7 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表