Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* 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: WiFi LED Toggle
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2024-09-29 15:43:25
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* wifi kapcsolatot szeretnék ami egy ledet kapol be */
- /* és ki. */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <WiFi.h> // Include the WiFi library for ESP32
- #include <WiFiClient.h> // Include the WiFiClient library for handling client connections
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t led_LED_PIN_D4 = 4; // Define the pin for the LED
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool led_LED_PIN_D4_rawData = false; // Initialize the LED state (off)
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float led_LED_PIN_D4_phyData = 0.0; // Placeholder for physical data (not used in this example)
- // WiFi credentials
- const char* ssid = "YourWiFiSSID"; // Replace with your WiFi SSID
- const char* password = "YourWiFiPassword"; // Replace with your WiFi password
- void setup(void)
- {
- // Initialize serial communication for debugging
- Serial.begin(115200);
- // Connect to WiFi
- WiFi.begin(ssid, password);
- Serial.print("Connecting to WiFi");
- // Wait for connection
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("Connected to WiFi");
- // Set the LED pin as output
- pinMode(led_LED_PIN_D4, OUTPUT);
- }
- void loop(void)
- {
- // Refresh output data
- updateOutputs();
- // Check WiFi connection status
- if (WiFi.status() == WL_CONNECTED) {
- led_LED_PIN_D4_rawData = !led_LED_PIN_D4_rawData; // Toggle LED state
- delay(1000); // Wait for 1 second before toggling again
- }
- }
- void updateOutputs()
- {
- digitalWrite(led_LED_PIN_D4, led_LED_PIN_D4_rawData); // Update the LED state
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement