2014年10月31日 星期五

Raspberry Pi module b+ GPIO Mode





最近定了這個新的版子,用舊的方法方法寫了以後發現PIN28以後的GPIO竟然出現錯誤訊息
valueError the channel send is invalid


看了一下發現很多人也有這樣問題
解答是在PI裡面要用另外一種模式BCM mode,就可以控制新增的GPIO
GPIO.setmode(GPIO.BCM)


The GPIO.BOARD option specifies that you are referring to the pins by the number of the pin the the plug - i.e the numbers printed on the board (e.g. P1) and in the middle of the diagrams below.
The GPIO.BCM option means that you are referring to the pins by the "Broadcom SOC channel" number, these are the numbers after "GPIO" in the green rectangles around the outside of the below diagrams:
Unfortunately the BCM numbers changed between versions of the Model B, and you'll need to work out which one you have guide here. So it may be safer to use the BOARD numbers if you are going to use more than one pi in a project.


Board mode寫的腳位就是pin 的腳位

BCM mode 寫的是在PINGPIO的編號,要查一下自己Pi的硬體版本

ps. SDA與SCL雖然寫是GPIO,但是不能被讀出,不要拿這兩個來當普通GPIO


沒有留言:

張貼留言