Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. /*
  2. AnalogReadSerial
  3.  
  4. Reads an analog input on pin 0, prints the result to the Serial Monitor.
  5. Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  6. Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
  7.  
  8. This example code is in the public domain.
  9.  
  10. http://www.arduino.cc/en/Tutorial/AnalogReadSerial
  11. */
  12.  
  13. int analog = A0;
  14.  
  15. // the setup routine runs once when you press reset:
  16. void setup() {
  17. // initialize serial communication at 9600 bits per second:
  18. Serial.begin(9600);
  19. }
  20.  
  21. // the loop routine runs over and over again forever:
  22. void loop() {
  23. // read the input on analog pin 0:
  24. int sensorValue = analogRead(analog);
  25. // print out the value you read:
  26. Serial.println(sensorValue);
  27. delay(50); // delay in between reads for stability
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement