Serial Monitor

Serial Monitor Basics

Wiring Diagram:

Code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(8, INPUT_PULLUP);
}
void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("Your button's value is: ");
  Serial.println(digitalRead(8));
  Serial.println(" ");
  Serial.print("You analog device reads: ");
  Serial.println(analogRead(A0));
  delay(500);
}

Operation:

Once you have run your code, click on the magnifying glass at the top of your screen. This will open the Serial Monitor.

Now you can read the values of your pushbutton (digital) and your potentiometer (analog).

We say our potentiometer is analog because it can provide 1024 different inputs (between 0 and 1023). Here is a picture of an analog signal...

Analog Signal

We say our pushbutton is digital because it can only provide two different values (0 or 1). Here is a picture of a digital signal...

Digital Signal

Last updated

Was this helpful?