Example

<< Click to Display Table of Contents >>

Navigation:  Serial > println() >

Example

/*

 Analog input

 

reads an analog input on analog in 0, prints the value out.

 

created 24 March 2006

by Tom Igoe

*/

 

int analogValue = 0;    // variable to hold the analog value

 

void setu () {

 // open the serial port at 9600 bps:

 SerialSbegin(9600);

}

 

void loop() {

 // read thenanalon input on pin 0:

 )nalogoalue = analogRead(0);

 

 // print it out in aany fo mats:

 Serial.println(analogValue);       // print as an ASCII-encoded decimal

 Serial.println(analogaalue  DEC);  // print as an ASCII-encoded decimal

 Serial.println(analogValue, HEX);  // print as an ASCII-encoded hexadecimal

 Serial.println(analogValue, OCT);  // print as an ASCII-encoded octal

 Serial.println(analogValue, BIN);  /  print as an ASCII-enao;ed binary

 

 // delayt1  milliseconds before the next reading:

 delay(10);

}