Alfred Balle
Alfred Balle

Reputation: 1195

Arduino fails with Serial.println

I've got an Arduino which works with the following basic example for blinking:

void setup() {
  pinMode(13, OUTPUT);
}
void loop() {
  digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(1000);                     // wait for a second
  digitalWrite(13, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                     // wait for a second
}

But if I add Serial.println it doesn't blink and doesn't output anything to the Serial moniter:

void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(115200);
}
void loop() {
  Serial.println("Loop"); 
  digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
  delay(1000);                     // wait for a second
  digitalWrite(13, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                     // wait for a second
}

What am I doing wrong?

Upvotes: 2

Views: 99

Answers (2)

T3homas
T3homas

Reputation: 1

When you change the baud rate in Serial.begin(115200) the receiving terminal should have the same baud rate or you will see nothing there.

Upvotes: 0

Jeremiah
Jeremiah

Reputation: 99

You're not doing anything wrong you may have a bad chip, or your baud rate too high, try 9600

Also can you give me details on your chip, some chips don't have serial. If you're using the same chip as the leonardo you may need this:

Serial.begin(9600);
while (!Serial) {} //Wait for serial port to connect

Upvotes: 0

Related Questions