Skip to content

Instantly share code, notes, and snippets.

@jazzyjackson
Created April 13, 2019 01:41
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 jazzyjackson/4be16b53730a8639690514907d34eb45 to your computer and use it in GitHub Desktop.
Save jazzyjackson/4be16b53730a8639690514907d34eb45 to your computer and use it in GitHub Desktop.
/*
AnalogReadSerial + Power & Ground
Reads an analog input on pin A2, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Plug a potentiometer into A0, A2, and A4.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(A0, OUTPUT);
pinMode(A4, OUTPUT);
digitalWrite(A0, HIGH);
digitalWrite(A4, LOW);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A2);
// print out the value you read:
Serial.println(sensorValue);
tone(9, sensorValue);
delay(1); // delay in between reads for stability
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment