Advertisement
pleasedontcode

**WiFi Control** rev_01

Mar 4th, 2025
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **WiFi Control**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-03-04 17:17:10
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* crea un codice su arduino per un progetto di un */
  21.     /* led comandato tramite wifi su esp32 */
  22. /****** END SYSTEM REQUIREMENTS *****/
  23.  
  24. /* START CODE */
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <WiFiEspAT.h> // Include WiFi library
  28.  
  29. // Emulate Serial1 on pins 6/7 if not present
  30. #if defined(ARDUINO_ARCH_AVR) && !defined(HAVE_HWSERIAL1)
  31. #include <SoftwareSerial.h>
  32. SoftwareSerial Serial1(6, 7); // RX, TX
  33. #define AT_BAUD_RATE 9600
  34. #else
  35. #define AT_BAUD_RATE 115200
  36. #endif
  37.  
  38. /****** FUNCTION PROTOTYPES *****/
  39. void setup(void);
  40. void loop(void);
  41.  
  42. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  43. const uint8_t myLED_LED_PIN_D2 = 2;
  44.  
  45. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  46. /***** used to store raw data *****/
  47. bool myLED_LED_PIN_D2_rawData = 0;
  48.  
  49. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  50. /***** used to store data after characteristic curve transformation *****/
  51. float myLED_LED_PIN_D2_phyData = 0.0;
  52.  
  53. // WiFi credentials
  54. const char* ssid = "your_SSID"; // Replace with your SSID
  55. const char* password = "your_PASSWORD"; // Replace with your password
  56.  
  57. WiFiClient client; // Create a WiFiClient object
  58.  
  59. void setup(void)
  60. {
  61.     // put your setup code here, to run once:
  62.     Serial.begin(115200);
  63.     while (!Serial);
  64.  
  65.     Serial1.begin(AT_BAUD_RATE);
  66.     WiFi.init(Serial1);
  67.  
  68.     if (WiFi.status() == WL_NO_MODULE) {
  69.         Serial.println();
  70.         Serial.println("Communication with WiFi module failed!");
  71.         // don't continue
  72.         while (true);
  73.     }
  74.  
  75.     // Connect to WiFi
  76.     Serial.println("Connecting to WiFi...");
  77.     WiFi.begin(ssid, password);
  78.     while (WiFi.status() != WL_CONNECTED) {
  79.         delay(1000);
  80.         Serial.print('.');
  81.     }
  82.     Serial.println();
  83.     Serial.println("Connected to WiFi network.");
  84.  
  85.     pinMode(myLED_LED_PIN_D2, OUTPUT);
  86. }
  87.  
  88. void loop(void)
  89. {
  90.     // put your main code here, to run repeatedly:
  91.     updateOutputs(); // Refresh output data
  92. }
  93.  
  94. void updateOutputs()
  95. {
  96.     digitalWrite(myLED_LED_PIN_D2, myLED_LED_PIN_D2_rawData);
  97. }
  98.  
  99. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement