Advertisement
pleasedontcode

Potentiometer Reader rev_01

Oct 30th, 2024
48
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: Potentiometer Reader
  13.     - Source Code NOT compiled for: Arduino Mega
  14.     - Source Code created on: 2024-10-30 22:22:12
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* read pot each second and print on serial. */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /****** DEFINITION OF LIBRARIES *****/
  24.  
  25. /****** FUNCTION PROTOTYPES *****/
  26. void setup(void);
  27. void loop(void);
  28.  
  29. /***** DEFINITION OF ANALOG INPUT PINS *****/
  30. const uint8_t pot_Potentiometer_Vout_PIN_A0 = A0;
  31.  
  32. // Variable to store the potentiometer value
  33. int potValue = 0;
  34.  
  35. void setup(void)
  36. {
  37.     // Initialize serial communication at 9600 bits per second
  38.     Serial.begin(9600);
  39.    
  40.     // Set the potentiometer pin as an input
  41.     pinMode(pot_Potentiometer_Vout_PIN_A0, INPUT);
  42. }
  43.  
  44. void loop(void)
  45. {
  46.     // Read the potentiometer value from the analog pin
  47.     potValue = analogRead(pot_Potentiometer_Vout_PIN_A0);
  48.    
  49.     // Print the potentiometer value to the serial monitor
  50.     Serial.println(potValue);
  51.    
  52.     // Wait for 1 second before the next reading
  53.     delay(1000);
  54. }
  55.  
  56. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement