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 compiled for: Arduino Pro Mini 3.3V
- - Source Code created on: 2024-09-27 23:22:17
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* read and provide pot value via wifi */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** 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 "keys.h" // Include the keys.h 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
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
- const char* ssid = WIFI_SSID; // WiFi SSID from keys.h
- const char* password = WIFI_PASSWORD; // WiFi Password from keys.h
- void setup(void)
- {
- // Initialize serial communication
- Serial.begin(115200);
- // Connect to WiFi
- WiFi.begin(ssid, password);
- 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
- }
- /****** DEFINITION OF CREDENTIALS IN keys.h *****/
- #ifndef KEYS_H
- #define KEYS_H
- // Define WiFi credentials
- extern const char* WIFI_SSID; // WiFi SSID
- extern const char* WIFI_PASSWORD; // WiFi Password
- extern const char* DEVICE_ID; // Device ID
- extern const char* DEVICE_TOKEN; // Device Token
- #endif // KEYS_H
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement