When I used Serial.println()
in the code I naively believed I would see the characters that I sent displayed on that little black area just under the interface (just like a terminal).
#include <Servo.h>
int moveServo;
Servo myservo;
void setup()
{
myservo.attach(0);
Serial.println(" Hello Earth");
Serial.println();
}
void loop() {
}
Can someone tell me just where Hello Earth
would be displayed?
2 Answers 2
The IDE on your computer has a menu item under the tools menu called "Serial Monitor." On my Mac, at least, it is indeed a black area under the source editor for the current sketch.
It won't work unless you call the Serial.begin()
function in your setup method before the first Serial.print()/println()/write()
function call.
Something like this:
//Set up the serial port @ 9600 baud for display back to the computer
Serial.begin(9600);
delay(25);
Serial.println("Hello world!":);
You can open the serial console in the Arduino IDE by pressing ctrl-shift-M (as in Monitor) or selecting it in the menu.
Also, to use the serial interface, you have to initialize it using Serial.begin(9600);
in setup()
before calling any other function which writes to it. You can use any other baud rate - but this is the default in the Arduino IDE, if you change it, you should change it in the IDE too.