Created
April 10, 2012 14:36
-
-
Save sfentress/2351803 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 | |
Reads an analog input on pin A0, prints the result to the serial monitor | |
This example code is in the public domain. | |
*/ | |
int pin = A0; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(pin, INPUT); // set pin to input | |
// If you are using a resistive sensor with a high resistance (> 5 kOhms) | |
// you can automatically add a 20 kOhm pullup resistor in code by uncommenting to following line: | |
//digitalWrite(pin, HIGH); // turn on pullup resistors | |
} | |
void loop() { | |
int sensorValue = analogRead(pin); | |
Serial.println(sensorValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment