Serial.println
Serial is useful for sending information and data back to your computer, from Arduino. Arduino can pass this information through the USB cable to your computer. Your computer can then show it to you.
Serial.println
Inputs
It takes several different kinds of inputs.
- a String in quotes, like this:
Serial.println("Hello!");
- an
int
or another type of number, like this:Serial.println(5);
- a reading from an Awesome Shield component, like this:
Serial.println(awesome.knob.reading());
- a variable (in this case called
brightness
), like this:Serial.println(brightness)
;
Result
It sends the input back to your computer as text. You can view this text by clicking the magnifying glass icon in the top right hand corner of your Arduino IDE window.
Example
// create a variable called brightness
// and set the variable equal to a lightSensor reading
int brightness = awesome.lightSensor.reading();
// send the value of the brightness variable
// over the Serial connection
Serial.println(brightness);
Tips
Serial.println()
is really helpful if you want to see the live value of a variable while the Arduino is running your program.