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 Control**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2025-03-04 17:17:10
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* crea un codice su arduino per un progetto di un */
- /* led comandato tramite wifi su esp32 */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <WiFiEspAT.h> // Include WiFi library
- // Emulate Serial1 on pins 6/7 if not present
- #if defined(ARDUINO_ARCH_AVR) && !defined(HAVE_HWSERIAL1)
- #include <SoftwareSerial.h>
- SoftwareSerial Serial1(6, 7); // RX, TX
- #define AT_BAUD_RATE 9600
- #else
- #define AT_BAUD_RATE 115200
- #endif
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t myLED_LED_PIN_D2 = 2;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool myLED_LED_PIN_D2_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float myLED_LED_PIN_D2_phyData = 0.0;
- // WiFi credentials
- const char* ssid = "your_SSID"; // Replace with your SSID
- const char* password = "your_PASSWORD"; // Replace with your password
- WiFiClient client; // Create a WiFiClient object
- void setup(void)
- {
- // put your setup code here, to run once:
- Serial.begin(115200);
- while (!Serial);
- Serial1.begin(AT_BAUD_RATE);
- WiFi.init(Serial1);
- if (WiFi.status() == WL_NO_MODULE) {
- Serial.println();
- Serial.println("Communication with WiFi module failed!");
- // don't continue
- while (true);
- }
- // Connect to WiFi
- Serial.println("Connecting to WiFi...");
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED) {
- delay(1000);
- Serial.print('.');
- }
- Serial.println();
- Serial.println("Connected to WiFi network.");
- pinMode(myLED_LED_PIN_D2, OUTPUT);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- }
- void updateOutputs()
- {
- digitalWrite(myLED_LED_PIN_D2, myLED_LED_PIN_D2_rawData);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement