Skip to content

Instantly share code, notes, and snippets.

@sfentress
Created April 10, 2012 14:36
Show Gist options
  • Save sfentress/2351803 to your computer and use it in GitHub Desktop.
Save sfentress/2351803 to your computer and use it in GitHub Desktop.
/*
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