I am attempting to control a stepper motor with Sparkfun's Big Easy Driver, and I see the line "Serial.println();" they put in the example code. Why is there no argument and what function does this serve?
//Declare pin functions on Arduino
#define stp 2
#define dir 3
#define MS1 4
#define MS2 5
#define MS3 6
#define EN 7
//Declare variables for functions
char user_input;
int x;
int y;
int state;
void setup() {
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(MS1, OUTPUT);
pinMode(MS2, OUTPUT);
pinMode(MS3, OUTPUT);
pinMode(EN, OUTPUT);
resetBEDPins(); //Set step, direction, microstep and enable pins to default states
Serial.begin(9600); //Open Serial connection for debugging
Serial.println("Begin motor control");
Serial.println();
//Print function list for user selection
Serial.println("Enter number for control option:");
Serial.println("1. Turn at default microstep mode.");
Serial.println("2. Reverse direction at default microstep mode.");
Serial.println("3. Turn at 1/16th microstep mode.");
Serial.println("4. Step forward and reverse directions.");
Serial.println();
}
2 Answers 2
It simply prints a newline to the serial monitor. Just for spacing.
To complement jose can u c's answer: the Arduino Serial object uses
CRLF as the end-of-line marker. That's an ASCII CR (carriage return,
or '\r'
in C) followed by ASCII LF (line feed, '\n'
in C). Thus,
Serial.println();
is equivalent to
Serial.print("\r\n");
-
This is a cool expansion on some fundamental formatting stuff. Thank you for the infoJackalakalaka– Jackalakalaka2019年04月10日 20:23:17 +00:00Commented Apr 10, 2019 at 20:23
ctrl-k
or click the{}
button .... all of the code will be indented by 4 spaces, which causes it to be displayed as code ...... upvote for being concerned with code formattingserial.print("\n");
gives same result asserial.println();
Serial.println()
outputs a'\r'
before the'\n'
, whichSerial.print("\n")
doesn't.