Skip to main content
M7890.1
Associate III
June 6, 2021
Solved

Why does the LCD hangs when it prints negative numbers in the form -xxxx?

The LCD hangs when it prints negative numbers lesser than -999, or more specifically, the whole program hangs. Does anyone know the reason for this? I have attached my code below.

(The code is too long to be pasted here, I attached the file.)

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
June 6, 2021

Try making the buffer big enough to hold all the characters and a trailing NUL

char lcd_data[8]; // try 16

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

2 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
June 6, 2021

Try making the buffer big enough to hold all the characters and a trailing NUL

char lcd_data[8]; // try 16

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
M7890.1
M7890.1Author
Associate III
June 11, 2021

Tried that and solved my problem. Thanks!