列印出模擬值

int val = 0;    // variable used to store the value
                // coming from the sensor

void setup() {
  Serial.begin(9600); //Begin serializer to print out value

  // Note: Analogue pins are
  // automatically set as inputs
}

void loop() {

  val = analogRead(0); // read the value from
                       // the sensor connected to A0.

  Serial.println(val); //Prints the value coming in from the analog sensor
 
  delay(10); // stop the program for
             // some time
}