Created
April 13, 2019 01:41
-
-
Save jazzyjackson/4be16b53730a8639690514907d34eb45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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