Created
July 19, 2015 22:52
-
-
Save dwblair/cd418a51e3f5a9d9393b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 0, prints the result to the serial monitor. | |
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. | |
This example code is in the public domain. | |
*/ | |
int led = 9; | |
// the setup routine runs once when you press reset: | |
void setup() { | |
// initialize serial communication at 9600 bits per second: | |
Serial.begin(9600); | |
pinMode(led, OUTPUT); | |
} | |
// the loop routine runs over and over again forever: | |
void loop() { | |
// read the input on analog pin 0: | |
int sensorValue = analogRead(A0); | |
// print out the value you read: | |
Serial.println(sensorValue); | |
delay(1); // delay in between reads for stability | |
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) | |
delay(100); // wait for a second | |
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW | |
delay(100); // wait for a second | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment