Advertisement
pleasedontcode

Potentiometer Reader rev_02

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