Can't get info to the Serial Monitor

I am new, so I am probably doing something I should not do. I simply trying to display a value for C ,
It complies with no problem. I have selected my Arduino Board "Arduino Uno Rev 4 Minima" and the port: /dev/cu.usbmodem14601. Is there something I am missing? I am trying to keep it simple to see if I can get the serial monitor to work. Mike

My code is:
void setup() {

// put your setup code here, to run once:

Serial.begin(9600);
int a = 2;
int b = 2;
int c = a + b;
Serial .print (c);
}

void loop() {
// put your main code here, to run repeatedly:

}

what bit-rate is the Serial.monitor set to (bottom right)?

are you using the Arduino IDE's serial monitor?

It is set to /dev/cu.usbmodem14601

This contains a space before the dot/fullstop/period. Remove that space.

I am using a MAC

I have all already changed it to: Serial .println (c);

Where I have placed the X, you have a space. remove it and try again.

I removed the space and re complied wich went ok but still nothing on the serial monitor.

// 02_04_add

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);

int a = 2;

int b = 2;

int c = a + b;

Serial.println(c);

}

void loop() {

// put your main code here, to run repeatedly:

}

It even works with the space . And the baudrate has no meaning because the R4 Minima has a native USB port.

@makeors : which IDE version are you using? The problem is, that USB connection must be established after upload, and that takes time. You need to wait after the Serial.begin:

void setup() {

// put your setup code here, to run once:

Serial.begin(9600);
while(!Serial);
int a = 2;
int b = 2;
int c = a + b;
Serial .print (c);
}

void loop() {
// put your main code here, to run repeatedly:

}

Another point is, that after uploading, the port cannot be opend ( because the connection is not yet astablished. This at least with IDE 1.8.9 . You must close and reopen the monitor after uploading.

[Edit] With IDE2 it works directly after uploading ( but waiting with 'while' is mandatory!)..

2 Likes

That space is not the problem, even

Serial      .     print     (c);

works correctly

2 Likes

It worked problem-solved!

Thank you! Mike

1 Like

I did not expect this. Any whitespace, anywhere. Thank you.

1 Like

even this:

Serial 
    .  
       print 
  (c)
      ;

works.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.