How to key in "DEL"

Hey guys, I would like to ask how to insert a "DEL" character in Arduino which means in ASCII code NO. 127, I have typed the following sample code, and it seems returning a space bar for me instead of deleting the last character.

int level= analogRead(A0);

if (level>500){ Serial.print('a');} else {Serial.print(127);} delay(1000);

Thank you very much!

The Arduino serial monitor can't delete anything.

You need a more complex serial terminal. Then you can do things like positioning the cursor on the screen, clearing the screen and even using colours.

can you explain more please?

He is referring to Terminal Emulators. The Arduino has its own simplistic terminal emulator: the Serial Monitor window. But if you need the "window" to interpret the characters (like DEL or escape sequences), you have to use a smarter terminal emulator application. On Windoze, putty is a common choice.

Instead of opening the Serial Monitor window, you start this app and tell it to connect to a certain COM port, the same as you selected in the IDE. When your sketch does a Serial.print, characters get sent over the USB cable to the PC, where the app will read those characters. If they're normal printable characters, like "Hello world!", they get displayed just like Serial Monitor would have displayed them.

But if they're special characters, like DELs, the app can interpret them. In your case, the DEL would move the cursor backwards and erase that cell in the app window. There are also escape sequences you can print that will change color, erase the screen, blink, invert, or move the cursor to a certain row and column.

Cheers, /dev