ESP32-S3 板在引脚 48 上不闪烁

问题描述 投票:0回答:2

我重置了ESP32-S3板并上传了简单的闪烁代码,但没有任何反应

#define LED_BUILTIN 48 

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_BUILTIN,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 digitalWrite(LED_BUILTIN,HIGH);
 delay(1000);
 digitalWrite(LED_BUILTIN,LOW);
 delay(1000);
}
arduino arduino-esp32
2个回答
0
投票

如果您想主动驱动(写入)某个引脚(例如使 LED 闪烁),则必须将其设置为输出。

因此您在设置函数中的代码应该更正为:

pinMode(LED_BUILTIN,OUTPUT);

0
投票

我检查了串行监视器,它准确地打印了值,所以我所做的,我只是删除了

#define LED_BUILTIN 48
并且它起作用了。 这是最终的工作代码。

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);  
  Serial.println("LED Test");// wait for a second
}
© www.soinside.com 2019 - 2024. All rights reserved.