## 調用方法:
`pinMode(pin,mode,automatic)`
## 參數
`pin`\- 用于設置引腳模式的引腳
`mode`\- 模式 - “模擬”、“輸入”、“輸入上拉”、“輸入下拉”、“輸出”、“開漏”、“af輸出”或“af opendrain”的字符串。如果要恢復到自動引腳模式設置,請不要包含此參數或使用“auto”。
`automatic`\- 可選,默認值為 false。如果為 true,后續命令將自動更改狀態(請參閱下面的注釋)
## 描述
設置給定引腳的模式。
* `auto`/`undefined`\- 不要更改狀態,但允許 /etc 更改 根據需要自動更改狀態[digitalWrite](digitalWrite.md)
* `analog`\- 模擬輸入
* `input`\- 數字輸入
* `input_pullup`\- 數字輸入,內置~40k上拉電阻
* `input_pulldown`\- 數字輸入,內置~40k下拉電阻
* `output`\- 數字輸出
* `opendrain`\- 數字輸出,僅下拉至0v。發送 邏輯使引腳開路`1`
* `opendrain_pullup`\- 數字輸出可下拉至0v。發送一個邏輯使能內部 ~40k 上拉電阻`1`
* `af_output`\- 內置外設的數字輸出
* `af_opendrain`\- 內置外設的數字輸出,只拉動 低至 0V。發送邏輯使引腳開路`1`
**注意:** 除非先調用 [digitalRead](digitalRead.md) 或 [digitalWrite](digitalWrite.md) ,否則會自動設置引腳模式。如果要將引腳設置為自動模式,只需要調用
~~~
pinMode(pin, "auto");
~~~
或第三個參數設為true
~~~
pinMode(pin, "output", true);
~~~
- Espruino簡介
- API
- 全局Globals
- acceleration()
- analogRead(pin)
- analogWrite(pin, value, options)
- atob(base64Data)
- btoa(binaryData)
- changeInterval(id, time)
- clearInterval(id)
- clearTimeout(id)
- clearWatch(id)
- compass()
- decodeURIComponent(str)
- digitalPulse(pin, value, time)
- digitalRead(pin)
- digitalWrite(pin, value)
- dump()
- echo(echoOn)
- edit(funcName)
- encodeURIComponent(str)
- eval(code)
- getPinMode(pin)
- getSerial()
- getTime()
- isFinite(x)
- isNaN(x)
- load(filename)
- parseFloat(string)
- parseInt(string, radix)
- peek16(addr, count)
- peek32(addr, count)
- peek8(addr, count)
- pinMode(pin, mode, automatic)
- poke16(addr, value)
- poke32(addr, value)
- poke8(addr,value)
- print(text, ...)
- require(moduleName)
- reset(clearFlash)
- save()
- setBusyIndicator(pin)
- setDeepSleep(sleep)
- setInterval(function, timeout, args, ...)
- setSleepIndicator(pin)
- setTime(time)
- setTimeout(function, timeout, args, ...)
- setWatch(function, pin, options)
- shiftOut(pins, options, data)
- show(image)
- trace()
- ESP8266
- ESP8266.crc32
- ESP8266.deepSleep
- ESP8266.dumpSocketInfo
- ESP8266.getFreeFlash
- ESP8266.getResetInfo
- ESP8266.getState
- ESP8266.logDebug
- ESP8266.neopixelWrite
- ESP8266.ping
- ESP8266.printLog
- ESP8266.readLog
- ESP8266.reboot
- ESP8266.setCPUFreq
- ESP8266.setLog
- ESP32
- ESP32.deepSleep(us)
- ESP32.deepSleepExt0(pin, level)
- ESP32.deepSleepExt1(pinVar, mode)
- ESP32.enableBLE(enable)
- ESP32.enableWifi(enable)
- ESP32.getState()
- ESP32.getWakeupCause()
- ESP32.reboot()
- ESP32.setAtten(pin, atten)
- ESP32.setBLE_Debug(level)
- ESP32.setOTAValid(isValid)
- Wifi
- event associated
- event auth_change
- Wifi.connect(ssid, options, callback)
- event connected
- event dhcp_timeout
- Wifi.disconnect(callback)
- event disconnected
- Wifi.getAPDetails(callback)
- Wifi.getAPIP(callback)
- Wifi.getDetails(callback)
- Wifi.getHostByName(hostname, callback)
- Wifi.getIP(callback)
- Wifi.getStatus(callback)
- Wifi.ping(hostname, callback)
- event probe_recv
- Wifi.restore()
- Wifi.save(what)
- Wifi.scan(callback)
- Wifi.setAPIP(settings, callback)
- Wifi.setConfig(settings)
- Wifi.setHostname(hostname, callback)
- Wifi.setIP(settings, callback)
- Wifi.setSNTP(server, tz_offset)
- event sta_joined
- event sta_left
- Wifi.startAP(ssid, options, callback)
- Wifi.stopAP(callback)
- Wifi.turbo(enable, callback)
- Modules
- Modules.addCached(id, sourcecode)
- Modules.getCached()
- Modules.removeAllCached()
- Modules.removeCached(id)
- Flash
- Flash.erasePage(addr)
- Flash.getFree()
- Flash.getPage(addr)
- Flash.read(length, addr)
- Flash.write(data, addr)
- Storage
- Storage.compact(showMessage)
- Storage.debug()
- Storage.erase(name)
- Storage.eraseAll()
- Storage.getFree(checkInternalFlash)
- Storage.getStats(checkInternalFlash)
- Storage.hash(regex)
- Storage.list(regex, filter)
- Storage.open(name, mode)
- Storage.optimise()
- Storage.read(name, offset, length)
- Storage.readArrayBuffer(name)
- Storage.readJSON(name, noExceptions)
- Storage.write(name, data, offset, size)
- Storage.writeJSON(name, data)
- StorageFile
- StorageFile.erase()
- StorageFile.getLength()
- StorageFile.pipe(destination, options)
- StorageFile.read(len)
- StorageFile.readLine()
- StorageFile.write(data)
- 模塊 Modules
- 使用模塊進行工作
- 內置模塊
- Espruino 模塊
- 來自 Github(或互聯網上的任何地方)
- 從 Storage 加載模塊
- 從 NPM 加載模塊
- 從一個本地文件夾
- 從 SD 卡 加載模塊
- 從互聯網加載模塊
- 已有模塊
- 常見問題
- 編寫和提交模塊(或更改)