pleasedontcode

WiFi Controller rev_03

Jul 27th, 2025
168
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 Controller
  13.     - Source Code NOT compiled for: Arduino Opta WiFi
  14.     - Source Code created on: 2025-07-27 15:11:27
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Implement a WiFi connection setup using the */
  21.     /* Arduino Opta WiFi module to enable wireless */
  22.     /* communication for the project. Use the onboard */
  23.     /* WiFi resources to connect to a specified network. */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /* START CODE */
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <Adafruit_NeoPixel.h>  //https://github.com/adafruit/Adafruit_NeoPixel
  30. #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
  31. #include <WiFi.h> // Include WiFi library for Arduino Opta WiFi module
  32.  
  33. /****** FUNCTION PROTOTYPES *****/
  34. void setup(void);
  35. void loop(void);
  36. void connectWiFi(void);
  37.  
  38. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  39. const uint8_t button_PushButton_PIN_A0 = A0;
  40.  
  41. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  42. const uint8_t myLED_RGB_LEDRGB_Red_PIN_D0 = 0;
  43. const uint8_t myLED_RGB_LEDRGB_Green_PIN_D1 = 1;
  44. const uint8_t myLED_RGB_LEDRGB_Blue_PIN_D2 = 2;
  45.  
  46. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  47. /***** used to store raw data *****/
  48. bool myLED_RGB_LEDRGB_Red_PIN_D0_rawData = 0;
  49. bool myLED_RGB_LEDRGB_Green_PIN_D1_rawData = 0;
  50. bool myLED_RGB_LEDRGB_Blue_PIN_D2_rawData = 0;
  51.  
  52. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  53. /***** used to store data after characteristic curve transformation *****/
  54. float myLED_RGB_LEDRGB_Red_PIN_D0_phyData = 0.0;
  55. float myLED_RGB_LEDRGB_Green_PIN_D1_phyData = 0.0;
  56. float myLED_RGB_LEDRGB_Blue_PIN_D2_phyData = 0.0;
  57.  
  58. /****** WiFi credentials *****/
  59. const char* ssid = "Your_SSID"; // Replace with your WiFi network SSID
  60. const char* password = "Your_PASSWORD"; // Replace with your WiFi password
  61.  
  62. /****** LIBRARY CLASS INSTANCES *****/
  63. // No specific instances needed for WiFi, using the WiFi library functions
  64.  
  65. void connectWiFi() {
  66.   Serial.println("Connecting to WiFi...");
  67.   WiFi.begin(ssid, password);
  68.   while (WiFi.status() != WL_CONNECTED) {
  69.     delay(500);
  70.     Serial.print(".");
  71.   }
  72.   Serial.println("");
  73.   Serial.println("WiFi connected");
  74.   Serial.print("IP address: ");
  75.   Serial.println(WiFi.localIP());
  76. }
  77.  
  78. void setup(void)
  79. {
  80.   // put your setup code here, to run once:
  81.  
  82.   Serial.begin(115200);
  83.   // Connect to WiFi
  84.   connectWiFi();
  85.  
  86.   pinMode(button_PushButton_PIN_A0, INPUT_PULLUP);
  87.  
  88.   pinMode(myLED_RGB_LEDRGB_Red_PIN_D0, OUTPUT);
  89.   pinMode(myLED_RGB_LEDRGB_Green_PIN_D1, OUTPUT);
  90.   pinMode(myLED_RGB_LEDRGB_Blue_PIN_D2, OUTPUT);
  91. }
  92.  
  93. void loop(void)
  94. {
  95.   // put your main code here, to run repeatedly:
  96.  
  97.   updateOutputs(); // Refresh output data
  98. }
  99.  
  100. void updateOutputs()
  101. {
  102.   digitalWrite(myLED_RGB_LEDRGB_Red_PIN_D0, myLED_RGB_LEDRGB_Red_PIN_D0_rawData);
  103.   digitalWrite(myLED_RGB_LEDRGB_Green_PIN_D1, myLED_RGB_LEDRGB_Green_PIN_D1_rawData);
  104.   digitalWrite(myLED_RGB_LEDRGB_Blue_PIN_D2, myLED_RGB_LEDRGB_Blue_PIN_D2_rawData);
  105. }
  106.  
  107. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment