RPi.GPIO
編輯歷史
| 時間 | 作者 | 版本 |
|---|---|---|
| 2017-07-19 14:10 – 14:10 | r0 – r1 | |
顯示 diff+ RPi.GPIO
+
+ Python.org的PyPI (Python Package Index)
+ https://pypi.python.org
+ 列出全部可以pip install的package (modules的source code的打包壓縮tar.gz檔)
+ RPi專用的RPi.GPIO也在其中
+ https://pypi.python.org/pypi/RPi.GPIO
+
+ Note that this module is unsuitable for real-time or timing critical applications. This is because you can not predict when Python will be busy garbage collecting. It also runs under the Linux kernel which is not suitable for real time applications - it is multitasking O/S and another process may be given priority over the CPU, causing jitter in your program. If you are after true real-time performance and predictability, buy yourself an Arduino http://www.arduino.cc !
+
+ Note that the current release does not support SPI, I2C, hardware PWM or serial functionality on the RPi yet. This is planned for the near future - watch this space! One-wire functionality is also planned.
+
+ Although hardware PWM is not available yet, software PWM is available to use on all channels.
+
+ For examples and documentation, visit http://sourceforge.net/p/raspberry-gpio-python/wiki/Home/
+
+ 點Wiki: Examples再點PWM
+ https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/
+ 有可靠的PWM範例
+
+ 一個PWM物件stop後的頻率會莫名其妙變成1000
+
+
+
+ motor PWM
+ *import RPi.GPIO as GPIO
+ *GPIO.setmode(GPIO.BOARD)
+ *
+ *GPIO.setup(40 , GPIO.OUT , initial = False) # initial 確保馬達初始都為低電位
+ *GPIO.setup(38 , GPIO.OUT , initial = False)
+ *
+ *GPIO.setup(36 , GPIO.OUT) #Enable PWM 使用的腳位
+ *p = GPIO.PWM(36 , 100) #Frequency = 100
+ *
+ *p.start(50) #DutyCycle = 50
+ *
+ *GPIO.output(40 , True)
+ *GPIO.output(38 , False)
+ *'''
+ *兩腳位一高一低產生電位差
+ *'''
+ *try:
+ * while True:
+ * pass
+ *except:
+ * GPIO.cleanup() #發生錯誤就全部停止 腳位全部改成低電位
|
||