赞
踩
@[esp8266接口状态设置和读写]
esp8266有GPIO0-GPIO15
GPIO0-15有内置上拉电阻
GPIO16内置下拉电阻
esp8266的IO口在没有接上拉或下拉电阻的时候,会处在悬空状态可能是高电平/低电平不确定。esp8266内置了上拉与下拉电阻。
int key1 = D6; int key1State = 0; void setup() { // put your setup code here, to run once: pinMode(key1,INPUT_PULLUP); //输入模式并启用上拉电阻 pinMode(GPIO1,OUTPUT); Serial.begin(115200);//串口速率 } void loop() { // put your main code here, to run repeatedly: key1State = digitalRead(key1); Serial.println(key1State);//串口发送 digitalWrite(GPIO1,1);//设IO口为高电平 delay(300); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。