Hi people, is there a way to lcd.print("uploading") if updating the sketch? I know it seems a little pedantic but I hate how my lcd screen freezes on its last print whilst updating.
Cheers. Rob.
ok cool. I take that as arduino sketch, a nano, and LCD I2c is not capable of this then.
@RobMormile ignore comments by @script-writer, it's a generative AI bot.
Short answer is no, you can't. The Nano gets no warning from your pc/laptop that the upload is about to happen, so it can't update the LCD to show "updating" before the upload begins.
yeah thought thats the case. Sounds like it needs to be a code in arduino sketch program itself.
Thanks for the responses.
Like I said, that won't work. The Nano won't know when to print "uploading" to the LCD. There is no signal from the pc/laptop to the Nano to forewarn it that the upload is about to start.
It might be possible to create a custom bootloader to do it, but that is very advanced stuff. Also that custom bootloader would be much larger than a regular bootloader so would significantly reduce the available space for your sketches.
One possibility would be to connect the reset pin of the LCD to the reset pin of the Nano, so that when the upload starts, the Nano and LCD are reset simultaneously. That would clear the LCD. However, the reset pin of the LCD is not easily accessible if you are using an LCD with an i2c backpack. You could try soldering an extra wire to the LCD reset pin.
EDIT: my bad, the most common type of LCD don't have a reset pin, so this idea won't work. (Thanks @bperrybap )
Another possibility...
You could power the LCD from an Arduino pin, or at least use an Arduino pin to control the power to the LCD. That way, as soon as the upload starts, power would be cut to the LCD. When the upload is done and your sketch starts running, it can set the pin HIGH to power up the LCD.
If the LCD is 16x2 character with a single backlight LED, the current it draws should be modest and an Arduino pin may be able to handle it directly. For larger LCDs like 20x4 or graphic LCDs, these have multiple backlights and the current will be too high for an Arduino pin to supply it directly, so you would need to use a transistor.
I like that idea ![]()
Such a bootloader would become a rather big program, because it must include the entire display library in order to address the display and print on it. Once you change or remove the display you risk that the bootloader won't work any more.
It could be done with or without a hw mod, and a little bit of extra code.
Tie RST to an INT pin also, and let an ISR write the message on the LCD. Works if there's enough delay before RST pin changes state, otherwise a modification is needed to create such.
Of course this works the same when you otherwise do a reset, so perhaps a message "Reset / Uploading new sketch" would settle our pedantic attention for details ![]()
nice.
How, exactly? Why would an interrupt be triggered before the reset pin changes state?
Reserve your judgement until @ledsyn explains how that might work.
If the reset circuit by its design create a delay (long enough). I'm not saying it is, but if. Otherwise a delay can be created in hardware. It all goes to how much work one wanna put into it.
Why don't you take a look at the schematic for the Nano, and let us know if you think it does create a delay that could be used to trigger an interrupt a sufficient length of time before the reset occurs?
I have, and I'm not confident there is.
But there are other ways:
Route reset to some other pin, or program reset pin to normal IO. In sketch write to display upon reset, set watchdog timer and do nothing.
My view is that development which includes uploading is very different than normal operation. In this case what you wanting is a visual effect during uploads.
While it may not be what you want, there is already a visual happening on the screen. Especially if you turn on upload messages in the IDE.
My opinion on this, is that while it is possible to do something like you want. It is not trivial and would required custom h/w and s/w.
i.e. h/w mods to your Arduino board, a custom bootloader, and some custom code in the sketch.
IMO, not worth it.
more details below.
---- bill
IMO, this idea of trapping RESET is theoretically possible but requires quite a few mods (h/w and s/w) and simply isn't worth it.
You can't re-progam the reset pin on a processor to be normal. It is a h/w reset.
You may not understand how the Arduino auto-reset and bootloader upload works.
The serial port DTR or RTS signal is wired nearly directly to the reset pin on the processor. (sometimes through a resistor)
If using DTR a capacitor changes an active low signal into a momentary pulse to allow the processor to run.
But basically the trigger for starting a upload is resetting the processor to force it back to the bootloader code.
This reset forces the processor into the bootloader (without warning) where the bootloader, depending on a few conditions, either jumps directly to the application code (sketch) or looks for some serial data for a short period (like 0.5 second) of time to start a download. If there are no commands that come in from the serial port in that period, it jumps to the application code.
When the reset pin is held down,
there is no way to you can do anything since the processor is being held in reset.
Now if you start doing h/w re-wiring, ok you can change a few things, but there isn't much time to do much given the host needs the bootloader to start within like 50ms
since it will start sending upload commands.
Could you do it with enough h/w mods and a custom bootloader?
Probably, but it isn't something that can be done with just mods to the sketch.
It would take h/w mods to the board and a custom bootloader since I believe the bootloader will jump directly to the sketch after a watchdog reset so a watchdog reset can't be used to get into the boorloader for the purpose of uploading.
i.e. if you had a fancy sketch that would catch the "reset" signal from a re-wired auto reset circuit on a modified board, the sketch could muck with the LCD and watchdog into the bootoloader. However that would restart the sketch rather than look for an upload.
And if you patch the bootloader to work around this, then it would only work if the host does retries since the first few attempts at sending upload commands would fail while the LCD was being updated up to when the processor watchdogged.
(The Arduino protocol in avrdude will do several retries)
In terms of wiring the reset signal to an a LCD with an I2C backpack. There is no reset signal on a hd44780 LCD display. That is why the hd44780 initialization sequence has a specific set of commands in a specific order that get the host and LCD back in sync for 8 bit vs 4 bit modes and back in nibble sync in 4 bit mode.
--- bill
You're right, I was getting confused with OLED displays or something! Bang goes that idea.
I think powering down the LCD when the Arduino gets reset is the only simple/practical option.
I agree with you overall. My ideas are just hacks, to show it can be done.
This is something that can be done, albeit very definite - only a high voltage programmer can reverse it.
https://forum.arduino.cc/t/use-reset-pin-as-i-o-pin/163943
This thread has been
, take care now!
OK, forgot about that.
But if the reset pin is disabled to make the pin an input that would just be an alternative to h/w mods.
It would still require some custom code in the sketch, and a modified bootloader to make it all work.
IMO, not worth the effort.
If there is an issue in the s/w to process this i/o pin "reset", the board becomes soft bricked until the processor is re-programmed using ISP or high voltage programming.
IMO, other things are more important than a visual effect on an LCD during uploading, particularly since the IDE already provides a visual indication of the upload process in the IDE GUI.
For me, things like a good design (h/w & s/w) for the project. And then testing of the final work/project are more important.
But that's just me.
--- bill