|
CLASS DOCUMENTS
REPORTS & ASSIGNMENTS
CLASS CONTENT
USING THIS SITE
registered authors login here You are: (logout) For more on PMWiki, see pmwiki.org |
Simple Adc Readsimple ADC reading By Jamie Allen If you get all messed up, just start again with this.
int potPin = 0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val = 0; // variable to store the value coming from the sensor
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
digitalWrite(ledPin, HIGH); // sets the LED off
val = analogRead(potPin); // read the value from the sensor
Serial.print(”Raw Value: “);
Serial.println(val, DEC); // print as an ASCII-encoded decimal
delay(20);
}
|