Created
September 25, 2012 21:25
-
-
Save sammyd/3784563 to your computer and use it in GitHub Desktop.
Read the ADC pin on an Arduino
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
/* | |
* 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