I'm sending data over serial which should cause functions to fire on the unit. This is not happening. I want to use the onboard LED to blink when digitalWrite is called since I cannot print to the serial monitor (I get an error when I try). The blinking will tell me if my function is being called. So this is not an excercise in getting the light itself just to blink.
When I send data over serial to the mega the onboard lights go haywire, even thought I have no calls turning them on anywhere. I even explicity turn them off. This activity ruins my ability to use the lights as I want.
I've googled but all I get is the Blink tutorial. How can I do this? Where can I find out more about this particular blinkig during transfer activity?
This is a compact gist so there might be syntax errors. This is not runnable. I just want to know how to use the lights as I asked, which would not be related to any particular code anyway.
How? I have serial port open and data is going over it. That seems like the same port that the monitor uses.
I have tried this long before posting here.
That would suggest you are doing something wrong. Using serial print is a standard way of debugging.
How are you trying to debug? Note it needs to be a different serial channel than the one you are trying to use for your serial transfer.
What Arduino are you using?
You did but you did not post all your code.
What do you want to trigger this, if it is just a line of code then use digital write to turn it on when you send stuff, and turn it off some time later, maybe even use delay before turning it off just to test when your code is getting to that point.
Ok, I'll look at this again and see if I can get it to work. But the data is all coming in via USB which for me is COM8. Seems like the monitor uses this too maybe, and so cannot be used while data is going over it. I wasn't able to find another question about this issue but I did try.
My code is too dense to post as is. I'll post a more thourough example though.
what microcontroller are you using?
A lot of microcontrollers (but not all) have mimimum two hardware-UARTs or are fast enough to send data over two serial connections.
One for your application one for the serial debugging.
This requires a second USB-to-TTL-converter but you can buy them for 5 to 10$
Another option is to use such a logic analyser https://www.ebay.de/itm/314021190415
You can even do decoding a lot of protocols including serial 8N1 etc.
I mentioned I'm using a mega in my post. It has 4 serial ports. The serial monitor is blocked by the incoming serial data and I can't use it concurrently. If I want help with this, I'll ask a separate question. Thanks for the other debugging info.
My question here is about the lights. How do I do what I asked with the lights?
As long as data is in the serial buffer, the LED will be off, once you have read evevrything it will be on.
What is at the receiving end? How much control do you have over it? If it's some software that you wrote, you can add debug functionality to it.
Do you have a TTL-to-USB breakout board? You can hook that up to the Mega (e.g. Serial1) If not, do you have an Uno or Nano? If so, you can use them as a TTL-to-USB converter and use e.g. the Mega's Serial1 as your debug port; keep Uno/Nano in reset (with a wire), Mega TX1 to Uno/Nano TX, Mega RX1 to Uno/Nano RX and on the Mega, use e.g. Serial1.print.