Skip to content

Instantly share code, notes, and snippets.

@peow2373
Created March 11, 2020 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peow2373/20cf1417168f5f21c2b0adbd628df4c4 to your computer and use it in GitHub Desktop.
Save peow2373/20cf1417168f5f21c2b0adbd628df4c4 to your computer and use it in GitHub Desktop.
Reads the values from two analog inputs and prints those values to the serial monitor
// These constants won't change. They're used to give names to the pins used:
int analogInPin1 = A0; // Analog input pin that the first potentiometer is attached to
int analogInPin2 = A1; // Analog input pin that the second potentiometer is attached to
int sensorValue1 = 0; // value read from the first potentiometer
int sensorValue2 = 0; // calue read from the second potentiometer
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue1 = analogRead(analogInPin1);
// read the analog in value:
sensorValue2 = analogRead(analogInPin2);
// print the analog inputs to the Serial Monitor:
Serial.print(sensorValue1);
Serial.print("||");
Serial.println(sensorValue2);
// wait 5 milliseconds before the next loop for the analog-to-digital
// converter to settle after the last reading:
delay(5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment