Advertisement
belrey10

ADVK2 Potentiometer

Nov 2nd, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 1.18 KB | Source Code | 0 0
  1. // Potentiometer 0 - Serial Plotter: sample code for Arduino Uno & Arduino Mega
  2. //
  3. // Use Serial Plotter in Arduino IDE to inspect potentiometer state in real time!
  4.  
  5. const byte          ANALOG_PIN =   A0;
  6. const unsigned long BAUD_RATE  = 9600;  // serial-port speed in bits per second
  7.  
  8. // These two constants prevent the Serial Plotter from autoscaling the y-axis:
  9.  
  10. const int           PLOT_MIN   =    0;  // lowest value to plot
  11. const int           PLOT_MAX   = 1023;  // highest value to plot
  12.  
  13. void setup() {
  14.   Serial.begin(BAUD_RATE);  // set speed of serial port
  15. }
  16.  
  17. void loop() {
  18.   // Send three values per line (pot, min, max) to serial port for plotting:
  19.   Serial.print("potentiometer:");        // text label (description + colon)
  20.   Serial.print(analogRead(ANALOG_PIN));  // potentiometer state (0 to 1023)
  21.   Serial.print(" minimum:");             // separator (space) + text label
  22.   Serial.print(PLOT_MIN);                // anchor bottom of plot window
  23.   Serial.print(" maximum:");             // separator + text label
  24.   Serial.println(PLOT_MAX);              // anchor top of plot window
  25.   // Call to Serial.println() function above generates end-of-line character(s).
  26. }
Tags: ADVK2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement