ESP32 Code gut?

Hi, ich würde gerne fragen ob dieser code gut ist weil ich kenne mich nicht aus und da kommt immer dieser fehlercode:
'sendDiscordNotification' was not declared in this scope

#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>


const char* ssid = "WLanSSID";
const char* password = "Password";


const char* webhook_url = "https://discord.com/api/webhooks/MyWebhook";



const int doorbellPin = 13;


bool doorbellState = LOW;


void setup() {
  Serial.begin(115200);
  

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Verbindung zum WLAN wird hergestellt...");
  }
  Serial.println("WLAN verbunden!");
  

  pinMode(doorbellPin, INPUT);
}


void loop() {
  doorbellState = digitalRead(doorbellPin);



  if (doorbellState == HIGH) {
    sendDiscordNotification();
    delay(5000);
  }


  delay(100);
}


void sendDiscordNotification() {
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;


    http.begin(webhook_url);


    http.addHeader("Content-Type", "application/json");



    String payload = "{\"content\": \"Es hat geklingelt!\"}";


    int httpResponseCode = http.POST(payload);


    if (httpResponseCode > 0) {
      String response = http.getString();
      Serial.println(httpResponseCode);
      Serial.println(response);
    } else {
      Serial.print("Fehler bei der HTTP Anfrage: ");
      Serial.println(httpResponseCode);
    }



    http.end();
  } else {
    Serial.println("WiFi Verbindung verloren");
  }
}
Arduino, Code, Programmiersprache, C (Programmiersprache), Arduino IDE

Meistgelesene Fragen zum Thema Programmiersprache