Advertisement
pleasedontcode

WiFi Potentiometer rev_22

Oct 1st, 2024
57
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 Potentiometer
  13.     - Source Code NOT compiled for: Arduino Pro Mini 3.3V
  14.     - Source Code created on: 2024-10-01 09:24:44
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* read and provide pot value via wifi */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /********* User code review feedback **********
  25. #### Feedback 1 ####
  26. - rename header keys.h in key1.h
  27. #### Feedback 2 ####
  28. - remove key1.h
  29. #### Feedback 3 ####
  30. - change key1.h in key2.h
  31. #### Feedback 4 ####
  32. - put credentials into secret.h header for privacy
  33. #### Feedback 5 ####
  34. - remove key1 and key2 headers.
  35. #### Feedback 6 ####
  36. - add key with credentials on key1.h and call it from ino file.
  37. #### Feedback 7 ####
  38. - don't manage the file where there is no code inside.
  39. #### Feedback 8 ####
  40. - remove key1.cpp and key2.h
  41. #### Feedback 9 ####
  42. - put wifi credentials into key.h and remove all other source code
  43. s.
  44. #### Feedback 10 ####
  45. - remove "key2.h"
  46. ********* User code review feedback **********/
  47.  
  48. /****** DEFINITION OF LIBRARIES *****/
  49. #include <SPI.h>  // Include SPI library for communication with the WiFi module
  50. #include <WiFi.h> // Include WiFi library for WiFi functionality
  51.  
  52. /****** FUNCTION PROTOTYPES *****/
  53. void setup(void);
  54. void loop(void);
  55.  
  56. /***** DEFINITION OF ANALOG INPUT PINS *****/
  57. const uint8_t pot_Potentiometer_Vout_PIN_A0 = A0;  // Define the analog pin for the potentiometer
  58.  
  59. // WiFi credentials
  60. const char* ssid = "your_SSID";  // Replace with your WiFi SSID
  61. const char* password = "your_PASSWORD";  // Replace with your WiFi password
  62.  
  63. void setup(void)
  64. {
  65.     // Initialize serial communication
  66.     Serial.begin(115200);
  67.    
  68.     // Connect to WiFi using credentials
  69.     WiFi.begin(ssid, password);  // Use credentials defined above
  70.     Serial.println("Connecting to WiFi...");
  71.    
  72.     // Wait for connection
  73.     while (WiFi.status() != WL_CONNECTED) {
  74.         delay(1000);
  75.         Serial.println("Connecting...");
  76.     }
  77.    
  78.     Serial.println("Connected to WiFi");
  79.    
  80.     // Set the potentiometer pin as input
  81.     pinMode(pot_Potentiometer_Vout_PIN_A0, INPUT);
  82. }
  83.  
  84. void loop(void)
  85. {
  86.     // Read the potentiometer value
  87.     int potValue = analogRead(pot_Potentiometer_Vout_PIN_A0);  // Read the analog value from the potentiometer
  88.    
  89.     // Print the potentiometer value to the serial monitor
  90.     Serial.print("Potentiometer Value: ");
  91.     Serial.println(potValue);
  92.    
  93.     // Add a small delay to avoid flooding the serial output
  94.     delay(1000);  // Delay for 1 second
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement