Advertisement
pleasedontcode

WiFi Potentiometer rev_14

Sep 28th, 2024
74
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-09-28 14:35:56
  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. ********* User code review feedback **********/
  30.  
  31. /****** DEFINITION OF LIBRARIES *****/
  32. #include <SPI.h>  // Include SPI library for communication with the WiFi module
  33. #include <WiFi.h> // Include WiFi library for WiFi functionality
  34.  
  35. /****** FUNCTION PROTOTYPES *****/
  36. void setup(void);
  37. void loop(void);
  38.  
  39. /***** DEFINITION OF ANALOG INPUT PINS *****/
  40. const uint8_t pot_Potentiometer_Vout_PIN_A0 = A0;  // Define the analog pin for the potentiometer
  41.  
  42. /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
  43. const char* ssid = "YOUR_WIFI_SSID";  // Replace with your WiFi SSID
  44. const char* password = "YOUR_WIFI_PASSWORD";  // Replace with your WiFi Password
  45.  
  46. void setup(void)
  47. {
  48.     // Initialize serial communication
  49.     Serial.begin(115200);
  50.    
  51.     // Connect to WiFi
  52.     WiFi.begin(ssid, password);
  53.     Serial.println("Connecting to WiFi...");
  54.    
  55.     // Wait for connection
  56.     while (WiFi.status() != WL_CONNECTED) {
  57.         delay(1000);
  58.         Serial.println("Connecting...");
  59.     }
  60.    
  61.     Serial.println("Connected to WiFi");
  62.    
  63.     // Set the potentiometer pin as input
  64.     pinMode(pot_Potentiometer_Vout_PIN_A0, INPUT);
  65. }
  66.  
  67. void loop(void)
  68. {
  69.     // Read the potentiometer value
  70.     int potValue = analogRead(pot_Potentiometer_Vout_PIN_A0);  // Read the analog value from the potentiometer
  71.    
  72.     // Print the potentiometer value to the serial monitor
  73.     Serial.print("Potentiometer Value: ");
  74.     Serial.println(potValue);
  75.    
  76.     // Add a small delay to avoid flooding the serial output
  77.     delay(1000);  // Delay for 1 second
  78. }
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement