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 Potentiometer
- - Source Code NOT compiled for: Arduino Pro Mini 3.3V
- - Source Code created on: 2024-10-01 08:59:09
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* read and provide pot value via wifi */
- /****** END SYSTEM REQUIREMENTS *****/
- /********* User code review feedback **********
- #### Feedback 1 ####
- - rename header keys.h in key1.h
- #### Feedback 2 ####
- - remove key1.h
- #### Feedback 3 ####
- - change key1.h in key2.h
- #### Feedback 4 ####
- - put credentials into secret.h header for privacy
- #### Feedback 5 ####
- - remove key1 and key2 headers.
- #### Feedback 6 ####
- - add key with credentials on key1.h and call it from ino file.
- ********* User code review feedback **********/
- /****** DEFINITION OF LIBRARIES *****/
- #include <SPI.h> // Include SPI library for communication with the WiFi module
- #include <WiFi.h> // Include WiFi library for WiFi functionality
- #include "key1.h" // Include the header file for WiFi credentials
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF ANALOG INPUT PINS *****/
- const uint8_t pot_Potentiometer_Vout_PIN_A0 = A0; // Define the analog pin for the potentiometer
- void setup(void)
- {
- // Initialize serial communication
- Serial.begin(115200);
- // Connect to WiFi using credentials from key1.h
- WiFi.begin(ssid, password); // Use credentials from key1.h
- Serial.println("Connecting to WiFi...");
- // Wait for connection
- while (WiFi.status() != WL_CONNECTED) {
- delay(1000);
- Serial.println("Connecting...");
- }
- Serial.println("Connected to WiFi");
- // Set the potentiometer pin as input
- pinMode(pot_Potentiometer_Vout_PIN_A0, INPUT);
- }
- void loop(void)
- {
- // Read the potentiometer value
- int potValue = analogRead(pot_Potentiometer_Vout_PIN_A0); // Read the analog value from the potentiometer
- // Print the potentiometer value to the serial monitor
- Serial.print("Potentiometer Value: ");
- Serial.println(potValue);
- // Add a small delay to avoid flooding the serial output
- delay(1000); // Delay for 1 second
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement