Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: "Wi-Fi Blink" - Source Code NOT compiled for: ESP32 DevKit V1 - Source Code created on: 2024-06-11 14:08:20 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* ESP32 code LED blinking in specific patterns to */ /* two ESP32 devices. Red, Blue, Green and Yellow LED */ /* blinking in a pre-programmed delays. Add Firebase */ /* integration for web hosting, authentication and */ /* using realtime database. */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
#include
//https://github.com/mobizt/Firebase-ESP32 #include
// Provide the token generation process info. #include
// Provide an RTDB helper functions. /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); void blinkPattern(void); /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t GPIO23_LED_PIN_D4 = 4; const uint8_t GPIO22_LED_PIN_D13 = 13; const uint8_t GPIO21_LED_PIN_D14 = 14; const uint8_t GPIO19_LED_PIN_D16 = 16; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool GPIO23_LED_PIN_D4_rawData = 0; bool GPIO22_LED_PIN_D13_rawData = 0; bool GPIO21_LED_PIN_D14_rawData = 0; bool GPIO19_LED_PIN_D16_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float GPIO23_LED_PIN_D4_phyData = 0.0; float GPIO22_LED_PIN_D13_phyData = 0.0; float GPIO21_LED_PIN_D14_phyData = 0.0; float GPIO19_LED_PIN_D16_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ // Define Firebase Data object FirebaseData fbdo; // Define the FirebaseAuth data for authentication data FirebaseAuth auth; // Define the FirebaseConfig data for config data FirebaseConfig config; // WiFi credentials #define WIFI_SSID "your_wifi_ssid" #define WIFI_PASSWORD "your_wifi_password" // Firebase project API Key #define API_KEY "your_firebase_api_key" // Firebase project URL #define DATABASE_URL "your_firebase_database_url" // User credentials #define USER_EMAIL "your_email" #define USER_PASSWORD "your_password" void setup(void) { // put your setup code here, to run once: Serial.begin(115200); // Connect to Wi-Fi WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting to Wi-Fi"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(300); } Serial.println(); Serial.print("Connected with IP: "); Serial.println(WiFi.localIP()); Serial.println(); // Assign the api key (required) config.api_key = API_KEY; // Assign the user sign in credentials auth.user.email = USER_EMAIL; auth.user.password = USER_PASSWORD; // Assign the RTDB URL (required) config.database_url = DATABASE_URL; // Assign the callback function for the long running token generation task config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h // Initialize the library with the Firebase authen and config. Firebase.begin(&config, &auth); // Optional, set AP reconnection in setup() Firebase.reconnectWiFi(true); pinMode(GPIO23_LED_PIN_D4, OUTPUT); pinMode(GPIO22_LED_PIN_D13, OUTPUT); pinMode(GPIO21_LED_PIN_D14, OUTPUT); pinMode(GPIO19_LED_PIN_D16, OUTPUT); } void loop(void) { // put your main code here, to run repeatedly: updateOutputs(); // Refresh output data blinkPattern(); // Execute LED blinking pattern } void updateOutputs() { digitalWrite(GPIO23_LED_PIN_D4, GPIO23_LED_PIN_D4_rawData); digitalWrite(GPIO22_LED_PIN_D13, GPIO22_LED_PIN_D13_rawData); digitalWrite(GPIO21_LED_PIN_D14, GPIO21_LED_PIN_D14_rawData); digitalWrite(GPIO19_LED_PIN_D16, GPIO19_LED_PIN_D16_rawData); } void blinkPattern() { // Example blinking pattern GPIO23_LED_PIN_D4_rawData = HIGH; updateOutputs(); delay(500); GPIO23_LED_PIN_D4_rawData = LOW; updateOutputs(); delay(500); GPIO22_LED_PIN_D13_rawData = HIGH; updateOutputs(); delay(500); GPIO22_LED_PIN_D13_rawData = LOW; updateOutputs(); delay(500); GPIO21_LED_PIN_D14_rawData = HIGH; updateOutputs(); delay(500); GPIO21_LED_PIN_D14_rawData = LOW; updateOutputs(); delay(500); GPIO19_LED_PIN_D16_rawData = HIGH; updateOutputs(); delay(500); GPIO19_LED_PIN_D16_rawData = LOW; updateOutputs(); delay(500); } /* END CODE */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)