/#define PORT_TX D5 //改为使用Arduino风格的引脚编号(D5)
//下面的代码需要修改为ESP8266的GPIO操作方式
//例如,PORTD |= 1 << (7 - (i%8)) 改为 digitalWrite(D7, HIGH)
//PORTD &= !(1 << (7 - (i%8))) 改为 digitalWrite(D7, LOW)
void setup() {
DDRD |= 1 << (7 - (PORT_TX % 8));
...
}
void loop() {
...
if((bitmask & (1 << i)) == (1 << i)) {
digitalWrite(PORT_TX, HIGH);
...
digitalWrite(PORT_TX, LOW);
}
...
}
//修改后的代码
void setup() {
pinMode(PORT_TX, OUTPUT);
...
}
void loop() {
...
if((bitmask & (1 << i)) == (1 << i)) {
digitalWrite(PORT_TX, HIGH);
...
digitalWrite(PORT_TX, LOW);
}
...
}
/#define PORT_TX D5 //改为使用Arduino风格的引脚编号(D5)
//下面的代码需要修改为ESP8266的GPIO操作方式
//例如,PORTD |= 1 << (7 - (i%8)) 改为 digitalWrite(D7, HIGH)
//PORTD &= !(1 << (7 - (i%8))) 改为 digitalWrite(D7, LOW)
void setup() {
DDRD |= 1 << (7 - (PORT_TX % 8));
...
}
void loop() {
...
if((bitmask & (1 << i)) == (1 << i)) {
digitalWrite(PORT_TX, HIGH);
...
digitalWrite(PORT_TX, LOW);
}
...
}
//修改后的代码
void setup() {
pinMode(PORT_TX, OUTPUT);
...
}
void loop() {
...
if((bitmask & (1 << i)) == (1 << i)) {
digitalWrite(PORT_TX, HIGH);
...
digitalWrite(PORT_TX, LOW);
}
...
}
举报