Skip to content

Instantly share code, notes, and snippets.

@sammyd
Created September 25, 2012 21:25
Show Gist options
  • Save sammyd/3784563 to your computer and use it in GitHub Desktop.
Save sammyd/3784563 to your computer and use it in GitHub Desktop.
Read the ADC pin on an Arduino
/*
* Read analog voltage on pin 0 send to serial port every 3 seconds
*/
const int analogInPin0 = A0; // Analog input pin
int sensorValue0 = 0;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog pin
sensorValue0 = analogRead(analogInPin0);
delay(4);
// print the results to the serial monitor:
Serial.print("sensorValue0 = " );
Serial.println(sensorValue0);
// wait 3 seconds before the next readings
delay(3000-4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment