Serial print issue

Hello,

I am new here, and I am just beginning with Arduino. I bought myself a UNO, and I write my programs on Arduino IDE 1.8.19.

Yet, I cannot figure out how to serial print the values I want, even if I took the pre-written Arduino program:

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  delay(1);
}

I do know that the connecting is correct (I looked it up on Arduino's website) but I don't know why the value doesn't print.

Do I have to upload a specific library, or is there another issue here?

Thank you for your time and attention.

Eagle.

Welcome to the forum

No extra library needed

What baud rate do you have the Serial monitor set to ?
Can you print text OK ?

At what step do you get stuck?

Can you select "Verify/Compile" from the "Sketch" menu and have the sketch compile without error? The band just below the sketch should say "Done compiling.".

Can you select "Sketch -> Upload" and have the sketch uploaded to your Arduino UNO without error? The band just below the sketch should say "Done uploading.".

Can you select "Tools -> Serial Monitor" and have the Serial Monitor window pop up? Does the baud setting at the bottom of Serial Monitor match the baud rate you used in Serial.begin()?

@eagle84eagle I know you are new and that the forum you posted in is badly named but:-
Installation and Troubleshooting is for Problems with the Arduino IDE itself NOT your project. It says so in the description of the section. Therefore I have moved your post here. Please be more careful where you post in future.

You may want to read this before you proceed:-
how to get the best out of this forum

@eagle84eagle
1. Please, check that Baud Rate of the Serial Monitor (Fig-1) is set at 9600.
2. Change delay(1); to delay(1000); in the sketch of post #1.
3. Remove everything from A0-pin (if you have connected anything) and then connect 3.3V of the UNO Bard with A0-pin using a short jumper.

4. Check that display shows about 675 at 1-sec interval.


Figure-1:

Quick tip ( for the future ) is to print some text ( ( eg “Go!”) after your serialbegin line in setup.

Helps to determine if you have a problem further on in your sketch by showing that print is working ok .

Finally an obvious one - you are uploading using a USB lead and keeping this in place to view on the monitor ( on the same port setting )

Serial.begin(9600);

I prefer to have a BlinkNcount sketch to test boards; here is one for UNO'ish AVR 8-bit board:

/*
  BlinknCount on AVR Nano/Atmega328P; Windows 10 Pro; 20210720 tested
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  Sketch uses 2322 bytes (7%) of program storage space. Maximum is 30720 bytes.
  Global variables use 234 bytes (11%) of dynamic memory, leaving 1814 bytes for local variables. Maximum is 2048 bytes.
  Micro ------------------------
  Sketch uses 4364 bytes (15%) of program storage space. Maximum is 28672 bytes.
  Global variables use 199 bytes (7%) of dynamic memory, leaving 2361 bytes for local variables. Maximum is 2560 bytes.
 */

#include <Streaming.h>        // requires library from http://arduiniana.org/libraries/streaming/
#define BOARD_LED_PIN 13      // most 8-bit AVR boards
#define BAUD          9600
#define ON_Time       750     // mS
#define OFF_Time      250

int n = 0;

void setup() {                
  // initialize the digital pin as an output.
  pinMode(BOARD_LED_PIN, OUTPUT);
  Serial.begin(BAUD);
  Serial << "Blink LED & count Demo" << "\n \r" << "by MRB" << "\n\r\n\r" ; 
}

void loop() {
  digitalWrite(BOARD_LED_PIN, HIGH);   // set the LED on
  delay(ON_Time);                      // wait
  digitalWrite(BOARD_LED_PIN, LOW);    // set the LED off
  delay(OFF_Time);                     // wait
  Serial << "Loop #: " << ++n << "\n\r" ;
}

That requires people to read and interpret that description. :roll_eyes:

Yes but posting any response requires people to read and interpret the answers you post.

Look I am no fan of this. I think it is one of the most stupid labels there is. The people who look after these things point blank refuse to change it. Go complain to them. Stop carping to me about it.

So little point explaining anything. :roll_eyes:

If I was carping to you, I would use a PM. :grin:

Clearly no-one is "looking after these things" in any respect. :face_with_raised_eyebrow:

Can the title of this be renamed to, "Chasing souls away in ten posts?"

Oh, I didn't know that we had to open the Serial Monitor manually, I thought that it would open itself automatically. Thanks a lot for your answer, and for anyone's answers as well.

1 Like

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