Serial Print Not Displaying

Good morning.

I am new to using the Arduino. My aim is to have a programme that will display the time on a LCD and also trigger events each second, minute and hour.

I have built a working LCD clock using a guide from Instructables and am now trying to include a trigger for the events. I found some code from another guide and have merged the two.

The new programme compiles and loads correctly, but does not appear to execute. The display continues to operate correctly, but when I open the serial monitor, nothing shows in it. I wish to use the monitor to check what the time is and to monitor events as I try to create them.

I have posted my code in the attachment: would anyone be able to suggest quite where I have gone wrong? The serial print section is at the end of the code.

Thank you.

James

LED_Timer_Controller.ino (8.31 KB)

Where in the program do you call the trigger_LED() function ?

 digitalWrite(99, HIGH);

How many digital pins does your Arduino have ?

I have not written the trigger in yet as I wanted to get the serial print working first. I shall probably put it where I the current trigger is and define it in set up. I plan to use pin 13 with the built-in LED for testing. The reference to pin 99 is a dummy from the example code that I used.

I am using an Uno board.

Please read the post by Nick Gammon at the top of the Forum on how to post here, especially the use of code tags when presenting source code. For smaller programs, attaching the code is not a good idea as a lot of people here do not like to open unknown files. Also, before you post your code using code tags, use Ctrl-T in the IDE. It will reformat your code into a standard style format.

OK. Let's take this slowly

The only place in the code where you Serial.print() anything is in the trigger_LED() function
Your program does not call the trigger_LED() function

Can you see why you might not be seeing any serial output ?

Bob,

Thank you. I have put a call to the trigger_LED function in the void loop now and it is working as hoped. I was concentrating on trying to get the function written, I forgot about actually calling it.

I had also set the wrong baud rate in my original code, which cannot have helped.

Regards,

James.

catceefer:
Bob,

Thank you. I have put a call to the trigger_LED function in the void loop now and it is working as hoped. I was concentrating on trying to get the function written, I forgot about actually calling it.

I had also set the wrong baud rate in my original code, which cannot have helped.

Regards,

James.

I don't understand your last comment. How can you set a wrong baud rate? The serial print generates a clock signal that is sent with the data. The receiver, your computer, uses that clock signal to interpret the data. What ever baud rate you specified will be used.

Paul

I don't understand your last comment. How can you set a wrong baud rate? The serial print generates a clock signal that is sent with the data. The receiver, your computer, uses that clock signal to interpret the data. What ever baud rate you specified will be used.

Would you care to expand on that ?

If you print at say, 9600 baud, and set the receive rate at say 115,200 baud you will see no sensible output in the Serial monitor.

UKHeliBob:
Would you care to expand on that ?

If you print at say, 9600 baud, and set the receive rate at say 115,200 baud you will see no sensible output in the Serial monitor.

The USB connection is bi-directional with data sent at the clock rate. Each device sends it’s own clock frequency. Where would you set a receive clock frequency that would override that sent from the PC?

Paul

Paul_KD7HB:
The USB connection is bi-directional with data sent at the clock rate. Each device sends it's own clock frequency. Where would you set a receive clock frequency that would override that sent from the PC?

Paul

Try it. Write a sketch that puts out a few sentences over serial and use Serial.begin(9600) in the code. Then open the Serial monitor and set the baud rate on the Serial Monitor to 115200. Run the code. See the nonsense characters. Understand.

I think that we might be talking at cross purposes here, so let's find out.

Try this code

void setup()
{
  Serial.begin(9600);
  Serial.println("Hello World");
}

void loop()
{
}

If you were to set the baud rate of the Serial monitor to 115200 what would you expect to see when you open it ?

UKHeliBob:
I think that we might be talking at cross purposes here, so let's find out.

Try this code

void setup()

{
 Serial.begin(9600);
 Serial.println("Hello World");
}

void loop()
{
}



If you were to set the baud rate of the Serial monitor to 115200 what would you expect to see when you open it ?

Doing exactly this, as an experiment, with my code that was printing perfectly rendered the text in the serial monitor as gibberish. Reverting to 9600 in the code, to match the board settings, reverted to legible text. Useful confirmation of one of original errors.

Regards,

James.

I await Paul's reply with interest.

UKHeliBob:
I await Paul's reply with interest.

Paul's response:
Thank you all for the test. I was wrong in my assumption that USB had both data and clock signals. Similar to PS/2 and SPI. Wrong.

This morning I asked Wikipedia about USB and finally, towards the end, I see the data lines are differential, NRZI. Not needing "ground" reference. The communication packet/message begins with with a sync character, hence the need for a USART on the Arduino.

A second clue, which I always see, but did not make a connection, is the Arduino development environment always looking for an Arduino on a COM? port on the USB connector. The program is using terminal emulation, RS-232 emulation, to talk to the arduino, but going through the USB. They are not using native USB communication.

This is the basic reason both devices need the same "baud rate". The boot loader on the Arduino must also be using terminal emulation.

Thank you all for the help. Now it's time to go shovel snow!

Paul

Paul_KD7HB:
Now it's time to go shovel snow!

I'm jealous, haven't seen snow in years.

sterretje:
I'm jealous, haven't seen snow in years.

Just got back from clearing about 12 inches new so I can get a vehicle out of the garage and onto the not plowed, but well traveled road. And, still coming down. 17 degrees.

I have an Arduino program to test, but need to get to the shop so I can use a scope to see the results. I suppose it can wait for a bit longer. March, perhaps!

Paul

We only got a couple inches, 7 HP Husqvarna snowblower took care of it pretty quick. Warm weather later this week should melt off any I missed.