关于Wifiduino的看门狗导致重启的问题
我打算写一个从4*3的矩阵键盘读取数字并在串口中显示的程序,然后烧进Wifiduino之后串口就一直显示下面的信息,似乎因为看门狗一直在重启。我百度了说在循环里加上喂狗的语句或者加delay就可以了,但是都试过了还是不行,在每个for循环里都加过delay还有ESP.wdt_feed(),还有人说是因为供电不足导致的,求大佬指点const int numRows = 4;//键盘的行数const int numCols = 3;//键盘的列数
const int debounceTime = 20;//开关稳定需要的毫秒数
//keymap定义相应的键被按下时返回的字符
const char keymap = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
const int rowPins = {8, 3, 4, 6};
const int colPins = {7, 9, 5};
void setup(){
Serial.begin(9600);
for(int row = 0; row < numRows; row++)
{
pinMode(rowPins, INPUT);
digitalWrite(rowPins, HIGH);
delay(2000);
}
for(int column = 0; column < numCols; column++)
{
pinMode(colPins, OUTPUT);
digitalWrite(colPins, HIGH);
}
}
void loop(){
char key = getKey();
if(key != 0)
{
Serial.print("Got key");
Serial.println(key);
}
delay(2000);
}
char getKey()
{
char key = 0;
for(int column = 0; column < numCols; column++)
{
digitalWrite(colPins, LOW);
for(int row = 0; row < numRows; row++)
{
delay(100);
if(digitalRead(rowPins) == LOW)
{
delay(debounceTime);
while(digitalRead(rowPins) == LOW);
key = keymap;
delay(100);
}
delay(100);
}
digitalWrite(colPins, HIGH);
}
return key;
} while(digitalRead(rowPins) == LOW);
循环里面要喂狗 乱用引脚再怎么喂狗都没用,另外,常规的arduino函数都会自动喂狗,除了while(1);这种 XlinliY.Zhang 发表于 2022-5-3 13:30
乱用引脚再怎么喂狗都没用,另外,常规的arduino函数都会自动喂狗,除了while(1);这种 ...
哪能看出来乱用了哇,小白求指点
页:
[1]